: set -u ######################################################################## # Those parameters are used in test mode argone=${1-notset} argtwo=${2-notset} if [ $argone = "notset" ] ; then envone=${NETWENVONE-notset} if [ $envone != "notset" ] ; then argone=$envone fi fi if [ $argtwo = "notset" ] ; then envtwo=${NETWENVTWO-notset} if [ $envtwo != "notset" ] ; then argtwo=$envtwo fi fi ######################################################################## . ./compil/unix/version.sh echo "Netwib version ${NETWIBDEF_VERSION} (${NETWIBDEF_VERSIONMAJOR} ${NETWIBDEF_VERSIONMINOR} ${NETWIBDEF_VERSIONMICRO})" netwv="${NETWIBDEF_VERSIONMAJOR}${NETWIBDEF_VERSIONMINOR}" ######################################################################## echo "Loading config.dat" . ./config.dat ######################################################################## echo "System name selection" unames=`(uname -s) 2>/dev/null || echo unknown` case $unames in "AIX" ) NETWIBDEF_SYSNAME="AIX" ;; "FreeBSD" ) NETWIBDEF_SYSNAME="FreeBSD" ;; "HP-UX" ) NETWIBDEF_SYSNAME="HPUX" ;; "Linux" ) NETWIBDEF_SYSNAME="Linux" ;; "Darwin" ) NETWIBDEF_SYSNAME="MacOS" ;; "NetBSD" ) NETWIBDEF_SYSNAME="NetBSD" ;; "OpenBSD" ) NETWIBDEF_SYSNAME="OpenBSD" ;; "OSF1" ) NETWIBDEF_SYSNAME="Tru64UNIX" ;; "SunOS" ) NETWIBDEF_SYSNAME="Solaris" ;; * ) echo "Error: Could not guess NETWIBDEF_SYSNAME."; echo "Edit genemake to set NETWIBDEF_SYSNAME, and rerun genemake."; echo "Please contact Laurent to permanently solve this problem."; exit 1 ;; esac echo " NETWIBDEF_SYSNAME=$NETWIBDEF_SYSNAME" ######################################################################## echo "System architecture selection" unamem=`(uname -m) 2>/dev/null || echo unknown` case $unamem in "i386" | "i486" | "i586" | "i686" | "x86" | "i86pc" | i*86 ) NETWIBDEF_SYSARCH="i386" ;; "ia64" ) NETWIBDEF_SYSARCH="ia64" ;; "amd64" | "x86_64" ) NETWIBDEF_SYSARCH="amd64" ;; alpha* ) NETWIBDEF_SYSARCH="alpha" ;; "hppa" | 9000/* | hp* | parisc* ) NETWIBDEF_SYSARCH="hppa" ;; m68* ) NETWIBDEF_SYSARCH="m68k" ;; sparc* | sun* ) NETWIBDEF_SYSARCH="sparc" ;; "sparc64" ) NETWIBDEF_SYSARCH="sparc64" ;; "ppc" | "powerpc" | "macppc" | "Power Macintosh" ) NETWIBDEF_SYSARCH="ppc" ;; "ppc64" | "powerpc64" ) NETWIBDEF_SYSARCH="ppc64" ;; arm* ) NETWIBDEF_SYSARCH="arm" ;; mips* ) NETWIBDEF_SYSARCH="mips" ;; "s390" ) NETWIBDEF_SYSARCH="s390" ;; * ) echo "Error: Could not guess NETWIBDEF_SYSARCH."; echo "Edit genemake to set NETWIBDEF_SYSARCH, and rerun genemake."; echo "Please contact Laurent to permanently solve this problem."; exit 1 ;; esac echo " NETWIBDEF_SYSARCH=$NETWIBDEF_SYSARCH" ######################################################################## echo "Checking programs" progcheck () { progname=$1 progdesc="$2" type $progname 2> /dev/null 1> /dev/null if [ "$?Z" != "0Z" ] ; then echo "Error: the $progdesc '$progname' wasn't found" exit 1 else echo " $progname yes" fi } progcheck $NETWIBDEF_PROGCC "compiler" progcheck $NETWIBDEF_PROGAR "archiver" progcheck $NETWIBDEF_PROGRANLIB "program" progcheck $NETWIBDEF_PROGGREP "grep" ######################################################################## echo "Checking directories" dircheck () { dirname=$1 dirdesc="$2" if [ ! -d $dirname ] ; then echo "Warning: the $dirdesc directory '$dirname' wasn't found" else echo " $dirname yes" fi } dircheck $NETWIBDEF_INSTPREFIX "prefix" dircheck $NETWIBDEF_INSTINCLUDE "include" dircheck $NETWIBDEF_INSTLIB "library" dircheck $NETWIBDEF_INSTBIN "binary" dircheck $NETWIBDEF_INSTMAN "man" dircheck $NETWIBDEF_INSTMAN3 "man3" ######################################################################## echo "Compilation options selection" # options gccOpt=$NETWIBDEF_PROGCC_OPT # includes gccInc=$NETWIBDEF_PROGCC_INC # libraries gccLib=$NETWIBDEF_PROGCC_LIB case $NETWIBDEF_SYSNAME in "AIX" ) gccOptPic="-fpic" gccOptSo="-shared" ;; "FreeBSD" ) gccOptPic="-fpic" gccOptSo="-shared -Xlinker \"-hlibnetwib$netwv.so\"" ;; "Linux" ) gccOptPic="-fpic" gccOptSo="-shared -Xlinker \"-hlibnetwib$netwv.so\"" ;; "MacOS" ) gccOptPic="-fpic" gccOptSo="-shared -Xlinker \"-hlibnetwib$netwv.so\"" ;; "NetBSD" ) gccOptPic="-fpic" gccOptSo="-shared" ;; "OpenBSD" ) gccOptPic="-fpic" gccOptSo="-shared" ;; "Solaris" ) gccOptPic="-fpic" gccOptSo="-shared -Xlinker \"-hlibnetwib$netwv.so\"" gccLib="$gccLib -lsocket -lnsl -lresolv" ;; "HPUX" ) gccOptPic="-fpic" gccOptSo="-shared" ;; "Tru64UNIX" ) gccOptPic="-fpic" gccOptSo="-shared" ;; "Unsupported" ) gccOptPic="-fpic" gccOptSo="-shared -Xlinker \"-hlibnetwib$netwv.so\"" ;; * ) echo "Error: unknown NETWIBDEF_SYSNAME"; exit 1;; esac # option needed to relocate for dynamic linking if [ "Z$NETWIBDEF_PROGCC_OPTPIC" != "Z" ] ; then # user value overwrites gccOptPic=$NETWIBDEF_PROGCC_OPTPIC fi # option needed to construct a shared object if [ "Z$NETWIBDEF_PROGCC_OPTSO" != "Z" ] ; then # user value overwrites gccOptSo=$NETWIBDEF_PROGCC_OPTSO fi ######################################################################## checkcompilfile () { echo config.check.tmp.c } checkmsgfile () { echo config.check.tmp.msg } checkcompil () { checktext="$1" checkccOpt="$2" checkccInc="$3" checkccLib="$4" checkverbose="${5-0}" # note : we do not put $gccOpt because it is too strict (Wall) compilcom="$NETWIBDEF_PROGCC $checkccOpt $gccInc $checkccInc" compilcom="$compilcom -o config.check.tmp" compilcom="$compilcom config.check.tmp.c $gccLib $checkccLib" $compilcom 2> config.check.tmp.err 1> config.check.tmp.err if [ "$?Z" != "0Z" ] ; then echo " $checktext no" CHECKCOMPILRESULT=0 if [ $checkverbose -eq 1 ] ; then echo "--------I used the command :" echo " $compilcom" echo "--------I wasn't able to compile the following test :" cat config.check.tmp.c echo "--------I got the following errors :" cat config.check.tmp.err fi else echo " $checktext yes" CHECKCOMPILRESULT=1 fi } checkcompilstd () { checktext="$1" checkccOpt="$2" checkccInc="$3" checkccLib="$4" checkverb="${5-0}" # add standard defines and includes mv config.check.tmp.c config.check.tmp.c2 echo "" > config.check.tmp.c case ${NETWIBDEF_SYSNAME} in "AIX" ) ;; "FreeBSD" ) ;; "HPUX" ) echo "#define _HPUX_SOURCE 1" >> config.check.tmp.c echo "#define _LARGEFILE_SOURCE 1" >> config.check.tmp.c echo "#define _FILE_OFFSET_BITS 64" >> config.check.tmp.c ;; "Linux" ) echo "#define _GNU_SOURCE 1" >> config.check.tmp.c echo "#define _POSIX_SOURCE 1" >> config.check.tmp.c echo "#define _BSD_SOURCE 1" >> config.check.tmp.c echo "#define _LARGEFILE_SOURCE 1" >> config.check.tmp.c echo "#define _FILE_OFFSET_BITS 64" >> config.check.tmp.c ;; "MacOS" ) ;; "NetBSD" ) ;; "OpenBSD" ) ;; "Tru64UNIX" ) echo "#define _POSIX_PII 1" >> config.check.tmp.c echo "#define _POSIX_C_SOURCE 1" >> config.check.tmp.c echo "#define _XOPEN_SOURCE 500" >> config.check.tmp.c ;; "Solaris" ) echo "#define __EXTENSIONS__ 1" >> config.check.tmp.c echo "#define _POSIX_PTHREAD_SEMANTICS 1" >> config.check.tmp.c echo "#define _LARGEFILE_SOURCE 1" >> config.check.tmp.c echo "#define _FILE_OFFSET_BITS 64" >> config.check.tmp.c ;; esac echo "#include " >> config.check.tmp.c echo "#include " >> config.check.tmp.c echo "#include " >> config.check.tmp.c cat config.check.tmp.c2 >> config.check.tmp.c rm config.check.tmp.c2 checkcompil "$checktext" "$checkccOpt" "$checkccInc" "$checkccLib" $checkverb } checkexec () { checktext="$1" ./config.check.tmp 2> config.check.tmp.err 1> config.check.tmp.err if [ "$?Z" != "0Z" ] ; then rm -f core echo " exec $checktext no" CHECKEXECRESULT=0 else echo " exec $checktext yes" CHECKEXECRESULT=1 fi } checkcompilyes () { echo $CHECKCOMPILRESULT } checkcompilno () { if [ $CHECKCOMPILRESULT -eq 0 ] ; then echo 1 else echo 0 fi } checkexecyes () { echo $CHECKEXECRESULT } checkexecresult () { cat config.check.tmp.err } checkceclean () { rm -f config.check.tmp.c config.check.tmp.c2 rm -f config.check.tmp config.check.tmp.err rm -f config.check.tmp.msg CHECKCOMPILRESULT=0 CHECKEXECRESULT=0 } checkceclean ######################################################################## echo "Check if compiler works" cat > `checkcompilfile` < `checkcompilfile` < #include #include int main(void) { puts("hello"); return(0); } EOF checkcompil "real_test" "" "" "" 1 resulttest=`checkcompilyes` if [ $resulttest -eq 0 ] ; then exit 1 fi resulttest=`checkcompilyes` if [ $resulttest -eq 1 ] ; then NETWIBDEF_PROGCCALIAS=1 fi checkexec "real_test" if [ `checkexecyes` -eq 0 ] ; then exit 1 fi checkcompil "real_test with -fno-strict-aliasing" "-fno-strict-aliasing" "" "" NETWIBDEF_PROGCCALIAS=0 resulttest=`checkcompilyes` if [ $resulttest -eq 1 ] ; then NETWIBDEF_PROGCCALIAS=1 fi # the -Werror is for FreeBSD < 5.0, which must have _POSIX_C_SOURCE # always defined. So to set -Wundef, it must be supported by gcc, and # a simple file must compile without _POSIX_C_SOURCE. checkcompil "real_test with -Wundef" "-Wundef -Werror" "" "" NETWIBDEF_PROGCCWUNDEF=0 resulttest=`checkcompilyes` if [ $resulttest -eq 1 ] ; then NETWIBDEF_PROGCCWUNDEF=1 fi checkcompil "real_test with -Wsign-compare" "-Wsign-compare" "" "" NETWIBDEF_PROGCCWSIGNC=0 resulttest=`checkcompilyes` if [ $resulttest -eq 1 ] ; then NETWIBDEF_PROGCCWSIGNC=1 fi ######################################################################## echo "Processor endianness selection" NETWIBDEF_ARCH_ENDIAN="unknown" cat > `checkcompilfile` < #include int main(void) { union { struct { unsigned char a; unsigned char b; unsigned char c; unsigned char d; } one; unsigned int two; } u; u.two = 0x12345678u; if (u.one.a == 0x78 && u.one.b == 0x56 && u.one.c == 0x34 && u.one.d == 0x12) { puts("0"); } else if (u.one.a == 0x12 && u.one.b == 0x34 && u.one.c == 0x56 && u.one.d == 0x78) { puts("1"); } else { return(-1); } return(0); } EOF checkcompilstd "compile" "" "" "" if [ `checkcompilyes` -eq 1 ] ; then checkexec "program" if [ `checkexecyes` -eq 1 ] ; then NETWIBDEF_ARCH_ENDIAN=`checkexecresult` fi fi checkceclean if [ "Z$NETWIBDEF_ARCH_ENDIAN" = "Zunknown" ] ; then echo "Error: Could not guess NETWIBDEF_ARCH_ENDIAN."; echo "Please contact Laurent to permanently solve this problem."; exit 1 fi echo " NETWIBDEF_ARCH_ENDIAN=$NETWIBDEF_ARCH_ENDIAN" ######################################################################## echo "Processor size selection" NETWIBDEF_ARCH_BITS="unknown" cat > `checkcompilfile` < #include int main(void) { printf("%d\n", (int)(sizeof(void*)*8)); return(0); } EOF checkcompilstd "compile" "" "" "" if [ `checkcompilyes` -eq 1 ] ; then checkexec "program" if [ `checkexecyes` -eq 1 ] ; then NETWIBDEF_ARCH_BITS=`checkexecresult` fi fi checkceclean if [ "Z$NETWIBDEF_ARCH_BITS" = "Zunknown" ] ; then echo "Error: Could not guess NETWIBDEF_ARCH_BITS."; echo "Please contact Laurent to permanently solve this problem."; exit 1 fi echo " NETWIBDEF_ARCH_BITS=$NETWIBDEF_ARCH_BITS" ######################################################################## echo "Processor alignment selection" # Note: we tried to guess using an invalid program, but this cause # problems. It's better to hard code them. NETWIBDEF_ARCH_ALIGN=1 if [ $NETWIBDEF_SYSARCH = "i386" ] ; then NETWIBDEF_ARCH_ALIGN=0 fi echo " NETWIBDEF_ARCH_ALIGN=$NETWIBDEF_ARCH_ALIGN" ######################################################################## ######################################################################## echo "Obtain variables size" # common function variablesizebits=0 variablesize () { name="$1" variablesizebits=0 cat > `checkcompilfile` < int main(void) { printf("%d\n", sizeof($name)*8); return(0); } EOF checkcompilstd "$name" "" "" "" 1 if [ `checkcompilyes` -eq 1 ] ; then checkexec "program" if [ `checkexecyes` -eq 1 ] ; then variablesizebits=`checkexecresult` fi fi checkceclean echo " type $name is of size $variablesizebits bits" } # obtain bit size (set to 0 if unsupported on current system) variablesize "char" ; netwib_bits_char=$variablesizebits variablesize "short" ; netwib_bits_short=$variablesizebits variablesize "int" ; netwib_bits_int=$variablesizebits variablesize "long" ; netwib_bits_long=$variablesizebits variablesize "long long" ; netwib_bits_long_long=$variablesizebits # note: we do not use intx_t because they are not always defined, # unsigned version can be _uintx_t or uintx_t, etc. So its better # to guess from standard types # set type echo "Summary:" # if [ $netwib_bits_char -eq 8 ] ; then NETWIBDEF_TYPE_INT8="char" NETWIBDEF_TYPE_UINT8="unsigned char" else echo "Error: Could not guess NETWIBDEF_TYPE_INT8."; echo "Please contact Laurent to permanently solve this problem."; exit 1 fi echo " NETWIBDEF_TYPE_INT8=$NETWIBDEF_TYPE_INT8" # if [ $netwib_bits_short -eq 16 ] ; then NETWIBDEF_TYPE_INT16="short" NETWIBDEF_TYPE_UINT16="unsigned short" else echo "Error: Could not guess NETWIBDEF_TYPE_INT16."; echo "Please contact Laurent to permanently solve this problem."; exit 1 fi echo " NETWIBDEF_TYPE_INT16=$NETWIBDEF_TYPE_INT16" # if [ $netwib_bits_int -eq 32 ] ; then NETWIBDEF_TYPE_INT32="int" NETWIBDEF_TYPE_UINT32="unsigned int" elif [ $netwib_bits_long -eq 32 ] ; then NETWIBDEF_TYPE_INT32="long" NETWIBDEF_TYPE_UINT32="unsigned long" else echo "Error: Could not guess NETWIBDEF_TYPE_INT32."; echo "Please contact Laurent to permanently solve this problem."; exit 1 fi echo " NETWIBDEF_TYPE_INT32=$NETWIBDEF_TYPE_INT32" # if [ $argone = "test" -a $argtwo = "netwox" -a $NETWIBDEF_ARCH_BITS -eq 32 ] ; then NETWIBDEF_TYPE_INT64="unsupported" NETWIBDEF_TYPE_UINT64="unsupported" NETWIBDEF_TYPE_INT64_FAKE=1 else if [ $netwib_bits_long -eq 64 ] ; then NETWIBDEF_TYPE_INT64="long" NETWIBDEF_TYPE_UINT64="unsigned long" NETWIBDEF_TYPE_INT64_FAKE=0 elif [ $netwib_bits_long_long -eq 64 ] ; then NETWIBDEF_TYPE_INT64="long long" NETWIBDEF_TYPE_UINT64="unsigned long long" NETWIBDEF_TYPE_INT64_FAKE=0 else NETWIBDEF_TYPE_INT64="unsupported" NETWIBDEF_TYPE_UINT64="unsupported" NETWIBDEF_TYPE_INT64_FAKE=1 fi fi echo " NETWIBDEF_TYPE_INT64=$NETWIBDEF_TYPE_INT64" ######################################################################## echo "Library selection" #--------- # we have one thread library # we try to compile this fake program cat > `checkcompilfile` < int main(void) { pthread_t *p; pthread_create(p, NULL, NULL, NULL); return(0); } EOF checkcompil "posix threads [-lpthread]" "" "" "-lpthread" NETWIBDEF_LIBPTHREADINSTALLED=`checkcompilyes` NETWIBDEF_LIBPTHREADFROMDCE=0 NETWIBDEF_LIBPTHREADFROMMIT=0 if [ $NETWIBDEF_LIBPTHREADINSTALLED -eq 1 ] ; then gccLib="$gccLib -lpthread" fi if [ $NETWIBDEF_LIBPTHREADINSTALLED -eq 0 ] ; then # try FreeBSD, OpenBSD, etc. checkcompil "posix threads [-pthread]" "" "" "-pthread" NETWIBDEF_LIBPTHREADINSTALLED=`checkcompilyes` if [ $NETWIBDEF_LIBPTHREADINSTALLED -eq 1 ] ; then gccLib="$gccLib -pthread" fi fi if [ $NETWIBDEF_LIBPTHREADINSTALLED -eq 0 ] ; then checkcompil "posix threads [-pthread NetBSD]" "" "-I/usr/pkg/include" "-L/usr/pkg/lib -lpthread" NETWIBDEF_LIBPTHREADINSTALLED=`checkcompilyes` if [ $NETWIBDEF_LIBPTHREADINSTALLED -eq 1 ] ; then gccInc="$gccInc -I/usr/pkg/include" gccLib="$gccLib -L/usr/pkg/lib -lpthread" echo "You might need to run export LD_RUN_PATH='/usr/pkg/lib:...' before make" fi fi if [ $NETWIBDEF_LIBPTHREADINSTALLED -eq 0 ] ; then # try MIT implementation (SuSE 5.1) checkcompil "posix threads [-lpthreads]" "-D_MIT_POSIX_THREADS=1" "" "-lpthreads" NETWIBDEF_LIBPTHREADINSTALLED=`checkcompilyes` if [ $NETWIBDEF_LIBPTHREADINSTALLED -eq 1 ] ; then gccOpt="$gccOpt -D_MIT_POSIX_THREADS=1" gccLib="$gccLib -lpthreads" NETWIBDEF_LIBPTHREADFROMMIT=1 fi fi checkceclean if [ $NETWIBDEF_LIBPTHREADINSTALLED -eq 0 ] ; then # try DCE (prototypes of posix draft 4) cat > `checkcompilfile` < int main(void) { pthread_t *p; pthread_attr_t a; pthread_create(p, a, NULL, NULL); return(0); } EOF checkcompil "posix threads [-ldce]" "" "" "-ldce" NETWIBDEF_LIBPTHREADINSTALLED=`checkcompilyes` if [ $NETWIBDEF_LIBPTHREADINSTALLED -eq 1 ] ; then gccLib="$gccLib -ldce" NETWIBDEF_LIBPTHREADFROMDCE=1 fi checkceclean fi if [ $NETWIBDEF_LIBPTHREADINSTALLED -eq 0 ] ; then echo "Error: we could not find a thread library" exit 1 fi #--------- # we have libpcap NETWIBDEF_LIBPCAPINSTALLED=0 NETWIBDEF_LIBPCAPFROMREDHAT=0 gccIncPcap="" if [ -d /usr/include/pcap/ ] ; then echo " /usr/include/pcap/ exists" gccIncPcap="$gccIncPcap -I/usr/include/pcap/" NETWIBDEF_LIBPCAPFROMREDHAT=1 fi gccLibPcap="-lpcap" # we try to compile this fake program cat > `checkcompilfile` < int main(void) { char e[1000]; void * t; t = pcap_open_live(e, 0, 0, 0, e); return(0); } EOF checkcompil "libpcap" "" "$gccIncPcap" "$gccLibPcap" NETWIBDEF_LIBPCAPINSTALLED=`checkcompilyes` if [ $NETWIBDEF_LIBPCAPINSTALLED -eq 0 ] ; then gccIncPcap="$gccIncPcap -I/usr/local/include/" gccLibPcap="$gccLibPcap -L/usr/local/lib/" checkcompil "libpcap [2nd try]" "" "$gccIncPcap" "$gccLibPcap" 1 NETWIBDEF_LIBPCAPINSTALLED=`checkcompilyes` fi if [ $NETWIBDEF_LIBPCAPINSTALLED -eq 1 ] ; then gccInc="$gccInc $gccIncPcap" gccLib="$gccLib $gccLibPcap" fi checkceclean #--------- # we have libnet NETWIBDEF_LIBNETINSTALLED=0 NETWIBDEF_LIBNETVERSION11=0 gccOptLnet="" gccIncLnet="" gccLibLnet="" type libnet-config 2> /dev/null 1> /dev/null if [ "$?Z" != "0Z" ] ; then gccLibLnet="$gccLibLnet -lnet" else echo " libnet-config yes" gccOptLnet="$gccOptLnet "`libnet-config --defines` gccLibLnet="$gccLibLnet "`libnet-config --libs` fi # we try to compile this fake program cat > `checkcompilfile` < `checkcompilfile` < `checkcompilfile` < #include int main(void) { openpty(NULL, NULL, NULL, NULL, NULL); return(0); } EOF checkcompil "pty/tty (-lutil)" "" "" "-lutil" NETWIBDEF_LIBUTILINSTALLED=`checkcompilyes` if [ $NETWIBDEF_LIBUTILINSTALLED -eq 1 ] ; then gccLib="$gccLib -lutil" fi checkceclean ######################################################################## ######################################################################## echo "Check present includes" checkcompilinc () { incname="$1" incname2=${2-notset} incname3=${3-notset} incname4=${4-notset} incname5=${5-notset} addinc="" echo "" >> `checkcompilfile` if [ $incname2 != "notset" ] ; then echo "#include <$incname2>" >> `checkcompilfile` addinc="$incname2" fi if [ $incname3 != "notset" ] ; then echo "#include <$incname3>" >> `checkcompilfile` if [ "Z$addinc" = "Z" ] ; then addinc="$incname3" else addinc="$addinc,$incname3" fi fi if [ $incname4 != "notset" ] ; then echo "#include <$incname4>" >> `checkcompilfile` if [ "Z$addinc" = "Z" ] ; then addinc="$incname4" else addinc="$addinc,$incname4" fi fi if [ $incname5 != "notset" ] ; then echo "#include <$incname5>" >> `checkcompilfile` if [ "Z$addinc" = "Z" ] ; then addinc="$incname5" else addinc="$addinc,$incname5" fi fi if [ "Z$addinc" != "Z" ] ; then addinc=" [+$addinc]" fi echo "#include <$incname>" >> `checkcompilfile` echo "int main(void) { return(0); }" >> `checkcompilfile` checkcompil "$incname$addinc" "" "" "" } #--- checkcompilinc "pthread.h" NETWIBDEF_HAVEINCL_PTHREAD=`checkcompilyes` checkceclean #--- checkcompilinc "stropts.h" NETWIBDEF_HAVEINCL_STROPTS=`checkcompilyes` checkceclean #--- checkcompilinc "sched.h" NETWIBDEF_HAVEINCL_SCHED=`checkcompilyes` checkceclean #--- checkcompilinc "pty.h" NETWIBDEF_HAVEINCL_PTY=`checkcompilyes` checkceclean #--- checkcompilinc "sys/poll.h" NETWIBDEF_HAVEINCL_SYS_POLL=`checkcompilyes` checkceclean if [ $NETWIBDEF_HAVEINCL_SYS_POLL -eq 0 ] ; then # OpenBSD needs stdlib to be included before checkcompilinc "sys/poll.h" "stdlib.h" NETWIBDEF_HAVEINCL_SYS_POLL=`checkcompilyes` checkceclean fi #--- checkcompilinc "sys/param.h" NETWIBDEF_HAVEINCL_SYS_PARAM=`checkcompilyes` checkceclean #--- checkcompilinc "sys/sysctl.h" NETWIBDEF_HAVEINCL_SYS_SYSCTL=`checkcompilyes` checkceclean if [ $NETWIBDEF_HAVEINCL_SYS_SYSCTL -eq 0 ] ; then checkcompilinc "sys/sysctl.h" "sys/types.h" NETWIBDEF_HAVEINCL_SYS_SYSCTL=`checkcompilyes` checkceclean fi if [ $NETWIBDEF_HAVEINCL_SYS_SYSCTL -eq 0 ] ; then if [ $NETWIBDEF_HAVEINCL_SYS_PARAM -eq 1 ] ; then checkcompilinc "sys/sysctl.h" "sys/types.h" "sys/param.h" NETWIBDEF_HAVEINCL_SYS_SYSCTL=`checkcompilyes` checkceclean fi fi #--- checkcompilinc "sys/ioctl.h" NETWIBDEF_HAVEINCL_SYS_IOCTL=`checkcompilyes` checkceclean #--- checkcompilinc "sys/sockio.h" NETWIBDEF_HAVEINCL_SYS_SOCKIO=`checkcompilyes` checkceclean #--- checkcompilinc "sys/dlpi.h" NETWIBDEF_HAVEINCL_SYS_DLPI=`checkcompilyes` checkceclean if [ $NETWIBDEF_HAVEINCL_SYS_DLPI -eq 0 ] ; then checkcompilinc "sys/dlpi.h" "sys/types.h" NETWIBDEF_HAVEINCL_SYS_DLPI=`checkcompilyes` checkceclean fi #--- checkcompilinc "sys/bufmod.h" NETWIBDEF_HAVEINCL_SYS_BUFMOD=`checkcompilyes` checkceclean if [ $NETWIBDEF_HAVEINCL_SYS_BUFMOD -eq 0 ] ; then checkcompilinc "sys/bufmod.h" "sys/types.h" NETWIBDEF_HAVEINCL_SYS_BUFMOD=`checkcompilyes` checkceclean fi #--- checkcompilinc "sys/mman.h" NETWIBDEF_HAVEINCL_SYS_MMAN=`checkcompilyes` checkceclean if [ $NETWIBDEF_HAVEINCL_SYS_MMAN -eq 0 ] ; then checkcompilinc "sys/mman.h" "sys/types.h" NETWIBDEF_HAVEINCL_SYS_MMAN=`checkcompilyes` checkceclean fi #--- checkcompilinc "net/ethernet.h" NETWIBDEF_HAVEINCL_NET_ETHERNET=`checkcompilyes` checkceclean if [ $NETWIBDEF_HAVEINCL_NET_ETHERNET -eq 0 ] ; then checkcompilinc "net/ethernet.h" "sys/types.h" NETWIBDEF_HAVEINCL_NET_ETHERNET=`checkcompilyes` checkceclean fi #--- checkcompilinc "net/if_arp.h" NETWIBDEF_HAVEINCL_NET_IF_ARP=`checkcompilyes` checkceclean if [ $NETWIBDEF_HAVEINCL_NET_IF_ARP -eq 0 ] ; then checkcompilinc "net/if_arp.h" "sys/types.h" "sys/socket.h" NETWIBDEF_HAVEINCL_NET_IF_ARP=`checkcompilyes` checkceclean fi #--- checkcompilinc "net/if_types.h" NETWIBDEF_HAVEINCL_NET_IF_TYPES=`checkcompilyes` checkceclean #--- checkcompilinc "net/if_dl.h" NETWIBDEF_HAVEINCL_NET_IF_DL=`checkcompilyes` checkceclean if [ $NETWIBDEF_HAVEINCL_NET_IF_DL -eq 0 ] ; then checkcompilinc "net/if_dl.h" "sys/types.h" NETWIBDEF_HAVEINCL_NET_IF_DL=`checkcompilyes` checkceclean fi if [ $NETWIBDEF_HAVEINCL_NET_IF_DL -eq 0 ] ; then checkcompilinc "net/if_dl.h" "sys/types.h" "sys/socket.h" NETWIBDEF_HAVEINCL_NET_IF_DL=`checkcompilyes` checkceclean fi #--- checkcompilinc "net/bpf.h" NETWIBDEF_HAVEINCL_NET_BPF=`checkcompilyes` checkceclean if [ $NETWIBDEF_HAVEINCL_NET_BPF -eq 0 ] ; then checkcompilinc "net/bpf.h" "sys/types.h" NETWIBDEF_HAVEINCL_NET_BPF=`checkcompilyes` checkceclean fi if [ $NETWIBDEF_HAVEINCL_NET_BPF -eq 0 ] ; then checkcompilinc "net/bpf.h" "sys/types.h" "sys/time.h" NETWIBDEF_HAVEINCL_NET_BPF=`checkcompilyes` checkceclean fi #--- checkcompilinc "netinet/if_ether.h" NETWIBDEF_HAVEINCL_NETINET_IF_ETHER=`checkcompilyes` checkceclean if [ $NETWIBDEF_HAVEINCL_NETINET_IF_ETHER -eq 0 ] ; then checkcompilinc "netinet/if_ether.h" "sys/types.h" "sys/socket.h" NETWIBDEF_HAVEINCL_NETINET_IF_ETHER=`checkcompilyes` checkceclean fi if [ $NETWIBDEF_HAVEINCL_NETINET_IF_ETHER -eq 0 ] ; then checkcompilinc "netinet/if_ether.h" "sys/types.h" "sys/socket.h" "net/if.h" NETWIBDEF_HAVEINCL_NETINET_IF_ETHER=`checkcompilyes` checkceclean fi if [ $NETWIBDEF_HAVEINCL_NETINET_IF_ETHER -eq 0 ] ; then checkcompilinc "netinet/if_ether.h" "sys/types.h" "sys/socket.h" "netinet/in.h" NETWIBDEF_HAVEINCL_NETINET_IF_ETHER=`checkcompilyes` checkceclean fi if [ $NETWIBDEF_HAVEINCL_NETINET_IF_ETHER -eq 0 ] ; then checkcompilinc "netinet/if_ether.h" "sys/types.h" "sys/socket.h" "net/if.h" "netinet/in.h" NETWIBDEF_HAVEINCL_NETINET_IF_ETHER=`checkcompilyes` checkceclean fi #--- checkcompilinc "netinet/ether.h" NETWIBDEF_HAVEINCL_NETINET_ETHER=`checkcompilyes` checkceclean #--- checkcompilinc "netpacket/packet.h" NETWIBDEF_HAVEINCL_NETPACKET_PACKET=`checkcompilyes` checkceclean #--- checkcompilinc "asm/page.h" NETWIBDEF_HAVEINCL_ASM_PAGE=`checkcompilyes` checkceclean #--- checkcompilinc "mach/machine/vm_param.h" NETWIBDEF_HAVEINCL_MACH_MACHINE_VMPARAM=`checkcompilyes` checkceclean #--- checkcompilinc "machine/param.h" NETWIBDEF_HAVEINCL_MACHINE_PARAM=`checkcompilyes` checkceclean ######################################################################## ######################################################################## echo "Check include conflicts" #--- # Under OpenBSD, if_arp.h conflicts with if.h. In this case, # if_arp.h must not be included. if [ $NETWIBDEF_HAVEINCL_NET_IF_ARP -eq 1 ] ; then checkcompilinc "net/if_arp.h" "sys/types.h" "sys/socket.h" "net/if.h" NETWIBDEF_HAVEINCL_NET_IF_ARP=`checkcompilyes` checkceclean fi ######################################################################## ######################################################################## echo "Check present types" #--- cat > `checkcompilfile` < `checkcompilfile` < #include int main(void) { socklen_t s; return(0); } EOF checkcompilstd "socklen_t" "" "" "" NETWIBDEF_HAVETYPE_SOCKLEN_T=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { sighandler_t s; return(0); } EOF checkcompilstd "sighandler_t" "" "" "" NETWIBDEF_HAVETYPE_SIGHANDLER_T=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { sig_t s; return(0); } EOF checkcompilstd "sig_t" "" "" "" NETWIBDEF_HAVETYPE_SIG_T=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < `checkcompilfile` < int main(void) { pthread_rwlock_t s; return(0); } EOF checkcompilstd "pthread_rwlock_t" "" "" "" NETWIBDEF_HAVETYPE_PTHREAD_RWLOCK_T=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < #include #include int main(void) { struct sockaddr_in6 *psain6; psain6->sin6_addr.s6_addr[0] = 3; return(0); } EOF checkcompilstd "sockaddr_in6" "" "" "" NETWIBDEF_HAVETYPE_SOCKADDR_IN6=`checkcompilyes` checkceclean ######################################################################## ######################################################################## echo "Check present fields" #--- cat > `checkcompilfile` < int main(void) { struct tm *ptm; ptm->tm_gmtoff = 0; return(0); } EOF checkcompilstd "tm_gmtoff" "" "" "" NETWIBDEF_HAVEFIELD_TM_GMTOFF=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < #include int main(void) { struct sockaddr *psa; psa->sa_len = 0; return(0); } EOF checkcompilstd "sockaddr.sa_len" "" "" "" NETWIBDEF_HAVEFIELD_SOCKADDR_SALEN=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < #include #include int main(void) { struct sockaddr_in *psain; psain->sin_len = 0; return(0); } EOF checkcompilstd "sockaddr_in.sain_len" "" "" "" NETWIBDEF_HAVEFIELD_SOCKADDRIN_SINLEN=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < #include #include int main(void) { struct sockaddr_in6 *psain6; psain6->sin6_len = 0; return(0); } EOF checkcompilstd "sockaddr_in.sain_len" "" "" "" NETWIBDEF_HAVEFIELD_SOCKADDRIN6_SIN6LEN=`checkcompilyes` checkceclean ######################################################################## ######################################################################## echo "Check present functions" #--- cat > `checkcompilfile` < `checkcompilfile` < `checkcompilfile` < `checkcompilfile` < `checkcompilfile` < int main(void) { pcap_freecode(NULL); return(0); } EOF checkcompilstd "pcap_freecode (1 param)" "" "" "" NETWIBDEF_HAVEFUNC_PCAP_FREECODE=`checkcompilyes` checkceclean fi #--- NETWIBDEF_HAVEFUNC_PCAP_FREECODE2=0 if [ $NETWIBDEF_LIBPCAPINSTALLED = 1 ] ; then cat > `checkcompilfile` < int main(void) { pcap_freecode(NULL, NULL); return(0); } EOF checkcompilstd "pcap_freecode (2 param)" "" "" "" NETWIBDEF_HAVEFUNC_PCAP_FREECODE2=`checkcompilyes` checkceclean fi #--- NETWIBDEF_HAVEFUNC_PCAP_OPENDEAD=0 if [ $NETWIBDEF_LIBPCAPINSTALLED = 1 ] ; then cat > `checkcompilfile` < int main(void) { pcap_open_dead(0, 0); return(0); } EOF checkcompilstd "pcap_open_dead" "" "" "" NETWIBDEF_HAVEFUNC_PCAP_OPENDEAD=`checkcompilyes` checkceclean fi #--- cat > `checkcompilfile` < int main(void) { char *p; poll(NULL, 0, 0); return(0); } EOF checkcompilstd "poll" "" "" "" NETWIBDEF_HAVEFUNC_POLL=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { long l; l = dirfd(NULL); return(0); } EOF checkcompilstd "dirfd" "" "" "" NETWIBDEF_HAVEFUNC_DIRFD=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < `checkcompilfile` < `checkcompilfile` < `checkcompilfile` < `checkcompilfile` < #include int main(void) { long l; l = getrlimit(0,NULL); return(0); } EOF checkcompilstd "getrlimit" "" "" "" NETWIBDEF_HAVEFUNC_GETRLIMIT=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { nanosleep(NULL,NULL); return(0); } EOF checkcompilstd "nanosleep" "" "" "" NETWIBDEF_HAVEFUNC_NANOSLEEP=`checkcompilyes` if [ $NETWIBDEF_HAVEFUNC_NANOSLEEP -eq 0 ] ; then checkcompilstd "nanosleep [-lrt]" "" "" "-lrt" NETWIBDEF_HAVEFUNC_NANOSLEEP=`checkcompilyes` if [ $NETWIBDEF_HAVEFUNC_NANOSLEEP -eq 1 ] ; then gccLib="$gccLib -lrt" fi fi if [ $NETWIBDEF_HAVEFUNC_NANOSLEEP -eq 0 ] ; then checkcompilstd "nanosleep [-lposix4]" "" "" "-lposix4" NETWIBDEF_HAVEFUNC_NANOSLEEP=`checkcompilyes` if [ $NETWIBDEF_HAVEFUNC_NANOSLEEP -eq 1 ] ; then gccLib="$gccLib -lposix4" fi fi checkceclean #--- cat > `checkcompilfile` < `checkcompilfile` < int main(void) { gettimeofday(NULL, NULL); return(0); } EOF checkcompilstd "gettimeofday" "" "" "" NETWIBDEF_HAVEFUNC_GETTIMEOFDAY=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { clock_gettime(0, NULL); return(0); } EOF checkcompilstd "clock_gettime" "" "" "" NETWIBDEF_HAVEFUNC_CLOCK_GETTIME=`checkcompilyes` if [ $NETWIBDEF_HAVEFUNC_CLOCK_GETTIME -eq 0 ] ; then checkcompilstd "clock_gettime [-lrt]" "" "" "-lrt" NETWIBDEF_HAVEFUNC_CLOCK_GETTIME=`checkcompilyes` if [ $NETWIBDEF_HAVEFUNC_CLOCK_GETTIME -eq 1 ] ; then gccLib="$gccLib -lrt" fi fi if [ $NETWIBDEF_HAVEFUNC_CLOCK_GETTIME -eq 0 ] ; then checkcompilstd "clock_gettime [-lposix4]" "" "" "-lposix4" NETWIBDEF_HAVEFUNC_CLOCK_GETTIME=`checkcompilyes` if [ $NETWIBDEF_HAVEFUNC_CLOCK_GETTIME -eq 1 ] ; then gccLib="$gccLib -lposix4" fi fi checkceclean #--- NETWIBDEF_HAVEFUNC_PTHREAD_DELAY_NP=0 if [ $NETWIBDEF_HAVEINCL_PTHREAD = 1 ] ; then cat > `checkcompilfile` < int main(void) { pthread_delay_np(NULL); return(0); } EOF checkcompilstd "pthread_delay_np" "" "" "" NETWIBDEF_HAVEFUNC_PTHREAD_DELAY_NP=`checkcompilyes` checkceclean fi #--- NETWIBDEF_HAVEFUNC_PTHREAD_MUTEX_TIMEDLOCK=0 if [ $NETWIBDEF_HAVEINCL_PTHREAD = 1 ] ; then cat > `checkcompilfile` < int main(void) { pthread_mutex_timedlock(NULL, NULL); return(0); } EOF checkcompilstd "pthread_mutex_timedlock" "" "" "" NETWIBDEF_HAVEFUNC_PTHREAD_MUTEX_TIMEDLOCK=`checkcompilyes` checkceclean fi #--- NETWIBDEF_HAVEFUNC_PTHREAD_RWLOCK_TIMEDRDLOCK=0 if [ $NETWIBDEF_HAVEINCL_PTHREAD = 1 ] ; then cat > `checkcompilfile` < int main(void) { pthread_rwlock_timedrdlock(NULL, NULL); return(0); } EOF checkcompilstd "pthread_rwlock_timedrdlock" "" "" "" NETWIBDEF_HAVEFUNC_PTHREAD_RWLOCK_TIMEDRDLOCK=`checkcompilyes` checkceclean fi #--- NETWIBDEF_HAVEFUNC_PTHREAD_RWLOCK_TIMEDWRLOCK=0 if [ $NETWIBDEF_HAVEINCL_PTHREAD = 1 ] ; then cat > `checkcompilfile` < int main(void) { pthread_rwlock_timedwrlock(NULL, NULL); return(0); } EOF checkcompilstd "pthread_rwlock_timedwrlock" "" "" "" NETWIBDEF_HAVEFUNC_PTHREAD_RWLOCK_TIMEDWRLOCK=`checkcompilyes` checkceclean fi #--- NETWIBDEF_HAVEFUNC_PTHREAD_YIELD=0 if [ $NETWIBDEF_HAVEINCL_PTHREAD = 1 ] ; then cat > `checkcompilfile` < int main(void) { pthread_yield(); return(0); } EOF checkcompilstd "pthread_yield" "" "" "" NETWIBDEF_HAVEFUNC_PTHREAD_YIELD=`checkcompilyes` checkceclean fi #--- NETWIBDEF_HAVEFUNC_SCHED_YIELD=0 if [ $NETWIBDEF_HAVEINCL_SCHED = 1 ] ; then cat > `checkcompilfile` < int main(void) { sched_yield(); return(0); } EOF checkcompilstd "sched_yield" "" "" "" NETWIBDEF_HAVEFUNC_SCHED_YIELD=`checkcompilyes` if [ $NETWIBDEF_HAVEINCL_SCHED = 0 ] ; then checkcompilstd "sched_yield [-lposix4]" "" "" "-lposix4" NETWIBDEF_HAVEFUNC_SCHED_YIELD=`checkcompilyes` if [ $NETWIBDEF_HAVEFUNC_SCHED_YIELD -eq 1 ] ; then gccLib="$gccLib -lposix4" fi fi checkceclean fi #--- cat > `checkcompilfile` < #include int main(void) { getpwnam_r(NULL, NULL, NULL, 0, NULL); return(0); } EOF checkcompilstd "getpwnam_r" "" "" "" NETWIBDEF_HAVEFUNC_GETPWNAM_R=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < #include int main(void) { getgrnam_r(NULL, NULL, NULL, 0, NULL); return(0); } EOF checkcompilstd "getgrnam_r" "" "" "" NETWIBDEF_HAVEFUNC_GETGRNAM_R=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < #include int main(void) { getgrgid_r(NULL, NULL, NULL, 0, NULL); return(0); } EOF checkcompilstd "getgrgid_r" "" "" "" NETWIBDEF_HAVEFUNC_GETGRGID_R=`checkcompilyes` checkceclean #--- if [ $NETWIBDEF_LIBPTHREADFROMDCE -eq 1 ] ; then cat > `checkcompilfile` < int main(void) { readdir_r(NULL, NULL); return(0); } EOF else cat > `checkcompilfile` < int main(void) { readdir_r(NULL, NULL, NULL); return(0); } EOF fi checkcompilstd "readdir_r" "" "" "" NETWIBDEF_HAVEFUNC_READDIR_R=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL); return(0); } EOF checkcompilstd "gethostbyname_r" "" "" "" NETWIBDEF_HAVEFUNC_GETHOSTBYNAME_R=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL); return(0); } EOF checkcompilstd "gethostbyaddr_r" "" "" "" NETWIBDEF_HAVEFUNC_GETHOSTBYADDR_R=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0); return(0); } EOF checkcompilstd "getnameinfo" "" "" "" NETWIBDEF_HAVEFUNC_GETNAMEINFO=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { getaddrinfo(NULL, NULL, NULL, NULL); return(0); } EOF checkcompilstd "getaddrinfo" "" "" "" NETWIBDEF_HAVEFUNC_GETADDRINFO=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { getipnodebyname(NULL, 0, 0, NULL); return(0); } EOF checkcompilstd "getipnodebyname" "" "" "" NETWIBDEF_HAVEFUNC_GETIPNODEBYNAME=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { getipnodebyaddr(NULL, 0, 0, NULL); return(0); } EOF checkcompilstd "getipnodebyaddr" "" "" "" NETWIBDEF_HAVEFUNC_GETIPNODEBYADDR=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { localtime_r(NULL, NULL); return(0); } EOF checkcompilstd "localtime_r" "" "" "" NETWIBDEF_HAVEFUNC_LOCALTIME_R=`checkcompilyes` checkceclean ######################################################################## ######################################################################## echo "Check present variables" #--- cat > `checkcompilfile` < int main(void) { h_errno = 0; return(0); } EOF checkcompilstd "h_errno" "" "" "" NETWIBDEF_HAVEVAR_HERRNO=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { int i = PATH_MAX; return(0); } EOF checkcompilstd "PATH_MAX" "" "" "" NETWIBDEF_HAVEVAR_PATH_MAX=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { int i = NAME_MAX; return(0); } EOF checkcompilstd "NAME_MAX" "" "" "" NETWIBDEF_HAVEVAR_NAME_MAX=`checkcompilyes` checkceclean #--- echo "#include " > `checkcompilfile` if [ $NETWIBDEF_HAVEINCL_SYS_MMAN -eq 1 ] ; then echo "#include " >> `checkcompilfile` fi if [ $NETWIBDEF_HAVEINCL_SYS_PARAM -eq 1 ] ; then echo "#include " >> `checkcompilfile` fi if [ $NETWIBDEF_HAVEINCL_MACHINE_PARAM -eq 1 ] ; then echo "#include " >> `checkcompilfile` fi if [ $NETWIBDEF_HAVEINCL_ASM_PAGE -eq 1 ] ; then echo "#include " >> `checkcompilfile` fi if [ $NETWIBDEF_HAVEINCL_MACH_MACHINE_VMPARAM -eq 1 ] ; then echo "#include " >> `checkcompilfile` fi echo "int main(void){int i; i = PAGE_SIZE;}" >> `checkcompilfile` checkcompilstd "PAGE_SIZE" "" "" "" NETWIBDEF_HAVEVAR_PAGE_SIZE=`checkcompilyes` checkceclean #--- echo "" > `checkcompilfile` if [ $NETWIBDEF_HAVEINCL_SYS_MMAN -eq 1 ] ; then echo "#include " >> `checkcompilfile` fi if [ $NETWIBDEF_HAVEINCL_SYS_PARAM -eq 1 ] ; then echo "#include " >> `checkcompilfile` fi if [ $NETWIBDEF_HAVEINCL_MACHINE_PARAM -eq 1 ] ; then echo "#include " >> `checkcompilfile` fi if [ $NETWIBDEF_HAVEINCL_ASM_PAGE -eq 1 ] ; then echo "#include " >> `checkcompilfile` fi echo "int main(void){int i; i = PAGESIZE;}" >> `checkcompilfile` checkcompilstd "PAGESIZE" "" "" "" NETWIBDEF_HAVEVAR_PAGESIZE=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < #include #include #include #include int main(void) { int fd, un; ioctl(fd, BIOCSHDRCMPLT, &un); return(0); } EOF checkcompilstd "BIOCSHDRCMPLT" "" "" "" NETWIBDEF_HAVEVAR_BIOCSHDRCMPLT=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < #include #include #include int main(void) { int fd, un; ioctl(fd, SIOCGLIFCONF, &un); return(0); } EOF checkcompilstd "SIOCGLIFCONF" "" "" "" NETWIBDEF_HAVEVAR_SIOCGLIFCONF=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < #include int main(void) { int i = AF_INET6; return(0); } EOF checkcompilstd "AF_INET6" "" "" "" NETWIBDEF_HAVEVAR_AF_INET6=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { int i = _SC_GETPW_R_SIZE_MAX; return(0); } EOF checkcompilstd "_SC_GETPW_R_SIZE_MAX" "" "" "" NETWIBDEF_HAVEVAR_SC_GETPW_R_SIZE_MAX=`checkcompilyes` checkceclean #--- cat > `checkcompilfile` < int main(void) { int i = _SC_GETGR_R_SIZE_MAX; return(0); } EOF checkcompilstd "_SC_GETGR_R_SIZE_MAX" "" "" "" NETWIBDEF_HAVEVAR_SC_GETGR_R_SIZE_MAX=`checkcompilyes` checkceclean ######################################################################## ######################################################################## echo "Generate the different files" ######### deffile="netwib/def.h" echo " Creation of $deffile" echo "#define NETWIBDEF_SYSNAME_Unix 1" > $deffile echo "#define NETWIBDEF_SYSNAME \"$NETWIBDEF_SYSNAME\"" >> $deffile echo "#define NETWIBDEF_SYSNAME_$NETWIBDEF_SYSNAME 1" >> $deffile echo "#define NETWIBDEF_SYSARCH \"$NETWIBDEF_SYSARCH\"" >> $deffile echo "#define NETWIBDEF_SYSARCH_$NETWIBDEF_SYSARCH 1" >> $deffile echo "#define NETWIBDEF_ARCH_ENDIAN $NETWIBDEF_ARCH_ENDIAN" >> $deffile echo "#define NETWIBDEF_ARCH_BITS $NETWIBDEF_ARCH_BITS" >> $deffile echo "#define NETWIBDEF_ARCH_ALIGN $NETWIBDEF_ARCH_ALIGN" >> $deffile echo "#define NETWIBDEF_VERSION \"$NETWIBDEF_VERSION\"" >> $deffile echo "#define NETWIBDEF_VERSIONMAJOR $NETWIBDEF_VERSIONMAJOR" >> $deffile echo "#define NETWIBDEF_VERSIONMINOR $NETWIBDEF_VERSIONMINOR" >> $deffile echo "#define NETWIBDEF_VERSIONMICRO $NETWIBDEF_VERSIONMICRO" >> $deffile echo "#define NETWIBDEF_LIBPTHREADINSTALLED $NETWIBDEF_LIBPTHREADINSTALLED">>$deffile echo "#define NETWIBDEF_LIBPTHREADFROMDCE $NETWIBDEF_LIBPTHREADFROMDCE">>$deffile echo "#define NETWIBDEF_LIBPTHREADFROMMIT $NETWIBDEF_LIBPTHREADFROMMIT">>$deffile echo "#define NETWIBDEF_LIBPCAPINSTALLED $NETWIBDEF_LIBPCAPINSTALLED">>$deffile echo "#define NETWIBDEF_LIBPCAPFROMREDHAT $NETWIBDEF_LIBPCAPFROMREDHAT">>$deffile echo "#define NETWIBDEF_LIBNETINSTALLED $NETWIBDEF_LIBNETINSTALLED" >> $deffile echo "#define NETWIBDEF_LIBNETVERSION11 $NETWIBDEF_LIBNETVERSION11" >> $deffile echo "#define NETWIBDEF_LIBUTILINSTALLED $NETWIBDEF_LIBUTILINSTALLED" >> $deffile echo "#define NETWIBDEF_PROGCC \"$NETWIBDEF_PROGCC\"" >> $deffile echo "#define NETWIBDEF_PROGCCALIAS $NETWIBDEF_PROGCCALIAS" >> $deffile echo "#define NETWIBDEF_PROGCCWUNDEF $NETWIBDEF_PROGCCWUNDEF" >> $deffile echo "#define NETWIBDEF_PROGCCWSIGNC $NETWIBDEF_PROGCCWSIGNC" >> $deffile echo "#define NETWIBDEF_PROGAR \"$NETWIBDEF_PROGAR\"" >> $deffile echo "#define NETWIBDEF_PROGRANLIB \"$NETWIBDEF_PROGRANLIB\"" >> $deffile echo "#define NETWIBDEF_PROGGREP \"$NETWIBDEF_PROGGREP\"" >> $deffile echo "#define NETWIBDEF_INSTPREFIX \"$NETWIBDEF_INSTPREFIX\"" >> $deffile echo "#define NETWIBDEF_INSTINCLUDE \"$NETWIBDEF_INSTINCLUDE\"" >> $deffile echo "#define NETWIBDEF_INSTLIB \"$NETWIBDEF_INSTLIB\"" >> $deffile echo "#define NETWIBDEF_INSTBIN \"$NETWIBDEF_INSTBIN\"" >> $deffile echo "#define NETWIBDEF_INSTMAN \"$NETWIBDEF_INSTMAN\"" >> $deffile echo "#define NETWIBDEF_INSTMAN3 \"$NETWIBDEF_INSTMAN3\"" >> $deffile echo "#define NETWIBDEF_SUPPORT_SNIFF $NETWIBDEF_SUPPORT_SNIFF" >> $deffile echo "#define NETWIBDEF_SUPPORT_SPOOF $NETWIBDEF_SUPPORT_SPOOF" >> $deffile echo "#define NETWIBDEF_SUPPORT_ENCODETYPE_PCAP $NETWIBDEF_SUPPORT_ENCODETYPE_PCAP" >> $deffile echo "#define NETWIBDEF_TYPE_INT8 $NETWIBDEF_TYPE_INT8" >> $deffile echo "#define NETWIBDEF_TYPE_UINT8 $NETWIBDEF_TYPE_UINT8" >> $deffile echo "#define NETWIBDEF_TYPE_INT16 $NETWIBDEF_TYPE_INT16" >> $deffile echo "#define NETWIBDEF_TYPE_UINT16 $NETWIBDEF_TYPE_UINT16" >> $deffile echo "#define NETWIBDEF_TYPE_INT32 $NETWIBDEF_TYPE_INT32" >> $deffile echo "#define NETWIBDEF_TYPE_UINT32 $NETWIBDEF_TYPE_UINT32" >> $deffile echo "#define NETWIBDEF_TYPE_INT64 $NETWIBDEF_TYPE_INT64" >> $deffile echo "#define NETWIBDEF_TYPE_UINT64 $NETWIBDEF_TYPE_UINT64" >> $deffile echo "#define NETWIBDEF_TYPE_INT64_FAKE $NETWIBDEF_TYPE_INT64_FAKE" >> $deffile echo "#define NETWIBDEF_HAVEINCL_PTHREAD $NETWIBDEF_HAVEINCL_PTHREAD" >> $deffile echo "#define NETWIBDEF_HAVEINCL_STROPTS $NETWIBDEF_HAVEINCL_STROPTS" >> $deffile echo "#define NETWIBDEF_HAVEINCL_SCHED $NETWIBDEF_HAVEINCL_SCHED" >> $deffile echo "#define NETWIBDEF_HAVEINCL_PTY $NETWIBDEF_HAVEINCL_PTY" >> $deffile echo "#define NETWIBDEF_HAVEINCL_SYS_POLL $NETWIBDEF_HAVEINCL_SYS_POLL" >> $deffile echo "#define NETWIBDEF_HAVEINCL_SYS_PARAM $NETWIBDEF_HAVEINCL_SYS_PARAM" >> $deffile echo "#define NETWIBDEF_HAVEINCL_SYS_SYSCTL $NETWIBDEF_HAVEINCL_SYS_SYSCTL" >> $deffile echo "#define NETWIBDEF_HAVEINCL_SYS_IOCTL $NETWIBDEF_HAVEINCL_SYS_IOCTL" >> $deffile echo "#define NETWIBDEF_HAVEINCL_SYS_SOCKIO $NETWIBDEF_HAVEINCL_SYS_SOCKIO" >> $deffile echo "#define NETWIBDEF_HAVEINCL_SYS_DLPI $NETWIBDEF_HAVEINCL_SYS_DLPI" >> $deffile echo "#define NETWIBDEF_HAVEINCL_SYS_BUFMOD $NETWIBDEF_HAVEINCL_SYS_BUFMOD" >> $deffile echo "#define NETWIBDEF_HAVEINCL_SYS_MMAN $NETWIBDEF_HAVEINCL_SYS_MMAN" >> $deffile echo "#define NETWIBDEF_HAVEINCL_NET_ETHERNET $NETWIBDEF_HAVEINCL_NET_ETHERNET" >> $deffile echo "#define NETWIBDEF_HAVEINCL_NET_IF_ARP $NETWIBDEF_HAVEINCL_NET_IF_ARP" >> $deffile echo "#define NETWIBDEF_HAVEINCL_NET_IF_TYPES $NETWIBDEF_HAVEINCL_NET_IF_TYPES" >> $deffile echo "#define NETWIBDEF_HAVEINCL_NET_IF_DL $NETWIBDEF_HAVEINCL_NET_IF_DL" >> $deffile echo "#define NETWIBDEF_HAVEINCL_NET_BPF $NETWIBDEF_HAVEINCL_NET_BPF" >> $deffile echo "#define NETWIBDEF_HAVEINCL_NETINET_IF_ETHER $NETWIBDEF_HAVEINCL_NETINET_IF_ETHER" >> $deffile echo "#define NETWIBDEF_HAVEINCL_NETINET_ETHER $NETWIBDEF_HAVEINCL_NETINET_ETHER" >> $deffile echo "#define NETWIBDEF_HAVEINCL_NETPACKET_PACKET $NETWIBDEF_HAVEINCL_NETPACKET_PACKET" >> $deffile echo "#define NETWIBDEF_HAVEINCL_ASM_PAGE $NETWIBDEF_HAVEINCL_ASM_PAGE" >> $deffile echo "#define NETWIBDEF_HAVEINCL_MACH_MACHINE_VMPARAM $NETWIBDEF_HAVEINCL_MACH_MACHINE_VMPARAM" >> $deffile echo "#define NETWIBDEF_HAVEINCL_MACHINE_PARAM $NETWIBDEF_HAVEINCL_MACHINE_PARAM" >> $deffile echo "#define NETWIBDEF_HAVETYPE_SIZE_T $NETWIBDEF_HAVETYPE_SIZE_T" >> $deffile echo "#define NETWIBDEF_HAVETYPE_SOCKLEN_T $NETWIBDEF_HAVETYPE_SOCKLEN_T" >> $deffile echo "#define NETWIBDEF_HAVETYPE_SIGHANDLER_T $NETWIBDEF_HAVETYPE_SIGHANDLER_T" >> $deffile echo "#define NETWIBDEF_HAVETYPE_SIG_T $NETWIBDEF_HAVETYPE_SIG_T" >> $deffile echo "#define NETWIBDEF_HAVETYPE_OFF_T $NETWIBDEF_HAVETYPE_OFF_T" >> $deffile echo "#define NETWIBDEF_HAVETYPE_PTHREAD_RWLOCK_T $NETWIBDEF_HAVETYPE_PTHREAD_RWLOCK_T" >> $deffile echo "#define NETWIBDEF_HAVETYPE_SOCKADDR_IN6 $NETWIBDEF_HAVETYPE_SOCKADDR_IN6" >> $deffile echo "#define NETWIBDEF_HAVEFIELD_TM_GMTOFF $NETWIBDEF_HAVEFIELD_TM_GMTOFF" >> $deffile echo "#define NETWIBDEF_HAVEFIELD_SOCKADDR_SALEN $NETWIBDEF_HAVEFIELD_SOCKADDR_SALEN" >> $deffile echo "#define NETWIBDEF_HAVEFIELD_SOCKADDRIN_SINLEN $NETWIBDEF_HAVEFIELD_SOCKADDRIN_SINLEN" >> $deffile echo "#define NETWIBDEF_HAVEFIELD_SOCKADDRIN6_SIN6LEN $NETWIBDEF_HAVEFIELD_SOCKADDRIN6_SIN6LEN" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_ETHER_NTOHOST $NETWIBDEF_HAVEFUNC_ETHER_NTOHOST" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_ETHER_HOSTTON $NETWIBDEF_HAVEFUNC_ETHER_HOSTTON" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_HSTRERROR $NETWIBDEF_HAVEFUNC_HSTRERROR" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_SNPRINTF $NETWIBDEF_HAVEFUNC_SNPRINTF" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_PCAP_FREECODE $NETWIBDEF_HAVEFUNC_PCAP_FREECODE" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_PCAP_FREECODE2 $NETWIBDEF_HAVEFUNC_PCAP_FREECODE2" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_PCAP_OPENDEAD $NETWIBDEF_HAVEFUNC_PCAP_OPENDEAD" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_POLL $NETWIBDEF_HAVEFUNC_POLL" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_DIRFD $NETWIBDEF_HAVEFUNC_DIRFD" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_FPATHCONF $NETWIBDEF_HAVEFUNC_FPATHCONF" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_PATHCONF $NETWIBDEF_HAVEFUNC_PATHCONF" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_SYSCONF $NETWIBDEF_HAVEFUNC_SYSCONF" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_GETPAGESIZE $NETWIBDEF_HAVEFUNC_GETPAGESIZE" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_GETRLIMIT $NETWIBDEF_HAVEFUNC_GETRLIMIT" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_NANOSLEEP $NETWIBDEF_HAVEFUNC_NANOSLEEP" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_USLEEP $NETWIBDEF_HAVEFUNC_USLEEP" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_GETTIMEOFDAY $NETWIBDEF_HAVEFUNC_GETTIMEOFDAY" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_CLOCK_GETTIME $NETWIBDEF_HAVEFUNC_CLOCK_GETTIME" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_PTHREAD_DELAY_NP $NETWIBDEF_HAVEFUNC_PTHREAD_DELAY_NP" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_PTHREAD_MUTEX_TIMEDLOCK $NETWIBDEF_HAVEFUNC_PTHREAD_MUTEX_TIMEDLOCK" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_PTHREAD_RWLOCK_TIMEDRDLOCK $NETWIBDEF_HAVEFUNC_PTHREAD_RWLOCK_TIMEDRDLOCK" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_PTHREAD_RWLOCK_TIMEDWRLOCK $NETWIBDEF_HAVEFUNC_PTHREAD_RWLOCK_TIMEDWRLOCK" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_PTHREAD_YIELD $NETWIBDEF_HAVEFUNC_PTHREAD_YIELD" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_SCHED_YIELD $NETWIBDEF_HAVEFUNC_SCHED_YIELD" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_GETPWNAM_R $NETWIBDEF_HAVEFUNC_GETPWNAM_R" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_GETGRNAM_R $NETWIBDEF_HAVEFUNC_GETGRNAM_R" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_GETGRGID_R $NETWIBDEF_HAVEFUNC_GETGRGID_R" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_READDIR_R $NETWIBDEF_HAVEFUNC_READDIR_R" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_GETHOSTBYNAME_R $NETWIBDEF_HAVEFUNC_GETHOSTBYNAME_R" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_GETHOSTBYADDR_R $NETWIBDEF_HAVEFUNC_GETHOSTBYADDR_R" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_GETNAMEINFO $NETWIBDEF_HAVEFUNC_GETNAMEINFO" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_GETADDRINFO $NETWIBDEF_HAVEFUNC_GETADDRINFO" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_GETIPNODEBYNAME $NETWIBDEF_HAVEFUNC_GETIPNODEBYNAME" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_GETIPNODEBYADDR $NETWIBDEF_HAVEFUNC_GETIPNODEBYADDR" >> $deffile echo "#define NETWIBDEF_HAVEFUNC_LOCALTIME_R $NETWIBDEF_HAVEFUNC_LOCALTIME_R" >> $deffile echo "#define NETWIBDEF_HAVEVAR_HERRNO $NETWIBDEF_HAVEVAR_HERRNO" >> $deffile echo "#define NETWIBDEF_HAVEVAR_PATH_MAX $NETWIBDEF_HAVEVAR_PATH_MAX" >> $deffile echo "#define NETWIBDEF_HAVEVAR_NAME_MAX $NETWIBDEF_HAVEVAR_NAME_MAX" >> $deffile echo "#define NETWIBDEF_HAVEVAR_PAGE_SIZE $NETWIBDEF_HAVEVAR_PAGE_SIZE" >> $deffile echo "#define NETWIBDEF_HAVEVAR_PAGESIZE $NETWIBDEF_HAVEVAR_PAGESIZE" >> $deffile echo "#define NETWIBDEF_HAVEVAR_BIOCSHDRCMPLT $NETWIBDEF_HAVEVAR_BIOCSHDRCMPLT" >> $deffile echo "#define NETWIBDEF_HAVEVAR_SIOCGLIFCONF $NETWIBDEF_HAVEVAR_SIOCGLIFCONF" >> $deffile echo "#define NETWIBDEF_HAVEVAR_AF_INET6 $NETWIBDEF_HAVEVAR_AF_INET6" >> $deffile echo "#define NETWIBDEF_HAVEVAR_SC_GETPW_R_SIZE_MAX $NETWIBDEF_HAVEVAR_SC_GETPW_R_SIZE_MAX" >> $deffile echo "#define NETWIBDEF_HAVEVAR_SC_GETGR_R_SIZE_MAX $NETWIBDEF_HAVEVAR_SC_GETGR_R_SIZE_MAX" >> $deffile ######### netwibconfig="./compil/unix/netwib-config" echo " Creation of $netwibconfig" cat > $netwibconfig <&2 fi # get all parameters while test \$# -gt 0; do case \$1 in -v | --version) echo_v=yes ;; -c | --cflags) echo_c=yes ;; -l | --libs) echo_l=yes ;; -cl | -lc) echo_c=yes echo_l=yes ;; -d | --def | --define) if test \$# -ne 2; then usage \$0 3 1>&2 fi adefine \$2 exit ;; *) usage \$0 2 1>&2 esac shift done # print version, and exit if test "\$echo_v" = "yes"; then echo "$NETWIBDEF_VERSION" exit 0 fi EOF echo "#initialize printed variables" >> $netwibconfig add=1 if [ "Z$NETWIBDEF_INSTINCLUDE" = "Z/usr/include" ] ; then # do not add /usr/include add=0 fi if [ $add -eq 1 ] ; then r=`echo "main(void){}" | $NETWIBDEF_PROGCC -v -E -I $NETWIBDEF_INSTINCLUDE - 2>&1 | $NETWIBDEF_PROGGREP 'changing search order for system directory "'$NETWIBDEF_INSTINCLUDE'"'` if [ "Z$r" != "Z" ] ; then add=0 fi fi if [ $add -eq 1 ] ; then r=`echo "main(void){}" | $NETWIBDEF_PROGCC -v -E -I $NETWIBDEF_INSTINCLUDE - 2>&1 | $NETWIBDEF_PROGGREP 'ignoring duplicate directory "'$NETWIBDEF_INSTINCLUDE'"'` if [ "Z$r" != "Z" ] ; then add=0 fi fi if [ $add -eq 1 ] ; then echo "echo_c_=\"-I$NETWIBDEF_INSTINCLUDE\"" >> $netwibconfig else echo "echo_c=no" >> $netwibconfig fi commonv="-lnetwib $gccLib" if [ $add -eq 1 ] ; then # suppose lib is also a gcc default directory echo "echo_l_=\"-L$NETWIBDEF_INSTLIB $commonv\"" >> $netwibconfig else echo "echo_l_=\"$commonv\"" >> $netwibconfig fi cat >> $netwibconfig < Makefile <> Makefile <> Makefile fi cat >> Makefile <> Makefile echo "# dependence list" >> Makefile echo "NETWIBSRC=." >> Makefile cat compil/unix/filedep >> Makefile ######### echo "" >> Makefile cat compil/unix/incmake >> Makefile ######### cat >> Makefile <> Makefile fi cat >> Makefile <