#!/bin/sh # # Search for GCC or XL C/C++, former if both exist # # To add another compiler, just create Makefile.XXX and add XXX to $CCS # # To prevent ugly Makefile extensions, underscore and chars following it # in the name XXX are automatically removed before locating relevant # Makefile. This is why compiler "xlc_r" has Makefile extension "xlc". # This can be disabled if neccessary. # CCS="xlc_r gcc" # # Look for supported compilers # for c in $CCS; do if CCPATH=`which $c 2>&1` && [ -z "${CCPATH%%/*}" ]; then CC="$c" break fi done # # Make a link to a proper Makefile.* # if [ -z "$CC" ]; then echo "Unable to find GNU GCC or IBM XL C/C++. Fix your PATH!" exit 1 else echo "Using $CCPATH to compile Cntlm" [ -h Makefile ] && rm -f Makefile 2>/dev/null case "$CC" in gcc) # default Makefile is for GCC; just revert back to # GCC if Makefile is linked to other compiler version if [ ! -f Makefile ]; then mv Makefile.gcc Makefile fi ;; *) # backup default GCC Makefile and create a link to other if [ -f Makefile ]; then mv Makefile Makefile.gcc fi EXT=`echo "$CC" | sed 's/_.*//'` ln -s Makefile.$EXT Makefile ;; esac fi STAMP=configure-stamp CONFIG=config/config.h TESTS="endian strdup socklen_t gethostname" #[ -f $STAMP ] && exit 0 touch $STAMP rm -f $CONFIG for i in $TESTS; do printf "Checking $i... " printf "#define config_$i " >> $CONFIG OUT=`$CC -D_POSIX_C_SOURCE=199506L -D_ISOC99_SOURCE -D_REENTRANT -o config/$i config/$i.c 2>&1` rc=$? if [ $rc -ne 0 ]; then # -o -n "$OUT" ]; then rc=0 RET=no else RET=`./config/$i` rc=$? [ -z "$RET" ] && if [ $rc -eq 0 ]; then RET="no"; else RET=yes; fi fi echo $rc >> $CONFIG echo $RET done