]> arthur.barton.de Git - bup.git/blobdiff - config/configure.inc
change mktemp to be compatible with busybox
[bup.git] / config / configure.inc
index 2f293deb44f60eee7cb3e460ebdb53062798bb9f..9d105ac7a2b8901087fcc13f8e97d1f6fc87476f 100644 (file)
@@ -47,6 +47,16 @@ ac_standard="--src=DIR               where the source lives (.)
 
 __fail=exit
 
+
+__ac_tmpdir=''
+__ac_clean_up () {
+    if test "$__ac_tmpdir"; then
+        rm -rf "$__ac_tmpdir"
+    fi
+}
+trap __ac_clean_up EXIT
+
+
 if dirname B/A 2>/dev/null >/dev/null; then
 __ac_dirname() {
     dirname "$1"
@@ -290,15 +300,15 @@ AC_CONTINUE () {
 AC_CHECK_HEADERS () {
     AC_PROG_CC
 
-    echo "/* AC_CHECK_HEADERS */" > /tmp/ngc$$.c
+    echo "/* AC_CHECK_HEADERS */" > "$__ac_tmpdir/ngc$$.c"
     for hdr in $*; do
-       echo "#include <$hdr>" >> /tmp/ngc$$.c
+       echo "#include <$hdr>" >> "$__ac_tmpdir/ngc$$.c"
     done
-    echo "main() { }" >> /tmp/ngc$$.c
+    echo "main() { }" >> "$__ac_tmpdir/ngc$$.c"
 
     LOGN "checking for header $hdr"
 
-    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c; then
+    if $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c"; then
        AC_DEFINE 'HAVE_'`echo $hdr | tr 'a-z' 'A-Z' | tr './' '_'` 1
        TLOG " (found)"
        rc=0
@@ -306,7 +316,7 @@ AC_CHECK_HEADERS () {
        TLOG " (not found)"
        rc=1
     fi
-    rm -f /tmp/ngc$$.c /tmp/ngc$$
+    rm -f "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$"
     return $rc
 }
 
@@ -319,14 +329,14 @@ AC_CHECK_FUNCS () {
 
 F=$1
 shift
-rm -f /tmp/ngc$$.c
+rm -f "$__ac_tmpdir/ngc$$.c"
 
 while [ "$1" ]; do
-    echo "#include <$1>" >> /tmp/ngc$$.c
+    echo "#include <$1>" >> "$__ac_tmpdir/ngc$$.c"
     shift
 done
 
-    cat >> /tmp/ngc$$.c << EOF
+    cat >> "$__ac_tmpdir/ngc$$.c" << EOF
 main()
 {
 
@@ -336,18 +346,18 @@ EOF
 
     LOGN "checking for the $F function"
 
-    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $LIBS; then
+    if $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" $LIBS; then
        AC_DEFINE `echo ${2:-HAVE_$F} | tr 'a-z' 'A-Z'` 1
        TLOG " (found)"
        rc=0
     else
        echo "offending command was:"
-       cat /tmp/ngc$$.c
-       echo "$AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $LIBS"
+       cat "$__ac_tmpdir/ngc$$.c"
+       echo "$AC_CC -o $__ac_tmpdir/ngc$$ $__ac_tmpdir/ngc$$.c $LIBS"
        TLOG " (not found)"
        rc=1
     fi
-    rm -f /tmp/ngc$$.c /tmp/ngc$$
+    rm -f "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$"
     return $rc
 }
 
@@ -362,13 +372,13 @@ AC_CHECK_STRUCT () {
     struct=$1
     shift
 
-    rm -f /tmp/ngc$$.c
+    rm -f "$__ac_tmpdir/ngc$$.c"
 
     for include in $*; do
-       echo "#include <$include>" >> /tmp/ngc$$.c
+       echo "#include <$include>" >> "$__ac_tmpdir/ngc$$.c"
     done
 
-    cat >> /tmp/ngc$$.c << EOF
+    cat >> "$__ac_tmpdir/ngc$$.c" << EOF
 main()
 {
     struct $struct foo;
@@ -377,7 +387,7 @@ EOF
 
     LOGN "checking for struct $struct"
 
-    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $AC_LIBS 2>>config.log; then
+    if $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" $AC_LIBS 2>>config.log; then
        AC_DEFINE HAVE_STRUCT_`echo ${struct} | tr 'a-z' 'A-Z'`
        TLOG " (found)"
        rc=0
@@ -385,7 +395,7 @@ EOF
        TLOG " (not found)"
        rc=1
     fi
-    rm -f /tmp/ngc$$.c /tmp/ngc$$
+    rm -f "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$"
     return $rc
 }
 
@@ -402,13 +412,13 @@ AC_CHECK_FIELD () {
     field=$2
     shift 2
 
-    rm -f /tmp/ngc$$.c
+    rm -f "$__ac_tmpdir/ngc$$.c"
 
     for include in $*;do
-       echo "#include <$include>" >> /tmp/ngc$$.c
+       echo "#include <$include>" >> "$__ac_tmpdir/ngc$$.c"
     done
 
-    cat >> /tmp/ngc$$.c << EOF
+    cat >> "$__ac_tmpdir/ngc$$.c" << EOF
 main()
 {
     struct $struct foo;
@@ -419,7 +429,7 @@ EOF
 
     LOGN "checking that struct $struct has a $field field"
 
-    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $AC_LIBS 2>>config.log; then
+    if $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" $AC_LIBS 2>>config.log; then
        AC_DEFINE HAVE_`echo ${struct}_$field | tr 'a-z' 'A-Z'`
        TLOG " (yes)"
        rc=0
@@ -427,7 +437,7 @@ EOF
        TLOG " (no)"
        rc=1
     fi
-    rm -f /tmp/ngc$$.c /tmp/ngc$$
+    rm -f "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$"
     return $rc
 }
 
@@ -438,7 +448,7 @@ EOF
 AC_PROG_CC () {
     test "$AC_CC" && return 0
 
-    cat > /tmp/ngc$$.c << \EOF
+    cat > "$__ac_tmpdir/ngc$$.c" << \EOF
 #include <stdio.h>
 main()
 {
@@ -469,7 +479,7 @@ EOF
     fi
     echo "checking out the C compiler"
 
-    $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c
+    $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c"
     status=$?
 
     TLOGN " ($AC_CC)"
@@ -482,7 +492,7 @@ EOF
 
        if [ "$CFLAGS" ]; then
            test "$CFLAGS" && echo "validating CFLAGS=${CFLAGS}"
-           if $AC_CC $CFLAGS -o /tmp/ngc$$.o /tmp/ngc$$.c ; then
+           if $AC_CC $CFLAGS -o "$__ac_tmpdir/ngc$$.o" "$__ac_tmpdir/ngc$$.c" ; then
                AC_CFLAGS=${CFLAGS:-"-g"}
                test "$CFLAGS" && echo "CFLAGS=\"${CFLAGS}\" are okay"
            elif [ "$CFLAGS" ]; then
@@ -493,7 +503,7 @@ EOF
        fi
        if [ "$LDFLAGS" ]; then
            test "$LDFLAGS" && echo "validating LDFLAGS=${LDFLAGS}"
-           if $AC_CC $LDFLAGS -o /tmp/ngc$$ /tmp/ngc$$.o; then
+           if $AC_CC $LDFLAGS -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.o"; then
                AC_LDFLAGS=${LDFLAGS:-"-g"}
                test "$LDFLAGS" && TLOG "LDFLAGS=\"${LDFLAGS}\" are okay"
            elif [ "$LDFLAGS" ]; then
@@ -508,7 +518,7 @@ EOF
 
     AC_SUB 'CC' "$AC_CC"
 
-    rm -f /tmp/ngc$$ /tmp/ngc$$.c /tmp/ngc$$.o
+    rm -f "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$.o"
 
     return $status
 }
@@ -518,7 +528,7 @@ EOF
 # acLookFor actually looks for a program, without setting anything.
 #
 acLookFor () {
-    path=${AC_PATH:-$ac_default_path}
+    path="${AC_PATH:-$ac_default_path}"
     case "X$1" in
     X-[rx]) __mode=$1
            shift
@@ -530,8 +540,8 @@ acLookFor () {
     for program in $*; do
        IFS=":"
        for x in $path; do
-           if [ $__mode $x/$program -a -f $x/$program ]; then
-               echo $x/$program
+           if [ $__mode "$x/$program" -a -f "$x/$program" ]; then
+               echo "$x/$program"
                break 2
            fi
        done
@@ -566,7 +576,7 @@ MF_PATH_INCLUDE () {
        AC_MAK $SYM
        AC_DEFINE PATH_$__sym \""$DEST"\"
        AC_SUB $__sym "$DEST"
-       eval CF_$SYM=$DEST
+       eval CF_$SYM="'$DEST'"
        return 0
     else
        #AC_SUB $__sym ''
@@ -584,6 +594,7 @@ MF_PATH_INCLUDE () {
 # and fd 5 points to what used to be fd 1
 #
 AC_INIT () {
+    __ac_tmpdir=$(mktemp -d configure-XXXXXX)
     __config_files="config.cmd config.sub config.h config.mak config.log"
     __config_detritus="config.h.tmp"
     rm -f $__config_files $__config_detritus
@@ -655,7 +666,7 @@ EOF
     AC_PROG_CPP
     AC_PROG_INSTALL
 
-    ac_os=`uname -s | sed 's/[-_].*//'`
+    ac_os=`uname -s | sed 's/[-_].*//; s/[^a-zA-Z0-9]/_/g'`
     _os=`echo $ac_os | tr '[a-z]' '[A-Z]'`
     AC_DEFINE OS_$_os  1
     eval OS_${_os}=1
@@ -781,18 +792,18 @@ AC_PROG_LN_S () {
     DEST=`acLookFor ln`
 
     if [ "$DEST" ]; then
-       rm -f /tmp/b$$
-       $DEST -s /tmp/a$$ /tmp/b$$
-       if [ "`$AC_FIND_PROG /tmp/b$$ -type l -print`" ]; then
+       rm -f "$__ac_tmpdir/b$$"
+       "$DEST" -s "$__ac_tmpdir/a$$" "$__ac_tmpdir/b$$"
+       if [ "`$AC_FIND_PROG $__ac_tmpdir/b$$ -type l -print`" ]; then
            TLOG " ($DEST)"
            echo "$DEST exists, and ln -s works"
            AC_SUB 'LN_S' "$DEST -s"
-           rm -f /tmp/b$$
+           rm -f "$__ac_tmpdir/b$$"
        else
            AC_SUB 'LN_S' ''
            TLOG " ($DEST exists, but -s does not seem to work)"
            echo "$DEST exists, but ln -s doesn't seem to work"
-           rm -f /tmp/b$$
+           rm -f "$__ac_tmpdir/b$$"
            return 1
        fi
     else
@@ -812,7 +823,7 @@ AC_PROG_FIND () {
     if test -z "$AC_FIND_PROG"; then
        MF_PATH_INCLUDE FIND find
        rc=$?
-       AC_FIND_PROG=$DEST
+       AC_FIND_PROG="$DEST"
        return $rc
     fi
     return 0
@@ -827,7 +838,7 @@ AC_PROG_AWK () {
     if test -z "$AC_AWK_PROG"; then
        MF_PATH_INCLUDE AWK awk
        rc=$?
-       AC_AWK_PROG=$DEST
+       AC_AWK_PROG="$DEST"
        return $rc
     fi
     return 0
@@ -842,7 +853,7 @@ AC_PROG_SED () {
     if test -z "$AC_SED_PROG"; then
        MF_PATH_INCLUDE SED sed
        rc=$?
-       AC_SED_PROG=$DEST
+       AC_SED_PROG="$DEST"
        return $rc
     fi
     return 0
@@ -860,14 +871,14 @@ AC_HEADER_SYS_WAIT () {
 # AC_TYPE_PID_T checks to see if the pid_t type exists
 #
 AC_TYPE_PID_T () {
-    cat > /tmp/pd$$.c << EOF
+    cat > "$__ac_tmpdir/pd$$.c" << EOF
 #include <sys/types.h>
 main() { pid_t me; }
 EOF
 
     LOGN "checking for pid_t"
 
-    if $AC_CC -c /tmp/pd$$.c -o /tmp/pd$$.o; then
+    if $AC_CC -c "$__ac_tmpdir/pd$$.c" -o "$__ac_tmpdir/pd$$.o"; then
        TLOG " (found)"
        rc=0
     else
@@ -875,7 +886,7 @@ EOF
        TLOG " (not found)"
        rc=1
     fi
-    rm -f /tmp/pd$$.o /tmp/pd$$.c
+    rm -f "$__ac_tmpdir/pd$$.o" "$__ac_tmpdir/pd$$.c"
     return $rc
 }
 
@@ -884,12 +895,12 @@ EOF
 # AC_C_CONST checks to see if the compiler supports the const keyword
 #
 AC_C_CONST () {
-    cat > /tmp/pd$$.c << EOF
+    cat > "$__ac_tmpdir/pd$$.c" << EOF
 const char me=1;
 EOF
     LOGN "checking for \"const\" keyword"
 
-    if $AC_CC -c /tmp/pd$$.c -o /tmp/pd$$.o; then
+    if $AC_CC -c "$__ac_tmpdir/pd$$.c" -o "$__ac_tmpdir/pd$$.o"; then
        TLOG " (yes)"
        rc=0
     else
@@ -897,7 +908,7 @@ EOF
        TLOG " (no)"
        rc=1
     fi
-    rm -f /tmp/pd$$.o /tmp/pd$$.c
+    rm -f "$__ac_tmpdir/pd$$.o" "$__ac_tmpdir/pd$$.c"
     return $rc
 }
 
@@ -906,7 +917,7 @@ EOF
 # AC_SCALAR_TYPES checks to see if the compiler can generate 2 and 4 byte ints.
 #
 AC_SCALAR_TYPES () {
-    cat > /tmp/pd$$.c << EOF
+    cat > "$__ac_tmpdir/pd$$.c" << EOF
 #include <stdio.h>
 main()
 {
@@ -933,8 +944,8 @@ main()
 EOF
     rc=1
     LOGN "defining WORD & DWORD scalar types"
-    if $AC_CC /tmp/pd$$.c -o /tmp/pd$$; then
-       if /tmp/pd$$  >> $__cwd/config.h.tmp; then
+    if $AC_CC "$__ac_tmpdir/pd$$.c" -o "$__ac_tmpdir/pd$$"; then
+       if "$__ac_tmpdir/pd$$"  >> $__cwd/config.h.tmp; then
            rc=0
        fi
     fi
@@ -942,7 +953,7 @@ EOF
     0) TLOG "" ;;
     *) TLOG " ** FAILED **" ;;
     esac
-    rm -f /tmp/pd$$ /tmp/pd$$.c
+    rm -f "$__ac_tmpdir/pd$$" "$__ac_tmpdir/pd$$.c"
 }
 
 
@@ -1061,7 +1072,7 @@ AC_CHECK_RESOLVER () {
 
     TLOGN "checking for the Berkeley resolver library"
 
-    cat > /tmp/ngc$$.c << EOF
+    cat > "$__ac_tmpdir/ngc$$.c" << EOF
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <arpa/nameser.h>
@@ -1078,21 +1089,21 @@ EOF
 
     # first see if res_init() and res_query() actually exist...
 
-    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c; then
+    if $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c"; then
        __extralib=
-    elif $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c -lresolv; then
+    elif $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" -lresolv; then
        __extralib=-lresolv
        AC_LIBS="$AC_LIBS -lresolv"
     else
        TLOG " (not found)"
-       rm -f /tmp/ngc$$.c
+       rm -f "$__ac_tmpdir/ngc$$.c"
        return 1
     fi
 
     # if res_init() and res_query() actually exist, check to
     # see if the HEADER structure is defined ...
 
-    cat > /tmp/ngc$$.c << EOF
+    cat > "$__ac_tmpdir/ngc$$.c" << EOF
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <arpa/nameser.h>
@@ -1105,17 +1116,17 @@ main()
 }
 EOF
 
-    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $__extralib; then
+    if $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" $__extralib; then
        TLOG " (found)"
-    elif $AC_CC -DBIND_8_COMPAT -o /tmp/ngc$$ /tmp/ngc$$.c $__extralib; then
+    elif $AC_CC -DBIND_8_COMPAT -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" $__extralib; then
        TLOG " (bind9 with BIND_8_COMPAT)"
        AC_DEFINE BIND_8_COMPAT 1
     else
        TLOG " (broken)"
-       rm -f /tmp/ngc$$.c
+       rm -f "$__ac_tmpdir/ngc$$.c"
        return 1
     fi
-    rm -f /tmp/ngc$$.c
+    rm -f "$__ac_tmpdir/ngc$$.c"
     return 0
 }
 
@@ -1132,17 +1143,17 @@ AC_PROG_INSTALL () {
     unset IS_BSD
     if [ "$DEST" ]; then
        # BSD install or GNU install?  Let's find out...
-       touch /tmp/a$$
+       touch "$__ac_tmpdir/a$$"
 
-       $DEST /tmp/a$$ /tmp/b$$
+       "$DEST" "$__ac_tmpdir/a$$" "$__ac_tmpdir/b$$"
 
-       if test -r /tmp/a$$; then
+       if test -r "$__ac_tmpdir/a$$"; then
            LOG " ($DEST)"
        else
            IS_BSD=1
            LOG " ($DEST) bsd install"
        fi
-       rm -f /tmp/a$$ /tmp/b$$
+       rm -f "$__ac_tmpdir/a$$" "$__ac_tmpdir/b$$"
     else
        DEST=`acLookFor ginstall`
        if [ "$DEST" ]; then
@@ -1208,22 +1219,22 @@ EOD
 # compiler options
 #
 acCheckCPP () {
-       cat > /tmp/ngc$$.c << EOF
+       cat > "$__ac_tmpdir/ngc$$.c" << EOF
 #define FOO BAR
 
 FOO
 EOF
 
-    if $1 $2 /tmp/ngc$$.c > /tmp/ngc$$.o; then
-       if grep -v '#define' /tmp/ngc$$.o | grep -s BAR >/dev/null; then
+    if $1 $2 "$__ac_tmpdir/ngc$$.c" > "$__ac_tmpdir/ngc$$.o"; then
+       if grep -v '#define' "$__ac_tmpdir/ngc$$.o" | grep -s BAR >/dev/null; then
            echo "CPP=[$1], CPPFLAGS=[$2]"
            AC_SUB 'CPP' "$1"
            AC_SUB 'CPPFLAGS' "$2"
-           rm /tmp/ngc$$.c /tmp/ngc$$.o
+           rm "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$.o"
            return 0
        fi
     fi
-    rm /tmp/ngc$$.c /tmp/ngc$$.o
+    rm "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$.o"
     return 1
 }
 
@@ -1234,7 +1245,7 @@ EOF
 #
 AC_PROG_CPP () {
     if [ "$AC_CPP_PROG" ]; then
-       DEST=$AC_CPP_PROG
+       DEST="$AC_CPP_PROG"
     else
        __ac_path="$AC_PATH"
        AC_PATH="/lib:/usr/lib:${__ac_path:-$ac_default_path}"
@@ -1246,11 +1257,11 @@ AC_PROG_CPP () {
     LOGN "Looking for cpp"
     if [ "$DEST" ]; then
        TLOGN " ($DEST)"
-       acCheckCPP $DEST "$CPPFLAGS" || \
-                acCheckCPP $DEST -traditional-cpp -E || \
-                acCheckCPP $DEST -E || \
-                acCheckCPP $DEST -traditional-cpp -pipe || \
-                acCheckCPP $DEST -pipe || fail=1
+       acCheckCPP "$DEST" "$CPPFLAGS" || \
+                acCheckCPP "$DEST" -traditional-cpp -E || \
+                acCheckCPP "$DEST" -E || \
+                acCheckCPP "$DEST" -traditional-cpp -pipe || \
+                acCheckCPP "$DEST" -pipe || fail=1
 
        if [ "$fail" ]; then
            AC_FAIL " (can't run cpp as a pipeline)"
@@ -1287,7 +1298,11 @@ AC_MAK() {
 #
 # AC_DEFINE adds a #define to config.h
 AC_DEFINE() {
-    echo "#define $1 ${2:-1}" >> $__cwd/config.h.tmp
+    local name="$1" value="${2:-1}"
+    if ! printf -v "ac_defined_$name" '%s' "$value"; then
+        AC_FATAL 'AC_DEFINE unable to set "ac_defined_$name" to "$value"'
+    fi
+    echo "#define $name $value" >> $__cwd/config.h.tmp
 }
 
 #