Warning, /education/cantor/thirdparty/discount-2.2.6-patched/configure.inc is written in an unsupported language. File is not indexed.
0001 # Copyright (c) 1999-2017 David Parsons. All rights reserved. 0002 # 0003 # Redistribution and use in source and binary forms, with or without 0004 # modification, are permitted provided that the following conditions 0005 # are met: 0006 # 1. Redistributions of source code must retain the above copyright 0007 # notice, this list of conditions and the following disclaimer. 0008 # 2. Redistributions in binary form must reproduce the above copyright 0009 # notice, this list of conditions and the following disclaimer in 0010 # the documentation and/or other materials provided with the 0011 # distribution. 0012 # 3. My name may not be used to endorse or promote products derived 0013 # from this software without specific prior written permission. 0014 # 0015 # THIS SOFTWARE IS PROVIDED BY DAVID PARSONS ``AS IS'' AND ANY 0016 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 0017 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 0018 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID 0019 # PARSONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 0020 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 0021 # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0022 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 0023 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 0024 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 0025 # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 0026 # THE POSSIBILITY OF SUCH DAMAGE. 0027 # 0028 0029 0030 # 0031 # this preamble code is executed when this file is sourced and it picks 0032 # interesting things off the command line. 0033 # 0034 ac_default_path="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin" 0035 0036 ac_standard="--src=DIR where the source lives (.) 0037 --prefix=DIR where to install the final product (/usr/local) 0038 --execdir=DIR where to put executables (prefix/bin) 0039 --sbindir=DIR where to put static executables (prefix/sbin) 0040 --confdir=DIR where to put configuration information (/etc) 0041 --libdir=DIR where to put libraries (prefix/lib) 0042 --libexecdir=DIR where to put private executables 0043 --mandir=DIR where to put manpages" 0044 0045 0046 # remove files created by configure on abend 0047 # 0048 AC_EXIT() { 0049 rm -f $__config_files 0050 exit ${1:-1} 0051 } 0052 0053 __fail=AC_EXIT 0054 0055 0056 if dirname B/A 2>/dev/null >/dev/null; then 0057 __ac_dirname() { 0058 dirname "$1" 0059 } 0060 else 0061 __ac_dirname() { 0062 echo "$1" | sed -e 's:/[^/]*$::' 0063 } 0064 fi 0065 0066 __remove() { 0067 if [ \( -x "$1" \) -a "$__MACOS_DSYM" ]; then 0068 rm -rf "$1".dSYM 0069 fi 0070 rm -f "$@" 0071 } 0072 0073 ac_progname=$0 0074 ac_configure_command= 0075 Q=\' 0076 for x in "$@"; do 0077 ac_configure_command="$ac_configure_command $Q$x$Q" 0078 done 0079 # ac_configure_command="$*" 0080 0081 __d=`__ac_dirname "$ac_progname"` 0082 if [ "$__d" = "$ac_progname" ]; then 0083 AC_SRCDIR=`pwd` 0084 else 0085 AC_SRCDIR=`cd $__d;pwd` 0086 fi 0087 0088 __ac_dir() { 0089 if test -d "$1"; then 0090 (cd "$1";pwd) 0091 else 0092 echo "$1"; 0093 fi 0094 } 0095 0096 # 0097 # echo w/o newline 0098 # 0099 echononl() 0100 { 0101 ${ac_echo:-echo} "${@}$ac_echo_nonl" 0102 } 0103 0104 # 0105 # log something to the terminal and to a logfile. 0106 # 0107 LOG () { 0108 echo "$@" 0109 echo "$@" 1>&5 0110 } 0111 0112 # 0113 # log something to the terminal without a newline, and to a logfile with 0114 # a newline 0115 # 0116 LOGN () { 0117 echononl "$@" 1>&5 0118 echo "$@" 0119 } 0120 0121 # 0122 # log something to the terminal 0123 # 0124 TLOG () { 0125 echo "$@" 1>&5 0126 } 0127 0128 # 0129 # log something to the terminal, no newline 0130 # 0131 TLOGN () { 0132 echononl "$@" 1>&5 0133 } 0134 0135 0136 # 0137 # AC_CONTINUE tells configure not to bomb if something fails, but to 0138 # continue blithely along 0139 # 0140 AC_CONTINUE () { 0141 __fail="return" 0142 } 0143 0144 0145 # 0146 # generate a .o file from sources 0147 # 0148 __MAKEDOTO() { 0149 AC_PROG_CC 0150 0151 if $AC_CC -c -o ngc$$.o "$@" $LIBS 2>ngc$$.err; then 0152 __remove ngc$$.o ngc$$.err 0153 TLOG " (found)" 0154 return 0 0155 fi 0156 __remove ngc$$.o 0157 TLOG " (not found)" 0158 echo "test failed: command was $AC_CC -c -o ngc$$.o" "$@" $LIBS 0159 echo "output:" 0160 cat ngc$$.err 0161 __remove ngc$$.err 0162 echo "offending sources:" 0163 for x in "$@"; do 0164 echo "$x:" 0165 cat $x 0166 done 0167 return 1 0168 } 0169 0170 0171 # 0172 # Emulate gnu autoconf's AC_CHECK_HEADERS() function 0173 # 0174 AC_CHECK_HEADERS () { 0175 0176 AC_PROG_CPP 0177 0178 for __hdr in "$@"; do 0179 ( echo "/* AC_CHECK_HEADERS */" 0180 echo "#include <${__hdr}>" ) > ngc$$.c 0181 0182 LOGN "looking for header $__hdr" 0183 0184 if $AC_CPP_FILTER ngc$$.c >/dev/null; then 0185 AC_DEFINE 'HAVE_'`echo $__hdr | $AC_UPPERCASE | tr './' '_'` 1 0186 rc=0 0187 LOG " (found)" 0188 else 0189 rc=1 0190 LOG " (not found)" 0191 fi 0192 __remove ngc$$.c 0193 done 0194 # return code is only meaningful if one header is checked 0195 return $rc 0196 } 0197 0198 0199 # 0200 # emulate GNU autoconf's AC_CHECK_FUNCS function 0201 # 0202 AC_CHECK_FUNCS () { 0203 AC_PROG_CC 0204 0205 B=`echo "$1" | sed -e 's/(.*)//'` 0206 0207 case "$B" in 0208 "$1") F="$1()"; need_proto=1 ;; 0209 *) F="$1" ; unset need_proto ;; 0210 esac 0211 0212 shift 0213 __remove ngc$$.c 0214 0215 while [ "$1" ]; do 0216 echo "#include <$1>" >> ngc$$.c 0217 shift 0218 done 0219 0220 if [ "$need_proto" ]; then 0221 echo "void $F;" >> ngc$$.c 0222 fi 0223 0224 cat >> ngc$$.c << EOF 0225 int main() 0226 { 0227 0228 $F; 0229 } 0230 EOF 0231 0232 LOGN "looking for the $B function" 0233 0234 if $AC_CC $AC_CFLAGS $AC_LDFLAGS -o ngc$$ ngc$$.c $LIBS; then 0235 AC_DEFINE `echo ${2:-HAVE_$B} | $AC_UPPERCASE` 1 0236 TLOG " (found)" 0237 rc=0 0238 else 0239 echo "offending command was:" 0240 cat ngc$$.c 0241 echo "$AC_CC $AC_CFLAGS $AC_LDFLAGS -o ngc$$ ngc$$.c $LIBS" 0242 TLOG " (not found)" 0243 rc=1 0244 fi 0245 __remove ngc$$ ngc$$.c 0246 return $rc 0247 } 0248 0249 0250 # 0251 # check to see if some structure exists 0252 # 0253 # usage: AC_CHECK_STRUCT structure {include ...} 0254 # 0255 AC_CHECK_STRUCT () { 0256 struct=$1 0257 shift 0258 0259 __remove ngc$$.c 0260 0261 for include in $*; do 0262 echo "#include <$include>" >> ngc$$.c 0263 done 0264 0265 cat >> ngc$$.c << EOF 0266 int main() 0267 { 0268 struct $struct foo; 0269 } 0270 EOF 0271 0272 LOGN "looking for struct $struct" 0273 0274 if __MAKEDOTO ngc$$.c; then 0275 AC_DEFINE HAVE_STRUCT_`echo ${struct} | $AC_UPPERCASE` 0276 rc=0 0277 else 0278 rc=1 0279 fi 0280 __remove ngc$$.c 0281 return $rc 0282 } 0283 0284 0285 # 0286 # check to see if some type exists 0287 # 0288 # usage: AC_CHECK_TYPE type {include ...} 0289 # 0290 AC_CHECK_TYPE () { 0291 type=$1 0292 shift 0293 0294 __remove ngc$$.c 0295 0296 for include in $*; do 0297 echo "#include <$include>" >> ngc$$.c 0298 done 0299 0300 cat >> ngc$$.c << EOF 0301 int main() 0302 { 0303 $type foo; 0304 } 0305 EOF 0306 0307 LOGN "looking for $type type" 0308 0309 if __MAKEDOTO ngc$$.c; then 0310 AC_DEFINE HAVE_`echo ${type} | $AC_UPPERCASE` 0311 rc=0 0312 else 0313 rc=1 0314 fi 0315 __remove ngc$$.c 0316 return $rc 0317 } 0318 0319 0320 # 0321 # check to see if some structure contains a field 0322 # 0323 # usage: AC_CHECK_FIELD structure field {include ...} 0324 # 0325 AC_CHECK_FIELD () { 0326 0327 struct=$1 0328 field=$2 0329 shift 2 0330 0331 __remove ngc$$.c 0332 0333 for include in $*;do 0334 echo "#include <$include>" >> ngc$$.c 0335 done 0336 0337 cat >> ngc$$.c << EOF 0338 int main() 0339 { 0340 struct $struct foo; 0341 0342 foo.$field; 0343 } 0344 EOF 0345 0346 LOGN "checking that struct $struct has a $field field" 0347 0348 if __MAKEDOTO ngc$$.c; then 0349 # HAVE_STRUCT_ is for Gnu configure compatability 0350 AC_DEFINE HAVE_STRUCT_`echo ${struct}_$field | $AC_UPPERCASE` 0351 rc=0 0352 else 0353 rc=1 0354 fi 0355 __remove ngc$$.c 0356 return $rc 0357 } 0358 0359 0360 # 0361 # check that the C compiler works 0362 # 0363 AC_PROG_CC () { 0364 test "$AC_CC" && return 0 0365 0366 cat > ngc$$.c << \EOF 0367 extern void say(void*); 0368 int main() 0369 { 0370 say("hello, sailor"); 0371 } 0372 EOF 0373 cat > ngf$$.c << \EOF 0374 #include <stdio.h> 0375 void say(char* message) 0376 { 0377 puts(message); 0378 } 0379 EOF 0380 0381 TLOGN "checking the C compiler" 0382 0383 unset AC_CFLAGS AC_LDFLAGS __MACOS_DSYM 0384 0385 if [ "$CC" ] ; then 0386 AC_CC="$CC" 0387 elif [ "$WITH_PATH" ]; then 0388 AC_CC=`acLookFor cc` 0389 elif [ "`acLookFor cc`" ]; then 0390 # don't specify the full path if the user is looking in their $PATH 0391 # for a C compiler. 0392 AC_CC=cc 0393 fi 0394 0395 # finally check for POSIX c89 0396 test "$AC_CC" || AC_CC=`acLookFor c89` 0397 0398 if [ ! "$AC_CC" ]; then 0399 TLOG " (no C compiler found)" 0400 $__fail 1 0401 fi 0402 echo "checking out the C compiler" 0403 0404 $AC_CC -o ngc$$ ngc$$.c ngf$$.c 0405 status=$? 0406 echo "compile status = $status" 0407 0408 TLOGN " ($AC_CC)" 0409 0410 if [ $status -eq 0 ]; then 0411 if $AC_CC -x c /dev/null -dM -E 2>&1 | grep '__clang__' >/dev/null; then 0412 TLOG " yuck, you're using clang" 0413 IS_CLANG=T 0414 IS_BROKEN_CC=T 0415 elif $AC_CC -v 2>&1 | grep 'gcc version' >/dev/null; then 0416 TLOG " oh ick, it looks like gcc" 0417 IS_GCC=T 0418 IS_BROKEN_CC=T 0419 else 0420 TLOG " ok" 0421 fi 0422 0423 # check that the CFLAGS and LDFLAGS aren't bogus 0424 0425 unset AC_CFLAGS AC_LDFLAGS 0426 0427 if [ "$CFLAGS" ]; then 0428 test "$CFLAGS" && echo "validating CFLAGS=${CFLAGS}" 0429 if $AC_CC $CFLAGS -c -o ngc$$.o ngc$$.c ; then 0430 AC_CFLAGS=${CFLAGS:-"-g"} 0431 test "$CFLAGS" && TLOG "CFLAGS=\"${CFLAGS}\" are okay" 0432 elif [ "$CFLAGS" ]; then 0433 TLOG "ignoring bogus CFLAGS=\"${CFLAGS}\"" 0434 fi 0435 else 0436 AC_CFLAGS=-g 0437 fi 0438 if [ "$LDFLAGS" ]; then 0439 test "$LDFLAGS" && echo "validating LDFLAGS=${LDFLAGS}" 0440 if $AC_CC $CFLAGS $LDFLAGS -o ngc$$ ngc$$.c ngf$$.c; then 0441 AC_LDFLAGS=${LDFLAGS:-"-g"} 0442 test "$LDFLAGS" && TLOG "LDFLAGS=\"${LDFLAGS}\" are okay" 0443 elif [ "$LDFLAGS" ]; then 0444 TLOG "ignoring bogus LDFLAGS=\"${LDFLAGS}\"" 0445 fi 0446 else 0447 AC_LDFLAGS=${CFLAGS:-"-g"} 0448 fi 0449 0450 # macos-specific(?) test for .dSYM resource directories 0451 $AC_CC $AC_CFLAGS $AC_LDFLAGS -o ngc$$ ngc$$.c ngf$$.c 0452 ls -dl ngc$$* 0453 test -d ngc$$.dSYM && __MACOS_DSYM=1 0454 0455 else 0456 AC_FAIL " does not compile code properly" 0457 fi 0458 0459 __remove ngc$$ ngc$$.c ngc$$.o ngf$$.o ngf$$.c 0460 0461 return $status 0462 } 0463 0464 0465 # 0466 # acLookFor actually looks for a program, without setting anything. 0467 # 0468 acLookFor () { 0469 path=${AC_PATH:-$ac_default_path} 0470 case "X$1" in 0471 X-[rx]) __mode=$1 0472 shift 0473 ;; 0474 *) __mode=-x 0475 ;; 0476 esac 0477 oldifs="$IFS" 0478 for program in $*; do 0479 case "$program" in 0480 /*) if [ $__mode $program -a -f $program ]; then 0481 echo $program 0482 break 2 0483 fi ;; 0484 *) 0485 IFS=":" 0486 for x in $path; do 0487 if [ $__mode $x/$program -a -f $x/$program ]; then 0488 echo $x/$program 0489 break 3 0490 fi 0491 done ;; 0492 esac 0493 done 0494 IFS="$oldifs" 0495 unset __mode 0496 } 0497 0498 0499 # 0500 # check that a program exists and set its path 0501 # 0502 MF_PATH_INCLUDE () { 0503 SYM=$1; shift 0504 0505 case X$1 in 0506 X-[rx]) __mode=$1 0507 shift 0508 ;; 0509 *) unset __mode 0510 ;; 0511 esac 0512 0513 TLOGN "looking for $1" 0514 0515 DEST=`acLookFor $__mode $*` 0516 0517 __sym=`echo "$SYM" | $AC_UPPERCASE` 0518 if [ "$DEST" ]; then 0519 TLOG " ($DEST)" 0520 echo "$1 is $DEST" 0521 AC_MAK $SYM 0522 AC_DEFINE PATH_$__sym \""$DEST"\" 0523 AC_SUB $__sym "$DEST" 0524 eval CF_$SYM=$DEST 0525 return 0 0526 else 0527 #AC_SUB $__sym '' 0528 echo "$1 is not found" 0529 TLOG " (not found)" 0530 return 1 0531 fi 0532 } 0533 0534 # 0535 # AC_INIT starts the ball rolling 0536 # 0537 # After AC_INIT, fd's 1 and 2 point to config.log 0538 # and fd 5 points to what used to be fd 1 0539 # 0540 AC_INIT () { 0541 __config_files="config.cmd config.sub config.h config.mak" 0542 rm -f $__config_files 0543 __cwd=`pwd` 0544 exec 5>&1 1>"$__cwd"/config.log 2>&1 0545 AC_CONFIGURE_FOR=__AC_`echo $1 | sed -e 's/\..$//' | $AC_UPPERCASE | tr ' ' '_'`_D 0546 0547 # check to see whether to use echo -n or echo ...\c 0548 # 0549 echo -n hello > $$ 0550 echo world >> $$ 0551 if grep "helloworld" $$ >/dev/null; then 0552 ac_echo="echo -n" 0553 echo "[echo -n] works" 0554 else 0555 ac_echo="echo" 0556 echo 'hello\c' > $$ 0557 echo 'world' >> $$ 0558 if grep "helloworld" $$ >/dev/null; then 0559 ac_echo_nonl='\c' 0560 echo "[echo ...\\c] works" 0561 fi 0562 fi 0563 rm -f $$ 0564 0565 LOG "Configuring for [$1]" 0566 _MK_LIBRARIAN=Y 0567 0568 cat > "$__cwd"/config.h << EOF 0569 /* 0570 * configuration for $1${2:+" ($2)"}, generated `date` 0571 * by ${LOGNAME:-`whoami`}@`hostname` 0572 */ 0573 #ifndef $AC_CONFIGURE_FOR 0574 #define $AC_CONFIGURE_FOR 1 0575 0576 0577 EOF 0578 0579 unset __share 0580 if [ -d $AC_PREFIX/share/man ]; then 0581 for t in 1 2 3 4 5 6 7 8 9; do 0582 if [ -d $AC_PREFIX/share/man/man$t ]; then 0583 __share=/share 0584 elif [ -d $AC_PREFIX/share/man/cat$t ]; then 0585 __share=/share 0586 fi 0587 done 0588 else 0589 __share= 0590 fi 0591 0592 if [ -d $AC_PREFIX/libexec ]; then 0593 __libexec=libexec 0594 else 0595 __libexec=lib 0596 fi 0597 0598 0599 AC_PREFIX=${AC_PREFIX:-/usr/local} 0600 AC_EXECDIR=${AC_EXECDIR:-$AC_PREFIX/bin} 0601 AC_SBINDIR=${AC_SBINDIR:-$AC_PREFIX/sbin} 0602 AC_LIBDIR=${AC_LIBDIR:-$AC_PREFIX/lib} 0603 AC_MANDIR=${AC_MANDIR:-$AC_PREFIX$__share/man} 0604 AC_LIBEXEC=${AC_LIBEXEC:-$AC_PREFIX/$__libexec} 0605 AC_CONFDIR=${AC_CONFDIR:-/etc} 0606 0607 AC_PATH=${WITH_PATH:-$PATH} 0608 AC_PROG_CPP 0609 AC_PROG_INSTALL 0610 0611 ac_os=`uname -s` 0612 _os=`echo $ac_os | $AC_UPPERCASE | sed -e 's/[^A-Z0-9_].*$//'` 0613 AC_DEFINE OS_$_os 1 0614 eval OS_${_os}=1 0615 unset _os 0616 } 0617 0618 0619 # 0620 # AC_LIBRARY checks to see if a given library exists and contains the 0621 # given function. 0622 # usage: AC_LIBRARY function library [alternate ...] 0623 # 0624 AC_LIBRARY() { 0625 local SRC=$1 0626 shift 0627 0628 # first see if the function can be found in any of the 0629 # current libraries 0630 LOGN "Looking for the ${SRC} function" 0631 if AC_QUIET AC_CHECK_FUNCS $SRC; then 0632 AC_DEFINE HAVE_LIB`echo $1 | sed -e 's/-l//' | $AC_UPPERCASE` 0633 LOG "(found)" 0634 return 0 0635 fi 0636 0637 # then search through the supplied list of libraries 0638 local __libs="$LIBS" 0639 for x in "$@"; do 0640 LIBS="$__libs $x" 0641 if AC_QUIET AC_CHECK_FUNCS $SRC; then 0642 AC_DEFINE HAVE_LIB`echo $1 | sed -e 's/-l//' | $AC_UPPERCASE` 0643 LOG " (in $x)" 0644 return 0 0645 fi 0646 done 0647 LOG " (not found)" 0648 LIBS="$__libs" # reset LIBS if we couldn't find anything 0649 return 1 0650 } 0651 0652 0653 # 0654 # AC_PROG_LEX checks to see if LEX exists, and if it's lex or flex. 0655 # 0656 AC_PROG_LEX() { 0657 TLOGN "looking for lex " 0658 0659 DEST=`acLookFor lex` 0660 if [ "$DEST" ]; then 0661 AC_MAK LEX 0662 AC_DEFINE PATH_LEX \"$DEST\" 0663 AC_SUB 'LEX' "$DEST" 0664 echo "lex is $DEST" 0665 else 0666 DEST=`acLookFor flex` 0667 if [ "$DEST" ]; then 0668 AC_MAK FLEX 0669 AC_DEFINE 'LEX' \"$DEST\" 0670 AC_SUB 'LEX', "$DEST" 0671 echo "lex is $DEST" 0672 else 0673 AC_SUB LEX '' 0674 echo "neither lex or flex found" 0675 TLOG " (not found)" 0676 return 1 0677 fi 0678 fi 0679 TLOG "($DEST)" 0680 0681 if AC_LIBRARY yywrap -ll -lfl; then 0682 return 0 0683 else 0684 TLOG "(no lex library found)" 0685 return 1 0686 fi 0687 } 0688 0689 0690 # 0691 # AC_PROG_YACC checks to see if YACC exists, and if it's bison or 0692 # not. 0693 # 0694 AC_PROG_YACC () { 0695 0696 TLOGN "looking for yacc " 0697 0698 DEST=`acLookFor yacc` 0699 if [ "$DEST" ]; then 0700 AC_MAK YACC 0701 AC_DEFINE PATH_YACC \"$DEST\" 0702 AC_SUB 'YACC' "$DEST" 0703 TLOG "($DEST)" 0704 echo "yacc is $DEST" 0705 else 0706 DEST=`acLookFor bison` 0707 if [ "$DEST" ]; then 0708 AC_MAK BISON 0709 AC_DEFINE 'YACC' \"$DEST\" 0710 AC_SUB 'YACC' "$DEST -y" 0711 echo "yacc is $DEST -y" 0712 TLOG "($DEST -y)" 0713 else 0714 AC_SUB 'YACC' '' 0715 echo "neither yacc or bison found" 0716 TLOG " (not found)" 0717 return 1 0718 fi 0719 fi 0720 return 0 0721 } 0722 0723 0724 # 0725 # AC_PROG looks for a program 0726 # 0727 AC_PROG () { 0728 PN=`basename $1 | $AC_UPPERCASE | tr -dc $AC_UPPER_PAT` 0729 0730 if set | grep -v PROG_$PN >/dev/null; then 0731 TLOGN "looking for $1" 0732 0733 __pgm=`eval echo \\$$PN` 0734 if [ "$__pgm" ]; then 0735 TLOGN " (defined as $__pgm)" 0736 DEST=`acLookFor $__pgm` 0737 else 0738 DEST=`acLookFor $1` 0739 fi 0740 0741 if [ "$DEST" ]; then 0742 eval PROG_$PN="$DEST" 0743 AC_SUB $PN $DEST 0744 TLOG " ($DEST)" 0745 return 0 0746 fi 0747 AC_SUB $PN true 0748 TLOG " (not found)" 0749 return 1 0750 fi 0751 } 0752 0753 0754 # 0755 # AC_PROG_LN_S checks to see if ln exists, and, if so, if ln -s works 0756 # 0757 AC_PROG_LN_S () { 0758 test "$PROG_FIND" || AC_PROG_FIND 0759 0760 test "$PROG_LN_S" && return 0 0761 0762 TLOGN "looking for \"ln -s\"" 0763 DEST=`acLookFor ln` 0764 0765 if [ "$DEST" ]; then 0766 rm -f /tmp/b$$ 0767 $DEST -s /tmp/a$$ /tmp/b$$ 0768 if [ "`$PROG_FIND /tmp/b$$ -type l -print`" ]; then 0769 TLOG " ($DEST)" 0770 echo "$DEST exists, and ln -s works" 0771 PROG_LN_S="$DEST -s" 0772 AC_SUB 'LN_S' "$DEST -s" 0773 rm -f /tmp/b$$ 0774 else 0775 AC_SUB 'LN_S' '' 0776 TLOG " ($DEST exists, but -s does not seem to work)" 0777 echo "$DEST exists, but ln -s doesn't seem to work" 0778 rm -f /tmp/b$$ 0779 return 1 0780 fi 0781 else 0782 AC_SUB 'LN_S' '' 0783 echo "ln not found" 0784 TLOG " (not found)" 0785 return 1 0786 fi 0787 } 0788 0789 0790 # 0791 # AC_PROG_FIND looks for the find program and sets the FIND environment 0792 # variable 0793 # 0794 AC_PROG_FIND () { 0795 if test -z "$PROG_FIND"; then 0796 MF_PATH_INCLUDE FIND find 0797 rc=$? 0798 PROG_FIND=$CF_FIND 0799 return $rc 0800 fi 0801 return 0 0802 } 0803 0804 0805 # 0806 # AC_PROG_AWK looks for the awk program and sets the AWK environment 0807 # variable 0808 # 0809 AC_PROG_AWK () { 0810 if test -z "$AC_AWK_PROG"; then 0811 MF_PATH_INCLUDE AWK awk 0812 rc=$? 0813 AC_AWK_PROG=$DEST 0814 return $rc 0815 fi 0816 return 0 0817 } 0818 0819 0820 # 0821 # AC_PROG_SED looks for the sed program and sets the SED environment 0822 # variable 0823 # 0824 AC_PROG_SED () { 0825 if test -z "$AC_SED_PROG"; then 0826 MF_PATH_INCLUDE SED sed 0827 rc=$? 0828 AC_SED_PROG=$DEST 0829 return $rc 0830 fi 0831 return 0 0832 } 0833 0834 0835 # 0836 # AC_HEADER_SYS_WAIT looks for sys/wait.h 0837 # 0838 AC_HEADER_SYS_WAIT () { 0839 AC_CHECK_HEADERS sys/wait.h || return 1 0840 } 0841 0842 # 0843 # AC_TYPE_PID_T checks to see if the pid_t type exists 0844 # 0845 AC_TYPE_PID_T () { 0846 0847 AC_CHECK_TYPE pid_t sys/types.h 0848 return $? 0849 } 0850 0851 0852 # 0853 # check for the existence of __attribute__((__noreturn__)) 0854 # 0855 AC_CHECK_NORETURN() { 0856 AC_PROG_CC 0857 AC_CHECK_ATTRIBUTE noreturn 0858 } 0859 0860 AC_CHECK_ATTRIBUTE() { 0861 local __what=`echo $1 | tr 'a-z' 'A-Z'` 0862 0863 echo "extern int thing __attribute__((__"$1"__));" > ngc$$.c 0864 0865 TLOGN "Checking __attribute__((__${1}__)) " 0866 if $AC_CC -c ngc$$.c; then 0867 TLOG "(yes)" 0868 AC_DEFINE $__what ' __attribute__((__'$1'__))' 0869 else 0870 TLOG "(no)" 0871 AC_DEFINE $__what '/**/' 0872 fi 0873 rm -f ngc$$.o ngc$$.c 0874 } 0875 0876 0877 # 0878 # AC_C_CONST checks to see if the compiler supports the const keyword 0879 # 0880 AC_C_CONST () { 0881 cat > ngc$$.c << EOF 0882 const char me=1; 0883 EOF 0884 LOGN "checking for \"const\" keyword" 0885 0886 if __MAKEDOTO ngc$$.c; then 0887 rc=0 0888 else 0889 AC_DEFINE 'const' '/**/' 0890 rc=1 0891 fi 0892 __remove ngc$$.c 0893 return $rc 0894 } 0895 0896 0897 # 0898 # AC_C_VOLATILE checks to see if the compiler supports the volatile keyword 0899 # 0900 AC_C_VOLATILE () { 0901 echo 'f() { volatile char me=1; }' > ngc$$.c 0902 LOGN "checking for \"volatile\" keyword" 0903 0904 if __MAKEDOTO ngc$$.c; then 0905 rc=0 0906 else 0907 AC_DEFINE 'volatile' '/**/' 0908 rc=1 0909 fi 0910 __remove ngc$$.c 0911 return $rc 0912 } 0913 0914 0915 # 0916 # AC_C_INLINE checks to see if compiler supports the inline keyword 0917 # 0918 AC_C_INLINE() { 0919 echo 'inline int foo() { return 1; }' > ngc$$.c 0920 LOGN 'Checking for "inline" keyword' 0921 if __MAKEDOTO ngc$$.c; then 0922 rc=0 0923 else 0924 AC_DEFINE inline '/**/' 0925 rc=1 0926 fi 0927 __remove ngc$$.c 0928 return $rc 0929 } 0930 0931 0932 # 0933 # AC_WHATIS tries to print out the value of a macro 0934 # 0935 AC_WHATIS() { 0936 MODE=$1 # what it should be (string,int,char) 0937 shift 0938 MACRO=$1 # the macro name 0939 shift 0940 0941 case "$MODE" in 0942 string) 0943 __fmt='%s' ;; 0944 int) 0945 __fmt='%d' ;; 0946 char) 0947 __fmt='%c' ;; 0948 *) LOG "AC_WHATIS $MODE $MACRO -- mode isn't string, int, or char" 0949 return 1 ;; 0950 esac 0951 0952 ( echo '#include <stdio.h>' 0953 0954 for x in "$@"; do 0955 echo "#include <${x}>" 0956 done 0957 0958 echo "main() { printf(\"${MACRO}=\\\"${__fmt}\\\"\\n\", ${MACRO}); }" ) > _ngc$$.c 0959 0960 if $AC_CC $AC_CFLAGS -o _ngc$$ _ngc$$.c; then 0961 ./_ngc$$ 0962 rc=0 0963 else 0964 rc=1 0965 fi 0966 rm -f _ngc$$ _ngc$$.c 0967 return $rc 0968 } 0969 0970 0971 # 0972 # AC_SCALAR_TYPES checks to see if the compiler can generate 2 and 4 byte ints. 0973 # 0974 AC_SCALAR_TYPES () { 0975 0976 rc=1 0977 LOGN "defining WORD & DWORD scalar types" 0978 0979 # if AC_QUIET AC_CHECK_HEADERS WinDef.h; then 0980 # # windows machine; BYTE, WORD, DWORD already 0981 # # defined 0982 # echo "#include <WinDef.h>" >> "$__cwd"/config.h 0983 # TLOG " (defined in WinDef.h)" 0984 # return 0 0985 # fi 0986 0987 # try first to define them with the (allegedly) standard 0988 # unsigned scalar types 0989 # 0990 unset __i; 0991 if AC_QUIET AC_CHECK_HEADERS inttypes.h; then 0992 __i=inttypes.h 0993 elif AC_QUIET AC_CHECK_HEADERS stdint.h; then 0994 __i=stdint.h 0995 fi 0996 if AC_QUIET AC_CHECK_TYPE uint32_t $__i && \ 0997 AC_QUIET AC_CHECK_TYPE uint16_t $__i && \ 0998 AC_QUIET AC_CHECK_TYPE uint8_t $__i; then 0999 1000 while [ $# -gt 0 ]; do 1001 case "$1" in 1002 sub) ( if [ -z "$__i" ] ; then 1003 echo "s:@SCALAR_HEADER_INCLUDE@::g" 1004 else 1005 echo "s:@SCALAR_HEADER_INCLUDE@:#include <$__i>:g" 1006 fi 1007 echo "s:@DWORD@:uint32_t:g" 1008 echo "s:@WORD@:uint16_t:g" 1009 echo "s:@BYTE@:uint8_t:g" ) >> "$__cwd"/config.sub 1010 ;; 1011 *) ( echo "#define DWORD uint32_t" 1012 echo "#define WORD uint16_t" 1013 echo "#define BYTE uint8_t" ) >> "$__cwd"/config.h 1014 ;; 1015 esac 1016 shift 1017 done 1018 TLOG " (using standard types ${__i:+in <$__i>})" 1019 return 0 1020 fi 1021 1022 # and if that fails do a brute-force program that does sizeof()ication 1023 # to figure things out 1024 # 1025 cat > ngc$$.c << EOF 1026 #include <stdio.h> 1027 #include <string.h> 1028 1029 int pound_define = 1; 1030 1031 void 1032 say(char *w, char *v) 1033 { 1034 printf(pound_define ? "#define %s %s\n" 1035 : "s:@%s@:%s:g\n", w, v); 1036 } 1037 1038 int 1039 main(argc, argv) 1040 char **argv; 1041 { 1042 unsigned long v_long; 1043 unsigned int v_int; 1044 unsigned short v_short; 1045 1046 if ( argc > 1 && strcmp(argv[1], "sub") == 0 ) 1047 pound_define = 0; 1048 1049 if (sizeof v_long == 4) 1050 say("DWORD", "unsigned long"); 1051 else if (sizeof v_int == 4) 1052 say("DWORD", "unsigned int"); 1053 else 1054 return 1; 1055 1056 if (sizeof v_int == 2) 1057 say("WORD", "unsigned int"); 1058 else if (sizeof v_short == 2) 1059 say("WORD", "unsigned short"); 1060 else 1061 return 2; 1062 1063 say("BYTE", "unsigned char"); 1064 fprintf(stderr, "OK!"); 1065 return 0; 1066 } 1067 EOF 1068 1069 if $AC_CC ngc$$.c -o ngc$$; then 1070 if [ $# -gt 0 ]; then 1071 while [ "$1" ]; do 1072 case "$1" in 1073 sub)if ./ngc$$ sub >> "$__cwd"/config.sub; then 1074 echo "s:@SCALAR_HEADER_INCLUDE@::g" >> "$__cwd"/config.sub 1075 rc=0 1076 fi;; 1077 *) if ./ngc$$ >> "$__cwd"/config.h; then 1078 rc=0 1079 fi ;; 1080 esac 1081 shift 1082 done 1083 elif ./ngc$$ >> "$__cwd"/config.h; then 1084 rc=0 1085 fi 1086 if [ "$rc" != 0 ]; then 1087 if ./ngc$$ >> "$__cwd"/config.h; then 1088 rc=0 1089 fi 1090 fi 1091 fi 1092 __remove ngc$$ ngc$$.c 1093 case "$rc" in 1094 0) TLOG "" ;; 1095 *) AC_FAIL " ** FAILED **" ;; 1096 esac 1097 return $rc 1098 } 1099 1100 1101 # 1102 # AC_OUTPUT generates makefiles from makefile.in's 1103 # 1104 AC_OUTPUT () { 1105 1106 cd "$__cwd" 1107 AC_SUB 'LIBS' "$LIBS" 1108 1109 if test "$__MACOS_DSYM"; then 1110 # deal with extra OSX droppings, if they exist 1111 AC_SUB 'DISTCLEAN' 'rm -fr' 1112 AC_SUB 'GENERATED_FILES' "*.dSYM $*" 1113 else 1114 AC_SUB 'DISTCLEAN' 'rm -f' 1115 AC_SUB 'GENERATED_FILES' "$*" 1116 fi 1117 1118 AC_SUB 'CC' "$AC_CC" 1119 AC_SUB 'CFLAGS' "$AC_CFLAGS" 1120 AC_SUB 'LDFLAGS' "$AC_LDFLAGS" 1121 AC_SUB 'CPPFLAGS' "$CPPFLAGS" 1122 AC_SUB 'srcdir' "$AC_SRCDIR" 1123 AC_SUB 'prefix' "$AC_PREFIX" 1124 AC_SUB 'exedir' "$AC_EXECDIR" 1125 AC_SUB 'bindir' "$AC_EXECDIR" 1126 AC_SUB 'sbindir' "$AC_SBINDIR" 1127 AC_SUB 'libdir' "$AC_LIBDIR" 1128 AC_SUB 'libexec' "$AC_LIBEXEC" 1129 AC_SUB 'confdir' "$AC_CONFDIR" 1130 AC_SUB 'mandir' "$AC_MANDIR" 1131 1132 if [ "$_MK_LIBRARIAN" ] && echo "$__config_files" | grep -v librarian.sh >/dev/null; then 1133 # write a librarian that works with static libraries 1134 if AC_PROG_LN_S ; then 1135 __dolink=$PROG_LN_S 1136 elif AC_PROG ln; then 1137 __dolink=$PROG_LN 1138 elif AC_PROG cp; then 1139 __dolink=$PROG_CP 1140 else 1141 __dolink=: 1142 fi 1143 AC_PROG ar 1144 AC_PROG ranlib 1145 AC_SUB LD_LIBRARY_PATH HERE 1146 __config_files="$__config_files librarian.sh" 1147 cat > librarian.sh << EOF 1148 #! /bin/sh 1149 # 1150 # Build static libraries, hiding (some) ickiness from the makefile 1151 1152 ACTION=\$1; shift 1153 LIBRARY=\$1; shift 1154 VERSION=\$1; shift 1155 1156 case "\$ACTION" in 1157 make) # first strip out any libraries that might 1158 # be passed in on the object line 1159 objs= 1160 for x in "\$@"; do 1161 case "\$x" in 1162 -*) ;; 1163 *) objs="\$objs \$x" ;; 1164 esac 1165 done 1166 ${PROG_AR} crv \$LIBRARY.a \$objs 1167 ${PROG_RANLIB} \$LIBRARY.a 1168 rm -f \$LIBRARY 1169 ${__dolink} \$LIBRARY.a \$LIBRARY 1170 ;; 1171 files) echo "\${LIBRARY}.a" 1172 ;; 1173 install)$PROG_INSTALL -m 644 \${LIBRARY}.a \$1 1174 ;; 1175 esac 1176 EOF 1177 chmod +x librarian.sh 1178 fi 1179 1180 AC_SUB 'CONFIGURE_FILES' "$__config_files config.log" 1181 1182 if [ -r config.sub ]; then 1183 test "$AC_SED_PROG" || AC_PROG_SED 1184 test "$AC_SED_PROG" || return 1 1185 1186 echo >> config.h 1187 echo "#endif/* ${AC_CONFIGURE_FOR} */" >> config.h 1188 1189 rm -f config.cmd 1190 Q=\' 1191 cat - > config.cmd << EOF 1192 #! /bin/sh 1193 ${CC:+CC=${Q}${CC}${Q}} ${CFLAGS:+CFLAGS=${Q}${CFLAGS}${Q}} ${LDFLAGS:+LDFLAGS=${Q}${LDFLAGS}${Q}} $ac_progname $ac_configure_command 1194 EOF 1195 chmod +x config.cmd 1196 1197 __d=$AC_SRCDIR 1198 for makefile in $*;do 1199 if test -r "$__d/${makefile}.in"; then 1200 LOG "generating $makefile" 1201 ./config.md `__ac_dirname ./$makefile` 2>/dev/null 1202 $AC_SED_PROG -f config.sub < "$__d/${makefile}.in" > $makefile 1203 __config_files="$__config_files $makefile" 1204 else 1205 LOG "WARNING: ${makefile}.in does not exist!" 1206 fi 1207 done 1208 unset __d 1209 1210 else 1211 echo 1212 fi 1213 } 1214 1215 # 1216 # AC_CHECK_FLOCK checks to see if flock() exists and if the LOCK_NB argument 1217 # works properly. 1218 # 1219 AC_CHECK_FLOCK() { 1220 1221 AC_CHECK_HEADERS sys/types.h sys/file.h fcntl.h 1222 1223 cat << EOF > ngc$$.c 1224 #include <stdio.h> 1225 #include <sys/file.h> 1226 #include <sys/types.h> 1227 #include <fcntl.h> 1228 1229 int main() 1230 { 1231 int x = open("ngc$$.c", O_RDWR, 0666); 1232 int y = open("ngc$$.c", O_RDWR, 0666); 1233 1234 alarm(1); 1235 if (flock(x, LOCK_EX) != 0) 1236 exit(1); 1237 if (flock(y, LOCK_EX|LOCK_NB) == 0) 1238 exit(1); 1239 exit(0); 1240 } 1241 EOF 1242 1243 LOGN "checking flock() sanity" 1244 HAS_FLOCK=0 1245 if $AC_CC -o ngc$$ ngc$$.c ; then 1246 if ./ngc$$ ; then 1247 LOG " (good)" 1248 HAS_FLOCK=1 1249 AC_DEFINE HAS_FLOCK 1250 else 1251 LOG " (bad)" 1252 fi 1253 else 1254 LOG " (not found)" 1255 fi 1256 1257 __remove ngc$$ ngc$$.c 1258 1259 case "$HAS_FLOCK" in 1260 0) return 1 ;; 1261 *) return 0 ;; 1262 esac 1263 } 1264 1265 1266 # 1267 # AC_CHECK_RESOLVER finds out whether the berkeley resolver is 1268 # present on this system. 1269 # 1270 AC_CHECK_RESOLVER () { 1271 AC_PROG_CC 1272 1273 TLOGN "looking for the Berkeley resolver library" 1274 1275 __ACR_rc=0 1276 1277 cat > ngc$$.c << EOF 1278 #include <sys/types.h> 1279 #include <netinet/in.h> 1280 #include <arpa/nameser.h> 1281 #include <resolv.h> 1282 1283 int main() 1284 { 1285 char bfr[256]; 1286 1287 res_init(); 1288 res_query("hello", C_IN, T_A, bfr, sizeof bfr); 1289 } 1290 EOF 1291 1292 if $AC_CC -o ngc$$ ngc$$.c; then 1293 TLOG " (found)" 1294 elif $AC_CC -o ngc$$ ngc$$.c -lresolv; then 1295 TLOG " (yes, with -lresolv)" 1296 LIBS="$LIBS -lresolv" 1297 elif $AC_CC -DBIND_8_COMPAT -o ngc$$ ngc$$.c; then 1298 TLOG " (yes, with BIND_8_COMPAT)" 1299 AC_DEFINE BIND_8_COMPAT 1 1300 elif $AC_CC -DBIND_8_COMPAT -o ngc$$ ngc$$.c -lresolv; then 1301 TLOG " (yes, with BIND_8_COMPAT & -lresolv)" 1302 LIBS="$LIBS -lresolv" 1303 AC_DEFINE BIND_8_COMPAT 1 1304 else 1305 TLOG " (not found)" 1306 __ACR_rc=1 1307 fi 1308 __remove ngc$$ ngc$$.c 1309 return $__ACR_rc 1310 } 1311 1312 1313 # 1314 # AC_CHECK_ALLOCA looks for alloca 1315 # 1316 AC_CHECK_ALLOCA () { 1317 1318 AC_PROG_CC 1319 AC_CHECK_HEADERS stdlib.h 1320 1321 cat - > ngc$$.c << EOF 1322 #if T 1323 # include <alloca.h> 1324 #else 1325 # include <stdlib.h> 1326 #endif 1327 int main() 1328 { 1329 alloca(10); 1330 } 1331 EOF 1332 1333 LOGN "looking for the alloca function" 1334 if $AC_CC -DT ngc$$.c -o ngc$$; then 1335 AC_DEFINE 'HAVE_ALLOCA_H' 1 1336 status=0 1337 TLOG " (found in alloca.h)" 1338 elif $AC_CC ngc$$.c -o ngc$$; then 1339 TLOG " (found)" 1340 status=0 1341 else 1342 TLOG " (not found)" 1343 status=1 1344 fi 1345 __remove ngc$$ ngc$$.c 1346 return $status 1347 1348 } 1349 1350 1351 # 1352 # AC_CHECK_BASENAME looks for a copy of basename that does NOT use 1353 # a local static buffer to hold results in. 1354 # 1355 AC_CHECK_BASENAME() { 1356 TLOGN "looking for a reentrant basename " 1357 1358 cat > ngc$$.c << EOF 1359 #include <string.h> 1360 1361 extern char *basename(char*); 1362 1363 int main() 1364 { 1365 char *a = basename("/a/test"); 1366 char *b = basename("/a/nother"); 1367 1368 return (strcmp(a,b) != 0) ? 0 : 1; 1369 1370 } 1371 EOF 1372 1373 if $AC_CC -o ngc$$ ngc$$.c $LIBS; then 1374 if ./ngc$$; then 1375 TLOG "(found)" 1376 AC_DEFINE 'HAVE_BASENAME' 1 1377 AC_CHECK_HEADERS libgen.h 1378 else 1379 TLOG "(broken)" 1380 fi 1381 else 1382 TLOG "(not found)" 1383 fi 1384 __remove ngc$$ ngc$$.c 1385 } 1386 1387 # 1388 # AC_COMPILER_PIC checks for the compiler option to produce position independent 1389 # code. At the moment we assume gcc semantics. 1390 # 1391 AC_COMPILER_PIC () { 1392 AC_PROG_CC 1393 1394 LOGN "checking for C compiler option to produce PIC " 1395 echo "int some_variable = 0;" > ngc$$.c 1396 1397 if $AC_CC -c -fPIC -o ngc$$ ngc$$.c $LIBS; then 1398 AC_CFLAGS="$AC_CFLAGS -fPIC" 1399 LOG "(-fPIC)" 1400 __rc=0 1401 else 1402 LOG "(none)" 1403 __rc=1 1404 fi 1405 __remove ngc$$ ngc$$.c 1406 return $__rc 1407 } 1408 1409 1410 # generate a macosX librarian 1411 # 1412 __AC_MACOS_LIBRARIAN() { 1413 AC_SUB LD_LIBRARY_PATH DYLD_LIBRARY_PATH 1414 __config_files="$__config_files librarian.sh" 1415 cat > librarian.sh << EOF 1416 #! /bin/sh 1417 # 1418 # Build MacOS shared libraries, hiding (some) ickiness from the makefile 1419 1420 ACTION=\$1; shift 1421 LIBRARY=\$1; shift 1422 1423 eval \`awk -F. '{ printf "MAJOR=%d\n", \$1; 1424 printf "VERSION=%d.%d.%d\n", \$1, \$2, \$3; }' \$1\` 1425 shift 1426 1427 LIBNAME=\$LIBRARY.dylib 1428 FULLNAME=\$LIBNAME 1429 1430 case "\$ACTION" in 1431 make) FLAGS="$AC_CFLAGS -dynamiclib" 1432 VFLAGS="-current_version \$VERSION -compatibility_version \$MAJOR" 1433 1434 rm -f \$LIBRARY 1435 if $AC_CC \$FLAGS \$VFLAGS -o \$FULLNAME "\$@"; then 1436 $PROG_LN_S \$FULLNAME \$LIBRARY 1437 fi 1438 ;; 1439 files) echo "\$FULLNAME" 1440 ;; 1441 install)$PROG_INSTALL -c \$FULLNAME "\$1" 1442 ;; 1443 esac 1444 EOF 1445 chmod +x librarian.sh 1446 } 1447 1448 1449 # Generate an ELF librarian (for Linux, freebsd) 1450 # 1451 __AC_ELF_LIBRARIAN() { 1452 AC_SUB LD_LIBRARY_PATH LD_LIBRARY_PATH 1453 # -Wl option probably works, but be paranoid anyway 1454 _VFLAGS="$AC_PICFLAG -shared -Wl,-soname,ngc$$.so.1" 1455 if $AC_CC $_VFLAGS -o ngc$$.so ngc$$.c; then 1456 USE_SONAME=T 1457 fi 1458 LDCONFIG=`AC_PATH=/sbin:/usr/sbin:/usr/local/sbin acLookFor ldconfig` 1459 1460 if [ "$LDCONFIG" ]; then 1461 case `uname -s 2>/dev/null | $AC_UPPERCASE` in 1462 *BSD) # *BSD ldconfig, when passed a directory, blows away the 1463 # ld.so hints file and replaces it with one that's just 1464 # the files in the library. It needs a `-m` flag to 1465 # tell it to merge the new entries with the old 1466 LDCONFIG="$LDCONFIG -m" ;; 1467 esac 1468 fi 1469 1470 __config_files="$__config_files librarian.sh" 1471 cat > librarian.sh << EOF 1472 #! /bin/sh 1473 # 1474 # Build ELF shared libraries, hiding (some) ickiness from the makefile 1475 1476 ACTION=\$1; shift 1477 LIBRARY=\$1; shift 1478 1479 eval \`awk -F. '{ printf "MAJOR=%d\n", \$1; 1480 printf "VERSION=%d.%d.%d\n", \$1, \$2, \$3; }' \$1\` 1481 shift 1482 1483 LIBNAME=\$LIBRARY.so 1484 FULLNAME=\$LIBNAME.\$VERSION 1485 1486 case "\$ACTION" in 1487 make) FLAGS="$AC_CFLAGS -shared" 1488 unset VFLAGS 1489 test "$USE_SONAME" && VFLAGS="-Wl,-soname,\$LIBNAME.\$MAJOR" 1490 1491 rm -f \$LIBRARY \$LIBNAME \$LIBNAME.\$MAJOR 1492 if $AC_CC \$FLAGS \$VFLAGS -o \$FULLNAME "\$@"; then 1493 $PROG_LN_S \$FULLNAME \$LIBRARY 1494 $PROG_LN_S \$FULLNAME \$LIBNAME 1495 $PROG_LN_S \$FULLNAME \$LIBNAME.\$MAJOR 1496 fi 1497 ;; 1498 files) echo "\$FULLNAME" "\$LIBNAME" "\$LIBNAME.\$MAJOR" 1499 ;; 1500 install)$PROG_INSTALL -c \$FULLNAME "\$1" 1501 $PROG_LN_S -f \$FULLNAME \$1/\$LIBNAME.\$MAJOR 1502 $PROG_LN_S -f \$FULLNAME \$1/\$LIBNAME 1503 EOF 1504 test "$LDCONFIG" && echo ' '$LDCONFIG '"$1"' >> librarian.sh 1505 cat >> librarian.sh << EOF 1506 ;; 1507 esac 1508 EOF 1509 chmod +x librarian.sh 1510 } 1511 1512 1513 # 1514 # AC_CC_SHLIBS checks if the C compiler can produce shared libraries 1515 # and if it can writes a librarian that handles those libraries for us. 1516 # 1517 AC_CC_SHLIBS () { 1518 AC_PROG_CC || AC_FAIL "Need a C compiler to build shared libraries" 1519 AC_PROG_LN_S || AC_FAIL "Need to be able to make symbolic links for shared libraries" 1520 AC_PROG_INSTALL || AC_FAIL "Need an install program to install shared libraries" 1521 1522 LOGN "checking whether the C compiler can build shared libraries " 1523 1524 echo "int some_variable = 0;" > ngc$$.c 1525 1526 _MK_LIBRARIAN= 1527 if uname -a | grep Darwin >/dev/null; then 1528 # Claims to be macos? 1529 if $AC_CC $AC_PICFLAG -dynamiclib -o ngc$$.so ngc$$.c; then 1530 __AC_MACOS_LIBRARIAN 1531 1532 LOG "(yes; macos dylib)" 1533 __rc=0 1534 else 1535 LOG "(no)" 1536 __rc=1 1537 fi 1538 elif $AC_CC $AC_PICFLAG -shared -o ngc$$.so ngc$$.c; then 1539 __AC_ELF_LIBRARIAN 1540 LOG "(yes; -shared)" 1541 __rc=0 1542 else 1543 _MK_LIBRARIAN=Y 1544 LOG "(no)" 1545 __rc=1 1546 fi 1547 1548 __remove ngc$$.so ngc$$.c 1549 1550 return $__rc 1551 } 1552 1553 1554 # 1555 # AC_PROG_INSTALL finds the install program and guesses whether it's a 1556 # Berkeley or GNU install program 1557 # 1558 AC_PROG_INSTALL () { 1559 1560 if [ $PROG_INSTALL ]; then return; fi 1561 1562 DEST=`acLookFor install` 1563 1564 LOGN "looking for install" 1565 unset IS_BSD 1566 if [ "$DEST" ]; then 1567 # BSD install or GNU install? Let's find out... 1568 touch /tmp/a$$ 1569 1570 $DEST /tmp/a$$ /tmp/b$$ 1571 1572 if test -r /tmp/a$$; then 1573 LOG " ($DEST)" 1574 else 1575 IS_BSD=1 1576 LOG " ($DEST) bsd install" 1577 fi 1578 rm -f /tmp/a$$ /tmp/b$$ 1579 else 1580 DEST=`acLookFor ginstall` 1581 if [ "$DEST" ]; then 1582 LOG " ($DEST)" 1583 else 1584 DEST="false" 1585 LOG " (not found)" 1586 fi 1587 fi 1588 1589 if [ "$IS_BSD" ]; then 1590 PROG_INSTALL="$DEST -c" 1591 else 1592 PROG_INSTALL="$DEST" 1593 fi 1594 1595 # see if we can strip binaries 1596 echo 'main() { puts("hello, sailor!"); }' > ngc$$.c 1597 if $AC_CC -o ngc$$ ngc$$.c; then 1598 if $PROG_INSTALL -s -m 444 ngc$$ inst$$; then 1599 _strip="-s" 1600 else 1601 unset _strip 1602 LOG "(install -s does not appear to work?)" 1603 fi 1604 rm -f inst$$ 1605 fi 1606 rm -f ngc$$ ngc$$.c 1607 1608 AC_SUB 'INSTALL' "$PROG_INSTALL" 1609 AC_SUB 'INSTALL_PROGRAM' "$PROG_INSTALL $_strip -m 755" 1610 AC_SUB 'INSTALL_DATA' "$PROG_INSTALL -m 444" 1611 1612 # finally build a little directory installer 1613 # if mkdir -p works, use that, otherwise use install -d, 1614 # otherwise build a script to do it by hand. 1615 # in every case, test to see if the directory exists before 1616 # making it. 1617 1618 if mkdir -p $$a/b; then 1619 # I like this method best. 1620 __mkdir="mkdir -p" 1621 rmdir $$a/b 1622 rmdir $$a 1623 elif $PROG_INSTALL -d $$a/b; then 1624 __mkdir="$PROG_INSTALL -d" 1625 rmdir $$a/b 1626 rmdir $$a 1627 fi 1628 1629 __config_files="$__config_files config.md" 1630 AC_SUB 'INSTALL_DIR' "$__cwd/config.md" 1631 echo "#! /bin/sh" > ""$__cwd"/config.md" 1632 echo "# script generated" `date` "by configure.sh" >> ""$__cwd"/config.md" 1633 echo >> ""$__cwd"/config.md" 1634 if [ "$__mkdir" ]; then 1635 echo "test -d \"\$1\" || $__mkdir \"\$1\"" >> ""$__cwd"/config.md" 1636 echo "exit $?" >> ""$__cwd"/config.md" 1637 else 1638 cat - >> ""$__cwd"/config.md" << \EOD 1639 pieces=`IFS=/; for x in $1; do echo $x; done` 1640 dir= 1641 for x in $pieces; do 1642 dir="$dir$x" 1643 mkdir $dir || exit 1 1644 dir="$dir/" 1645 done 1646 exit 0 1647 EOD 1648 fi 1649 chmod +x "$__cwd"/config.md 1650 } 1651 1652 # 1653 # acCheckCPP is a local that runs a C preprocessor with a given set of 1654 # compiler options 1655 # 1656 acCheckCPP () { 1657 cat > ngc$$.c << EOF 1658 #define FOO BAR 1659 1660 FOO 1661 EOF 1662 1663 good= 1664 use_cflags= 1665 if $1 $2 $AC_CFLAGS ngc$$.c > ngc$$.o; then 1666 good=1 1667 use_cflags=1 1668 elif $1 $2 ngc$$.c > ngc$$.o; then 1669 good=1 1670 fi 1671 1672 if [ "$good" ]; then 1673 if grep -v '#define' ngc$$.o | grep -s BAR >/dev/null; then 1674 echo "CPP=[$1], CPP_PIPE=[$2${use_cflags:+ $AC_CFLAGS}]" 1675 AC_SUB 'CPP' "$1" 1676 AC_CPP_FILTER="$1 $2${use_cflags:+ $AC_CFLAGS}" 1677 rm ngc$$.c ngc$$.o 1678 return 0 1679 fi 1680 fi 1681 rm ngc$$.c ngc$$.o 1682 return 1 1683 } 1684 1685 # 1686 # AC_PROG_CPP checks for cpp, then checks to see which CPPFLAGS are needed 1687 # to run it as a filter. 1688 # 1689 AC_PROG_CPP () { 1690 test "$AC_CPP_FILTER" && return 1691 1692 AC_PROG_CC 1693 1694 if [ "$AC_CPP_PROG" ]; then 1695 DEST=$AC_CPP_PROG 1696 else 1697 __ac_path="$AC_PATH" 1698 AC_PATH="/lib:/usr/lib:${__ac_path:-$ac_default_path}" 1699 DEST=`acLookFor cpp` 1700 AC_PATH="$__ac_path" 1701 fi 1702 1703 unset fail 1704 LOGN "Looking for cpp" 1705 1706 if acCheckCPP "$AC_CC" -E; then 1707 TLOG " (using \$CC -E as a cpp pipeline)" 1708 return 0 1709 fi 1710 1711 if [ "$DEST" ]; then 1712 TLOGN " ($DEST)" 1713 acCheckCPP $DEST "$CPPFLAGS" || \ 1714 acCheckCPP $DEST -traditional-cpp -E || \ 1715 acCheckCPP $DEST -E || \ 1716 acCheckCPP $DEST -traditional-cpp -pipe || \ 1717 acCheckCPP $DEST -pipe || fail=1 1718 1719 if [ "$fail" ]; then 1720 AC_FAIL " (can't run cpp as a pipeline)" 1721 else 1722 TLOG " ok" 1723 return 0 1724 fi 1725 fi 1726 AC_FAIL " (not found)" 1727 } 1728 1729 # 1730 # AC_FAIL spits out an error message, then __fail's 1731 AC_FAIL() { 1732 LOG "$*" 1733 $__fail 1 1734 } 1735 1736 # 1737 # __ac_config_sed; a C program to do escaping for AC_SUB 1738 __ac_config_sed() { 1739 1740 1741 test -x config.sed && return 1742 1743 echo "generating config.sed" 1744 1745 AC_PROG_CC 1746 1747 cat > ngc$$.c << \EOF 1748 #include <stdio.h> 1749 1750 int 1751 main(argc, argv) 1752 int argc; 1753 char **argv; 1754 { 1755 char *p; 1756 1757 if (argc != 3) 1758 return 1; 1759 1760 printf("s;@%s@;", argv[1]); 1761 1762 for (p=argv[2]; *p; ++p) { 1763 if ( *p == ';' ) 1764 putchar('\\'); 1765 putchar(*p); 1766 } 1767 1768 puts(";g"); 1769 return 0; 1770 } 1771 EOF 1772 1773 if $AC_CC -o config.sed ngc$$.c; then 1774 rm -f ngc$$.c 1775 __config_files="$__config_files config.sed" 1776 else 1777 rm -f ngc$$.c 1778 AC_FAIL "Cannot generate config.sed helper program" 1779 fi 1780 } 1781 1782 # 1783 # AC_SUB writes a substitution into config.sub 1784 AC_SUB() { 1785 1786 _target="$1" 1787 shift 1788 1789 echo "target=$_target, rest=$*" 1790 1791 __ac_config_sed 1792 ./config.sed "$_target" "$*" >> "$__cwd"/config.sub 1793 } 1794 # 1795 # AC_TEXT writes arbitrary text into config.h 1796 AC_TEXT() { 1797 echo "$@" >> "$__cwd"/config.h 1798 } 1799 1800 # 1801 # AC_MAK writes a define into config.mak 1802 AC_MAK() { 1803 echo "HAVE_$1 = 1" >> "$__cwd"/config.mak 1804 } 1805 1806 # 1807 # AC_DEFINE adds a #define to config.h 1808 AC_DEFINE() { 1809 echo "#define $1 ${2:-1}" >> "$__cwd"/config.h 1810 } 1811 1812 # 1813 # AC_INCLUDE adds a #include to config.h 1814 AC_INCLUDE() { 1815 echo "#include \"$1\"" >> "$__cwd"/config.h 1816 } 1817 1818 # 1819 # AC_CONFIG adds a configuration setting to all the config files 1820 AC_CONFIG() { 1821 AC_DEFINE "PATH_$1" \""$2"\" 1822 AC_MAK "$1" 1823 AC_SUB "$1" "$2" 1824 } 1825 1826 # 1827 # AC_QUIET does something quietly 1828 AC_QUIET() { 1829 eval $* 5>/dev/null 1830 } 1831 1832 1833 AC_TR=`acLookFor tr` 1834 if [ "$AC_TR" ]; then 1835 # try posix-style tr 1836 ABC=`echo abc | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` 1837 if [ "$ABC" = "ABC" ]; then 1838 AC_UPPERCASE="$AC_TR abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ" 1839 AC_UPPER_PAT="ABCDEFGHIJKLMNOPQRSTUVWXYZ" 1840 else 1841 ABC=`echo abc | tr a-z A-Z` 1842 if [ "$ABC" = "ABC" ]; then 1843 AC_UPPERCASE="$AC_TR a-z A-Z" 1844 AC_UPPER_PAT="A-Z" 1845 else 1846 ABC=`echo abc | tr '[a-z]' '[A-Z]'` 1847 if [ "$ABC" = "ABC" ]; then 1848 AC_UPPERCASE="$AC_TR '[a-z]' '[A-Z]'" 1849 AC_UPPER_PAT="'[A-Z]'" 1850 else 1851 AC_FAIL "$AC_TR cannot translate lowercase to uppercase" 1852 return 0 1853 fi 1854 fi 1855 fi 1856 else 1857 AC_FAIL "configure requires a functional version of tr" 1858 fi 1859 1860 while [ $# -gt 0 ]; do 1861 unset matched 1862 1863 case X"$1" in 1864 X--src|X--srcdir) 1865 AC_SRCDIR=`__ac_dir "$2"` 1866 _set_srcdir=1 1867 shift 2;; 1868 1869 X--src=*|X--srcdir=*) 1870 __d=`echo "$1" | sed -e 's/^[^=]*=//'` 1871 AC_SRCDIR=`__ac_dir "$__d"` 1872 _set_srcdir=1 1873 shift 1 ;; 1874 1875 X--prefix) 1876 AC_PREFIX=`__ac_dir "$2"` 1877 _set_prefix=1 1878 shift 2;; 1879 1880 X--prefix=*) 1881 __d=`echo "$1"| sed -e 's/^[^=]*=//'` 1882 AC_PREFIX=`__ac_dir "$__d"` 1883 _set_prefix=1 1884 shift 1;; 1885 1886 X--confdir) 1887 AC_CONFDIR=`__ac_dir "$2"` 1888 _set_confdir=1 1889 shift 2;; 1890 1891 X--confdir=*) 1892 __d=`echo "$1" | sed -e 's/^[^=]*=//'` 1893 AC_CONFDIR=`__ac_dir "$__d"` 1894 _set_confdir=1 1895 shift 1;; 1896 1897 X--libexec|X--libexecdir) 1898 AC_LIBEXEC=`__ac_dir "$2"` 1899 _set_libexec=1 1900 shift 2;; 1901 1902 X--libexec=*|X--libexecdir=*) 1903 __d=`echo "$1" | sed -e 's/^[^=]*=//'` 1904 AC_LIBEXEC=`__ac_dir "$__d"` 1905 _set_libexec=1 1906 shift 1;; 1907 1908 X--lib|X--libdir) 1909 AC_LIBDIR=`__ac_dir "$2"` 1910 _set_libdir=1 1911 shift 2;; 1912 1913 X--lib=*|X--libdir=*) 1914 __d=`echo "$1" | sed -e 's/^[^=]*=//'` 1915 AC_LIBDIR=`__ac_dir "$__d"` 1916 _set_libdir=1 1917 shift 1;; 1918 1919 X--exec|X--execdir) 1920 AC_EXECDIR=`__ac_dir "$2"` 1921 _set_execdir=1 1922 shift 2;; 1923 1924 X--exec=*|X--execdir=*) 1925 __d=`echo "$1" | sed -e 's/^[^=]*=//'` 1926 AC_EXECDIR=`__ac_dir "$__d"` 1927 _set_execdir=1 1928 shift 1;; 1929 1930 X--sbin|X--sbindir) 1931 AC_SBINDIR=`__ac_dir "$2"` 1932 _set_sbindir=1 1933 shift 2;; 1934 1935 X--sbin=*|X--sbindir=*) 1936 __d=`echo "$1" | sed -e 's/^[^=]*=//'` 1937 AC_SBINDIR=`__ac_dir "$__d"` 1938 _set_sbindir=1 1939 shift 1;; 1940 1941 X--man|X--mandir) 1942 AC_MANDIR=`__ac_dir "$2"` 1943 _set_mandir=1 1944 shift 2;; 1945 1946 X--man=*|X--mandir=*) 1947 __d=`echo "$1" | sed -e 's/^[^=]*=//'` 1948 AC_MANDIR=`__ac_dir "$__d"` 1949 _set_mandir=1 1950 shift 1;; 1951 1952 X--use-*=*) 1953 _var=`echo "$1"| sed -n 's/^--use-\([A-Za-z][-A-Za-z0-9_]*\)=.*$/\1/p'` 1954 if [ "$_var" ]; then 1955 _val=`echo "$1" | sed -e 's/^--use-[^=]*=\(.*\)$/\1/'` 1956 _v=`echo $_var | $AC_UPPERCASE | tr '-' '_'` 1957 case X"$_val" in 1958 X[Yy][Ee][Ss]|X[Tt][Rr][Uu][Ee]) eval USE_${_v}=T ;; 1959 X[Nn][Oo]|X[Ff][Aa][Ll][Ss][Ee]) eval unset USE_${_v} ;; 1960 *) echo "Bad value for --use-$_var ; must be yes or no" 1961 exit 1 ;; 1962 esac 1963 else 1964 echo "Bad option $1. Use --help to show options" 1>&2 1965 exit 1 1966 fi 1967 shift 1 ;; 1968 1969 X--use-*) 1970 _var=`echo "$1"|sed -n 's/^--use-\([A-Za-z][-A-Za-z0-9_]*\)$/\1/p'` 1971 _v=`echo $_var | $AC_UPPERCASE | tr '-' '_'` 1972 eval USE_${_v}=T 1973 shift 1;; 1974 1975 X--with-*=*) 1976 _var=`echo "$1"| sed -n 's/^--with-\([A-Za-z][-A-Za-z0-9_]*\)=.*$/\1/p'` 1977 if [ "$_var" ]; then 1978 _val=`echo "$1" | sed -e 's/^--with-[^=]*=\(.*\)$/\1/'` 1979 _v=`echo $_var | $AC_UPPERCASE | tr '-' '_'` 1980 eval WITH_${_v}=\"$_val\" 1981 else 1982 echo "Bad option $1. Use --help to show options" 1>&2 1983 exit 1 1984 fi 1985 shift 1 ;; 1986 1987 X--with-*) 1988 _var=`echo "$1" | sed -n 's/^--with-\([A-Za-z][A-Za-z0-9_-]*\)$/\1/p'` 1989 if [ "$_var" ]; then 1990 _v=`echo $_var | $AC_UPPERCASE | tr '-' '_'` 1991 eval WITH_${_v}=1 1992 else 1993 echo "Bad option $1. Use --help to show options" 1>&2 1994 exit 1 1995 fi 1996 shift 1 ;; 1997 1998 X--help) 1999 echo "$ac_standard" 2000 test "$ac_help" && echo "$ac_help" 2001 exit 0;; 2002 2003 *) if [ "$LOCAL_AC_OPTIONS" ]; then 2004 eval "$LOCAL_AC_OPTIONS" 2005 else 2006 ac_error=T 2007 fi 2008 if [ "$ac_error" ]; then 2009 echo "Bad option $1. Use --help to show options" 1>&2 2010 exit 1 2011 fi ;; 2012 esac 2013 done 2014