diff options
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 338 |
1 files changed, 195 insertions, 143 deletions
diff --git a/configure b/configure index b8c76fc..a8ee590 100755 --- a/configure +++ b/configure @@ -58,6 +58,11 @@ echo () { printf %s\\n "$*" } +echon () { + IFS=" " + printf %s "$*" +} + quote () { tr '\n' ' ' <<EOF | grep '^[-[:alnum:]_=,./:]* $' >/dev/null 2>&1 && { echo "$1" ; return 0 ; } $1 @@ -116,12 +121,27 @@ tryldflag () { fi } + +# Sysdeps determination functions + +iscached () +{ + if test -n "$sysdepspre" && grep -qF "${1}: " "$sysdepspre" ; then + v=`grep -F "${1}: " "$sysdepspre" | tail -n 1 | awk '{print $2;}'` + echo "${1}: $v" >> "$sysdeps/sysdeps" + echo " ... user-provided: $v" + return 0 ; + else + return 1 ; + fi +} + choose () { what="$1" name="$2" - macro="$3" - echo "Checking whether system has $4..." - shift 4 + if iscached "$name" ; then return ; fi + echo "Checking whether system has $3..." + shift 3 libs="$*" r=true case "$what" in @@ -143,40 +163,122 @@ choose () { esac fi rm -f try$name.o try$name - echo "#undef ${package_macro_name}_HAS$macro" >> $sysdeps/sysdeps.h if $r ; then echo "$name: yes" >> $sysdeps/sysdeps - echo "#define ${package_macro_name}_HAS$macro" >> $sysdeps/sysdeps.h echo " ... yes" else echo "$name: no" >> $sysdeps/sysdeps echo " ... no" fi - echo >> $sysdeps/sysdeps.h +} + +trybasic () { + $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST -o "$tmpe" -c "$1" 2>/dev/null + r=$? + rm -f "$tmpe" + return $r +} + +tryendianness () { + echo "Checking endianness..." + if iscached endianness ; then return ; fi + for i in endian.h sys/endian.h machine/endian.h ; do + cat > "$tmpc" <<EOF +#include <$i> +int a = 1 ; +EOF + if trybasic "$tmpc" ; then + cat > "$tmpc" <<EOF +#ifndef _BSD_SOURCE +#define _BSD_SOURCE +#endif +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#ifndef _DEFAULT_SOURCE +#define _DEFAULT_SOURCE +#endif +#include <$i> +int a = LITTLE_ENDIAN ; +int b = BIG_ENDIAN ; +int c = BYTE_ORDER ; +EOF + trybasic "$tmpc" || exit 5 + for j in little big pdp ; do + k=`echo $j | tr a-z A-Z` + cat > "$tmpc" <<EOF +#ifndef _BSD_SOURCE +#define _BSD_SOURCE +#endif +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#ifndef _DEFAULT_SOURCE +#define _DEFAULT_SOURCE +#endif +#include <$i> +int a[BYTE_ORDER == ${k}_ENDIAN ? 1 : -1] ; +EOF + if trybasic "$tmpc" ; then + echo "endianness: $j" >> "$sysdeps/sysdeps" + echo " ... $j" + rm -f "$tmpc" + return + fi + done + rm -f "$tmpc" + echo "$0: error: unable to determine endianness according to $i" 1>&2 + exit 1 + fi + done + rm -f "$tmpc" + echo "$0: error: unable to determine endianness: no endian.h found" 1>&2 + exit 1 +} + +trysigned () { + cat > "$tmpc" <<EOF +#include <sys/types.h> +int a[($1)-1 < 0 ? 1 : -1] ; +EOF + trybasic "$tmpc" + r=$? + rm -f "$tmpc" + return $r +} + +trysizes () { + t="$1" ; shift + for arg ; do + cat > "$tmpc" <<EOF +#include <sys/types.h> +int a[sizeof($t) == $arg ? 1 : -1] ; +EOF + if trybasic "$tmpc" ; then + rm -f "$tmpc" + echo "$arg" + return + fi + done + rm -f "$tmpc" + echo "$0: error: unable to determine the size of $t on the target" 1>&2 + exit 1 +} + +trystdtype () { + t="$1" ; shift + iscached "sizeofu$t" || { echon "sizeofu${t}: " ; trysizes "$t" "$@" ; } >> "$sysdeps/sysdeps" } trytypes () { echo "Checking size and signedness of standard types..." - $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST $LDFLAGS_AUTO $LDFLAGS $LDFLAGS_POST -o output-types src/sysdeps/output-types.c - ./output-types >> $sysdeps/sysdeps - ./output-types | grep -F sizeof | while read key value ; do - caps=$(echo $key | sed s/:\$// | tr a-z A-Z) - echo "#undef ${package_macro_name}_${caps}" - echo "#define ${package_macro_name}_${caps} $value" - echo - done >> $sysdeps/sysdeps.h - ./output-types | grep -F signed | while read key value ; do - caps=$(echo $key | sed s/:\$// | tr a-z A-Z) - echo "#undef ${package_macro_name}_HASUN${caps}" - echo "#undef ${package_macro_name}_HAS${caps}" - if test $value = yes ; then - echo "#define ${package_macro_name}_HAS${caps}" - else - echo "#define ${package_macro_name}_HASUN${caps}" - fi - echo - done >> $sysdeps/sysdeps.h - rm -f output-types + trystdtype short 2 4 + trystdtype int 4 8 2 + trystdtype long 8 4 + for t in size uid gid pid time dev ino ; do + iscached "signed$t" || { echon "signed${t}: " ; if trysigned "${t}_t" ; then echo "yes" ; else echo "no" ; fi ; } >> "$sysdeps/sysdeps" + iscached "sizeof$t" || { echon "sizeof${t}: " ; trysizes "${t}_t" 4 8 2 ; } >> "$sysdeps/sysdeps" + done echo " ... done" } @@ -231,7 +333,7 @@ libdir='$prefix/lib/$package' includedir='$prefix/include' datadir='$prefix/etc' sysdepdir='$prefix/lib/$package/sysdeps' -sysdeps= +sysdepspre= shared=true static=true allpic=true @@ -261,7 +363,7 @@ for arg ; do --includedir=*) includedir=${arg#*=} ;; --datadir=*) datadir=${arg#*=} ;; --sysdepdir=*) sysdepdir=${arg#*=} ;; - --with-sysdeps=*) sysdeps=${arg#*=} ;; + --with-sysdeps=*) sysdepspre=${arg#*=} ;; --with-include=*) var=${arg#*=} ; stripdir var ; addincpath="$addincpath -I$var" ;; --with-lib=*) var=${arg#*=} ; stripdir var ; addlibspath="$addlibspath -L$var" ; vpaths="$vpaths $var" ;; --with-dynlib=*) var=${arg#*=} ; stripdir var ; addlibdpath="$addlibdpath -L$var" ; vpathd="$vpathd $var" ;; @@ -308,7 +410,7 @@ fi # Expand installation directories stripdir prefix -for i in exec_prefix dynlibdir libdir includedir datadir sysdepdir sysdeps sproot ; do +for i in exec_prefix dynlibdir libdir includedir datadir sysdepdir sysdepspre sproot ; do eval tmp=\${$i} eval $i=$tmp stripdir $i @@ -419,22 +521,21 @@ if $shared ; then tryldflag LDFLAGS -Wl,--hash-style=both fi -if test -n "$sysdeps" ; then - if test ! -d $sysdeps || test ! -f $sysdeps/target ; then - echo "$0: error: $sysdeps is not a valid sysdeps directory" +if test -n "$sysdepspre" ; then + if test ! -d "$sysdepspre" || test ! -f $sysdepspre/target ; then + echo "$0: error: $sysdepspre is not a valid sysdeps directory" exit 1 fi - if [ "x$target" != "x$(cat $sysdeps/target)" ] ; then - echo "$0: error: target $target does not match the contents of $sysdeps/target" + if [ "x$target" != "x$(cat $sysdepspre/target)" ] ; then + echo "$0: error: target $target does not match the contents of $sysdepspre/target" exit 1 fi - echo "Using pre-computed sysdeps in $sysdeps." - spawn_lib=$(cat $sysdeps/spawn.lib) - socket_lib=$(cat $sysdeps/socket.lib) - sysclock_lib=$(cat $sysdeps/sysclock.lib) - tainnow_lib=$(cat $sysdeps/tainnow.lib) - timer_lib=$(cat $sysdeps/timer.lib) - util_lib=$(cat $sysdeps/util.lib) + echo "Using pre-computed sysdeps in $sysdepspre." + spawn_lib=$(cat $sysdepspre/spawn.lib) + socket_lib=$(cat $sysdepspre/socket.lib) + sysclock_lib=$(cat $sysdepspre/sysclock.lib) + timer_lib=$(cat $sysdepspre/timer.lib) + util_lib=$(cat $sysdepspre/util.lib) else if test -n "$cross" ; then echo "$0: warning: possible cross-build attempt with a native compiler" 1>&2 @@ -442,17 +543,6 @@ else sysdeps=sysdeps.cfg mkdir -p $sysdeps echo "$target" > $sysdeps/target - echo "target: $target" > $sysdeps/sysdeps - cat <<EOF > $sysdeps/sysdeps.h -/* ISC license. */ - -#ifndef SYSDEPS_H -#define SYSDEPS_H - -#undef SKALIBS_TARGET -#define SKALIBS_TARGET "$target" - -EOF exec 3>&1 util_lib= @@ -461,105 +551,68 @@ EOF socket_lib=`trylibs lsock 'accessible socket functions' -lsocket -lnsl` || fail "$0: unable to determine socket.lib sysdep" echo "$socket_lib" > $sysdeps/socket.lib - hasclock=true - sysclock_lib=`trylibs clockrt 'clock_gettime()' -lrt` || hasclock=false - tainnow_lib=$sysclock_lib + hasclock=yes + sysclock_lib=`trylibs clockrt 'clock_gettime()' -lrt` || hasclock=no echo "$sysclock_lib" > $sysdeps/sysclock.lib - echo "$tainnow_lib" > $sysdeps/tainnow.lib - echo "#undef ${package_macro_name}_HASCLOCKRT" >> $sysdeps/sysdeps.h - if $hasclock ; then - echo 'clockrt: yes' >> $sysdeps/sysdeps - echo "#define ${package_macro_name}_HASCLOCKRT" >> $sysdeps/sysdeps.h - else - echo 'clockrt: no' >> $sysdeps/sysdeps - fi - echo >> $sysdeps/sysdeps.h - choose cl clockmon CLOCKMON CLOCK_MONOTONIC $sysclock_lib - choose cl clockboot CLOCKBOOT CLOCK_BOOTTIME $sysclock_lib + echo "clockrt: $hasclock" >> $sysdeps/sysdeps - hasspawn=true - spawn_lib=`trylibs posixspawn 'posix_spawn()' -lrt` || hasspawn=false + choose cl clockmon CLOCK_MONOTONIC $sysclock_lib + choose cl clockboot CLOCK_BOOTTIME $sysclock_lib + + hasspawn=yes + spawn_lib=`trylibs posixspawn 'posix_spawn()' -lrt` || hasspawn=no echo "$spawn_lib" > $sysdeps/spawn.lib - echo "#undef ${package_macro_name}_HASPOSIXSPAWN" >> $sysdeps/sysdeps.h - if $hasspawn ; then - echo 'posixspawn: yes' >> $sysdeps/sysdeps - echo "#define ${package_macro_name}_HASPOSIXSPAWN" >> $sysdeps/sysdeps.h - else - echo 'posixspawn: no' >> $sysdeps/sysdeps - fi - echo >> $sysdeps/sysdeps.h + echo "posixspawn: $hasspawn" >> $sysdeps/sysdeps - hastimer=true - timer_lib=`trylibs timer 'timer_create()' -lrt` || hastimer=false + hastimer=yes + timer_lib=`trylibs timer 'timer_create()' -lrt` || hastimer=no echo "$timer_lib" > $sysdeps/timer.lib - echo "#undef ${package_macro_name}_HASTIMER" >> $sysdeps/sysdeps.h - if $hastimer ; then - echo 'timer: yes' >> $sysdeps/sysdeps - echo "#define ${package_macro_name}_HASTIMER" >> $sysdeps/sysdeps.h - else - echo 'timer: no' >> $sysdeps/sysdeps - fi - echo >> $sysdeps/sysdeps.h + echo "timer: $hastimer" >> $sysdeps/sysdeps exec 3>&- - echo "Checking system endianness..." - $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST $LDFLAGS_AUTO $LDFLAGS $LDFLAGS_POST -o tryendianness src/sysdeps/tryendianness.c - endianness=$(./tryendianness) || fail "$0: unable to determine endianness" - echo "endianness: $endianness" >> $sysdeps/sysdeps - { - echo "#undef ${package_macro_name}_ENDIANNESS" - echo "#define ${package_macro_name}_ENDIANNESS \"$endianness\"" - echo - } >> $sysdeps/sysdeps.h - echo " ... $endianness" - rm -f tryendianness - + tryendianness trytypes - choose clr nullispointer NULLISPOINTER 'a pointer-typed NULL' - choose clr accept4 ACCEPT4 'accept4()' - choose c cmsgcloexec CMSGCLOEXEC 'MSG_CMSG_CLOEXEC' - choose clr devurandom DEVURANDOM '/dev/urandom' - choose cl dirfd DIRFD 'dirfd()' - choose cl eventfd EVENTFD 'eventfd()' - choose cl flock FLOCK 'flock()' - choose cl getpeereid GETPEEREID 'getpeereid()' - choose cl sopeercred SOPEERCRED 'SO_PEERCRED' - choose cl getpeerucred GETPEERUCRED 'getpeerucred()' - choose cl ipv6 IPV6 'IPv6 support' $socket_lib - choose clr malloc0 MALLOC0 'non-NULL malloc(0)' - choose c msgdontwait MSGDONTWAIT 'MSG_DONTWAIT' - choose c odirectory ODIRECTORY 'O_DIRECTORY' - choose cl openat OPENAT 'openat()' - choose cl linkat LINKAT 'linkat()' - choose cl memmem MEMMEM 'memmem()' - choose clr pipe2 PIPE2 'pipe2()' - choose clr ppoll PPOLL 'ppoll()' - choose cl revoke REVOKE 'revoke()' - choose cl sendfile SENDFILE 'sendfile()' - choose cl setgroups SETGROUPS 'setgroups()' - choose cl settimeofday SETTIMEOFDAY 'settimeofday()' - choose clr signalfd SIGNALFD 'signalfd()' - choose clr splice SPLICE 'splice()' - choose cl strcasestr STRCASESTR 'strcasestr()' - choose c strnlen STRNLEN 'strnlen()' - choose c uint64t UINT64T 'uint64_t' - choose cl futimens FUTIMENS 'futimens()' - choose cl futimes FUTIMES 'futimes()' - choose cl arc4random ARC4RANDOM 'arc4random()' - choose cl arc4random_addrandom ARC4RANDOM_ADDRANDOM 'arc4random_addrandom()' - choose clr getrandom GETRANDOM 'getrandom()' - choose cl itimer ITIMER 'setitimer()' - choose cl namespaces NAMESPACES 'namespaces' - choose cl nsgetparent NSGETPARENT 'NS_GET_PARENT' - choose cl explicit_bzero EXPLICIT_BZERO 'explicit_bzero()' - choose clr emptyregex EMPTYREGEX 'regcomp() accept empty regexes' - - echo '#endif' >> $sysdeps/sysdeps.h -fi + choose cl accept4 'accept4()' + choose c cmsgcloexec 'MSG_CMSG_CLOEXEC' + choose cl dirfd 'dirfd()' + choose cl eventfd 'eventfd()' + choose cl flock 'flock()' + choose cl getrandom 'getrandom()' + choose cl getpeereid 'getpeereid()' + choose cl sopeercred 'SO_PEERCRED' + choose cl getpeerucred 'getpeerucred()' + choose cl ipv6 'IPv6 support' $socket_lib + choose c msgdontwait 'MSG_DONTWAIT' + choose c odirectory 'O_DIRECTORY' + choose cl openat 'openat()' + choose cl linkat 'linkat()' + choose cl memmem 'memmem()' + choose cl pipe2 'pipe2()' + choose cl ppoll 'ppoll()' + choose cl revoke 'revoke()' + choose cl sendfile 'sendfile()' + choose cl setgroups 'setgroups()' + choose cl settimeofday 'settimeofday()' + choose cl signalfd 'signalfd()' + choose cl splice 'splice()' + choose cl strcasestr 'strcasestr()' + choose c strnlen 'strnlen()' + choose c uint64t 'uint64_t' + choose cl futimens 'futimens()' + choose cl futimes 'futimes()' + choose cl arc4random 'arc4random()' + choose cl arc4random_addrandom 'arc4random_addrandom()' + choose cl itimer 'setitimer()' + choose cl namespaces 'namespaces' + choose cl nsgetparent 'NS_GET_PARENT' + choose cl explicit_bzero 'explicit_bzero()' + + choose clr emptyregex 'regcomp() accept empty regexes' + choose clr nullispointer 'a pointer-typed NULL' + choose clr devurandom '/dev/urandom' + choose clr malloc0 'non-NULL malloc(0)' -echo "Copying $sysdeps/sysdeps.h to src/include/${package}/sysdeps.h ..." -cat < $sysdeps/sysdeps.h > src/include/${package}/sysdeps.h -echo " ... done" +fi echo "Creating config.mak..." cmdline=$(quote "$0") @@ -587,7 +640,6 @@ ipv6 := ${ipv6} SPAWN_LIB := ${spawn_lib} SOCKET_LIB := ${socket_lib} SYSCLOCK_LIB := ${sysclock_lib} -TAINNOW_LIB := ${tainnow_lib} TIMER_LIB := ${timer_lib} UTIL_LIB := ${util_lib} CC := ${CC_AUTO} |