#!/bin/sh # # Configuration script for Services. # # IRC Services is copyright (c) 1996-2009 Andrew Church. # E-mail: # Parts written by Andrew Kempe and others. # This program is free but copyrighted software; see the file GPL.txt for # details. ########################################################################### # Temporary directory to use for various things. CONFTMP=conf-tmp ########################################################################### # Nifty handy functions. # Echo something and stay on the same line. echo2 () { $ECHO2 "$*$ECHO2SUF" # these are defined below } # Write a line to the log file, including the current test mode. log () { echo >&3 "$MODE: $*" } # Run a command, writing the command, output, and exit status (if nonzero) # to the log. run () { echo >&3 "$MODE: >>> $*" ("$@") >&3 2>&3 &3 "$MODE: *** Command failed (exit code $xxres)" fi return $xxres } # Test whether a file exists (some shells don't have "test -e"). exists () { if [ -f $1 -o -d $1 -o -p $1 -o -c $1 -o -b $1 ] ; then return 0 else return 1 fi } # Run grep without any output. grep_q () { grep >/dev/null 2>&1 "$@" } ########################################################################### # How can we echo something without going to the next line? ECHO2SUF='' if [ "`echo -n a ; echo -n b`" = "ab" ] ; then ECHO2='echo -n' elif [ "`echo 'a\c' ; echo 'b\c'`" = "ab" ] ; then ECHO2='echo' ; ECHO2SUF='\c' elif [ "`printf 'a' 2>&1 ; printf 'b' 2>&1`" = "ab" ] ; then ECHO2='printf "%s"' else # oh well... ECHO2='echo' fi export ECHO2 ECHO2SUF ########################################################################### # Kludge around GNU coreutils stuffiness. (Some versions of `head' refused # to recognize the standard "head -1" syntax, insisting on "head -n 1".) head_is_broken="" if [ x`echo test | head -1 2>/dev/null` != xtest ] ; then head_is_broken=broken elif [ "x`echo test | head -1 2>&1 >/dev/null`" != x ] ; then head_is_broken=broken fi HEAD () { if test "$head_is_broken" ; then count=$1; shift head -n`echo x$count | cut -c3-` "$@" else head "$@" fi } ########################################################################### # Return the default flags for the given C compiler. def_cc_flags () { GCC=no a=`echo "x$1" | cut -c1-4` if [ "$a" = "xgcc" -o "x$1" = "xkgc" ] ; then GCC=yes elif "$1" --version 2>/dev/null | grep_q '(GCC)' ; then GCC=yes fi if [ $GCC = yes ] ; then echo "-O2 -fno-strict-aliasing" elif [ "X$1" = "Xicc" ] ; then echo "-O0 -wd144,167,556" fi } ########################################################################### # Test for the presence of a given include file or function. If the # variable TEST is non-empty, it contains code to be placed at the end of # main(), and should return 0 if everything is okay, else 1. # # For includes: Pass the include filename as an argument. The variable # HAVE_include_name, where "include_name" is the name of the include file # with letters uppercased and non-alphanumerics replaced by underscores, is # set to 1 if the include file is present, else 0. # # For functions: Pass the return type, function name, and prototype as # arguments. The variable HAVE_function, where "function" is the name # of the function with letters uppercased, is set to 1 if the function is # available, else 0. # # For both: The result code of the function will be 0 (true) if the entity # is present, else 1 (false). test_include () { include="$1" inc2="`echo $include | sed 'y+abcdefghijklmnopqrstuvwxyz/.-+ABCDEFGHIJKLMNOPQRSTUVWXYZ___+'`" if [ -f "/usr/include/$include" ] ; then eval "HAVE_${inc2}=1" log "found $include in /usr/include" return 0 fi cat >$CONFTMP/test.c < int main() { return 0; } EOT if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then eval "HAVE_${inc2}=1" log "found $include" return 0 else eval "HAVE_${inc2}=0" log "didn't find $include" return 1 fi } test_function () { rettype="$1" func="$2" proto="$3" if [ ! "$rettype" -o ! "$func" ] ; then log "test_function: missing parameter(s)" return 1 fi if [ ! "$proto" ] ; then proto="(...)" fi func2=`echo $func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` if [ ! "$TEST" ] ; then TEST="return 0;" fi cat >$CONFTMP/test.c <&1 ; then eval "HAVE_${func2}=1" log "found $func" return 0 else eval "HAVE_${func2}=0" log "didn't find $func" return 1 fi } ########################################################################### # If something happens that really shouldn't: whoa_there () { cat <&2 "Unknown option/parameter: $option" exitval=1 else exitval=0 fi cat >&2 <); overrides -bindest/-datdest *** Controlling Services features *** Note that the following functions can be disabled by adding "no-" before the option name; for example, "-no-use-local-funcs". For options with a * before the option name, the option is on by default, and you must explicitly give -no-option-name to disable it. -use-local-funcs Force the use of compatibility functions over system library functions (for debugging) -use-static-modules Force modules to be compiled statically, even if dynamic modules could be used * -sorted-lists Keep nickname/channel lists sorted (causes a performance penalty on large networks) * -clean-compile Attempt to compile with no warnings (causes a slight performance penalty) -memchecks Perform extra checks on memory allocation (for debugging only; causes a significant performance penalty) -showallocs Log all memory allocation activity (for debugging only; ignored unless -memchecks is enabled) -dumpcore Causes Services to attempt to write a core file if it crashes (for debugging) *** Other options *** -check Check whether this script has already been run and whether the cache is up-to-date. Exits with status 0 if up-to-date, 1 if not. GNU-style long options (--option[=value]) may also be used. Note that environment variables such as CC and CFLAGS are ignored; use the corresponding command-line options (-cc, -cflags, etc.) instead. EOT exit $exitval fi fi done ########################################################################### echo "" echo "Beginning IRC Services configuration." echo "" ########################################################################### # First, test for the presence of a config.cache file. If found, either # don't use it (-ignore-cache), or let the user know how to not use it and # then use it. if [ -f config.cache -a -r config.cache -a ! "$IGNORE_CACHE" ] ; then cat <configure.log MODE=" " TEST="" export MODE TEST ########################################################################### # Check whether we have a working "test FILE_A -nt FILE_B". MODE="check_test_nt " if [ "$TEST_NT" ] ; then log "cache says $TEST_NT" else echo2 "Checking sanity of /bin/sh... " touch $CONFTMP/file1 sleep 2 # just in case sleep 1 really does a sleep 0.997 or some such touch $CONFTMP/file2 if run /bin/sh -c "test $CONFTMP/file2 -nt $CONFTMP/file1" ; then TEST_NT=test log "test works" echo "high." elif run /bin/test $CONFTMP/file2 -nt $CONFTMP/file1 ; then TEST_NT=/bin/test log "/bin/test works" echo "medium." elif run /usr/bin/test $CONFTMP/file2 -nt $CONFTMP/file1 ; then TEST_NT=/usr/bin/test log "/usr/bin/test works" echo "medium." else log "neither test nor /bin/test nor /usr/bin/test work!" echo "low." echo " Warning: Compilation may fail unless you pass a saner shell to make:" echo " make [or gmake] SHELL=/usr/local/bin/bash ..." fi fi ########################################################################### # Search for a compiler. MODE="find_cc " # Don't use the cached flags unless we use the cached compiler as well CACHED_CC_FLAGS=$CC_FLAGS CC_FLAGS=bonkle echo2 "Searching for a suitable compiler... " if [ "$USER_CC" ] ; then CC="$USER_CC" echo "(supplied) using $CC." log user supplied \`"$CC'" elif [ "$CC" ] ; then echo "(cached) using $CC." log cache supplied \`"$CC'" CC_FLAGS=$CACHED_CC_FLAGS elif run gcc --version ; then version=`gcc --version 2>&1 | HEAD -1 | sed 's/nb[0-9]//' | sed 's/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]//g' | sed 's/[^0-9]*[^0-9.]\([0-9][0-9.]*\).*/\1/'` vmajor=`echo "x.$version.0" | cut -d. -f2` vminor=`echo "x.$version.0" | cut -d. -f3` if test "x$version" = x || (echo "x$vmajor" | cut -c2- | grep '[^0-9]' >/dev/null 2>&1) || (echo "x$vminor" | cut -c2- | grep '[^0-9]' >/dev/null 2>&1) ; then log "unparseable version string: $version" cat <$CONFTMP/test.c "int main(){return 1;}" if run icc $CONFTMP/test.c -o $CONFTMP/test ; then CC=icc elif run cc $CONFTMP/test.c -o $CONFTMP/test ; then CC=cc else echo "no C compiler found!" echo " Use the -cc command line option to specify your C compiler." log "automatic tests failed" exit 1 fi # See if it handles ANSI. cat >$CONFTMP/test.c <$CONFTMP/test.c <$CONFTMP/test.c < void foo(int a,...) { va_list args, args2; va_start(args,a); va_copy(args2, args); va_end(args); va_end(args2); } int main() { foo(1,2); return 0; } EOT if run $CC $CONFTMP/test.c -o $CONFTMP/test && run $CONFTMP/test ; then log "va_copy ok." else log "va_copy NG! Aborting." cat <$CONFTMP/test.c <1 ? 24 : 42); return 0; } EOT if run $CC $CC_FLAGS -fstack-protector $CONFTMP/test.c -o $CONFTMP/test then log "SSP present" # See if the bug exists; if so, disable stack protection. Test # twice just in case the bug exists but the stack happens to # randomly contain 42. a=`$CONFTMP/test` b=`$CONFTMP/test x` log "test results: a=[$a] b=[$b]" if [ "$a" != 42 -o "$b" != 24 ] ; then CC_FLAGS="$CC_FLAGS -fno-stack-protector" log "SSP bug found, disabling" else log "SSP bug not detected" fi else log "SSP not present" fi echo2 "Testing default compiler flags ($CC_FLAGS)... " cat >$CONFTMP/test.c <$CONFTMP/test.c < #if defined(__sparc__) # define APPLY __builtin_apply((void *)bar,__builtin_apply_args(),64); asm("ld [%sp-128],%i0") #elif defined(__POWERPC__) # define APPLY __builtin_apply((void *)bar,__builtin_apply_args(),64); asm("mr r0,r3") #else # define APPLY __builtin_return(__builtin_apply((void *)bar,__builtin_apply_args(),64)) #endif int bar(int hogehoge) { return printf("%d", hogehoge); } int foo(int xyzzy) { APPLY; } int main(int ac, char **av) { printf(" %d",foo(ac>1?9:42)); return 0; } EOT if run $CC $CC_FLAGS -fno-inline-functions $CONFTMP/test.c -o $CONFTMP/test then run $CONFTMP/test # to get the output into the log file a=`$CONFTMP/test` b=`$CONFTMP/test x` log "test results: a=[$a] b=[$b]" if [ "$a" != "42 2" -o "$b" != "9 1" ] ; then log "-fstack-protector check failed!" cat <$CONFTMP/test.c <$CONFTMP/test.c "int main(){return 1;}" if run $CC $CC_FLAGS $CC_LFLAGS $CONFTMP/test.c -o $CONFTMP/test ; then if [ -f $CONFTMP/test.exe ] ; then log using .exe EXE_SUFFIX=.exe elif [ -f $CONFTMP/test ] ; then log using nothing EXE_SUFFIX="" else log "can't find executable, assuming nothing" EXE_SUFFIX= fi else log "can't link test program, assuming nothing" EXE_SUFFIX= fi fi ########################################################################### # See what libraries we have that we might need. MODE="find_libs " echo2 "Let's see what libraries we need..." if [ "$CC_LIBS" != bonkle ] ; then if [ "$CC_LIBS" ] ; then echo " (cached) $CC_LIBS" else echo " (cached) none" fi log cache supplied \`"$CC_LIBS'" else CC_LIBS= HAVE_RESOLV=0 cat >$CONFTMP/test.c <$CONFTMP/test-pow.c <$CONFTMP/test-socket.c <$CONFTMP/test-gethost.c <$CONFTMP/test-hstrerror.c <$CONFTMP/test-crypt.c <$CONFTMP/test-dlopen.c < int main(int argc, char **argv) { void *lib1 = dlopen("$CONFTMP/test-lib.so", RTLD_NOW | RTLD_GLOBAL); void *lib2 = dlopen("$CONFTMP/test-lib2.so", RTLD_NOW | RTLD_GLOBAL); printf("%d %d %d\n", lib1 ? 1 : 0, lib2 ? (dlsym(lib2,"foo") ? 1 : 2) : 0, lib2 ? (dlsym(0,"foo") ? 1 : 2) : 0); if (lib1) dlclose(lib1); if (lib2) dlclose(lib2); return 0; } EOT cat >$CONFTMP/test-lib.c <$CONFTMP/test-lib2.c </dev/null` log "symbol resolution test: $CONFTMP/test => $a" if [ "x$a" = "x0 1 1" ] ; then log "symbol resolution test succeeded" else log "symbol resolution test failed" OK= fi else log "couldn't run symbol resolution test program" OK= fi fi if [ "$OK" ] ; then cat >$CONFTMP/test-dynamic2.c < int main(int argc, char **argv) { printf("%d\n", foo(atoi(argv[1]))); } int quux(int xyzzy) { return xyzzy+1; } EOT cat >$CONFTMP/test-dynamic.c < $a" if [ "x$a" = "x4" ] ; then log "symbol resolution test: succeeded => using dynamic modules (dlfcn)" else log "symbol resolution test: bad output (expected 4)" OK= fi else log "symbol resolution test: dynamic compile failed" OK= fi fi fi # dlfcn test if [ "$OK" ] ; then log "checking for underscores in symbols" cat >$CONFTMP/test-dynamic2.c < #include int main(int argc, char **argv) { void *handle = dlopen(NULL, 0); printf("%d%d\n", dlsym(handle,"foo")!=NULL ? 1 : 0, dlsym(handle,"_foo")!=NULL ? 1 : 0); return 0; } int quux(int x) {return x;} EOT if run $CC $CC_FLAGS $CC_DYN_LFLAGS $CC_LIBS $CC_DYN_LIBS $CONFTMP/test-dynamic2.c $CONFTMP/test.so -o $CONFTMP/test then a=`$CONFTMP/test` log "underscore test: $CONFTMP/test => $a" with_underscore=`echo "$a" | cut -c2` without_underscore=`echo "$a" | cut -c1` if [ "x$with_underscore" = "x1" ] ; then log "underscore test: succeeded with preceding underscore" SYMS_NEED_UNDERSCORES=1 elif [ "x$without_underscore" = "x1" ] ; then log "underscore test: succeeded with no preceding underscore" SYMS_NEED_UNDERSCORES=0 else log "underscore test: failed?! (bizarre output)" OK= fi else log "underscore test: dynamic compile failed" OK= fi fi # underscore test if [ "$OK" ] ; then echo "yes." STATIC_MODULES=0 else log "static modules selected" echo "no." STATIC_MODULES=1 CC_SHARED= CC_DYN_LFLAGS= CC_DYN_LIBS= SYMS_NEED_UNDERSCORES= fi fi fi # Also check for ranlib, and use it if found. MODE="check_ranlib " echo2 "Checking whether ranlib exists... " if [ "$RANLIB" ] ; then if [ "x$RANLIB" = xranlib ] ; then log "cache says yes" echo "(cached) yes." else log "cache says no" echo "(cached) no." fi else if run echo test >$CONFTMP/testfile ; then : ; else log "couldn't create temp file!" echo "" echo "" echo "*** WHOA THERE! ***" echo "" echo "Unable to create a temporary file!" echo "Are you out of disk space?" exit 4 fi if run ar -rc $CONFTMP/test.a $CONFTMP/testfile ; then if run ranlib $CONFTMP/test.a ; then log "ranlib found" RANLIB=ranlib echo "yes." else log "ranlib not found" RANLIB='echo >/dev/null' echo "no." fi else # no ar log "couldn't run ar!" if [ $STATIC_MODULES = 1 ] ; then echo "" cat <$CONFTMP/test.c < #include int main() { char a; int8_t b; printf("%d,%d", sizeof(a), sizeof(b)); return 0; } EOT else cat >$CONFTMP/test.c < int main() { char a; printf("%d,0", sizeof(a)); return 0; } EOT fi if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then a="`$CONFTMP/test`" log "test program output (sizeof(char),sizeof(int8_t)): $a" b=`echo "$a" | cut -d, -f1` c=`echo "$a" | cut -d, -f2` if [ ! "$a" ] ; then echo "test program failed! Assuming char." log "assuming char" TYPE_INT8=char elif [ "$c" = 1 ] ; then echo int8_t log "int8_t is 8 bits" TYPE_INT8=int8_t elif [ "$b" = 1 ] ; then echo char log "char is 8 bits" TYPE_INT8=char else cat >$CONFTMP/test.c < int main() { byte a; printf("%d", sizeof(a)); return 0; } EOT if run $CC $CC_FLAGS $CONFTMP/tset.c $CC_LIBS -o $CONFTMP/test ; then a="`$CONFTMP/test`" log "test program 2 output (sizeof(byte)): $a" if [ "$a" = 1 ] ; then echo byte log "byte is 8 bits" TYPE_INT8=byte fi else log "couldn't compile test program 2, assuming no byte type" fi if [ ! "$TYPE_INT8" ] ; then echo "none found?!" cat <$CONFTMP/test.c < #include int main() { int a; short b; int16_t c; printf("%d,%d,%d", sizeof(a), sizeof(b), sizeof(c)); return 0; } EOT else cat >$CONFTMP/test.c < int main() { int a; short b; printf("%d,%d,0", sizeof(a), sizeof(b)); return 0; } EOT fi if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then a="`$CONFTMP/test`" log "test program output (sizeof(int),sizeof(short),sizeof(int16_t)): $a" if [ ! "$a" ] ; then echo "test program failed! Assuming short." log "assuming short" TYPE_INT16=short else size_int=`echo $a | cut -d, -f1` size_short=`echo $a | cut -d, -f2` size_int16_t=`echo $a | cut -d, -f3` if [ "$size_int16_t" = 2 ] ; then echo int16_t log "int16_t is 16 bits" TYPE_INT16=int16_t elif [ $size_int = 2 ] ; then echo int log "int is 16 bits" TYPE_INT16=int elif [ $size_short = 2 ] ; then echo short log "short is 16 bits" TYPE_INT16=short else echo "none found?!" cat <$CONFTMP/test.c < #include int main() { int a; long b; int32_t c; printf("%d,%d,%d", sizeof(a), sizeof(b), sizeof(c)); return 0; } EOT else cat >$CONFTMP/test.c < int main() { int a; long b; printf("%d,%d,0", sizeof(a), sizeof(b)); return 0; } EOT fi if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then a="`$CONFTMP/test`" log "test program output (sizeof(int),sizeof(long),sizeof(int32_t)): $a" if [ ! "$a" ] ; then echo "test program failed! Assuming long." log "assuming long" TYPE_INT32=long else size_int=`echo $a | cut -d, -f1` size_long=`echo $a | cut -d, -f2` size_int32_t=`echo $a | cut -d, -f3` if [ "$size_int32_t" = 4 ] ; then echo int32_t log "int32_t is 32 bits" TYPE_INT32=int32_t elif [ $size_int = 4 ] ; then echo int log "int is 32 bits" TYPE_INT32=int elif [ $size_long = 4 ] ; then echo long log "long is 32 bits" TYPE_INT32=long else echo "none found?!" cat <$CONFTMP/test.c < #include int main() { long a; long long b; int64_t c; printf("%d,%d,%d", sizeof(a), sizeof(b), sizeof(c)); return 0; } EOT else cat >$CONFTMP/test.c < int main() { long a; long long b; printf("%d,%d,0", sizeof(a), sizeof(b)); return 0; } EOT fi if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then ran=1 else if [ "$HAVE_STDINT_H" = 1 ] ; then cat >$CONFTMP/test.c < #include int main() { long a; int64_t c; printf("%d,0,%d", sizeof(a), sizeof(c)); return 0; } EOT else cat >$CONFTMP/test.c < int main() { long a; printf("%d,0,0", sizeof(a)); return 0; } EOT fi if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then ran=1 fi fi if test $ran = 1 ; then a="`$CONFTMP/test`" log "test program output (sizeof(long),sizeof(long long),sizeof(int64_t)): $a" if [ ! "$a" ] ; then echo "test program failed! Assuming long long." log "assuming long long" TYPE_INT64="long long" else size_long=`echo $a | cut -d, -f1` size_long_long=`echo $a | cut -d, -f2` size_int64_t=`echo $a | cut -d, -f3` if [ "$size_int64_t" = 8 ] ; then echo int64_t log "int64_t is 64 bits" TYPE_INT64=int64_t elif [ $size_long = 8 ] ; then echo long log "long is 64 bits" TYPE_INT64=long elif [ $size_long_long = 8 ] ; then echo "long long" log "long long is 64 bits" TYPE_INT64="long long" else echo "none found?!" cat <$CONFTMP/test.c < int main() { int a = 0; printf("%d", sizeof(a)); return 0; } EOT if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then a="`$CONFTMP/test`" log "test program output (sizeof(int)): $a" if [ ! "$a" ] ; then echo "test program failed! Assuming 16 bits." log "assuming 16 bits" SIZEOF_INT=2 else SIZEOF_INT="$a" if [ $SIZEOF_INT -lt 2 ] ; then echo "`expr $SIZEOF_INT \* 8` bits... huh?" cat <$CONFTMP/test.c < int main() { long a = 0; printf("%d", sizeof(a)); return 0; } EOT if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then a="`$CONFTMP/test`" log "test program output (sizeof(long)): $a" if [ ! "$a" ] ; then echo "test program failed! Assuming 32 bits." log "assuming 32 bits" SIZEOF_LONG=4 else SIZEOF_LONG="$a" if [ $SIZEOF_LONG -lt 4 ] ; then echo "`expr $SIZEOF_LONG \* 8` bits... huh?" cat <$CONFTMP/test.c < int main() { void *a = 0; printf("%d", sizeof(a)); return 0; } EOT if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then a="`$CONFTMP/test`" log "test program output (sizeof(void *)): $a" if [ ! "$a" ] ; then echo "test program failed! Assuming 32 bits." log "assuming 32 bits" SIZEOF_PTR=4 else SIZEOF_PTR="$a" if [ $SIZEOF_PTR -lt $SIZEOF_INT ] ; then echo "`expr $SIZEOF_PTR \* 8` bits... oops!" cat <$CONFTMP/test.c < #include int main() { time_t a = 0; printf("%d ", sizeof(a)); if (a-1 > 0) printf("(~(time_t)0)"); else printf("(((time_t)1<<(sizeof(time_t)*8-2))+(((time_t)1<<(sizeof(time_t)*8-2))-1))"); return 0; } EOT if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then a="`$CONFTMP/test`" log "test program output (sizeof(time_t) MAX_TIME_T): $a" if [ ! "$a" ] ; then echo "test program failed! Assuming 32 bits." log "assuming 32 bits" SIZEOF_TIME_T=4 else SIZEOF_TIME_T=`echo "$a" | cut -d\ -f1` MAX_TIME_T=`echo "$a" | cut -d\ -f2` if [ $SIZEOF_TIME_T = 4 ] ; then echo 32 bits log "32 bits" elif [ $SIZEOF_TIME_T = 8 ] ; then echo "64 bits (nifty!)" log "64 bits" elif [ $SIZEOF_TIME_T -gt 4 ] ; then echo "`expr $SIZEOF_TIME_T \* 8` bits... huh?" echo " If you experience any problems compiling or running Services, please" echo " report this." log "`expr $SIZEOF_TIME_T \* 8` bits" else echo "`expr $SIZEOF_TIME_T \* 8` bits... huh?" cat <$CONFTMP/test.c < #include int main() { gid_t a; printf("%d", sizeof(a)); return 0; } EOT if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then a="`$CONFTMP/test`" log "test program output (sizeof(gid_t)): $a" if [ ! "$a" ] ; then echo "test program failed! Assuming 16 bits." log "assuming 16 bits" SIZEOF_GID_T=2 else SIZEOF_GID_T=$a if [ $SIZEOF_GID_T = 4 ] ; then echo 32 bits log "32 bits" elif [ $SIZEOF_GID_T = 2 ] ; then echo "16 bits" log "16 bits" else echo "`expr $SIZEOF_GID_T \* 8` bits... huh?" echo " If you experience any problems compiling or running Services, please" echo " report this." log "`expr $SIZEOF_GID_T \* 8` bits" fi fi else echo "no gid_t found." log "couldn't compile test program, assuming no gid_t" SIZEOF_GID_T= HAVE_SETREGID=0 fi fi MODE="check_socklen_t " echo2 "Checking for socklen_t... " if [ "$HAVE_SOCKLEN_T" ] ; then if [ $HAVE_SOCKLEN_T = 1 ] ; then echo "(cached) present." log "cache said present" else echo "(cached) not present." log "cache said not present" fi else cat >$CONFTMP/test.c < #include int main() { socklen_t a; return 0; } EOT if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then log "socklen_t found" echo "present." HAVE_SOCKLEN_T=1 else log "socklen_t not found" echo "not present." HAVE_SOCKLEN_T=0 fi fi ########################################################################### # AIX workaround. MODE="check_aix_intNN " echo2 "Seeing if your system defines int16/int32... " res="`run egrep int16\|int32 /usr/include/sys/systypes.h`" if [ "$res" ] ; then echo "found." echo " (This is bad, but we can work around it.)" log "int16/int32 types found, enabling workaround" INTTYPE_WORKAROUND=1 else echo "not found (this is good)." log "int16/int32 types not found" INTTYPE_WORKAROUND=0 fi ########################################################################### # Look for missing/broken built-in routines, and similar compatibility # stuff. MODE="check_strerror " if [ "$USE_LOCAL_FUNCS" ] ; then log "not checking (-use-local-funcs)" echo "Not checking for presence of strerror (-use-local-funcs specified)." HAVE_STRERROR=0 HAVE_SYS_ERRLIST=0 else echo2 "How to complain when something goes wrong... " if [ "$HAVE_STRERROR" ] ; then if [ "$HAVE_STRERROR" = 1 ] ; then echo "(cached) strerror()." log "cache supplied strerror()" elif [ "$HAVE_SYS_ERRLIST" = 1 ] ; then echo "(cached) sys_errlist." log "cache supplied sys_errlist" else HAVE_SYS_ERRLIST=0 # just in case... you never know. echo "(cached) pseudo sys_errlist." log "cache supplied pseudo sys_errlist" fi else cat >$CONFTMP/test.c <$CONFTMP/test.c <$CONFTMP/test.c <$CONFTMP/test.c <&1` log "sysname: $sysname" case $sysname in *Linux) CP_ALL="/bin/cp -dpr"; log "guessing: cp -dpr";; CYGWIN) CP_ALL="/bin/cp -dpr"; log "guessing: cp -dpr";; *) CP_ALL="/bin/cp -pr"; log "guessing: cp -pr";; esac run rm -rf $CONFTMP/test* run echo test >$CONFTMP/test run cp $CONFTMP/test $CONFTMP/test2 if run /bin/mkdir $CONFTMP/testA && run /bin/mkdir $CONFTMP/testB && run /bin/mv $CONFTMP/test2 $CONFTMP/testA ; then : else echo "" echo "" echo "*** WHOA THERE! ***" echo "" echo "A few simple mkdir's and mv's failed!" echo "Are you out of disk space?" exit 4 fi if run $CP_ALL $CONFTMP/testA $CONFTMP/testB/testC && run cmp $CONFTMP/testA/test2 $CONFTMP/testB/testC/test2 ; then echo "$CP_ALL" log \`"$CP_ALL' works" else log \`"$CP_ALL' doesn't work" run /bin/rm -rf $CONFTMP/testB/* if run sh -c '/bin/tar Ccf $CONFTMP/testA - . | /bin/tar Cxf $CONFTMP/testB -' then echo "tar (yuck)" CP_ALL='$(TOPDIR)/cp-recursive -t' log "using tar" else log "tar failed(!)" echo "" echo " Neither cp nor tar work! I give up." exit 2 fi fi fi ########################################################################### # Create files. echo2 "Creating config.h... " rm -f config.h.new cat >config.h.new <>config.h.new <>config.h.new <>config.h.new <>config.h.new <>config.h.new <>config.h.new <>config.h.new <>config.h.new <>config.h.new <>config.h.new <>config.h.new <>config.h.new <>config.h.new </dev/null 2>&1 ; then rm -f config.h.new echo "done (unchanged)." else mv -f config.h.new config.h echo "done." fi ########################################################################### INSTEXEFLAGS="-m 750" INSTDATFLAGS="-m 640" MKDIRFLAGS="-m 750" echo2 "Creating Makefile.inc... " rm -f Makefile.inc.new cat >Makefile.inc.new <>Makefile.inc.new <>Makefile.inc.new <>Makefile.inc.new <>Makefile.inc.new </dev/null 2>&1 ; then rm -f Makefile.inc.new echo "done (unchanged)." else mv -f Makefile.inc.new Makefile.inc echo "done." fi ########################################################################### # Save results in cache for next time around. echo2 "Saving configuration results in config.cache... " cat <config.cache CONFIG_VERSION=$MY_CONFIG_VERSION BINDEST='$BINDEST' DATDEST='$DATDEST' TEST_NT='$TEST_NT' INSTALL='$INSTALL' MKDIR='$MKDIR' CP_ALL='$CP_ALL' CC='$CC' CC_FLAGS='$CC_FLAGS' CC_LFLAGS='$CC_LFLAGS' CC_LIBS='$CC_LIBS' SORTED_LISTS=$SORTED_LISTS CLEAN_COMPILE=$CLEAN_COMPILE MEMCHECKS=$MEMCHECKS SHOWALLOCS=$SHOWALLOCS DUMPCORE=$DUMPCORE STATIC_MODULES=$STATIC_MODULES CC_SHARED='$CC_SHARED' CC_DYN_LFLAGS='$CC_DYN_LFLAGS' CC_DYN_LIBS='$CC_DYN_LIBS' SYMS_NEED_UNDERSCORES=$SYMS_NEED_UNDERSCORES RANLIB='$RANLIB' TYPE_INT8=$TYPE_INT8 TYPE_INT16=$TYPE_INT16 TYPE_INT32=$TYPE_INT32 TYPE_INT64=$TYPE_INT64 SIZEOF_INT=$SIZEOF_INT SIZEOF_LONG=$SIZEOF_LONG SIZEOF_PTR=$SIZEOF_PTR SIZEOF_TIME_T=$SIZEOF_TIME_T MAX_TIME_T='$MAX_TIME_T' SIZEOF_GID_T=$SIZEOF_GID_T HAVE_SOCKLEN_T=$HAVE_SOCKLEN_T HAVE_STDINT_H=$HAVE_STDINT_H HAVE_STRINGS_H=$HAVE_STRINGS_H HAVE_SYS_SELECT_H=$HAVE_SYS_SELECT_H HAVE_SYS_SYSPROTO_H=$HAVE_SYS_SYSPROTO_H HAVE_STRERROR=$HAVE_STRERROR HAVE_SYS_ERRLIST=$HAVE_SYS_ERRLIST HAVE_SNPRINTF=$HAVE_SNPRINTF BAD_SNPRINTF=$BAD_SNPRINTF HAVE_HSTRERROR=$HAVE_HSTRERROR HAVE_STRTOK=$HAVE_STRTOK HAVE_STRICMP=$HAVE_STRICMP HAVE_STRCASECMP=$HAVE_STRCASECMP HAVE_STRDUP=$HAVE_STRDUP HAVE_STRSPN=$HAVE_STRSPN HAVE_STRSIGNAL=$HAVE_STRSIGNAL HAVE_GETTIMEOFDAY=$HAVE_GETTIMEOFDAY HAVE_SETGRENT=$HAVE_SETGRENT HAVE_SETREGID=$HAVE_SETREGID HAVE_UMASK=$HAVE_UMASK HAVE_FORK=$HAVE_FORK HAVE_GETHOSTBYNAME=$HAVE_GETHOSTBYNAME HAVE_GETSETRLIMIT=$HAVE_GETSETRLIMIT HAVE_CRYPT=$HAVE_CRYPT MISSING='$MISSING' EOT echo "done." ########################################################################### # Delete the temporary directory we created. rm -rf $CONFTMP ########################################################################### # All done! cat <