#!/bin/bash C_TEMPDIR=`mktemp -d /tmp/iwear-configure.XXXXXX` PQLIBDIRS="/usr/lib/ /usr/lib/pgsql/ /usr/local/pgsql/lib/" PQINCDIRS="/usr/include/ /usr/include/pgsql /usr/include/postgresql /usr/local/pgsql/include /usr/include/postgresql/8.0/" SSLINCDIRS="/usr/include/ssl /usr/include/openssl /usr/local/include/openssl /usr/local/include/ssl" GLIB2INCLUDES="/opt/gnome/lib/glib-2.0/include /opt/gnome/include/glib-2.0 /usr/lib/glib-2.0/include /usr/include/glib-2.0" GLIB2CONFIG="/opt/gnome/lib/glib-2.0/include /usr/lib/glib-2.0/include" GLIB2LIBDIRS="/opt/gnome/lib/ /usr/lib/" ORBITCPPINCLUDES="/usr/include/orbitcpp-2.0 /opt/gnome/include/orbitcpp-2.0/" ORBITCPPCONFIG="" ORBITCPPLIBDIRS="/opt/gnome/lib/ /usr/lib/" ORBITCPPIDLS="/usr/bin/orbit-idl-2 /opt/gnome/bin/orbit-idl-2" ORBIT2INCLUDES="/opt/gnome/include/orbit-2.0/ /usr/include/orbit-2.0" ORBIT2LIBDIRS="/opt/gnome/lib/ /usr/lib/" LINCINCLUDES="/opt/gnome/include/linc-1.0 /usr/include/linc-1.0" IWEARINCDIRS="$HOME/include/ $HOME/iwear/include /usr/include" IWEARLIBDIRS="$HOME/lib/ $HOME/iwear/lib /usr/lib" IWDBINCDIRS="$HOME/include/ $HOME/iwear/include /usr/include" IWDBLIBDIRS="$HOME/lib/ $HOME/iwear/lib /usr/lib" IWSENSINCDIRS="$HOME/include/ $HOME/iwear/include /usr/include" IWSENSLIBDIRS="$HOME/lib/ $HOME/iwear/lib /usr/lib" QT3INCDIRS="/usr/lib/qt3/include/ /usr/pkg/qt3/include/ /usr/include/qt3/" QT3LIBDIRS="/usr/lib/qt3/lib/ /usr/pkg/qt3/lib/ /usr/lib/qt3/" BOOSTINCDIRS="/usr/include" XERCESLIBDIRS="/usr/lib" XERCESINCDIRS="/usr/include" SYSLIB="/usr/lib" DLLIBS="# -ldl" THREADLIBS="# -pthread -lpthread" BAIL=no # For colored output ESC="\033[1" RED="$ESC;31m" GRN="$ESC;32m" YEL="$ESC;33m" BLU="$ESC;34m" VIO="$ESC;35m" TUK="$ESC;36m" WHT="$ESC;37m" NOR="\033[m" # Set the variables if not already set if [ -z $CC ] then CC=gcc fi if [ -z $CPP ] then CPP=g++ fi if [ -z $OIDL2 ] then OIDL2=/opt/gnome/bin/orbit-idl-2 fi function log { echo $* >> $CONFLOG } function logecho { echo $* log $* } function asctoint { ASCII=$1 # echo -en $ASCII | $HEXDUMP -d | head -1 | cut -d" " -f4 echo -en $ASCII | perl -e 'my $a = <>; print ord($a);' } function check_ostype # {{{ { logecho -en "Checking OS Type .. " SYSTYPE=$(uname -s) case $SYSTYPE in Linux) OS_TYPE=linux ;; Darwin) OS_TYPE=mac ;; SunOS) OS_TYPE=solaris ;; *) OS_TYPE=$OSTYPE logecho -en ". [OS Type $OS_TYPE not supported, proceeding anyways].. " ;; esac logecho -e ." "$OS_TYPE } # }}} function check_dynlib # {{{ { logecho -en "Checking for dynamic library suffix .. " case $OS_TYPE in solaris | linux) DYN_SUFFIX="so" ;; mac) DYN_SUFFIX="dylib" ;; *) DYN_SUFFIX="so" logecho -en ". [OS Type $OS_TYPE not supported, proceeding with .so.. " ;; esac logecho -e ." "$DYN_SUFFIX logecho -en "Checking for dynamic linker flags .. " case $OS_TYPE in solaris | linux) LIBFLAGS="-shared -Wl,-warn-once,-soname," ;; mac) LIBFLAGS="-flat_namespace -undefined suppress -dynamiclib -install_name" ;; *) LIBFLAGS="-shared -Wl,-warn-once,-soname," logecho -en ". [OS Type $OS_TYPE not supported, proceeding with $LIBFLAGS .. " ;; esac logecho -e ." "$LIBFLAGS } # }}} function cleanup # {{{ { if [ -d "$C_TEMPDIR" ] then log "Cleaning up temporary directories..." rm -r $C_TEMPDIR 2>&1 >> $CONFLOG fi } # }}} function check_version # {{{ { WANTED=$1 HAVE=$2 WHAT=$3 if [ -z "$4" ] then DISPLAY_WANTED=$WANTED else DISPLAY_WANTED=$4 fi if [ -z "$5" ] then DISPLAY_HAVE=$HAVE else DISPLAY_HAVE=$5 fi HAVE_MAJ=`echo $HAVE | cut -d"." -f1` HAVE_MIN=`echo $HAVE | cut -d"." -f2` HAVE_REL=`echo $HAVE | cut -d"." -f3` WANT_MAJ=`echo $WANTED | cut -d"." -f1` WANT_MIN=`echo $WANTED | cut -d"." -f2` WANT_REL=`echo $WANTED | cut -d"." -f3` VERSION_OK=yes log -e "Checking Version of $WHAT wanting $DISPLAY_WANTED and found $DISPLAY_HAVE" if [ $HAVE_MAJ -lt $WANT_MAJ ] then VERSION_OK=no echo "fail" echo "Your Major Version of $WHAT ($DISPLAY_HAVE) does not match the required one $DISPLAY_WANTED" return else if [ $HAVE_MAJ -eq $WANT_MAJ -a $HAVE_MIN -lt $WANT_MIN ] then echo "fail" echo "Your Minor Version of $WHAT ($DISPLAY_HAVE) does not match the required one $DISPLAY_WANTED" VERSION_OK=no return else if [ $HAVE_MAJ -eq $WANT_MAJ -a $HAVE_MIN -eq $WANT_MIN -a $HAVE_REL -lt $WANT_REL ] then echo "fail" echo "Your Release Version of $WHAT ($DISPLAY_HAVE) does not match the required one $DISPLAY_WANTED" VERSION_OK=no return fi fi fi } # }}} function toupper # {{{ { sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' } # }}} function tolower # {{{ { sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' } # }}} function logsetvar # {{{ { VAR=$1 CONT=$2 log -e "Setting $VAR=$CONT" eval "$VAR=$CONT" } # }}} function search_libdir # {{{ { LFLAG=$1 PDIRS=$2 TEMPO=$C_TEMPDIR/check_lib TEMPC=$C_TEMPDIR/check_lib.c FOUNDLIB="" cat > $TEMPC <> $CONFLOG 2>&1 if [ -x "$TEMPO" ] then FOUNDLIB=$dir return fi done } # }}} function test_include # {{{ { MCC=$1 CFILE=$2 LCFLAGS=$3 OFILE=$4 TTAG=$5 TRIALSS=$6 TRIAL="" log "Testing Program $CFILE" log "Contents : " cat $CFILE >> $CONFLOG log "CFLAGS = $LCFLAGS" rm -f $OFILE for inc in $TRIALSS do if [ "$inc" == "#" ] then inc="" fi log "Exec ($MCC $LCFLAGS $TTAG $inc -o $OFILE $CFILE)" $MCC $LCFLAGS ${TTAG}${inc} -o $OFILE $CFILE >> $CONFLOG 2>&1 if [ -x "$OFILE" ] then log "Setting TRIAL=$inc" TRIAL=$inc return fi done } # }}} # Sets BAIL=yes if the Version is wrong function check_gcc #{{{ { BAIL=no VERSION_OK=no WANTED_GCC=$1 logecho -en "Checking for $CC >= $WANTED_GCC ... " if [ "$FORCEGCC" == "yes" ] then logecho "(skipped - user override)" return fi TEMP_C="$C_TEMPDIR/check_gcc.c" TEMP_X=`mktemp $C_TEMPDIR/check_gcc.XXXXXX` cat > $TEMP_C < #ifndef __GNUC_PATCHLEVEL__ #define __GNUC_PATCHLEVEL__ 0 #endif int main ( void ) { printf("%d.%d.%d\n",__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__); return 0; } XEOF log -e "\nContents of $TEMP_C" cat $TEMP_C >> $CONFLOG log -e "exec( $CC $CFLAGS $TEMP_C -o $TEMP_X )" $CC $CFLAGS $TEMP_C -o $TEMP_X >> $CONFLOG 2>&1 rm -f $TEMP_C if [ ! -x $TEMP_X ] then logecho -e "Could not create executable, check compiler and CFLAGS" exec echo "Stop" fi read GCC_VER < <($TEMP_X) check_version $WANTED_GCC $GCC_VER "gcc" if [ "$VERSION_OK" != "yes" ] then BAIL=yes return fi logecho -e "$GCC_VER (OK)" rm -f $TEMP_X } #}}} # Sets BAIL=yes if the Version is wrong function check_gpp #{{{ { BAIL=no WANTED_GPP=$1 logecho -en "Checking for $CPP >= $WANTED_GPP ... " if [ "$FORCEGPP" == "yes" ] then echo "(skipped - user override)" return fi TEMP_CPP="$C_TEMPDIR/check_gcc.cpp" TEMP_X=`mktemp $C_TEMPDIR/check_gcc.XXXXXX` cat > $TEMP_CPP < #include #ifndef __GNUC_PATCHLEVEL__ #define __GNUC_PATCHLEVEL__ 0 #endif int main ( void ) { printf("%d.%d.%d\n",__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__); return 0; } XEOF log -e "\nContents of $TEMP_CPP" cat $TEMP_CPP >> $CONFLOG log -e "Exec( $CPP $CPPFLAGS $TEMP_CPP -o $TEMP_X )" $CPP $CPPFLAGS $TEMP_CPP -o $TEMP_X >> $CONFLOG 2>&1 rm -f $TEMP_CPP if [ ! -x $TEMP_X ] then BAIL=yes logecho -e "\nCould not create a program with $CPP please verify that its working properly" return fi read GPP_VER < <($TEMP_X 2>> $CONFLOG) if [ -z "$GPP_VER" ] then logecho -e "\nWe were able to build an executable, but the executable failed to run" BAIL=yes return fi check_version $WANTED_GPP $GPP_VER "g++" if [ "$VERSION_OK" != "yes" ] then BAIL=yes return fi logecho "$GPP_VER (OK)" logecho -en "Checking for $CPP extra warning flag... " GPP_MAJ=`echo $GPP_VER | cut -d"." -f1` GPP_MIN=`echo $GPP_VER | cut -d"." -f2` GPP_REL=`echo $GPP_VER | cut -d"." -f3` WEXTRA="-W" if [ $GPP_MAJ -ge 4 ] then WEXTRA="-Wextra" else if [ $GPP_MIN -ge 4 ] then WEXTRA="-Wextra" fi fi logecho " $WEXTRA" rm -f $TEMP_X } #}}} # Sets BAIL=yes if the Version is wrong function check_gmake #{{{ { MAKE=`which gmake` if [ -z $MAKE ] then MAKE=`which make` fi log -e "Found a make at $MAKE" WANTED_VER=$1 logecho -n "Checking for GNU Make >= $WANTED_VER ... " VER=`$MAKE --version 2>/dev/null | grep GNU | head -1 | sed 's/[^0-9\.]//g'` if [ -z "$VER" ] then echo "fail" echo "This Environment is compatible with GNU Make only." echo "Please install GNU Make or provide a link called gmake within \$PATH" BAIL=yes return 1 fi check_version $WANTED_VER $VER "gmake" if [ "$VERSION_OK" != "yes" ] then BAIL=yes return fi logecho -e "$VER (OK)" MAKEMD5=$(md5sum $MAKE | cut -d" " -f1) case $MAKEMD5 in 55abf10fc1cf2f59662a28662a2931b2 | 4efe0480f7fa6589ff382dcfdc5231a2 | e4014aa543f1e2e9fec083773af33385 | 1dd8dd18455acfe252a1f31d071748cb | 1c46755ef3c6ddf79321848af77341be ) BAIL=yes echo echo "Though we have detected a make version that satisfies the version" echo "required, it is in a blacklist of buggy make versions. We highly" echo "recommend that you upgrade your make version, since those make version" echo "wont work with the iwear makefiles" ;; *) # echo "md5sum : $MAKEMD5" ;; esac } #}}} # Sets $PKG_CONFIG to the pkg-config binary, leaves it empty if not present or # not to be used by user override function check_pkg_config #{{{ { PKG_CONFIG=`which pkg-config 2>/dev/null` logecho -n "Checking for pkg-config ... " if [ -z "$PKG_CONFIG" ] then logecho "no" else if [ "$NO_PKG_CONFIG" == "yes" ] then logecho "skipped (user override)" PKG_CONFIG="" else logecho "yes ($PKG_CONFIG)" fi fi } #}}} # The script needs sed sometimes function check_sed #{{{ { logecho -en "Checking for sed ... " SED=`which sed 2>/dev/null` if [ -z "$SED" ] then BAIL="yes" echo -e $RED logecho -n "(fail)"" " echo -en $YEL logecho -n "No sed in \$PATH" echo -e $NOR logecho "($PATH)" echo -e $YEL logecho "$0 needs sed in order to continue." logecho "Please install sed, add its location to the path," logecho "or create a symlink within the path to a functional sed" echo -e $NOR return fi logecho "(OK)" } # }}} # Check for installation of pgsql libraries and the headers # sets PG_INCLUDE and PG_LIBDIR and BAIL if not found or version too old function check_pgsql # {{{ { WANTED_VER=$1 echo -en "Checking for PostgreSQL >= $WANTED_VER ... " PG_CONFIG=`which pg__config 2>/dev/null` if [ -z "$PG_CONFIG" ] then logecho -en "(no pg_config) " TEMP_C="$C_TEMPDIR/check_libpq.c" TEMP_X=`mktemp $C_TEMPDIR/check_libpq.XXXXXX` cat > $TEMP_C <> $CONFLOG log -e "ATTEMPTING TO FIND DIRECTORIES VIA TRIAL COMPILE" test_include $CC $TEMP_C "$CFLAGS -lpq" $TEMP_X -L "$PQLIBDIRS" log -e "Found PG_LIBDIR=$TRIAL" PG_LIBDIR=$TRIAL if [ -z "$PG_LIBDIR" ] then logecho "failed. Could not find directory where libpq.so lives in" BAIL=yes return fi ######----------------------------------------------------------- log -e "Trial compiling for header files" cat > $TEMP_C < #include int main ( void ) { printf(PG_VERSION); return 0; } XEOF log -e "Contents of $TEMP_C" cat $TEMP_C >> $CONFLOG test_include $CC $TEMP_C "$CFLAGS" $TEMP_X -I "$PQINCDIRS" PG_INCLUDE=$TRIAL if [ -x "$TEMP_X" ] then PG_VER=`$TEMP_X` fi log -e "TEST INCLUDE COMPILE $PG_INCLUDE" log -e "PG_VER=$PG_VER" if [ -z "$PG_INCLUDE" -o -z "$PG_VER" ] then logecho "\nfailed. Could not find directory where libpq-fe.h lives in" BAIL=yes return fi else PG_VER=`$PG_CONFIG --version | cut -d" " -f2-` PG_INCLUDE=`$PG_CONFIG --includedir` PG_LIBDIR=`$PG_CONFIG --libdir` log -e "pg_config found, getting dirs and flags from there..." log -e "Setting PG_VER=$PG_VER" log -e "Setting PG_INCLUDE=$PG_INCLUDE" log -e "Setting PG_LIBDIR=$PG_LIBDIR" fi check_version $WANTED_VER $PG_VER "PostgreSQL" if [ "$VERSION_OK" != "yes" ] then BAIL=yes return fi logecho -e "$PG_VER (OK)" } # }}} function check_libpq # {{{ { logecho -en "Checking for usable libpq ... " TEMP_C="$C_TEMPDIR/check_libpq.c" TEMP_X=`mktemp $C_TEMPDIR/check_libpq.XXXXXX` cat > $TEMP_C < int main ( void ) { PQconnectStart("Hello World"); return 0; } XEOF log -e "Contents of $TEMP_C" cat $TEMP_C >> $CONFLOG log -e "Exec( $CC $CFLAGS -I $PG_INCLUDE -L$PG_LIBDIR -lpq $TEMP_C -o $TEMP_X )" $CC $CFLAGS -I $PG_INCLUDE -L$PG_LIBDIR -lpq $TEMP_C -o $TEMP_X >> $CONFLOG 2>&1 if [ ! -x "$TEMP_X" ] then logecho "fail" BAIL=yes logecho "We were not able to compile the test program for libpq" fi rm -f $TEMP_C rm -f $TEMP_X logecho "(OK)" } #}}} function check_linc # {{{ { logecho -en "Checking linc includes... " TEMP_C="$C_TEMPDIR/check_linc.c" TEMP_X=`mktemp $C_TEMPDIR/check_linc.XXXXXX` cat > $TEMP_C < int main ( void ) { return 0; } XEOF log -e "Contents of $TEMP_C" cat $TEMP_C >> $CONFLOG test_include $CC $TEMP_C "-I $GLIB2_CONFIG -I $GLIB2_INCLUDE" $TEMP_X -I "$LINCINCLUDES" LINC_INCLUDE=$TRIAL log -e "Succes, set LINC_INCLUDE=$LINC_INCLUDE" if [ ! -x "$TEMP_X" ] then logecho "fail" BAIL=yes logecho "We were not able to compile the test program for linc. Have you installed the Headers (-devel package of your distro) ?" else logecho "(OK)" fi # rm -f $TEMP_C rm -f $TEMP_X } #}}} function check_iwear # {{{ { WANTED_VER=$1 TEMP_C="$C_TEMPDIR/check_iwear.c" TEMP_X=`mktemp $C_TEMPDIR/check_iwear.XXXXXX` cat > $TEMP_C < int main ( void ) { printf("%lu.%lu.%lu\n",IWEAR_MAJOR,IWEAR_MINOR,IWEAR_RELEASE); return 0; } XEOF logecho -en "Checking for iWear core libraries ... " search_libdir "-liwear_core" "$IWEARLIBDIRS" logsetvar IWEAR_LIBDIR $FOUNDLIB if [ -z "$FOUNDLIB" ] then logecho -e "fail" logecho -e "We were not able to generate a check program for $CHECKME." logecho -e "please see $CONFLOG for details" BAIL=yes return fi logecho " (OK)" logecho -en "Checking for iWear core includes ... " log -e "Trial compiling $TEMP_C" cat $TEMP_C >> $CONFLOG test_include $CC $TEMP_C "$DLLIB -L$IWEAR_LIBDIR -liwear_core" $TEMP_X -I "$IWEARINCDIRS" IWEAR_INCLUDE=$TRIAL log -e "Succes, set IWEAR_INCLUDE=$IWEAR_INCLUDE" if [ ! -x "$TEMP_X" ] then logecho "fail" BAIL=yes logecho "We were not able to compile the test program for iWear core. Have you installed the Headers (-devel package of your distro) ?" else logecho -e "yes ($IWEAR_INCLUDE)" logecho -en "Checking for iWear core >= $WANTED_VER ... " IWEAR_VER=`$TEMP_X` check_version $WANTED_VER $IWEAR_VER "iWear" $WANTED_VER $IWEAR_VER if [ "$VERSION_OK" != "yes" ] then BAIL=yes fi fi # echo -e "Want : $WANTED_VER" # echo -e "Have : $SSL_VER" rm -f $TEMP_C rm -f $TEMP_X if [ "$BAIL" != "yes" ] then logecho "$IWEAR_VER (OK)" fi } #}}} function check_boost # {{{ { WANTED_VER=$1 TEMP_C="$C_TEMPDIR/check_boost.cpp" TEMP_X=`mktemp $C_TEMPDIR/check_boost.XXXXXX` cat > $TEMP_C < #include using namespace std; int main ( void ) { cout << BOOST_VERSION / 100000 << "." << BOOST_VERSION / 100 % 1000 << "." << BOOST_VERSION % 100 << endl; return 0; } XEOF logecho -en "Checking for boost includes ... " log -e "Trial compiling $TEMP_C" cat $TEMP_C >> $CONFLOG test_include $CPP $TEMP_C "$DLLIB" $TEMP_X -I "$BOOSTINCDIRS" boost_INCLUDE=$TRIAL log -e "Succes, set BOOST_INCLUDE=$BOOST_INCLUDE" if [ ! -x "$TEMP_X" ] then logecho "fail" BAIL=yes logecho "We were not able to compile the test program for boost headers. Have you installed the Headers (-devel package of your distro) ?" else logecho -e "yes ($BOOST_INCLUDE)" logecho -en "Checking for boost >= $WANTED_VER ... " BOOST_VER=`$TEMP_X` check_version $WANTED_VER $BOOST_VER "boost" $WANTED_VER $BOOST_VER if [ "$VERSION_OK" != "yes" ] then BAIL=yes fi fi # echo -e "Want : $WANTED_VER" # echo -e "Have : $SSL_VER" rm -f $TEMP_C rm -f $TEMP_X if [ "$BAIL" != "yes" ] then logecho "$BOOST_VER (OK)" fi } #}}} function check_iwdb # {{{ { WANTED_VER=$1 TEMP_C="$C_TEMPDIR/check_iwdb.c" TEMP_X=`mktemp $C_TEMPDIR/check_iwdb.XXXXXX` cat > $TEMP_C < int main ( void ) { printf("%lu.%lu.%lu\n",DBCLASSES_MAJOR,DBCLASSES_MINOR,DBCLASSES_RELEASE); return 0; } XEOF logecho -en "Checking for iwear database libraries ... " search_libdir "-liwdb" "$IWDBLIBDIRS" logsetvar IWDB_LIBDIR $FOUNDLIB if [ -z "$FOUNDLIB" ] then logecho -e "fail" logecho -e "We were not able to generate a check program for $CHECKME." logecho -e "please see $CONFLOG for details" BAIL=yes return fi logecho " (OK)" logecho -en "Checking for iwear database includes ... " log -e "Trial compiling $TEMP_C" cat $TEMP_C >> $CONFLOG test_include $CC $TEMP_C "$DLLIB -L$IWDB_LIBDIR -liwdb" $TEMP_X -I "$IWDBINCDIRS" IWDB_INCLUDE=$TRIAL log -e "Succes, set IWDB_INCLUDE=$IWDB_INCLUDE" if [ ! -x "$TEMP_X" ] then logecho "fail" BAIL=yes logecho "We were not able to compile the test program for iwdb core. Have you installed the Headers (-devel package of your distro) ?" else logecho -e "yes ($IWDB_INCLUDE)" logecho -en "Checking for iwdb core >= $WANTED_VER ... " IWDB_VER=`$TEMP_X` check_version $WANTED_VER $IWDB_VER "iwdb" $WANTED_VER $IWDB_VER if [ "$VERSION_OK" != "yes" ] then BAIL=yes fi fi # echo -e "Want : $WANTED_VER" # echo -e "Have : $SSL_VER" rm -f $TEMP_C rm -f $TEMP_X if [ "$BAIL" != "yes" ] then logecho "$IWDB_VER (OK)" fi } #}}} function check_iwsens # {{{ { WANTED_VER=$1 TEMP_C="$C_TEMPDIR/check_iwsens.c" TEMP_X=`mktemp $C_TEMPDIR/check_iwsens.XXXXXX` cat > $TEMP_C < int main ( void ) { printf("%lu.%lu.%lu\n",IWSENSCORE_MAJOR,IWSENSCORE_MINOR,IWSENSCORE_RELEASE); return 0; } XEOF logecho -en "Checking for iwear sensor core libraries ... " search_libdir "-liwsens" "$IWSENSLIBDIRS" logsetvar IWSENS_LIBDIR $FOUNDLIB if [ -z "$FOUNDLIB" ] then logecho -e "fail" logecho -e "We were not able to generate a check program for $CHECKME." logecho -e "please see $CONFLOG for details" BAIL=yes return fi logecho " (OK)" logecho -en "Checking for iwear sensor core includes ... " log -e "Trial compiling $TEMP_C" cat $TEMP_C >> $CONFLOG test_include $CC $TEMP_C "$DLLIB -L$IWSENS_LIBDIR -liwsens" $TEMP_X -I "$IWSENSINCDIRS" IWSENS_INCLUDE=$TRIAL log -e "Succes, set IWSENS_INCLUDE=$IWSENS_INCLUDE" if [ ! -x "$TEMP_X" ] then logecho "fail" BAIL=yes logecho "We were not able to compile the test program for iwsens core. Have you installed the Headers (-devel package of your distro) ?" else logecho -e "yes ($IWSENS_INCLUDE)" logecho -en "Checking for iwsens core >= $WANTED_VER ... " IWSENS_VER=`$TEMP_X` check_version $WANTED_VER $IWSENS_VER "iwsens" $WANTED_VER $IWSENS_VER if [ "$VERSION_OK" != "yes" ] then BAIL=yes fi fi # echo -e "Want : $WANTED_VER" # echo -e "Have : $SSL_VER" rm -f $TEMP_C rm -f $TEMP_X if [ "$BAIL" != "yes" ] then logecho "$IWSENS_VER (OK)" fi } #}}} function check_ssl # {{{ { WANTED_VER=$1 RW=$1 NUMVER=`echo $WANTED_VER | sed 's/[^0-9\.]//g'` SUBVER=`echo $WANTED_VER | sed 's/[0-9\.]//g'` REL=`asctoint $SUBVER` WANTED_VER="$NUMVER$REL" logecho -en "Checking for OpenSSL includes ... " TEMP_C="$C_TEMPDIR/check_ssl.c" TEMP_X=`mktemp $C_TEMPDIR/check_ssl.XXXXXX` cat > $TEMP_C < #include #include int main ( void ) { MD5_CTX ctx; MD5_Init(&ctx); // e.g. 0x0090702fL // 10 for 1. unsigned long int over = OPENSSL_VERSION_NUMBER; // over = 0x1101104fL; // 1.10.11d unsigned long int major = (over & 0xF0000000L) >> 28; if ( major > 9 ) major -= 6; unsigned long int minor = (over & 0x0FF00000L) >> 20; if ( minor > 9 ) minor -= 6; unsigned long int release = (over & 0x000FF000L) >> 12; if ( release > 9 ) release -= 6; unsigned long int patch = (over & 0x000000F0L) >> 4; printf("%lu.%lu.%lu%c\n",major,minor,release,(char)(96+patch)); return 0; } XEOF log -e "Trial compiling $TEMP_C" cat $TEMP_C >> $CONFLOG test_include $CC $TEMP_C "$DLLIB -lcrypto -lssl" $TEMP_X -I "$SSLINCDIRS" SSL_INCLUDE=$TRIAL log -e "Succes, set SSL_INCLUDE=$SSL_INCLUDE" if [ ! -x "$TEMP_X" ] then logecho "fail" BAIL=yes logecho "We were not able to compile the test program for openssl. Have you installed the Headers (-devel package of your distro) ?" else logecho -e "yes ($SSL_INCLUDE)" logecho -en "Checking for OpenSSL >= $RW ... " SSL_VER="0.9.7g" SSL_VER=`$TEMP_X` SW=$SSL_VER NUMVER=`echo $SSL_VER | sed 's/[^0-9\.]//g'` SUBVER=`echo $SSL_VER | sed 's/[0-9\.]//g'` REL=`asctoint $SUBVER` SSL_VER="$NUMVER$REL" check_version $WANTED_VER $SSL_VER "OpenSSL" $RW $SW if [ "$VERSION_OK" != "yes" ] then BAIL=yes fi fi # echo -e "Want : $WANTED_VER" # echo -e "Have : $SSL_VER" rm -f $TEMP_C rm -f $TEMP_X if [ "$BAIL" != "yes" ] then logecho "$SW (OK)" fi } #}}} function check_glib2 # {{{ { WANTED_VER=$1 logecho -en "Checking for glib2 includes ... " TEMP_C="$C_TEMPDIR/check_glib2.c" TEMP_X=`mktemp $C_TEMPDIR/check_ssl.XXXXXX` cat > $TEMP_C < #include int main ( void ) { return 0; } XEOF log -e "Trial compiling $TEMP_C" cat $TEMP_C >> $CONFLOG test_include $CC $TEMP_C "" $TEMP_X -I "$GLIB2INCLUDES" GLIB2_INCLUDE=$TRIAL log -e "Succes, set GLIB2_INCLUDE=$GLIB2_INCLUDE" if [ ! -x "$TEMP_X" ] then logecho "fail" BAIL=yes logecho "We were not able to compile the test program for glib2. Have you installed the Headers (-devel package of your distro) ?" logecho "Could not find glib.h in any of $GLIB2INCLUDES" return fi cat > $TEMP_C < int main ( void ) { return 0; // printf("%d.%d.%d\n", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION) } XEOF log -e "Trial compiling $TEMP_C" cat $TEMP_C >> $CONFLOG test_include $CC $TEMP_C "-I $GLIB2_INCLUDE" $TEMP_X -I "$GLIB2CONFIG" GLIB2_CONFIG=$TRIAL log -e "GLIB2_CONFIG=$GLIB2_CONFIG" if [ -z "$GLIB2_CONFIG" ] then BAIL=yes logecho -e "fail" logecho -e "Could not find glibconfig.h in any of $GLIB2CONFIG" return fi cat > $TEMP_C < int main ( void ) { printf("%d.%d.%d\n", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION); return 0; } XEOF log -e "Trial compiling $TEMP_C" cat $TEMP_C >> $CONFLOG test_include $CC $TEMP_C "-I $GLIB2_INCLUDE -I $GLIB2_CONFIG" $TEMP_X -L "$GLIB2LIBDIRS" GLIB2_LIBDIR=$TRIAL if [ -z "$GLIB2_LIBDIR" ] then BAIL=yes logecho -e "fail" logecho -e "Could not find libglib-2.0 in any of $GLIB2LIBDIRS" return fi GLIB2_VER=`$TEMP_X` check_version $WANTED_VER $GLIB2_VER "glib2" if [ "$VERSION_OK" != "yes" ] then BAIL=yes fi if [ "$BAIL" != "yes" ] then logecho "$GLIB2_VER (OK)" fi rm -f $TEMP_C rm -f $TEMP_X } #}}} function check_orbit2 # {{{ { WANTED_VER=$1 logecho -en "Checking for ORBit2 includes ... " TEMP_C="$C_TEMPDIR/check_ORBit2.c" TEMP_X=`mktemp $C_TEMPDIR/check_ORBit2.XXXXXX` cat > $TEMP_C < #include int main ( void ) { return 0; } XEOF log -e "Trial compiling $TEMP_C" cat $TEMP_C >> $CONFLOG if [ -z "$LINC_INCLUDE" ] then LINC_INCLUDE="/usr/include/linc-1.0" fi test_include $CC $TEMP_C "-I $LINC_INCLUDE -I $GLIB2_CONFIG -I $GLIB2_INCLUDE" $TEMP_X -I "$ORBIT2INCLUDES" ORBIT2_INCLUDE=$TRIAL log -e "Succes, set ORBIT2_INCLUDE=$ORBIT2_INCLUDE" if [ ! -x "$TEMP_X" ] then logecho "fail" BAIL=yes logecho "We were not able to compile the test program for ORBit2. Have you installed the Headers (-devel package of your distro) ?" else logecho "(OK)" fi ############# DONE CHECKING FOR HEADERS cat > $TEMP_C < int main ( void ) { printf("%d.%d.%d\n", ORBIT_MAJOR_VERSION, ORBIT_MINOR_VERSION, ORBIT_MICRO_VERSION); return 0; } XEOF ############# CHECKING LIBRARY PATH AND VERSION logecho -en "Checking for ORBit2 >= $WANTED_VER ... " log -e "Trial compiling $TEMP_C" cat $TEMP_C >> $CONFLOG if [ -z "$LINC_INCLUDE" ] then LINC_INCLUDE="/usr/include/linc-1.0" fi test_include $CC $TEMP_C "-lORBit-2 -I $LINC_INCLUDE -I $ORBIT2_INCLUDE" $TEMP_X -L "$ORBIT2LIBDIRS" ORBIT2_LIBDIR=$TRIAL log -e "Setting ORBIT2_LIBDIR=$TRIAL" if [ -z "$ORBIT2_LIBDIR" ] then BAIL=yes logecho -e "fail" logecho -e "Could not find libORBit-2 in any of $ORBIT2LIBDIRS" return fi ORBIT2_VER=`$TEMP_X` check_version $WANTED_VER $ORBIT2_VER "ORBit2" if [ "$VERSION_OK" != "yes" ] then BAIL=yes fi if [ "$BAIL" != "yes" ] then logecho "$ORBIT2_VER (OK)" fi rm -f $TEMP_C rm -f $TEMP_X } #}}} function check_orbitcpp # {{{ { WANTED_VER=$1 logecho -en "Checking for orbitcpp includes ... " TEMP_C="$C_TEMPDIR/check_orbitcpp.c" TEMP_X=`mktemp $C_TEMPDIR/check_orbitcpp.XXXXXX` cat > $TEMP_C < #include int main ( void ) { return 0; } XEOF log -e "Trial compiling $TEMP_C" cat $TEMP_C >> $CONFLOG if [ -z "$LINC_INCLUDE" ] then LINC_INCLUDE="/usr/include/linc-1.0" fi test_include $CPP $TEMP_C "-I $LINC_INCLUDE -I $ORBIT2_INCLUDE -I $GLIB2_CONFIG -I $GLIB2_INCLUDE" $TEMP_X -I "$ORBITCPPINCLUDES" ORBITCPP_INCLUDE=$TRIAL log -e "Succes, set ORBITCPP_INCLUDE=$ORBITCPP_INCLUDE" if [ ! -x "$TEMP_X" ] then logecho "fail" BAIL=yes logecho "We were not able to compile the test program for orbitcpp. Have you installed the Headers (-devel package of your distro) ?" fi cat > $TEMP_C < #include using namespace _orbitcpp; int main ( void ) { printf("%d.%d.%d\n", LIB_MAJOR_VERSION, LIB_MINOR_VERSION, LIB_MICRO_VERSION); return 0; } XEOF log -e "Trial compiling $TEMP_C" cat $TEMP_C >> $CONFLOG test_include $CPP $TEMP_C "-lORBit-2-cpp -I $ORBITCPP_INCLUDE" $TEMP_X -L "$ORBITCPPLIBDIRS" ORBITCPP_LIBDIR=$TRIAL log -e "ORBITCPP_LIBDIR=$ORBITCPP_LIBDIR" if [ -z "$ORBITCPP_LIBDIR" ] then BAIL=yes logecho -e "fail" logecho -e "Could not find libORBit-2-cpp in any of $ORBITCPPLIBDIRS" return fi ORBITCPP_VER=`$TEMP_X` check_version $WANTED_VER $ORBITCPP_VER "orbitcpp" if [ "$VERSION_OK" != "yes" ] then BAIL=yes fi if [ "$BAIL" != "yes" ] then logecho "$ORBITCPP_VER (OK)" fi rm -f $TEMP_C rm -f $TEMP_X logecho -en "Checking for orbit-idl-2 ... " for idl in $ORBITCPPIDLS do if [ -x $idl ] then ORBITCPPIDL=$idl fi done if [ -z "$ORBITCPPIDL" ] then echo "none" echo -e "Could not find orbit-idl-2 in any of $ORBITCPPIDLS" BAIL=yes else logecho "yes ($ORBITCPPIDL)" fi } #}}} function check_strnlen # {{{ { logecho -en "Checking for strnlen ... " TEMP_C="$C_TEMPDIR/check_strnlen.c" TEMP_X=`mktemp $C_TEMPDIR/check_strnlen.XXXXXX` cat > $TEMP_C < int main ( void ) { strnlen(NULL,0); } XEOF log -e "Test Program $TEMP_C" cat $TEMP_C >> $CONFLOG log -e "Exec( $CC $TEMP_C -o $TEMP_X )" $CC $TEMP_C -o $TEMP_X >> $CONFLOG 2>&1 if [ -x "$TEMP_X" ] then HAVE_STRNLEN="yes" logecho "yes" else HAVE_STRNLEN="no" logecho "no" fi rm -f $TEMP_C rm -f $TEMP_X } #}}} function check_clock_gettime # {{{ { logecho -en "Checking for clock_gettime ... " TEMP_C="$C_TEMPDIR/check_clock_gettime.c" TEMP_X=`mktemp $C_TEMPDIR/check_clock_gettime.XXXXXX` cat > $TEMP_C < int main ( void ) { clock_gettime(CLOCK_REALTIME,NULL); } XEOF log -e "Test Program $TEMP_C" cat $TEMP_C >> $CONFLOG log -e "Exec( $CC $TEMP_C -o $TEMP_X )" if [ "$OS_TYPE" == "linux" ] then $CC -lrt $TEMP_C -o $TEMP_X >> $CONFLOG 2>&1 else $CC $TEMP_C -o $TEMP_X >> $CONFLOG 2>&1 fi if [ -x "$TEMP_X" ] then HAVE_CLOCK_GETTIME="yes" logecho "yes" else HAVE_CLOCK_GETTIME="no" logecho "no" fi rm -f $TEMP_C rm -f $TEMP_X } #}}} function check_strcasestr # {{{ { logecho -en "Checking for strcasestr ... " TEMP_C="$C_TEMPDIR/check_strcasestr.c" TEMP_X=`mktemp $C_TEMPDIR/check_strcasestr.XXXXXX` cat > $TEMP_C < int main ( void ) { strcasestr(NULL,NULL); } XEOF log -e "Test Program $TEMP_C" cat $TEMP_C >> $CONFLOG log -e "Exec( $CC $TEMP_C -o $TEMP_X )" $CC $TEMP_C -o $TEMP_X >> $CONFLOG 2>&1 if [ -x "$TEMP_X" ] then HAVE_STRCASESTR="yes" echo "yes" else HAVE_STRCASESTR="no" echo "no" fi rm -f $TEMP_C rm -f $TEMP_X } #}}} function check_vasprintf # {{{ { logecho -en "Checking for vasprintf ... " TEMP_C="$C_TEMPDIR/check_vasprintf.c" TEMP_X=`mktemp $C_TEMPDIR/check_vasprintf.XXXXXX` cat > $TEMP_C < #include int main ( void ) { vasprintf(NULL,0); } XEOF log -e "Test Program $TEMP_C" cat $TEMP_C >> $CONFLOG log -e "Exec( $CC $TEMP_C -o $TEMP_X )" $CC $TEMP_C -o $TEMP_X >> $CONFLOG 2>&1 if [ -x "$TEMP_X" ] then HAVE_VASPRINTF="yes" logecho "yes" else HAVE_VASPRINTF="no" logecho "no" fi rm -f $TEMP_C rm -f $TEMP_X } #}}} function check_strerror_r # {{{ { logecho -en "Checking for strerror_r ... " TEMP_C="$C_TEMPDIR/check_strerror_r.c" TEMP_X=`mktemp $C_TEMPDIR/check_strerror_r.XXXXXX` cat > $TEMP_C < int main ( void ) { strerror_r(0,NULL,0); } XEOF log -e "Test Program $TEMP_C" cat $TEMP_C >> $CONFLOG log -e "Exec( $CC $TEMP_C -o $TEMP_X )" $CC $TEMP_C -o $TEMP_X >> $CONFLOG 2>&1 if [ -x "$TEMP_X" ] then HAVE_STRERROR_R="yes" logecho "yes" else HAVE_STRERROR_R="no" logecho "no" fi rm -f $TEMP_C rm -f $TEMP_X } #}}} function check_wireless # {{{ { case $OS_TYPE in linux) check_wireless_linux ;; mac) logecho -e $RED logecho logecho "Sorry, we dont have wireless support for MacOSX yet." logecho "It is heavily beeing worked on, please check a newer release." logecho -e $NOR ;; *) logecho -e $RED logecho logecho "Your Hosttype is not supportted for wireless operations" logecho -e $NOR ;; esac if [ "$HAVE_WIRELESS" != "yes" ] then logecho "Proceeding without wireless support" else logecho "Proceeding with wireless support" fi } # }}} function check_wireless_linux # {{{ { logecho -en "Checking for Linux wireless headers... " TEMP_C="$C_TEMPDIR/check_wireless.c" TEMP_X=`mktemp $C_TEMPDIR/check_wireless.XXXXXX` cat > $TEMP_C < #include int main ( void ) { printf("%d",WIRELESS_EXT); } XEOF log -e "Test Program $TEMP_C" cat $TEMP_C >> $CONFLOG log -e "Exec( $CC $TEMP_C -o $TEMP_X )" $CC $TEMP_C -o $TEMP_X >> $CONFLOG 2>&1 if [ -x "$TEMP_X" ] then HAVE_WIRELESS="yes" EXT_VER=$($TEMP_X) logecho "yes (wireless extensions $EXT_VER)" else HAVE_WIRELESS="no" logecho "no" logecho -e $RED logecho -e "We were unable to find the Linux Wireless Extension Headers" logecho -e $NOR # BAIL="yes" fi rm -f $TEMP_C rm -f $TEMP_X } #}}} function check_dlopen # {{{ { logecho -en "Checking for dlopen ... " TEMP_C="$C_TEMPDIR/check_dlopen.c" TEMP_X=`mktemp $C_TEMPDIR/check_dlopen.XXXXXX` cat > $TEMP_C < #include int main ( void ) { dlopen(NULL,0); } XEOF log -e "The Test Program $TEMP_C" cat $TEMP_C >> $CONFLOG DLLIB="none" test_include $CC $TEMP_C "$CFLAGS" $TEMP_X "" "$DLLIBS" DLLIB=$TRIAL log -e "Set DLLIB=$DLLIB" if [ -x "$TEMP_X" ] then logecho "(OK) with $DLLIB" fi if [ "$DLLIB" == "none" ] then logecho "fail. We were not able to determine how to use dlopen()" BAIL=yes fi LIBLIBS="$LIBLIBS $DLLIB" rm -f $TEMP_C rm -f $TEMP_X } #}}} function check_pthread # {{{ { logecho -en "Checking for libpthread... " TEMP_C="$C_TEMPDIR/check_pthread.c" TEMP_X=`mktemp $C_TEMPDIR/check_pthread.XXXXXX` cat > $TEMP_C < int main ( void ) { pthread_self(); } XEOF log -e "The Test Program $TEMP_C" cat $TEMP_C >> $CONFLOG TLIB="none" test_include $CC $TEMP_C "$CFLAGS" $TEMP_X "" "$THREADLIBS" TLIB=$TRIAL log -e "Set TLIB=$TLIB" if [ -x "$TEMP_X" ] then logecho "(OK) with $TLIB" fi if [ "$TLIB" == "none" ] then logecho "fail. We were not able to determine how to use POSIX Threads" BAIL=yes fi LIBLIBS="$LIBLIBS $TLIB" rm -f $TEMP_C rm -f $TEMP_X } #}}} function check_doxygen #{{{ { logecho -en "Checking for doxygen ... " DOXYGEN=`which doxygen 2>/dev/null` if [ -z "$DOXYGEN" ] then DOXYGEN="ls" echo "no" BAIL="yes" mkdir -p doc cat > doc/EMPTY </dev/null " else echo -e "$DOXYGEN (OK)" fi log -e "DOXYGEN=$DOXYGEN" } # }}} function check_libpqxx # {{{ { WANTED_VER=$1 logecho -en "Checking for usable libpqxx ... " if [ "$PKG_CONFIG" ] then $PKG_CONFIG --exists libpqxx EXIST=$? if [ "$EXIST" == 0 ] then logecho "(OK)" else logecho "failed" logecho "We were not able to locate libpqxx via pkg-config" BAIL=yes return fi PQX_VER=$($PKG_CONFIG --modversion libpqxx) else TEMP_CPP="$C_TEMPDIR/check_libpq.cpp" TEMP_X=`mktemp $C_TEMPDIR/check_libpq.XXXXXX` cat > $TEMP_CPP < #include int main ( void ) { pqxx::connection Conn; int maj, min, rel; printf(VERSION); } XEOF log -e "TEst Program $TEMP_CPP" cat $TEMP_CPP >> $CONFLOG log -e "Exec( $CPP $CPPFLAGS -I $PG_INCLUDE -lpqxx $TEMP_CPP -o $TEMP_X)" $CPP $CPPFLAGS -I $PG_INCLUDE -lpqxx $TEMP_CPP -o $TEMP_X >> $CONFLOG 2>&1 if [ ! -x $TEMP_X ] then logecho -e "fail" logecho -e "We were not able to generate a check program, please see $CONFLOG for details" BAIL=yes return fi logecho "(OK)" PQX_VER=`$TEMP_X 2>/dev/null` fi logecho -en "Checking for libpqxx >= $WANTED_VER ... " check_version $WANTED_VER $PQX_VER "libpqxx" if [ "$VERSION_OK" != "yes" ] then BAIL=yes return fi rm -f $TEMP_CPP rm -f $TEMP_X logecho -e "$PQX_VER (OK)" } #}}} function check_xerces # {{{ { WANTED_VER=$1 CHECKME=xerces logecho -en "Checking for lib$CHECKME ..." search_libdir "-lxerces-c" "$XERCESLIBDIRS" logsetvar XERCES_LIBDIR $FOUNDLIB if [ -z "$FOUNDLIB" ] then logecho -e "fail" logecho -e "We were not able to generate a check program for $CHECKME." logecho -e "please see $CONFLOG for details" BAIL=yes return fi logecho "(OK)" TEMP_CPP="$C_TEMPDIR/check_xerces.cpp" TEMP_X=`mktemp $C_TEMPDIR/check_xerces.XXXXXX` cat > $TEMP_CPP < #include int main ( void ) { printf("%d.%d.%d", XERCES_VERSION_MAJOR, XERCES_VERSION_MINOR, XERCES_VERSION_REVISION); return 0; } XEOF logecho -en "Checking for $CHECKME includes ... " test_include $CPP $TEMP_CPP "$CFLAGS" $TEMP_X -I "$XERCESINCDIRS" if [ -x $TEMP_X ] then XER_VER=$($TEMP_X) logecho " (OK)" else logecho -e " failed" BAIL=yes return fi logecho -en "Checking for $CHECKME >= $WANTED_VER ... " check_version $WANTED_VER $XER_VER "xerces" if [ "$VERSION_OK" != "yes" ] then BAIL=yes return fi rm -f $TEMP_CPP rm -f $TEMP_X logecho -e "$XER_VER (OK)" } #}}} function check_qt3 # {{{ { WANTED_VER=$1 CHECKME=qt3 logecho -en "Checking for lib$CHECKME ..." search_libdir "-lqt-mt" "$QT3LIBDIRS" logsetvar QT3_LIBDIR $FOUNDLIB if [ -z "$FOUNDLIB" ] then logecho -e "fail" logecho -e "We were not able to generate a check program for $CHECKME." logecho -e "please see $CONFLOG for details" BAIL=yes return fi logecho "(OK)" TEMP_CPP="$C_TEMPDIR/check_qt3.cpp" TEMP_X=`mktemp $C_TEMPDIR/check_qt3.XXXXXX` cat > $TEMP_CPP < #include int main ( void ) { printf(QT_VERSION_STR); return 0; } XEOF logecho -en "Checking for $CHECKME includes ... " test_include $CPP $TEMP_CPP "$CFLAGS" $TEMP_X -I "$QT3INCDIRS" logsetvar QT3_INCLUDE $TRIAL if [ -x $TEMP_X ] then QT3_VER=$($TEMP_X) logecho " (OK)" else logecho -e " failed" BAIL=yes return fi logecho -en "Checking for $CHECKME >= $WANTED_VER ... " check_version $WANTED_VER $QT3_VER "qt3" if [ "$VERSION_OK" != "yes" ] then BAIL=yes return fi rm -f $TEMP_CPP rm -f $TEMP_X logecho -e "$QT3_VER (OK)" QT3_BINDIR=$(echo -n $QT3_LIBDIR | sed 's/lib\/$/bin\//') logecho -en "Checking for moc compiler in $QT3_BINDIR ... " if [ -x $QT3_BINDIR/moc ] then MOC=$QT3_BINDIR/moc logecho -e "($MOC)" else BAIL=yes return fi } #}}} function set_incdir #{{{ { INCDIR=$1 if [ ! -z "$INCDIR" ] then echo "INCLUDES:=\$(INCLUDES) -I $INCDIR" >> $MAKEFILE fi } #}}} function set_libdir #{{{ { LIBDIR=$1 if [ ! -z "$LIBDIR" ] then echo "LIBSEARCH:=\$(LIBSEARCH) -L $LIBDIR" >> $MAKEFILE fi } #}}} function check_echo # {{{ { logecho -en "Checking how to invoke echo in make ... " OUTPUT=`echo -en` if [ -z "$OUTPUT" ] then logecho " with -en" ECHOEN="echo -en" else logecho " plain" ECHOEN="echo" fi } # }}} # This generates the makefile from all the set variables function gen_makefile # {{{ { if [ ! -z "$C_TEMPDIR" ] then rm -rf $C_TEMPDIR fi MAKEFILE=$1 logecho -e "Generating $MAKEFILE" cat > $MAKEFILE <> $MAKEFILE fi if [ ! -z "$CPPFLAGS" ] then echo -e "Overriding \$CPPFLAGS to \"$CPPFLAGS\"" echo -e "\nCPPFLAGS=$CPPFLAGS" >> $MAKEFILE fi echo -e "\nCC=$CC" >> $MAKEFILE echo -e "CPP=$CPP" >> $MAKEFILE echo -e "\nLIBNAME=$LIBNAME" >> $MAKEFILE echo -e "LIBVERSION=$VERSION" >> $MAKEFILE echo -e "PREFIX=$PREFIX" >> $MAKEFILE echo -e "SYSCONF=$SYSCONF" >> $MAKEFILE echo -e "LIBS=$LIBS" >> $MAKEFILE echo -e "LIBLIBS=$LIBLIBS" >> $MAKEFILE echo -e "INCLUDES=$INCLUDES" >> $MAKEFILE echo -e "EXTRACLEANFILES=$EXTRACLEANFILES" >> $MAKEFILE echo -e "STERILFILES=$STERILFILES" >> $MAKEFILE echo -e "STERILDIRS=$STERILDIRS" >> $MAKEFILE echo -e "LIBSEARCH=$PREFIX/lib/" >> $MAKEFILE echo -e "DISTNAME=$DISTNAME" >> $MAKEFILE echo -e "DISTDIR=$DISTDIR" >> $MAKEFILE echo -e "DOXYGEN=$DOXYGEN" >> $MAKEFILE echo -e "ECHOEN=$ECHOEN" >> $MAKEFILE echo -e "DLLIB=$DLLIB" >> $MAKEFILE echo -e "DYN_SUFFIX=$DYN_SUFFIX" >> $MAKEFILE echo -e "LIBFLAGS=$LIBFLAGS" >> $MAKEFILE echo -e "WEXTRA=$WEXTRA" >> $MAKEFILE echo -e "CPPFLAGS:=\$(CPPFLAGS) \$(WEXTRA)" >> $MAKEFILE echo >> $MAKEFILE echo -en "SRCDIRS=" >> $MAKEFILE for dir in $SRCDIRS do echo -en "\$(TOPDIR)/$dir " >> $MAKEFILE done echo >> $MAKEFILE echo >> $MAKEFILE #MAINSRC=`echo -e $SRDIRS | cut -d" " -f1` if [ "$HAVE_STRCASESTR" == "no" ] then LIBFILES_src="$LIBFILES_src strcasestr.o" fi if [ "$HAVE_STRNLEN" == "no" ] then LIBFILES_src="$LIBFILES_src strnlen.o" fi if [ "$HAVE_CLOCK_GETTIME" == "no" ] then LIBFILES_src="$LIBFILES_src clock_gettime.o" fi set_incdir $PG_INCLUDE set_incdir $SSL_INCLUDE set_incdir $GLIB2_INCLUDE set_incdir $ORBITCPP_INCLUDE set_incdir $ORBIT2_INCLUDE set_incdir $GLIB2_CONFIG set_incdir $IWEAR_INCLUDE set_incdir $QT3_INCLUDE set_libdir $GLIB2_LIBDIR set_libdir $ORBIT2_LIBDIR set_libdir $QT3_LIBDIR set_libdir $IWEAR_LIBDIR set_libdir $ORBITCPP_LIBDIR for dir in $SRCDIRS do VARNAME="\$LIBFILES_$dir" eval "FILES=$VARNAME" # echo -e "$VARNAME=$FILES" | sed 's/^\$//' >> $MAKEFILE NVARNAME=$(echo -e "$VARNAME=" | sed 's/^\$//') echo -en $NVARNAME >> $MAKEFILE for file in $FILES do echo -n $file" " >> $MAKEFILE done echo >> $MAKEFILE done if [ ! -z "$ORBITCPPIDL" ] then echo "OIDL2:=$ORBITCPPIDL" >> $MAKEFILE fi if [ ! -z "$MOC" ] then echo "MOC=$MOC" >> $MAKEFILE fi } # }}} # This generates the config.h header function gen_config # {{{ { CONFIG_H=$1 log -e "Generating $CONFIG_H" cat > $CONFIG_H <> $CONFIG_H echo -e "#define __CONFIG_H" >> $CONFIG_H echo -e "\n#define PREFIX \"$PREFIX\"" >> $CONFIG_H echo -e "\n#define DYN_SUFFIX \"$DYN_SUFFIX\"" >> $CONFIG_H echo -e "\n#define SYSCONF \"$SYSCONF\"" >> $CONFIG_H echo -e "#define ARCH \"$CPU\"" >> $CONFIG_H # TODO We need to really check for gnu compatible environment echo -e "\n#ifndef _GNU_SOURCE" >> $CONFIG_H echo -e "#define _GNU_SOURCE" >> $CONFIG_H echo -e "#endif\n" >> $CONFIG_H echo -e "#endif\n\n" >> $CONFIG_H # # End global config.h ... the next is specific to iwear headers, and therefore should only origin there echo -e "#ifndef __${GPREFIX}_CONFIG_H" >> $CONFIG_H echo -e "#define __${GPREFIX}_CONFIG_H" >> $CONFIG_H if [ "$SSL_INCLUDE" ] then echo -e "\n#undef SSL_INCLUDE" >> $CONFIG_H echo -e "#define SSL_INCLUDE $SSL_INCLUDE" >> $CONFIG_H echo -e "#define SSINC(x) " >> $CONFIG_H echo -e "#ifndef OPENSSL_NO_KRB5" >> $CONFIG_H echo -e "#define OPENSSL_NO_KRB5" >> $CONFIG_H echo -e "#endif " >> $CONFIG_H fi if [ "$HAVE_STRNLEN" == "yes" ] then echo -e "\n#undef HAVE_STRNLEN" >> $CONFIG_H echo -e "#define HAVE_STRNLEN 1" >> $CONFIG_H fi if [ "$HAVE_STRCASESTR" == "yes" ] then echo -e "\n#undef HAVE_STRCASESTR" >> $CONFIG_H echo -e "#define HAVE_STRCASESTR 1" >> $CONFIG_H fi if [ "$HAVE_VASPRINTF" == "yes" ] then echo -e "\n#undef HAVE_VASPRINTF" >> $CONFIG_H echo -e "#define HAVE_VASPRINTF 1" >> $CONFIG_H fi if [ "$HAVE_STRERROR_R" == "yes" ] then echo -e "\n#undef HAVE_STRERROR_R" >> $CONFIG_H echo -e "#define HAVE_STRERROR_R 1" >> $CONFIG_H fi if [ "$HAVE_CLOCK_GETTIME" == "yes" ] then echo -e "\n#undef HAVE_CLOCK_GETTIME" >> $CONFIG_H echo -e "#define HAVE_CLOCK_GETTIME 1" >> $CONFIG_H fi if [ $OS_TYPE == "mac" ] then echo -e "\n#undef IW_MAC" >> $CONFIG_H echo -e "#define IW_MAC 1" >> $CONFIG_H fi if [ $OS_TYPE == "solaris" ] then echo -e "\n#undef IW_SOLARIS" >> $CONFIG_H echo -e "#define IW_SOLARIS 1" >> $CONFIG_H fi echo -e "\n#endif" >> $CONFIG_H VPREF=`echo -e $DISTNAME | toupper | sed 's/-/_/g'` if [ ! -z "$PG_INCLUDE" ] then echo -e "#define HAVE_IWPGDB 1" >> $CONFIG_H fi read V_MAJOR V_MINOR V_RELEASE < <(echo $VERSION | sed 's/\./ /g'); echo -e "\n#ifndef ${VPREF}_MAJOR" >> $CONFIG_H echo -e "#define ${VPREF}_MAJOR $V_MAJOR" >> $CONFIG_H echo -e "#define ${VPREF}_MINOR $V_MINOR" >> $CONFIG_H echo -e "#define ${VPREF}_RELEASE $V_RELEASE" >> $CONFIG_H echo -e "#endif" >> $CONFIG_H } # }}}