diff options
| author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2009-08-03 15:09:26 -0300 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2009-08-03 15:09:26 -0300 | 
| commit | 1a67368e93a9c74350c3c6a6c5d3d3aac4a801c3 (patch) | |
| tree | 6a8b11f47918b90fcde5fdc6bb2755e72b1a5bd0 /hardinfo2 | |
| parent | ee9d4e3e88adcb168c8dfbea6050d20ccdc1d91f (diff) | |
Add command-line parameters to configure script (see ./configure -h for details)
Diffstat (limited to 'hardinfo2')
| -rwxr-xr-x | hardinfo2/configure | 322 | 
1 files changed, 187 insertions, 135 deletions
| diff --git a/hardinfo2/configure b/hardinfo2/configure index b5903adf..e68b61c3 100755 --- a/hardinfo2/configure +++ b/hardinfo2/configure @@ -1,7 +1,7 @@  #!/usr/bin/env bash  # -# ToscoConf 0.04 -# Copyright (c) 2003-2004 Leandro Pereira <leandro@hardinfo.org> +# ToscoConf 0.05 +# Copyright (c) 2003-2009 Leandro Pereira <leandro@hardinfo.org>  # All rights reserved.  #  # This script is in the Tosco Public License. It may be copied and/or @@ -16,120 +16,172 @@  # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  # DATA, OR PROFITS; OR BUSINESS INTERRUPTION)  # -# (yes, I did a copy&paste from the BSD license, eat me) -# +# --------------------------------------------------------------------------- + +function usage { +   echo "Usage: [-l libdir] [-r release] [-h]" +    echo "  -l libdir    Specify the library dir [default=autodetect]" +    echo "  -r release   Build a (release,debug) version [default=autodetect]" +    echo "  -h           This help" +} + +ARGS=`getopt l:p:r:h $*` +if test $? != 0; then +    usage +    exit 1 +fi +set -- $ARGS + +FORCE_LIBDIR="" +FORCE_RELEASE="" + +for arg; do +    case "$arg" in +    -l) +        shift; +        FORCE_LIBDIR=$1; +        shift ;; +    -h) +        usage; +        exit 0 ;; +    -r) +        shift; +        case "$1" in +        release|debug) +            FORCE_RELEASE=$1 ;; +        *) +            echo "Invalid build type; use either release or debug" +	    exit 1 ;; +        esac +        shift;; +    esac +done +  # ---------------------------------------------------------------------------  PACKAGE=`basename ${PWD} | cut -d"-" -f1`;  VERSION=`basename ${PWD} | cut -d"-" -f2`;  if [ "$PACKAGE" == "$VERSION" ]; then -	VERSION=$(date +"%F.%H:%M:%S") -	RELEASE=0 +    VERSION=$(date +"%F.%H:%M:%S") +    RELEASE=0  else -	RELEASE=1 +    RELEASE=1  fi -echo "ToscoConf (version 0.04) for $PACKAGE version $VERSION" +echo "ToscoConf (version 0.05) for $PACKAGE version $VERSION" + +# --------------------------------------------------------------------------- + +case "$FORCE_RELEASE" in +    debug) RELEASE=0;; +    release) RELEASE=1;; +esac  # ---------------------------------------------------------------------------  echo "Determining system architecture."  OS=`uname` -case $OS in		 -	Linux) -		;; -	*) -		echo "$OS (not supported, yet!)" -		exit ;; -esac	 +case $OS in     +    Linux) +    ;; +    *) +    echo "$OS (not supported, yet!)" +    exit ;; +esac      PROC=`uname -m`  LIBDIR='/usr/lib'  case $PROC in -	i?86) -		ln -sf linux/x86 arch/this -		ARCH="ARCH_i386" ;; -	ppc*) -		ln -sf linux/ppc arch/this -		ARCH="ARCH_PPC" ;; -	x86_64) -		ln -sf linux/x86_64 arch/this -		ARCH="ARCH_x86_64" -		LIBDIR="/usr/lib64" ;; -	mips*) -		ln -sf linux/mips arch/this -		ARCH="ARCH_MIPS" ;; -	parisc*) -		ln -sf linux/parisc arch/this -		ARCH="ARCH_PARISC" ;; -	sparc*) -		ln -sf linux/sparc arch/this -		ARCH="ARCH_SPARC" ;; -	armv*) -		ln -sf linux/armv4l arch/this -		ARCH="ARCH_ARMV4L" ;; -        ia64) -                ln -sf linux/ia64  arch/this -                ARCH="ARCH_IA64" ;; -        alpha) -                ln -sf linux/alpha  arch/this -                ARCH="ARCH_ALPHA" ;; -        s390*) -                ln -sf linux/s390  arch/this -                ARCH="ARCH_S390" ;; -	m68k) -		ln -sf linux/m68k arch/this -		ARCH="ARCH_m68k" ;; -	sh*) -		ln -sf linux/sh arch/this -		ARCH="ARCH_sh" ;; - +    i?86) +        ln -sf linux/x86 arch/this +        ARCH="ARCH_i386" ;; +    ppc*) +        ln -sf linux/ppc arch/this +        ARCH="ARCH_PPC" ;; +    x86_64) +        ln -sf linux/x86_64 arch/this +        ARCH="ARCH_x86_64" +        LIBDIR="/usr/lib64" ;; +    mips*) +        ln -sf linux/mips arch/this +        ARCH="ARCH_MIPS" ;; +    parisc*) +        ln -sf linux/parisc arch/this +        ARCH="ARCH_PARISC" ;; +    sparc*) +        ln -sf linux/sparc arch/this +        ARCH="ARCH_SPARC" ;; +    armv*) +        ln -sf linux/armv4l arch/this +        ARCH="ARCH_ARMV4L" ;; +    ia64) +        ln -sf linux/ia64  arch/this +        ARCH="ARCH_IA64" ;; +    alpha) +        ln -sf linux/alpha  arch/this +        ARCH="ARCH_ALPHA" ;; +    s390*) +        ln -sf linux/s390  arch/this +        ARCH="ARCH_S390" ;; +    m68k) +        ln -sf linux/m68k arch/this +        ARCH="ARCH_m68k" ;; +    sh*) +        ln -sf linux/sh arch/this +        ARCH="ARCH_sh" ;;  esac  if [ "x$ARCH" == "x" ]; then -	echo "Your architecture is not supported yet. Please send the" -	echo "output of the following commands to leandro@hardinfo.org:" -	echo "" -	echo "  $ cat /proc/cpuinfo" -	echo "  $ uname -a" -	echo "  $ uname -m" -	exit 1 +    echo "Your architecture is not supported yet. Please send the" +    echo "output of the following commands to leandro@hardinfo.org:" +    echo "" +    echo "  $ cat /proc/cpuinfo" +    echo "  $ uname -a" +    echo "  $ uname -m" +    exit 1  fi  # --------------------------------------------------------------------------- -echo "Compiling $PACKAGE for $OS $PROC ($ARCH)." +echo "Building $PACKAGE for $OS $PROC ($ARCH)."  echo ""  # --------------------------------------------------------------------------- +if [ "x$FORCE_LIBDIR" != "x" ]; then +    echo "Forcing libdir to be $FORCE_LIBDIR" +    LIBDIR=$FORCE_LIBDIR +fi + +# --------------------------------------------------------------------------- +  GTK2=-1  MIN_VERSION="2.6.0"  echo -n "Checking for GTK version >= ${MIN_VERSION}... "  for i in `which pkg-config`; do -	$i --errors-to-stdout gtk+-2.0 \ -		--atleast-version=$MIN_VERSION > /dev/null -	case $? in -		0) -			GTK_FLAGS=`pkg-config gtk+-2.0 --cflags` -			GTK_LIBS=`pkg-config gtk+-2.0 --libs` -			echo "found `pkg-config gtk+-2.0 --modversion`" -			GTK2=1 -			break ;; -		*) -			echo "not found." ;; -	esac +    $i --errors-to-stdout gtk+-2.0 \ +    --atleast-version=$MIN_VERSION > /dev/null +    case $? in +    0) +        GTK_FLAGS=`pkg-config gtk+-2.0 --cflags` +        GTK_LIBS=`pkg-config gtk+-2.0 --libs` +        echo "found `pkg-config gtk+-2.0 --modversion`" +        GTK2=1 +        break ;; +    *) +        echo "not found." ;; +    esac  done  # --------------------------------------------------------------------------  if [ $GTK2 -eq -1 ]; then -	echo -e "\nYou need the GTK libraries, including the development stuff." -	echo "If you're using Debian, running the command as root:" -	echo -e "\n\taptitude install libgtk2.0-dev\n" -	echo "Will do the trick." -	exit 1 +    echo -e "\nYou need the GTK libraries, including the development stuff." +    echo "If you're using Debian, running the command as root:" +    echo -e "\n\taptitude install libgtk2.0-dev\n" +    echo "Will do the trick." +    exit 1  fi  # --------------------------------------------------------------------------- @@ -138,110 +190,110 @@ SOUP=-1  MIN_VERSION="2.4"  echo -n "Checking for libsoup version >= ${MIN_VERSION}... "  for i in `which pkg-config`; do -	$i --errors-to-stdout libsoup-2.4 \ -		--atleast-version=$MIN_VERSION > /dev/null -	case $? in -		0) -			SOUP_FLAGS=`pkg-config libsoup-2.4 --cflags --static` -			SOUP_LIBS=`pkg-config libsoup-2.4 --libs --static` -			echo "found `pkg-config libsoup-2.4 --modversion`" -			SOUP=1 -			break ;; -		*) -			echo "not found." ;; -	esac +    $i --errors-to-stdout libsoup-2.4 \ +    --atleast-version=$MIN_VERSION > /dev/null +    case $? in +    0) +        SOUP_FLAGS=`pkg-config libsoup-2.4 --cflags --static` +        SOUP_LIBS=`pkg-config libsoup-2.4 --libs --static` +        echo "found `pkg-config libsoup-2.4 --modversion`" +        SOUP=1 +        break ;; +    *) +        echo "not found." ;; +    esac  done  # --------------------------------------------------------------------------  if [ $SOUP -eq -1 ]; then -	echo "Disabling libsoup support. (Network Updater won't be available.)" +    echo "Disabling libsoup support. (Network Updater won't be available.)"  fi  # --------------------------------------------------------------------------  echo -n "Checking for Linux Wireless Extensions (CONFIG_NET_RADIO)... "  if [ -e /proc/net/wireless ]; then -	echo "found." -	LINUX_WE=1 +    echo "found." +    LINUX_WE=1  else -	echo "not found." -	LINUX_WE=-1 +    echo "not found." +    LINUX_WE=-1  fi  # --------------------------------------------------------------------------  if [ $LINUX_WE -eq -1 ]; then -	echo "Disabling Linux Wireless Extensions support." +    echo "Disabling Linux Wireless Extensions support."  fi  # --------------------------------------------------------------------------  echo -e "\nWriting config.h..." -rm -f config.h -echo -e "#ifndef __CONFIG_H__\n#define __CONFIG_H__\n" > config.h - -echo "#define VERSION \"$VERSION\"" >> config.h - -echo "#define $ARCH" >> config.h -echo "#define ARCH     \"$ARCH\"" >> config.h +cat << EOF > config.h +#ifndef __CONFIG_H__ +#define __CONFIG_H__ + +#define VERSION "$VERSION" +#define $ARCH +#define ARCH "$ARCH" +#define PLATFORM "`uname`" +#define KERNEL "`uname -r`" +#define HOSTNAME "`hostname`" +#define PREFIX "/usr/share/hardinfo" +#define LIBPREFIX "$LIBDIR/hardinfo" -echo "#define PLATFORM \"`uname`\"" >> config.h -echo "#define KERNEL   \"`uname -r`\"" >> config.h -echo "#define HOSTNAME \"`hostname`\"" >> config.h - -echo "#define PREFIX \"/usr/share/hardinfo/\"" >> config.h -echo "#define LIBPREFIX \"/usr/lib/hardinfo/\"" >> config.h +EOF  if [ "$SOUP" == "1" ]; then -	echo "#define HAS_LIBSOUP" >> config.h +    echo "#define HAS_LIBSOUP" >> config.h  fi  if [ "$LINUX_WE" == "1" ]; then -	echo "#define HAS_LINUX_WE" >> config.h +    echo "#define HAS_LINUX_WE" >> config.h  fi  if [ "$RELEASE" == "1" ]; then -	echo "#define DEBUG(...)" >> config.h +    echo "#define DEBUG(...)" >> config.h  else -	echo '#define DEBUG(msg,...) fprintf(stderr, "*** %s:%d (%s) *** " msg "\n", \'  >> config.h -        echo '                               __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)' >> config.h +    echo '#define DEBUG(msg,...) fprintf(stderr, "*** %s:%d (%s) *** " msg "\n", \'  >> config.h +    echo '                   __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)' >> config.h  fi -echo "#define ENABLE_BINRELOC 1" >> config.h -echo "#define RELEASE $RELEASE" >> config.h +cat << EOF >> config.h +#define ENABLE_BINRELOC 1 +#define RELEASE $RELEASE -echo -e "\n#endif	/* __CONFIG_H__ */" >> config.h +#endif	/* __CONFIG_H__ */ +EOF  echo "Writing Makefile..." -rm -f Makefile -echo "GTK_LIBS = -lpthread -lgthread-2.0 -lrt ${GTK_LIBS}" > Makefile -echo "GTK_CFLAGS = ${GTK_FLAGS}" >> Makefile -echo "SOUP_LIBS = ${SOUP_LIBS}" >> Makefile -echo "SOUP_CFLAGS = ${SOUP_FLAGS}" >> Makefile -echo "PACKAGE = `basename ${PWD}`" >> Makefile -echo "ARCHOPTS = " >> Makefile -echo "LIBDIR = $LIBDIR" >> Makefile +cat << EOF > Makefile +GTK_LIBS = -lpthread -lgthread-2.0 -lrt ${GTK_LIBS} +GTK_CFLAGS = ${GTK_FLAGS} +SOUP_LIBS = ${SOUP_LIBS} +SOUP_CFLAGS = ${SOUP_FLAGS} +PACKAGE = `basename ${PWD}` +ARCHOPTS =  +LIBDIR = $LIBDIR +EOF  cat Makefile.in >> Makefile  echo -e "\nDone. Type \"make\" to compile the program.\n" -  if [ "$RELEASE" == 0 ]; then -	cat << EOF -********************************************************* -* This is work in progress! Please report bugs at:      * -*      http://developer.berlios.de/bugs/?group_id=5897  * -* Or send patches to:                                   * -*      http://developer.berlios.de/patch/?group_id=5897 * -********************************************************* +    cat << EOF +******************************************************************** +* This is work in progress! Please report bugs or send patches to: * +*                    http://bugs.hardinfo.org                      * +********************************************************************  EOF  else -	cat << EOF +    cat << EOF  If you get errors, probably you don't have the right libraries,  includes or utilities. However, if you're sure this is a bug in my -code, please send a patch (use "diff -u") to <leandro@hardinfo.org>. +code, please use the bug tracker at <http://bugs.hardinfo.org>.  EOF  fi | 
