3 # @(#) configure.inc 1.40@(#)
4 # Copyright (c) 1999-2007 David Parsons. All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in
13 # the documentation and/or other materials provided with the
15 # 3. My name may not be used to endorse or promote products derived
16 # from this software without specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED BY DAVID PARSONS ``AS IS'' AND ANY
19 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
22 # PARSONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24 # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
28 # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29 # THE POSSIBILITY OF SUCH DAMAGE.
34 # this preamble code is executed when this file is sourced and it picks
35 # interesting things off the command line.
37 ac_default_path="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
39 ac_standard="--src=DIR where the source lives (.)
40 --prefix=DIR where to install the final product (/usr/local)
41 --execdir=DIR where to put executables (prefix/bin)
42 --sbindir=DIR where to put static executables (prefix/sbin)
43 --confdir=DIR where to put configuration information (/etc)
44 --libdir=DIR where to put libraries (prefix/lib)
45 --libexecdir=DIR where to put private executables
46 --mandir=DIR where to put manpages"
53 if test "$__ac_tmpdir"; then
57 trap __ac_clean_up EXIT
60 if dirname B/A 2>/dev/null >/dev/null; then
66 echo "$1" | sed -e 's:/[^/]*$::'
74 ac_configure_command="$ac_configure_command $Q$x$Q"
76 # ac_configure_command="$*"
78 __d=`__ac_dirname "$ac_progname"`
79 if [ "$__d" = "$ac_progname" ]; then
82 AC_SRCDIR=`cd $__d;pwd`
93 while [ $# -gt 0 ]; do
98 AC_SRCDIR=`__ac_dir "$2"`
102 X--src=*|X--srcdir=*)
103 __d=`echo "$1" | sed -e 's/^[^=]*=//'`
104 AC_SRCDIR=`__ac_dir "$__d"`
109 AC_PREFIX=`__ac_dir "$2"`
114 __d=`echo "$1"| sed -e 's/^[^=]*=//'`
115 AC_PREFIX=`__ac_dir "$__d"`
120 AC_CONFDIR=`__ac_dir "$2"`
125 __d=`echo "$1" | sed -e 's/^[^=]*=//'`
126 AC_CONFDIR=`__ac_dir "$__d"`
130 X--libexec|X--libexecdir)
131 AC_LIBEXEC=`__ac_dir "$2"`
135 X--libexec=*|X--libexecdir=*)
136 __d=`echo "$1" | sed -e 's/^[^=]*=//'`
137 AC_LIBEXEC=`__ac_dir "$__d"`
142 AC_LIBDIR=`__ac_dir "$2"`
146 X--lib=*|X--libdir=*)
147 __d=`echo "$1" | sed -e 's/^[^=]*=//'`
148 AC_LIBDIR=`__ac_dir "$__d"`
153 AC_EXECDIR=`__ac_dir "$2"`
157 X--exec=*|X--execdir=*)
158 __d=`echo "$1" | sed -e 's/^[^=]*=//'`
159 AC_EXECDIR=`__ac_dir "$__d"`
164 AC_SBINDIR=`__ac_dir "$2"`
168 X--sbin=*|X--sbindir=*)
169 __d=`echo "$1" | sed -e 's/^[^=]*=//'`
170 AC_SBINDIR=`__ac_dir "$__d"`
175 AC_MANDIR=`__ac_dir "$2"`
179 X--man=*|X--mandir=*)
180 __d=`echo "$1" | sed -e 's/^[^=]*=//'`
181 AC_MANDIR=`__ac_dir "$__d"`
186 _var=`echo "$1"| sed -n 's/^--use-\([A-Za-z][-A-Za-z0-9_]*\)=.*$/\1/p'`
188 _val=`echo "$1" | sed -e 's/^--use-[^=]*=\(.*\)$/\1/'`
189 _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
191 X[Yy][Ee][Ss]|X[Tt][Rr][Uu][Ee]) eval USE_${_v}=T ;;
192 X[Nn][Oo]|X[Ff][Aa][Ll][Ss][Ee]) eval unset USE_${_v} ;;
193 *) echo "Bad value for --use-$_var ; must be yes or no"
197 echo "Bad option $1. Use --help to show options" 1>&2
203 _var=`echo "$1"|sed -n 's/^--use-\([A-Za-z][-A-Za-z0-9_]*\)$/\1/p'`
204 _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
209 _var=`echo "$1"| sed -n 's/^--with-\([A-Za-z][-A-Za-z0-9_]*\)=.*$/\1/p'`
211 _val=`echo "$1" | sed -e 's/^--with-[^=]*=\(.*\)$/\1/'`
212 _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
213 eval WITH_${_v}=\"$_val\"
215 echo "Bad option $1. Use --help to show options" 1>&2
221 _var=`echo "$1" | sed -n 's/^--with-\([A-Za-z][A-Za-z0-9_-]*\)$/\1/p'`
223 _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
226 echo "Bad option $1. Use --help to show options" 1>&2
233 test "$ac_help" && echo "$ac_help"
236 *) if [ "$LOCAL_AC_OPTIONS" ]; then
237 eval "$LOCAL_AC_OPTIONS"
241 if [ "$ac_error" ]; then
242 echo "Bad option $1. Use --help to show options" 1>&2
254 ${ac_echo:-echo} "${@}$ac_echo_nonl"
258 # log something to the terminal and to a logfile.
266 # log something to the terminal without a newline, and to a logfile with
275 # log something to the terminal
282 # log something to the terminal, no newline
290 # AC_CONTINUE tells configure not to bomb if something fails, but to
291 # continue blithely along
298 # Emulate gnu autoconf's AC_CHECK_HEADERS() function
300 AC_CHECK_HEADERS () {
303 echo "/* AC_CHECK_HEADERS */" > "$__ac_tmpdir/ngc$$.c"
305 echo "#include <$hdr>" >> "$__ac_tmpdir/ngc$$.c"
307 echo "main() { }" >> "$__ac_tmpdir/ngc$$.c"
309 LOGN "checking for header $hdr"
311 if $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c"; then
312 AC_DEFINE 'HAVE_'`echo $hdr | tr 'a-z' 'A-Z' | tr './' '_'` 1
319 rm -f "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$"
325 # emulate GNU autoconf's AC_CHECK_FUNCS function
332 rm -f "$__ac_tmpdir/ngc$$.c"
335 echo "#include <$1>" >> "$__ac_tmpdir/ngc$$.c"
339 cat >> "$__ac_tmpdir/ngc$$.c" << EOF
347 LOGN "checking for the $F function"
349 if $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" $LIBS; then
350 AC_DEFINE `echo ${2:-HAVE_$F} | tr 'a-z' 'A-Z'` 1
354 echo "offending command was:"
355 cat "$__ac_tmpdir/ngc$$.c"
356 echo "$AC_CC -o $__ac_tmpdir/ngc$$ $__ac_tmpdir/ngc$$.c $LIBS"
360 rm -f "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$"
366 # check to see if some structure exists
368 # usage: AC_CHECK_STRUCT structure {include ...}
375 rm -f "$__ac_tmpdir/ngc$$.c"
377 for include in $*; do
378 echo "#include <$include>" >> "$__ac_tmpdir/ngc$$.c"
381 cat >> "$__ac_tmpdir/ngc$$.c" << EOF
388 LOGN "checking for struct $struct"
390 if $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" $AC_LIBS 2>>config.log; then
391 AC_DEFINE HAVE_STRUCT_`echo ${struct} | tr 'a-z' 'A-Z'`
398 rm -f "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$"
404 # check to see if some structure contains a field
406 # usage: AC_CHECK_FIELD structure field {include ...}
415 rm -f "$__ac_tmpdir/ngc$$.c"
418 echo "#include <$include>" >> "$__ac_tmpdir/ngc$$.c"
421 cat >> "$__ac_tmpdir/ngc$$.c" << EOF
430 LOGN "checking that struct $struct has a $field field"
432 if $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" $AC_LIBS 2>>config.log; then
433 AC_DEFINE HAVE_`echo ${struct}_$field | tr 'a-z' 'A-Z'`
440 rm -f "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$"
446 # check that the C compiler works
449 test "$AC_CC" && return 0
451 cat > "$__ac_tmpdir/ngc$$.c" << \EOF
455 puts("hello, sailor");
459 TLOGN "checking the C compiler"
461 unset AC_CFLAGS AC_LDFLAGS
465 elif [ "$WITH_PATH" ]; then
467 elif [ "`acLookFor cc`" ]; then
468 # don't specify the full path if the user is looking in their $PATH
473 # finally check for POSIX c89
474 test "$AC_CC" || AC_CC=`acLookFor c89`
476 if [ ! "$AC_CC" ]; then
477 TLOG " (no C compiler found)"
480 echo "checking out the C compiler"
482 $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c"
486 if [ $status -eq 0 ]; then
489 # check that the CFLAGS and LDFLAGS aren't bogus
491 unset AC_CFLAGS AC_LDFLAGS
493 if [ "$CFLAGS" ]; then
494 test "$CFLAGS" && echo "validating CFLAGS=${CFLAGS}"
495 if $AC_CC $CFLAGS -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" ; then
496 AC_CFLAGS=${CFLAGS:-"-g"}
497 test "$CFLAGS" && echo "CFLAGS=\"${CFLAGS}\" are okay"
498 elif [ "$CFLAGS" ]; then
499 echo "ignoring bogus CFLAGS=\"${CFLAGS}\""
504 if [ "$LDFLAGS" ]; then
505 echo "validating LDFLAGS=${LDFLAGS}"
506 $AC_CC $AC_CFLAGS -c -o "$__ac_tmpdir/ngc$$.o" "$__ac_tmpdir/ngc$$.c"
507 if $AC_CC $AC_CFLAGS $LDFLAGS -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.o"; then
508 AC_LDFLAGS=${LDFLAGS:-"-g"}
509 test "$LDFLAGS" && TLOG "LDFLAGS=\"${LDFLAGS}\" are okay"
510 elif [ "$LDFLAGS" ]; then
511 TLOG "ignoring bogus LDFLAGS=\"${LDFLAGS}\""
514 AC_LDFLAGS=${CFLAGS:-"-g"}
517 AC_FAIL " does not compile code properly"
522 rm -f "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$.o"
529 # acLookFor actually looks for a program, without setting anything.
532 path="${AC_PATH:-$ac_default_path}"
541 for program in $*; do
544 if [ $__mode "$x/$program" -a -f "$x/$program" ]; then
556 # check that a program exists and set its path
569 TLOGN "looking for $1"
571 DEST=`acLookFor $__mode $*`
573 __sym=`echo "$SYM" | tr '[a-z]' '[A-Z]'`
578 AC_DEFINE PATH_$__sym \""$DEST"\"
579 AC_SUB $__sym "$DEST"
580 eval CF_$SYM="'$DEST'"
584 echo "$1 is not found"
592 # AC_INIT starts the ball rolling
594 # After AC_INIT, fd's 1 and 2 point to config.log
595 # and fd 5 points to what used to be fd 1
598 __ac_tmpdir=$(mktemp -d configure-XXXXXX)
599 __config_files="config.cmd config.sub config.h config.mak config.log"
600 __config_detritus="config.h.tmp"
601 rm -f $__config_files $__config_detritus
603 exec 5>&1 1>$__cwd/config.log 2>&1
604 AC_CONFIGURE_FOR=__AC_`echo $1 | sed -e 's/\..$//' | tr 'a-z' 'A-Z' | tr ' ' '_'`_D
606 # check to see whether to use echo -n or echo ...\c
610 if grep "helloworld" $$ >/dev/null; then
612 echo "[echo -n] works"
617 if grep "helloworld" $$ >/dev/null; then
619 echo "[echo ...\\c] works"
624 LOG "Configuring for [$1]"
626 rm -f $__cwd/config.h
627 cat > $__cwd/config.h.tmp << EOF
629 * configuration for $1${2:+" ($2)"}, generated `date`
630 * by ${LOGNAME:-`whoami`}@`hostname`
632 #ifndef $AC_CONFIGURE_FOR
633 #define $AC_CONFIGURE_FOR 1
639 if [ -d $AC_PREFIX/share/man ]; then
640 for t in 1 2 3 4 5 6 7 8 9; do
641 if [ -d $AC_PREFIX/share/man/man$t ]; then
643 elif [ -d $AC_PREFIX/share/man/cat$t ]; then
651 if [ -d $AC_PREFIX/libexec ]; then
658 AC_PREFIX=${AC_PREFIX:-/usr/local}
659 AC_EXECDIR=${AC_EXECDIR:-$AC_PREFIX/bin}
660 AC_SBINDIR=${AC_SBINDIR:-$AC_PREFIX/sbin}
661 AC_LIBDIR=${AC_LIBDIR:-$AC_PREFIX/lib}
662 AC_MANDIR=${AC_MANDIR:-$AC_PREFIX$__share/man}
663 AC_LIBEXEC=${AC_LIBEXEC:-$AC_PREFIX/$__libexec}
664 AC_CONFDIR=${AC_CONFDIR:-/etc}
666 AC_PATH=${WITH_PATH:-$PATH}
670 ac_os=`uname -s | sed 's/[-_].*//; s/[^a-zA-Z0-9]/_/g'`
671 _os=`echo $ac_os | tr '[a-z]' '[A-Z]'`
679 # AC_LIBRARY checks to see if a given library exists and contains the
681 # usage: AC_LIBRARY function library [alternate ...]
692 X-l*) __acllibs="$__acllibs $x" ;;
693 *) __aclhdrs="$__aclhdrs $x" ;;
697 # first see if the function can be found in any of the
699 AC_QUIET AC_CHECK_FUNCS $SRC $__aclhdrs && return 0
701 # then search through the list of libraries
703 for x in $__acllibs; do
705 if AC_QUIET AC_CHECK_FUNCS $SRC $__aclhdrs; then
706 AC_LIBS="$AC_LIBS $x"
715 # AC_PROG_LEX checks to see if LEX exists, and if it's lex or flex.
718 TLOGN "looking for lex "
723 AC_DEFINE PATH_LEX \"$DEST\"
727 DEST=`acLookFor flex`
730 AC_DEFINE 'LEX' \"$DEST\"
731 AC_SUB 'LEX', "$DEST"
735 echo "neither lex or flex found"
741 if AC_LIBRARY yywrap -ll -lfl; then
745 TLOG "(no lex library found)"
751 # AC_PROG_YACC checks to see if YACC exists, and if it's bison or
756 TLOGN "looking for yacc "
758 DEST=`acLookFor yacc`
761 AC_DEFINE PATH_YACC \"$DEST\"
762 AC_SUB 'YACC' "$DEST"
766 DEST=`acLookFor bison`
769 AC_DEFINE 'YACC' \"$DEST\"
770 AC_SUB 'YACC' "$DEST -y"
771 echo "yacc is $DEST -y"
775 echo "neither yacc or bison found"
785 # AC_PROG_LN_S checks to see if ln exists, and, if so, if ln -s works
788 test "$AC_FIND_PROG" || AC_PROG_FIND
790 test "$AC_FIND_PROG" || return 1
792 TLOGN "looking for \"ln -s\""
796 rm -f "$__ac_tmpdir/b$$"
797 "$DEST" -s "$__ac_tmpdir/a$$" "$__ac_tmpdir/b$$"
798 if [ "`$AC_FIND_PROG $__ac_tmpdir/b$$ -type l -print`" ]; then
800 echo "$DEST exists, and ln -s works"
801 AC_SUB 'LN_S' "$DEST -s"
802 rm -f "$__ac_tmpdir/b$$"
805 TLOG " ($DEST exists, but -s does not seem to work)"
806 echo "$DEST exists, but ln -s doesn't seem to work"
807 rm -f "$__ac_tmpdir/b$$"
820 # AC_PROG_FIND looks for the find program and sets the FIND environment
824 if test -z "$AC_FIND_PROG"; then
825 MF_PATH_INCLUDE FIND find
835 # AC_PROG_AWK looks for the awk program and sets the AWK environment
839 if test -z "$AC_AWK_PROG"; then
840 MF_PATH_INCLUDE AWK awk
850 # AC_PROG_SED looks for the sed program and sets the SED environment
854 if test -z "$AC_SED_PROG"; then
855 MF_PATH_INCLUDE SED sed
865 # AC_HEADER_SYS_WAIT looks for sys/wait.h
867 AC_HEADER_SYS_WAIT () {
868 AC_CHECK_HEADERS sys/wait.h || return 1
872 # AC_TYPE_PID_T checks to see if the pid_t type exists
875 cat > "$__ac_tmpdir/pd$$.c" << EOF
876 #include <sys/types.h>
880 LOGN "checking for pid_t"
882 if $AC_CC -c "$__ac_tmpdir/pd$$.c" -o "$__ac_tmpdir/pd$$.o"; then
886 echo "typedef int pid_t;" >> $__cwd/config.h.tmp
890 rm -f "$__ac_tmpdir/pd$$.o" "$__ac_tmpdir/pd$$.c"
896 # AC_C_CONST checks to see if the compiler supports the const keyword
899 cat > "$__ac_tmpdir/pd$$.c" << EOF
902 LOGN "checking for \"const\" keyword"
904 if $AC_CC -c "$__ac_tmpdir/pd$$.c" -o "$__ac_tmpdir/pd$$.o"; then
908 AC_DEFINE 'const' '/**/'
912 rm -f "$__ac_tmpdir/pd$$.o" "$__ac_tmpdir/pd$$.c"
918 # AC_SCALAR_TYPES checks to see if the compiler can generate 2 and 4 byte ints.
921 cat > "$__ac_tmpdir/pd$$.c" << EOF
925 unsigned long v_long;
927 unsigned short v_short;
929 if (sizeof v_long == 4)
930 puts("#define DWORD unsigned long");
931 else if (sizeof v_int == 4)
932 puts("#define DWORD unsigned int");
936 if (sizeof v_int == 2)
937 puts("#define WORD unsigned int");
938 else if (sizeof v_short == 2)
939 puts("#define WORD unsigned short");
942 puts("#define BYTE unsigned char");
947 LOGN "defining WORD & DWORD scalar types"
948 if $AC_CC "$__ac_tmpdir/pd$$.c" -o "$__ac_tmpdir/pd$$"; then
949 if "$__ac_tmpdir/pd$$" >> $__cwd/config.h.tmp; then
955 *) TLOG " ** FAILED **" ;;
957 rm -f "$__ac_tmpdir/pd$$" "$__ac_tmpdir/pd$$.c"
962 # AC_OUTPUT generates makefiles from makefile.in's
966 AC_SUB 'LIBS' "$AC_LIBS"
967 AC_SUB 'CONFIGURE_FILES' "$__config_files"
968 AC_SUB 'CONFIGURE_DETRITUS' "$__config_detritus"
969 AC_SUB 'GENERATED_FILES' "$*"
970 AC_SUB 'CFLAGS' "$AC_CFLAGS"
971 AC_SUB 'FCFLAGS' "$AC_FCFLAGS"
972 AC_SUB 'CPPFLAGS' "$AC_CPPFLAGS"
973 AC_SUB 'CXXFLAGS' "$AC_CXXFLAGS"
974 AC_SUB 'LDFLAGS' "$AC_LDFLAGS"
975 AC_SUB 'srcdir' "$AC_SRCDIR"
976 AC_SUB 'prefix' "$AC_PREFIX"
977 AC_SUB 'exedir' "$AC_EXECDIR"
978 AC_SUB 'sbindir' "$AC_SBINDIR"
979 AC_SUB 'libdir' "$AC_LIBDIR"
980 AC_SUB 'libexec' "$AC_LIBEXEC"
981 AC_SUB 'confdir' "$AC_CONFDIR"
982 AC_SUB 'mandir' "$AC_MANDIR"
984 if [ -r config.sub ]; then
985 test "$AC_SED_PROG" || AC_PROG_SED
986 test "$AC_SED_PROG" || return 1
989 echo "#endif/* ${AC_CONFIGURE_FOR} */" >> config.h.tmp
993 cat - > config.cmd << EOF
995 ${CXX:+CXX=${Q}${CXX}${Q}} ${CPPFLAGS:+CPPFLAGS=${Q}${CPPFLAGS}${Q}} ${CXXFLAGS:+CXXFLAGS=${Q}${CXXFLAGS}${Q}} ${FC:+FC=${Q}${FC}${Q}} ${FCFLAGS:+FCFLAGS=${Q}${FCFLAGS}${Q}} ${CC:+CC=${Q}${CC}${Q}} ${CFLAGS:+CFLAGS=${Q}${CFLAGS}${Q}} $ac_progname $ac_configure_command
1000 for makefile in $*;do
1001 if test -r $__d/${makefile}.in; then
1002 LOG "generating $makefile"
1003 ./config.md `__ac_dirname ./$makefile` 2>/dev/null
1004 $AC_SED_PROG -f config.sub < $__d/${makefile}.in > $makefile
1005 __config_files="$__config_files $makefile"
1007 LOG "WARNING: ${makefile}.in does not exist!"
1015 cp $__cwd/config.h.tmp $__cwd/config.h
1019 # AC_CHECK_FLOCK checks to see if flock() exists and if the LOCK_NB argument
1024 AC_CHECK_HEADERS sys/types.h sys/file.h fcntl.h
1028 #include <sys/file.h>
1029 #include <sys/types.h>
1034 int x = open("$$.c", O_RDWR, 0666);
1035 int y = open("$$.c", O_RDWR, 0666);
1037 if (flock(x, LOCK_EX) != 0)
1039 if (flock(y, LOCK_EX|LOCK_NB) == 0)
1045 LOGN "checking for flock()"
1047 if $AC_CC -o flock $$.c ; then
1061 case "$HAS_FLOCK" in
1069 # AC_CHECK_RESOLVER finds out whether the berkeley resolver is
1070 # present on this system.
1072 AC_CHECK_RESOLVER () {
1075 TLOGN "checking for the Berkeley resolver library"
1077 cat > "$__ac_tmpdir/ngc$$.c" << EOF
1078 #include <sys/types.h>
1079 #include <netinet/in.h>
1080 #include <arpa/nameser.h>
1088 res_query("hello", C_IN, T_A, bfr, sizeof bfr);
1092 # first see if res_init() and res_query() actually exist...
1094 if $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c"; then
1096 elif $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" -lresolv; then
1098 AC_LIBS="$AC_LIBS -lresolv"
1101 rm -f "$__ac_tmpdir/ngc$$.c"
1105 # if res_init() and res_query() actually exist, check to
1106 # see if the HEADER structure is defined ...
1108 cat > "$__ac_tmpdir/ngc$$.c" << EOF
1109 #include <sys/types.h>
1110 #include <netinet/in.h>
1111 #include <arpa/nameser.h>
1121 if $AC_CC -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" $__extralib; then
1123 elif $AC_CC -DBIND_8_COMPAT -o "$__ac_tmpdir/ngc$$" "$__ac_tmpdir/ngc$$.c" $__extralib; then
1124 TLOG " (bind9 with BIND_8_COMPAT)"
1125 AC_DEFINE BIND_8_COMPAT 1
1128 rm -f "$__ac_tmpdir/ngc$$.c"
1131 rm -f "$__ac_tmpdir/ngc$$.c"
1137 # AC_PROG_INSTALL finds the install program and guesses whether it's a
1138 # Berkeley or GNU install program
1140 AC_PROG_INSTALL () {
1142 DEST=`acLookFor install`
1144 LOGN "checking for install"
1146 if [ "$DEST" ]; then
1147 # BSD install or GNU install? Let's find out...
1148 touch "$__ac_tmpdir/a$$"
1150 "$DEST" "$__ac_tmpdir/a$$" "$__ac_tmpdir/b$$"
1152 if test -r "$__ac_tmpdir/a$$"; then
1156 LOG " ($DEST) bsd install"
1158 rm -f "$__ac_tmpdir/a$$" "$__ac_tmpdir/b$$"
1160 DEST=`acLookFor ginstall`
1161 if [ "$DEST" ]; then
1169 if [ "$IS_BSD" ]; then
1170 PROG_INSTALL="$DEST -c"
1172 PROG_INSTALL="$DEST"
1175 AC_SUB 'INSTALL' "$PROG_INSTALL"
1176 AC_SUB 'INSTALL_PROGRAM' "$PROG_INSTALL -s -m 755"
1177 AC_SUB 'INSTALL_DATA' "$PROG_INSTALL -m 444"
1179 # finally build a little directory installer
1180 # if mkdir -p works, use that, otherwise use install -d,
1181 # otherwise build a script to do it by hand.
1182 # in every case, test to see if the directory exists before
1185 if mkdir -p $$a/b; then
1186 # I like this method best.
1190 elif $PROG_INSTALL -d $$a/b; then
1191 __mkdir="$PROG_INSTALL -d"
1196 __config_files="$__config_files config.md"
1197 AC_SUB 'INSTALL_DIR' "$__cwd/config.md"
1198 echo "#! /bin/sh" > $__cwd/config.md
1199 echo "# script generated" `date` "by configure.sh" >> $__cwd/config.md
1200 echo >> $__cwd/config.md
1201 if [ "$__mkdir" ]; then
1202 echo "test -d \"\$1\" || $__mkdir \"\$1\"" >> $__cwd/config.md
1203 echo "exit $?" >> $__cwd/config.md
1205 cat - >> $__cwd/config.md << \EOD
1206 pieces=`IFS=/; for x in $1; do echo $x; done`
1208 for x in $pieces; do
1210 mkdir $dir || exit 1
1216 chmod +x $__cwd/config.md
1220 # acCheckCPP is a local that runs a C preprocessor with a given set of
1224 cat > "$__ac_tmpdir/ngc$$.c" << EOF
1230 if $1 $2 "$__ac_tmpdir/ngc$$.c" > "$__ac_tmpdir/ngc$$.o"; then
1231 if grep -v '#define' "$__ac_tmpdir/ngc$$.o" | grep -s BAR >/dev/null; then
1232 echo "CPP=[$1], CPPFLAGS=[$2]"
1234 AC_SUB 'CPPFLAGS' "$2"
1235 rm "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$.o"
1239 rm "$__ac_tmpdir/ngc$$.c" "$__ac_tmpdir/ngc$$.o"
1245 # AC_PROG_CPP checks for cpp, then checks to see which CPPFLAGS are needed
1246 # to run it as a filter.
1249 if [ "$AC_CPP_PROG" ]; then
1252 __ac_path="$AC_PATH"
1253 AC_PATH="/lib:/usr/lib:${__ac_path:-$ac_default_path}"
1254 DEST=`acLookFor cpp`
1255 AC_PATH="$__ac_path"
1259 LOGN "Looking for cpp"
1260 if [ "$DEST" ]; then
1262 acCheckCPP "$DEST" "$CPPFLAGS" || \
1263 acCheckCPP "$DEST" -traditional-cpp -E || \
1264 acCheckCPP "$DEST" -E || \
1265 acCheckCPP "$DEST" -traditional-cpp -pipe || \
1266 acCheckCPP "$DEST" -pipe || fail=1
1268 if [ "$fail" ]; then
1269 AC_FAIL " (can't run cpp as a pipeline)"
1275 AC_FAIL " (not found)"
1279 # AC_FAIL spits out an error message, then __fail's
1286 # AC_SUB writes a substitution into config.sub
1288 ( echononl "s;@$1@;"
1289 _subst=`echo $2 | sed -e 's/;/\\;/g'`
1291 echo ';g' ) >> $__cwd/config.sub
1295 # AC_MAK writes a define into config.mak
1297 echo "HAVE_$1 = 1" >> $__cwd/config.mak
1301 # AC_DEFINE adds a #define to config.h
1303 local name="$1" value="${2:-1}"
1304 if ! printf -v "ac_defined_$name" '%s' "$value"; then
1305 AC_FATAL 'AC_DEFINE unable to set "ac_defined_$name" to "$value"'
1307 echo "#define $name $value" >> $__cwd/config.h.tmp
1311 # AC_INCLUDE adds a #include to config.h
1313 echo "#include \"$1\"" >> $__cwd/config.h.tmp
1317 # AC_CONFIG adds a configuration setting to all the config files
1319 AC_DEFINE "PATH_$1" \""$2"\"
1325 # AC_QUIET does something quietly