+# -*-shell-script-*-
+
# @(#) configure.inc 1.40@(#)
# Copyright (c) 1999-2007 David Parsons. All rights reserved.
#
__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"
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
TLOG " (not found)"
rc=1
fi
- rm -f /tmp/ngc$$.c /tmp/ngc$$
+ rm -f "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$"
return $rc
}
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()
{
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
}
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;
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
TLOG " (not found)"
rc=1
fi
- rm -f /tmp/ngc$$.c /tmp/ngc$$
+ rm -f "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$"
return $rc
}
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;
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
TLOG " (no)"
rc=1
fi
- rm -f /tmp/ngc$$.c /tmp/ngc$$
+ rm -f "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$"
return $rc
}
AC_PROG_CC () {
test "$AC_CC" && return 0
- cat > /tmp/ngc$$.c << \EOF
+ cat > "$__ac_tmpdir/ngc$$.c" << \EOF
#include <stdio.h>
main()
{
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)"
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
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
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
}
# 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
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
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 ''
# 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"
- rm -f $__config_files
+ __config_detritus="config.h.tmp"
+ rm -f $__config_files $__config_detritus
__cwd=`pwd`
exec 5>&1 1>$__cwd/config.log 2>&1
AC_CONFIGURE_FOR=__AC_`echo $1 | sed -e 's/\..$//' | tr 'a-z' 'A-Z' | tr ' ' '_'`_D
LOG "Configuring for [$1]"
- cat > $__cwd/config.h << EOF
+ rm -f $__cwd/config.h
+ cat > $__cwd/config.h.tmp << EOF
/*
* configuration for $1${2:+" ($2)"}, generated `date`
* by ${LOGNAME:-`whoami`}@`hostname`
AC_PROG_CPP
AC_PROG_INSTALL
- ac_os=`uname -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
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
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
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
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
# 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
- echo "typedef int pid_t;" >> $__cwd/config.h
+ echo "typedef int pid_t;" >> $__cwd/config.h.tmp
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
}
# 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
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
}
# 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()
{
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; 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
0) TLOG "" ;;
*) TLOG " ** FAILED **" ;;
esac
- rm -f /tmp/pd$$ /tmp/pd$$.c
+ rm -f "$__ac_tmpdir/pd$$" "$__ac_tmpdir/pd$$.c"
}
cd $__cwd
AC_SUB 'LIBS' "$AC_LIBS"
AC_SUB 'CONFIGURE_FILES' "$__config_files"
+ AC_SUB 'CONFIGURE_DETRITUS' "$__config_detritus"
AC_SUB 'GENERATED_FILES' "$*"
AC_SUB 'CFLAGS' "$AC_CFLAGS"
AC_SUB 'FCFLAGS' "$AC_FCFLAGS"
test "$AC_SED_PROG" || AC_PROG_SED
test "$AC_SED_PROG" || return 1
- echo >> config.h
- echo "#endif/* ${AC_CONFIGURE_FOR} */" >> config.h
+ echo >> config.h.tmp
+ echo "#endif/* ${AC_CONFIGURE_FOR} */" >> config.h.tmp
rm -f config.cmd
Q=\'
else
echo
fi
+ cp $__cwd/config.h.tmp $__cwd/config.h
}
#
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>
# 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>
}
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
}
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
# 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
}
#
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}"
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)"
#
# AC_DEFINE adds a #define to config.h
AC_DEFINE() {
- echo "#define $1 ${2:-1}" >> $__cwd/config.h
+ 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
}
#
# AC_INCLUDE adds a #include to config.h
AC_INCLUDE() {
- echo "#include \"$1\"" >> $__cwd/config.h
+ echo "#include \"$1\"" >> $__cwd/config.h.tmp
}
#