1 # @(#) configure.inc 1.40@(#)
2 # Copyright (c) 1999-2007 David Parsons. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
7 # 1. Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # 2. Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in
11 # the documentation and/or other materials provided with the
13 # 3. My name may not be used to endorse or promote products derived
14 # from this software without specific prior written permission.
16 # THIS SOFTWARE IS PROVIDED BY DAVID PARSONS ``AS IS'' AND ANY
17 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
20 # PARSONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22 # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26 # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 # THE POSSIBILITY OF SUCH DAMAGE.
32 # this preamble code is executed when this file is sourced and it picks
33 # interesting things off the command line.
35 ac_default_path="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
37 ac_standard="--src=DIR where the source lives (.)
38 --prefix=DIR where to install the final product (/usr/local)
39 --execdir=DIR where to put executables (prefix/bin)
40 --sbindir=DIR where to put static executables (prefix/sbin)
41 --confdir=DIR where to put configuration information (/etc)
42 --libdir=DIR where to put libraries (prefix/lib)
43 --libexecdir=DIR where to put private executables
44 --mandir=DIR where to put manpages"
48 if dirname B/A 2>/dev/null >/dev/null; then
54 echo "$1" | sed -e 's:/[^/]*$::'
62 ac_configure_command="$ac_configure_command $Q$x$Q"
64 # ac_configure_command="$*"
66 __d=`__ac_dirname "$ac_progname"`
67 if [ "$__d" = "$ac_progname" ]; then
70 AC_SRCDIR=`cd $__d;pwd`
81 while [ $# -gt 0 ]; do
86 AC_SRCDIR=`__ac_dir "$2"`
91 __d=`echo "$1" | sed -e 's/^[^=]*=//'`
92 AC_SRCDIR=`__ac_dir "$__d"`
97 AC_PREFIX=`__ac_dir "$2"`
102 __d=`echo "$1"| sed -e 's/^[^=]*=//'`
103 AC_PREFIX=`__ac_dir "$__d"`
108 AC_CONFDIR=`__ac_dir "$2"`
113 __d=`echo "$1" | sed -e 's/^[^=]*=//'`
114 AC_CONFDIR=`__ac_dir "$__d"`
118 X--libexec|X--libexecdir)
119 AC_LIBEXEC=`__ac_dir "$2"`
123 X--libexec=*|X--libexecdir=*)
124 __d=`echo "$1" | sed -e 's/^[^=]*=//'`
125 AC_LIBEXEC=`__ac_dir "$__d"`
130 AC_LIBDIR=`__ac_dir "$2"`
134 X--lib=*|X--libdir=*)
135 __d=`echo "$1" | sed -e 's/^[^=]*=//'`
136 AC_LIBDIR=`__ac_dir "$__d"`
141 AC_EXECDIR=`__ac_dir "$2"`
145 X--exec=*|X--execdir=*)
146 __d=`echo "$1" | sed -e 's/^[^=]*=//'`
147 AC_EXECDIR=`__ac_dir "$__d"`
152 AC_SBINDIR=`__ac_dir "$2"`
156 X--sbin=*|X--sbindir=*)
157 __d=`echo "$1" | sed -e 's/^[^=]*=//'`
158 AC_SBINDIR=`__ac_dir "$__d"`
163 AC_MANDIR=`__ac_dir "$2"`
167 X--man=*|X--mandir=*)
168 __d=`echo "$1" | sed -e 's/^[^=]*=//'`
169 AC_MANDIR=`__ac_dir "$__d"`
174 _var=`echo "$1"| sed -n 's/^--use-\([A-Za-z][-A-Za-z0-9_]*\)=.*$/\1/p'`
176 _val=`echo "$1" | sed -e 's/^--use-[^=]*=\(.*\)$/\1/'`
177 _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
179 X[Yy][Ee][Ss]|X[Tt][Rr][Uu][Ee]) eval USE_${_v}=T ;;
180 X[Nn][Oo]|X[Ff][Aa][Ll][Ss][Ee]) eval unset USE_${_v} ;;
181 *) echo "Bad value for --use-$_var ; must be yes or no"
185 echo "Bad option $1. Use --help to show options" 1>&2
191 _var=`echo "$1"|sed -n 's/^--use-\([A-Za-z][-A-Za-z0-9_]*\)$/\1/p'`
192 _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
197 _var=`echo "$1"| sed -n 's/^--with-\([A-Za-z][-A-Za-z0-9_]*\)=.*$/\1/p'`
199 _val=`echo "$1" | sed -e 's/^--with-[^=]*=\(.*\)$/\1/'`
200 _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
201 eval WITH_${_v}=\"$_val\"
203 echo "Bad option $1. Use --help to show options" 1>&2
209 _var=`echo "$1" | sed -n 's/^--with-\([A-Za-z][A-Za-z0-9_-]*\)$/\1/p'`
211 _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
214 echo "Bad option $1. Use --help to show options" 1>&2
221 test "$ac_help" && echo "$ac_help"
224 *) if [ "$LOCAL_AC_OPTIONS" ]; then
225 eval "$LOCAL_AC_OPTIONS"
229 if [ "$ac_error" ]; then
230 echo "Bad option $1. Use --help to show options" 1>&2
242 ${ac_echo:-echo} "${@}$ac_echo_nonl"
246 # log something to the terminal and to a logfile.
254 # log something to the terminal without a newline, and to a logfile with
263 # log something to the terminal
270 # log something to the terminal, no newline
278 # AC_CONTINUE tells configure not to bomb if something fails, but to
279 # continue blithely along
286 # Emulate gnu autoconf's AC_CHECK_HEADERS() function
288 AC_CHECK_HEADERS () {
291 echo "/* AC_CHECK_HEADERS */" > /tmp/ngc$$.c
293 echo "#include <$hdr>" >> /tmp/ngc$$.c
295 echo "main() { }" >> /tmp/ngc$$.c
297 LOGN "checking for header $hdr"
299 if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c; then
300 AC_DEFINE 'HAVE_'`echo $hdr | tr 'a-z' 'A-Z' | tr './' '_'` 1
307 rm -f /tmp/ngc$$.c /tmp/ngc$$
313 # emulate GNU autoconf's AC_CHECK_FUNCS function
323 echo "#include <$1>" >> /tmp/ngc$$.c
327 cat >> /tmp/ngc$$.c << EOF
335 LOGN "checking for the $F function"
337 if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $LIBS; then
338 AC_DEFINE `echo ${2:-HAVE_$F} | tr 'a-z' 'A-Z'` 1
342 echo "offending command was:"
344 echo "$AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $LIBS"
348 rm -f /tmp/ngc$$.c /tmp/ngc$$
354 # check to see if some structure exists
356 # usage: AC_CHECK_STRUCT structure {include ...}
365 for include in $*; do
366 echo "#include <$include>" >> /tmp/ngc$$.c
369 cat >> /tmp/ngc$$.c << EOF
376 LOGN "checking for struct $struct"
378 if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $AC_LIBS 2>>config.log; then
379 AC_DEFINE HAVE_STRUCT_`echo ${struct} | tr 'a-z' 'A-Z'`
386 rm -f /tmp/ngc$$.c /tmp/ngc$$
392 # check to see if some structure contains a field
394 # usage: AC_CHECK_FIELD structure field {include ...}
406 echo "#include <$include>" >> /tmp/ngc$$.c
409 cat >> /tmp/ngc$$.c << EOF
418 LOGN "checking that struct $struct has a $field field"
420 if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $AC_LIBS 2>>config.log; then
421 AC_DEFINE HAVE_`echo ${struct}_$field | tr 'a-z' 'A-Z'`
428 rm -f /tmp/ngc$$.c /tmp/ngc$$
434 # check that the C compiler works
437 test "$AC_CC" && return 0
439 cat > /tmp/ngc$$.c << \EOF
443 puts("hello, sailor");
447 TLOGN "checking the C compiler"
449 unset AC_CFLAGS AC_LDFLAGS
453 elif [ "$WITH_PATH" ]; then
455 elif [ "`acLookFor cc`" ]; then
456 # don't specify the full path if the user is looking in their $PATH
461 # finally check for POSIX c89
462 test "$AC_CC" || AC_CC=`acLookFor c89`
464 if [ ! "$AC_CC" ]; then
465 TLOG " (no C compiler found)"
468 echo "checking out the C compiler"
470 $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c
474 if [ $status -eq 0 ]; then
477 # check that the CFLAGS and LDFLAGS aren't bogus
479 unset AC_CFLAGS AC_LDFLAGS
481 if [ "$CFLAGS" ]; then
482 test "$CFLAGS" && echo "validating CFLAGS=${CFLAGS}"
483 if $AC_CC $CFLAGS -o /tmp/ngc$$.o /tmp/ngc$$.c ; then
484 AC_CFLAGS=${CFLAGS:-"-g"}
485 test "$CFLAGS" && echo "CFLAGS=\"${CFLAGS}\" are okay"
486 elif [ "$CFLAGS" ]; then
487 echo "ignoring bogus CFLAGS=\"${CFLAGS}\""
492 if [ "$LDFLAGS" ]; then
493 test "$LDFLAGS" && echo "validating LDFLAGS=${LDFLAGS}"
494 if $AC_CC $LDFLAGS -o /tmp/ngc$$ /tmp/ngc$$.o; then
495 AC_LDFLAGS=${LDFLAGS:-"-g"}
496 test "$LDFLAGS" && TLOG "LDFLAGS=\"${LDFLAGS}\" are okay"
497 elif [ "$LDFLAGS" ]; then
498 TLOG "ignoring bogus LDFLAGS=\"${LDFLAGS}\""
501 AC_LDFLAGS=${CFLAGS:-"-g"}
504 AC_FAIL " does not compile code properly"
509 rm -f /tmp/ngc$$ /tmp/ngc$$.c /tmp/ngc$$.o
516 # acLookFor actually looks for a program, without setting anything.
519 path=${AC_PATH:-$ac_default_path}
528 for program in $*; do
531 if [ $__mode $x/$program -a -f $x/$program ]; then
543 # check that a program exists and set its path
556 TLOGN "looking for $1"
558 DEST=`acLookFor $__mode $*`
560 __sym=`echo "$SYM" | tr '[a-z]' '[A-Z]'`
565 AC_DEFINE PATH_$__sym \""$DEST"\"
566 AC_SUB $__sym "$DEST"
571 echo "$1 is not found"
579 # AC_INIT starts the ball rolling
581 # After AC_INIT, fd's 1 and 2 point to config.log
582 # and fd 5 points to what used to be fd 1
585 __config_files="config.cmd config.sub config.h config.mak config.log"
586 rm -f $__config_files
588 exec 5>&1 1>$__cwd/config.log 2>&1
589 AC_CONFIGURE_FOR=__AC_`echo $1 | sed -e 's/\..$//' | tr 'a-z' 'A-Z' | tr ' ' '_'`_D
591 # check to see whether to use echo -n or echo ...\c
595 if grep "helloworld" $$ >/dev/null; then
597 echo "[echo -n] works"
602 if grep "helloworld" $$ >/dev/null; then
604 echo "[echo ...\\c] works"
609 LOG "Configuring for [$1]"
611 cat > $__cwd/config.h << EOF
613 * configuration for $1${2:+" ($2)"}, generated `date`
614 * by ${LOGNAME:-`whoami`}@`hostname`
616 #ifndef $AC_CONFIGURE_FOR
617 #define $AC_CONFIGURE_FOR 1
623 if [ -d $AC_PREFIX/share/man ]; then
624 for t in 1 2 3 4 5 6 7 8 9; do
625 if [ -d $AC_PREFIX/share/man/man$t ]; then
627 elif [ -d $AC_PREFIX/share/man/cat$t ]; then
635 if [ -d $AC_PREFIX/libexec ]; then
642 AC_PREFIX=${AC_PREFIX:-/usr/local}
643 AC_EXECDIR=${AC_EXECDIR:-$AC_PREFIX/bin}
644 AC_SBINDIR=${AC_SBINDIR:-$AC_PREFIX/sbin}
645 AC_LIBDIR=${AC_LIBDIR:-$AC_PREFIX/lib}
646 AC_MANDIR=${AC_MANDIR:-$AC_PREFIX$__share/man}
647 AC_LIBEXEC=${AC_LIBEXEC:-$AC_PREFIX/$__libexec}
648 AC_CONFDIR=${AC_CONFDIR:-/etc}
650 AC_PATH=${WITH_PATH:-$PATH}
655 _os=`echo $ac_os | tr '[a-z]' '[A-Z]'`
663 # AC_LIBRARY checks to see if a given library exists and contains the
665 # usage: AC_LIBRARY function library [alternate ...]
676 X-l*) __acllibs="$__acllibs $x" ;;
677 *) __aclhdrs="$__aclhdrs $x" ;;
681 # first see if the function can be found in any of the
683 AC_QUIET AC_CHECK_FUNCS $SRC $__aclhdrs && return 0
685 # then search through the list of libraries
687 for x in $__acllibs; do
689 if AC_QUIET AC_CHECK_FUNCS $SRC $__aclhdrs; then
690 AC_LIBS="$AC_LIBS $x"
699 # AC_PROG_LEX checks to see if LEX exists, and if it's lex or flex.
702 TLOGN "looking for lex "
707 AC_DEFINE PATH_LEX \"$DEST\"
711 DEST=`acLookFor flex`
714 AC_DEFINE 'LEX' \"$DEST\"
715 AC_SUB 'LEX', "$DEST"
719 echo "neither lex or flex found"
725 if AC_LIBRARY yywrap -ll -lfl; then
729 TLOG "(no lex library found)"
735 # AC_PROG_YACC checks to see if YACC exists, and if it's bison or
740 TLOGN "looking for yacc "
742 DEST=`acLookFor yacc`
745 AC_DEFINE PATH_YACC \"$DEST\"
746 AC_SUB 'YACC' "$DEST"
750 DEST=`acLookFor bison`
753 AC_DEFINE 'YACC' \"$DEST\"
754 AC_SUB 'YACC' "$DEST -y"
755 echo "yacc is $DEST -y"
759 echo "neither yacc or bison found"
769 # AC_PROG_LN_S checks to see if ln exists, and, if so, if ln -s works
772 test "$AC_FIND_PROG" || AC_PROG_FIND
774 test "$AC_FIND_PROG" || return 1
776 TLOGN "looking for \"ln -s\""
781 $DEST -s /tmp/a$$ /tmp/b$$
782 if [ "`$AC_FIND_PROG /tmp/b$$ -type l -print`" ]; then
784 echo "$DEST exists, and ln -s works"
785 AC_SUB 'LN_S' "$DEST -s"
789 TLOG " ($DEST exists, but -s does not seem to work)"
790 echo "$DEST exists, but ln -s doesn't seem to work"
804 # AC_PROG_FIND looks for the find program and sets the FIND environment
808 if test -z "$AC_FIND_PROG"; then
809 MF_PATH_INCLUDE FIND find
819 # AC_PROG_AWK looks for the awk program and sets the AWK environment
823 if test -z "$AC_AWK_PROG"; then
824 MF_PATH_INCLUDE AWK awk
834 # AC_PROG_SED looks for the sed program and sets the SED environment
838 if test -z "$AC_SED_PROG"; then
839 MF_PATH_INCLUDE SED sed
849 # AC_HEADER_SYS_WAIT looks for sys/wait.h
851 AC_HEADER_SYS_WAIT () {
852 AC_CHECK_HEADERS sys/wait.h || return 1
856 # AC_TYPE_PID_T checks to see if the pid_t type exists
859 cat > /tmp/pd$$.c << EOF
860 #include <sys/types.h>
864 LOGN "checking for pid_t"
866 if $AC_CC -c /tmp/pd$$.c -o /tmp/pd$$.o; then
870 echo "typedef int pid_t;" >> $__cwd/config.h
874 rm -f /tmp/pd$$.o /tmp/pd$$.c
880 # AC_C_CONST checks to see if the compiler supports the const keyword
883 cat > /tmp/pd$$.c << EOF
886 LOGN "checking for \"const\" keyword"
888 if $AC_CC -c /tmp/pd$$.c -o /tmp/pd$$.o; then
892 AC_DEFINE 'const' '/**/'
896 rm -f /tmp/pd$$.o /tmp/pd$$.c
902 # AC_SCALAR_TYPES checks to see if the compiler can generate 2 and 4 byte ints.
905 cat > /tmp/pd$$.c << EOF
909 unsigned long v_long;
911 unsigned short v_short;
913 if (sizeof v_long == 4)
914 puts("#define DWORD unsigned long");
915 else if (sizeof v_int == 4)
916 puts("#define DWORD unsigned int");
920 if (sizeof v_int == 2)
921 puts("#define WORD unsigned int");
922 else if (sizeof v_short == 2)
923 puts("#define WORD unsigned short");
926 puts("#define BYTE unsigned char");
931 LOGN "defining WORD & DWORD scalar types"
932 if $AC_CC /tmp/pd$$.c -o /tmp/pd$$; then
933 if /tmp/pd$$ >> $__cwd/config.h; then
939 *) TLOG " ** FAILED **" ;;
941 rm -f /tmp/pd$$ /tmp/pd$$.c
946 # AC_OUTPUT generates makefiles from makefile.in's
950 AC_SUB 'LIBS' "$AC_LIBS"
951 AC_SUB 'CONFIGURE_FILES' "$__config_files"
952 AC_SUB 'GENERATED_FILES' "$*"
953 AC_SUB 'CFLAGS' "$AC_CFLAGS"
954 AC_SUB 'FCFLAGS' "$AC_FCFLAGS"
955 AC_SUB 'CXXFLAGS' "$AC_CXXFLAGS"
956 AC_SUB 'LDFLAGS' "$AC_LDFLAGS"
957 AC_SUB 'srcdir' "$AC_SRCDIR"
958 AC_SUB 'prefix' "$AC_PREFIX"
959 AC_SUB 'exedir' "$AC_EXECDIR"
960 AC_SUB 'sbindir' "$AC_SBINDIR"
961 AC_SUB 'libdir' "$AC_LIBDIR"
962 AC_SUB 'libexec' "$AC_LIBEXEC"
963 AC_SUB 'confdir' "$AC_CONFDIR"
964 AC_SUB 'mandir' "$AC_MANDIR"
966 if [ -r config.sub ]; then
967 test "$AC_SED_PROG" || AC_PROG_SED
968 test "$AC_SED_PROG" || return 1
971 echo "#endif/* ${AC_CONFIGURE_FOR} */" >> config.h
975 cat - > config.cmd << EOF
977 ${CXX:+CXX=${Q}${CXX}${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
982 for makefile in $*;do
983 if test -r $__d/${makefile}.in; then
984 LOG "generating $makefile"
985 ./config.md `__ac_dirname ./$makefile` 2>/dev/null
986 $AC_SED_PROG -f config.sub < $__d/${makefile}.in > $makefile
987 __config_files="$__config_files $makefile"
989 LOG "WARNING: ${makefile}.in does not exist!"
1000 # AC_CHECK_FLOCK checks to see if flock() exists and if the LOCK_NB argument
1005 AC_CHECK_HEADERS sys/types.h sys/file.h fcntl.h
1009 #include <sys/file.h>
1010 #include <sys/types.h>
1015 int x = open("$$.c", O_RDWR, 0666);
1016 int y = open("$$.c", O_RDWR, 0666);
1018 if (flock(x, LOCK_EX) != 0)
1020 if (flock(y, LOCK_EX|LOCK_NB) == 0)
1026 LOGN "checking for flock()"
1028 if $AC_CC -o flock $$.c ; then
1042 case "$HAS_FLOCK" in
1050 # AC_CHECK_RESOLVER finds out whether the berkeley resolver is
1051 # present on this system.
1053 AC_CHECK_RESOLVER () {
1056 TLOGN "checking for the Berkeley resolver library"
1058 cat > /tmp/ngc$$.c << EOF
1059 #include <sys/types.h>
1060 #include <netinet/in.h>
1061 #include <arpa/nameser.h>
1069 res_query("hello", C_IN, T_A, bfr, sizeof bfr);
1073 # first see if res_init() and res_query() actually exist...
1075 if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c; then
1077 elif $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c -lresolv; then
1079 AC_LIBS="$AC_LIBS -lresolv"
1086 # if res_init() and res_query() actually exist, check to
1087 # see if the HEADER structure is defined ...
1089 cat > /tmp/ngc$$.c << EOF
1090 #include <sys/types.h>
1091 #include <netinet/in.h>
1092 #include <arpa/nameser.h>
1102 if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $__extralib; then
1104 elif $AC_CC -DBIND_8_COMPAT -o /tmp/ngc$$ /tmp/ngc$$.c $__extralib; then
1105 TLOG " (bind9 with BIND_8_COMPAT)"
1106 AC_DEFINE BIND_8_COMPAT 1
1118 # AC_PROG_INSTALL finds the install program and guesses whether it's a
1119 # Berkeley or GNU install program
1121 AC_PROG_INSTALL () {
1123 DEST=`acLookFor install`
1125 LOGN "checking for install"
1127 if [ "$DEST" ]; then
1128 # BSD install or GNU install? Let's find out...
1131 $DEST /tmp/a$$ /tmp/b$$
1133 if test -r /tmp/a$$; then
1137 LOG " ($DEST) bsd install"
1139 rm -f /tmp/a$$ /tmp/b$$
1141 DEST=`acLookFor ginstall`
1142 if [ "$DEST" ]; then
1150 if [ "$IS_BSD" ]; then
1151 PROG_INSTALL="$DEST -c"
1153 PROG_INSTALL="$DEST"
1156 AC_SUB 'INSTALL' "$PROG_INSTALL"
1157 AC_SUB 'INSTALL_PROGRAM' "$PROG_INSTALL -s -m 755"
1158 AC_SUB 'INSTALL_DATA' "$PROG_INSTALL -m 444"
1160 # finally build a little directory installer
1161 # if mkdir -p works, use that, otherwise use install -d,
1162 # otherwise build a script to do it by hand.
1163 # in every case, test to see if the directory exists before
1166 if mkdir -p $$a/b; then
1167 # I like this method best.
1171 elif $PROG_INSTALL -d $$a/b; then
1172 __mkdir="$PROG_INSTALL -d"
1177 __config_files="$__config_files config.md"
1178 AC_SUB 'INSTALL_DIR' "$__cwd/config.md"
1179 echo "#! /bin/sh" > $__cwd/config.md
1180 echo "# script generated" `date` "by configure.sh" >> $__cwd/config.md
1181 echo >> $__cwd/config.md
1182 if [ "$__mkdir" ]; then
1183 echo "test -d \"\$1\" || $__mkdir \"\$1\"" >> $__cwd/config.md
1184 echo "exit $?" >> $__cwd/config.md
1186 cat - >> $__cwd/config.md << \EOD
1187 pieces=`IFS=/; for x in $1; do echo $x; done`
1189 for x in $pieces; do
1191 mkdir $dir || exit 1
1197 chmod +x $__cwd/config.md
1201 # acCheckCPP is a local that runs a C preprocessor with a given set of
1205 cat > /tmp/ngc$$.c << EOF
1211 if $1 $2 /tmp/ngc$$.c > /tmp/ngc$$.o; then
1212 if grep -v '#define' /tmp/ngc$$.o | grep -s BAR >/dev/null; then
1213 echo "CPP=[$1], CPPFLAGS=[$2]"
1215 AC_SUB 'CPPFLAGS' "$2"
1216 rm /tmp/ngc$$.c /tmp/ngc$$.o
1220 rm /tmp/ngc$$.c /tmp/ngc$$.o
1226 # AC_PROG_CPP checks for cpp, then checks to see which CPPFLAGS are needed
1227 # to run it as a filter.
1230 if [ "$AC_CPP_PROG" ]; then
1233 __ac_path="$AC_PATH"
1234 AC_PATH="/lib:/usr/lib:${__ac_path:-$ac_default_path}"
1235 DEST=`acLookFor cpp`
1236 AC_PATH="$__ac_path"
1240 LOGN "Looking for cpp"
1241 if [ "$DEST" ]; then
1243 acCheckCPP $DEST "$CPPFLAGS" || \
1244 acCheckCPP $DEST -traditional-cpp -E || \
1245 acCheckCPP $DEST -E || \
1246 acCheckCPP $DEST -traditional-cpp -pipe || \
1247 acCheckCPP $DEST -pipe || fail=1
1249 if [ "$fail" ]; then
1250 AC_FAIL " (can't run cpp as a pipeline)"
1256 AC_FAIL " (not found)"
1260 # AC_FAIL spits out an error message, then __fail's
1267 # AC_SUB writes a substitution into config.sub
1269 ( echononl "s;@$1@;"
1270 _subst=`echo $2 | sed -e 's/;/\\;/g'`
1272 echo ';g' ) >> $__cwd/config.sub
1276 # AC_MAK writes a define into config.mak
1278 echo "HAVE_$1 = 1" >> $__cwd/config.mak
1282 # AC_DEFINE adds a #define to config.h
1284 echo "#define $1 ${2:-1}" >> $__cwd/config.h
1288 # AC_INCLUDE adds a #include to config.h
1290 echo "#include \"$1\"" >> $__cwd/config.h
1294 # AC_CONFIG adds a configuration setting to all the config files
1296 AC_DEFINE "PATH_$1" \""$2"\"
1302 # AC_QUIET does something quietly