Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'config'

* config:
  config: more config stuff to config/ subdir, call it from Makefile.
  Initial import of configure.sh
  • Loading branch information...
commit bf6e0c48f278f3ea9917a7704ef5770a84cdb1b7 2 parents 081ca80 + 9fd2cd5
apenwarr authored
8 Makefile
@@ -57,11 +57,17 @@ install: all
57 57
58 58 %/clean:
59 59 $(MAKE) -C $* clean
  60 +
  61 +config/config.h: config/Makefile config/configure config/configure.inc \
  62 + $(wildcard config/*.in)
  63 + cd config && make config.h
60 64
61 65 lib/bup/_helpers$(SOEXT): \
  66 + config/config.h \
62 67 lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py
63 68 @rm -f $@
64   - cd lib/bup && LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" $(PYTHON) csetup.py build
  69 + cd lib/bup && \
  70 + LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" $(PYTHON) csetup.py build
65 71 cp lib/bup/build/*/_helpers$(SOEXT) lib/bup/
66 72
67 73 .PHONY: lib/bup/_version.py
7 config/.gitignore
... ... @@ -0,0 +1,7 @@
  1 +config.cmd
  2 +config.h
  3 +config.log
  4 +config.mak
  5 +config.md
  6 +config.sub
  7 +config.vars
8 config/Makefile
... ... @@ -0,0 +1,8 @@
  1 +-include config.vars
  2 +
  3 +config.h: configure configure.inc $(wildcard *.in)
  4 + ./configure
  5 +
  6 +clean:
  7 + rm -f ${CONFIGURE_FILES} ${GENERATED_FILES}
  8 + rm -f *~ .*~
2  config/config.vars.in
... ... @@ -0,0 +1,2 @@
  1 +CONFIGURE_FILES=@CONFIGURE_FILES@
  2 +GENERATED_FILES=@GENERATED_FILES@
57 config/configure
... ... @@ -0,0 +1,57 @@
  1 +#!/bin/sh
  2 +
  3 +TARGET=bup
  4 +
  5 +. ./configure.inc
  6 +
  7 +AC_INIT $TARGET
  8 +
  9 +if ! AC_PROG_CC; then
  10 + LOG " You need to have a functional C compiler to build $TARGET"
  11 + exit 1
  12 +fi
  13 +
  14 +TLOGN "checking the GNU make"
  15 +MAKE=`acLookFor make`
  16 +if [ -z "$MAKE" ]; then
  17 + AC_FAIL " Cannot find make";
  18 +fi
  19 +
  20 +MAKE_GNU=`$MAKE --version | grep "GNU Make"`
  21 +if [ -z "$MAKE_GNU" ]; then
  22 + AC_FAIL " $MAKE is not GNU Make"
  23 +fi
  24 +
  25 +MAKE_VERSION=`$MAKE --version | grep "GNU Make" | awk '{print $3}'`
  26 +if [ -z "$MAKE_VERSION" ]; then
  27 + AC_FAIL " $MAKE --version does not return sensible output?"
  28 +fi
  29 +expr "$MAKE_VERSION" '>=' '3.81' || AC_FAIL "$MAKE must be >= version 3.81"
  30 +TLOG " ok"
  31 +
  32 +TLOGN "checking the python"
  33 +PYTHON=`acLookFor python`
  34 +if [ -z "$PYTHON" ]; then
  35 + AC_FAIL " Cannot find python";
  36 +fi
  37 +TLOG " - you have some python program - ok"
  38 +
  39 +TLOGN "checking the git"
  40 +GIT=`acLookFor git`
  41 +if [ -z "$GIT" ]; then
  42 + AC_FAIL " Cannot find git";
  43 +fi
  44 +TLOG " - you have some git program - ok"
  45 +
  46 +
  47 +# assuming the above checks pass, get the path of everything
  48 +MF_PATH_INCLUDE GMAKE make gmake
  49 +MF_PATH_INCLUDE GIT git
  50 +MF_PATH_INCLUDE TAR tar gtar
  51 +MF_PATH_INCLUDE PYTHON python
  52 +
  53 +AC_CHECK_HEADERS sys/stat.h
  54 +AC_CHECK_FUNCS utimensat
  55 +AC_CHECK_FUNCS utime
  56 +
  57 +AC_OUTPUT config.vars
1,305 config/configure.inc
... ... @@ -0,0 +1,1305 @@
  1 +# @(#) configure.inc 1.40@(#)
  2 +# Copyright (c) 1999-2007 David Parsons. All rights reserved.
  3 +#
  4 +# Redistribution and use in source and binary forms, with or without
  5 +# modification, are permitted provided that the following conditions
  6 +# are met:
  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
  12 +# distribution.
  13 +# 3. My name may not be used to endorse or promote products derived
  14 +# from this software without specific prior written permission.
  15 +#
  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.
  28 +#
  29 +
  30 +
  31 +#
  32 +# this preamble code is executed when this file is sourced and it picks
  33 +# interesting things off the command line.
  34 +#
  35 +ac_default_path="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
  36 +
  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"
  45 +
  46 +__fail=exit
  47 +
  48 +if dirname B/A 2>/dev/null >/dev/null; then
  49 +__ac_dirname() {
  50 + dirname "$1"
  51 +}
  52 +else
  53 +__ac_dirname() {
  54 + echo "$1" | sed -e 's:/[^/]*$::'
  55 +}
  56 +fi
  57 +
  58 +ac_progname=$0
  59 +ac_configure_command=
  60 +Q=\'
  61 +for x in "$@"; do
  62 + ac_configure_command="$ac_configure_command $Q$x$Q"
  63 +done
  64 +# ac_configure_command="$*"
  65 +
  66 +__d=`__ac_dirname "$ac_progname"`
  67 +if [ "$__d" = "$ac_progname" ]; then
  68 + AC_SRCDIR=`pwd`
  69 +else
  70 + AC_SRCDIR=`cd $__d;pwd`
  71 +fi
  72 +
  73 +__ac_dir() {
  74 + if test -d "$1"; then
  75 + (cd "$1";pwd)
  76 + else
  77 + echo "$1";
  78 + fi
  79 +}
  80 +
  81 +while [ $# -gt 0 ]; do
  82 + unset matched
  83 +
  84 + case X"$1" in
  85 + X--src|X--srcdir)
  86 + AC_SRCDIR=`__ac_dir "$2"`
  87 + _set_srcdir=1
  88 + shift 2;;
  89 +
  90 + X--src=*|X--srcdir=*)
  91 + __d=`echo "$1" | sed -e 's/^[^=]*=//'`
  92 + AC_SRCDIR=`__ac_dir "$__d"`
  93 + _set_srcdir=1
  94 + shift 1 ;;
  95 +
  96 + X--prefix)
  97 + AC_PREFIX=`__ac_dir "$2"`
  98 + _set_prefix=1
  99 + shift 2;;
  100 +
  101 + X--prefix=*)
  102 + __d=`echo "$1"| sed -e 's/^[^=]*=//'`
  103 + AC_PREFIX=`__ac_dir "$__d"`
  104 + _set_prefix=1
  105 + shift 1;;
  106 +
  107 + X--confdir)
  108 + AC_CONFDIR=`__ac_dir "$2"`
  109 + _set_confdir=1
  110 + shift 2;;
  111 +
  112 + X--confdir=*)
  113 + __d=`echo "$1" | sed -e 's/^[^=]*=//'`
  114 + AC_CONFDIR=`__ac_dir "$__d"`
  115 + _set_confdir=1
  116 + shift 1;;
  117 +
  118 + X--libexec|X--libexecdir)
  119 + AC_LIBEXEC=`__ac_dir "$2"`
  120 + _set_libexec=1
  121 + shift 2;;
  122 +
  123 + X--libexec=*|X--libexecdir=*)
  124 + __d=`echo "$1" | sed -e 's/^[^=]*=//'`
  125 + AC_LIBEXEC=`__ac_dir "$__d"`
  126 + _set_libexec=1
  127 + shift 1;;
  128 +
  129 + X--lib|X--libdir)
  130 + AC_LIBDIR=`__ac_dir "$2"`
  131 + _set_libdir=1
  132 + shift 2;;
  133 +
  134 + X--lib=*|X--libdir=*)
  135 + __d=`echo "$1" | sed -e 's/^[^=]*=//'`
  136 + AC_LIBDIR=`__ac_dir "$__d"`
  137 + _set_libdir=1
  138 + shift 1;;
  139 +
  140 + X--exec|X--execdir)
  141 + AC_EXECDIR=`__ac_dir "$2"`
  142 + _set_execdir=1
  143 + shift 2;;
  144 +
  145 + X--exec=*|X--execdir=*)
  146 + __d=`echo "$1" | sed -e 's/^[^=]*=//'`
  147 + AC_EXECDIR=`__ac_dir "$__d"`
  148 + _set_execdir=1
  149 + shift 1;;
  150 +
  151 + X--sbin|X--sbindir)
  152 + AC_SBINDIR=`__ac_dir "$2"`
  153 + _set_sbindir=1
  154 + shift 2;;
  155 +
  156 + X--sbin=*|X--sbindir=*)
  157 + __d=`echo "$1" | sed -e 's/^[^=]*=//'`
  158 + AC_SBINDIR=`__ac_dir "$__d"`
  159 + _set_sbindir=1
  160 + shift 1;;
  161 +
  162 + X--man|X--mandir)
  163 + AC_MANDIR=`__ac_dir "$2"`
  164 + _set_mandir=1
  165 + shift 2;;
  166 +
  167 + X--man=*|X--mandir=*)
  168 + __d=`echo "$1" | sed -e 's/^[^=]*=//'`
  169 + AC_MANDIR=`__ac_dir "$__d"`
  170 + _set_mandir=1
  171 + shift 1;;
  172 +
  173 + X--use-*=*)
  174 + _var=`echo "$1"| sed -n 's/^--use-\([A-Za-z][-A-Za-z0-9_]*\)=.*$/\1/p'`
  175 + if [ "$_var" ]; then
  176 + _val=`echo "$1" | sed -e 's/^--use-[^=]*=\(.*\)$/\1/'`
  177 + _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
  178 + case X"$_val" in
  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"
  182 + exit 1 ;;
  183 + esac
  184 + else
  185 + echo "Bad option $1. Use --help to show options" 1>&2
  186 + exit 1
  187 + fi
  188 + shift 1 ;;
  189 +
  190 + X--use-*)
  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 '-' '_'`
  193 + eval USE_${_v}=T
  194 + shift 1;;
  195 +
  196 + X--with-*=*)
  197 + _var=`echo "$1"| sed -n 's/^--with-\([A-Za-z][-A-Za-z0-9_]*\)=.*$/\1/p'`
  198 + if [ "$_var" ]; then
  199 + _val=`echo "$1" | sed -e 's/^--with-[^=]*=\(.*\)$/\1/'`
  200 + _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
  201 + eval WITH_${_v}=\"$_val\"
  202 + else
  203 + echo "Bad option $1. Use --help to show options" 1>&2
  204 + exit 1
  205 + fi
  206 + shift 1 ;;
  207 +
  208 + X--with-*)
  209 + _var=`echo "$1" | sed -n 's/^--with-\([A-Za-z][A-Za-z0-9_-]*\)$/\1/p'`
  210 + if [ "$_var" ]; then
  211 + _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
  212 + eval WITH_${_v}=1
  213 + else
  214 + echo "Bad option $1. Use --help to show options" 1>&2
  215 + exit 1
  216 + fi
  217 + shift 1 ;;
  218 +
  219 + X--help)
  220 + echo "$ac_standard"
  221 + test "$ac_help" && echo "$ac_help"
  222 + exit 0;;
  223 +
  224 + *) if [ "$LOCAL_AC_OPTIONS" ]; then
  225 + eval "$LOCAL_AC_OPTIONS"
  226 + else
  227 + ac_error=T
  228 + fi
  229 + if [ "$ac_error" ]; then
  230 + echo "Bad option $1. Use --help to show options" 1>&2
  231 + exit 1
  232 + fi ;;
  233 + esac
  234 +done
  235 +
  236 +
  237 +#
  238 +# echo w/o newline
  239 +#
  240 +echononl()
  241 +{
  242 + ${ac_echo:-echo} "${@}$ac_echo_nonl"
  243 +}
  244 +
  245 +#
  246 +# log something to the terminal and to a logfile.
  247 +#
  248 +LOG () {
  249 + echo "$@"
  250 + echo "$@" 1>&5
  251 +}
  252 +
  253 +#
  254 +# log something to the terminal without a newline, and to a logfile with
  255 +# a newline
  256 +#
  257 +LOGN () {
  258 + echononl "$@" 1>&5
  259 + echo "$@"
  260 +}
  261 +
  262 +#
  263 +# log something to the terminal
  264 +#
  265 +TLOG () {
  266 + echo "$@" 1>&5
  267 +}
  268 +
  269 +#
  270 +# log something to the terminal, no newline
  271 +#
  272 +TLOGN () {
  273 + echononl "$@" 1>&5
  274 +}
  275 +
  276 +
  277 +#
  278 +# AC_CONTINUE tells configure not to bomb if something fails, but to
  279 +# continue blithely along
  280 +#
  281 +AC_CONTINUE () {
  282 + __fail="return"
  283 +}
  284 +
  285 +#
  286 +# Emulate gnu autoconf's AC_CHECK_HEADERS() function
  287 +#
  288 +AC_CHECK_HEADERS () {
  289 + AC_PROG_CC
  290 +
  291 + echo "/* AC_CHECK_HEADERS */" > /tmp/ngc$$.c
  292 + for hdr in $*; do
  293 + echo "#include <$hdr>" >> /tmp/ngc$$.c
  294 + done
  295 + echo "main() { }" >> /tmp/ngc$$.c
  296 +
  297 + LOGN "checking for header $hdr"
  298 +
  299 + if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c; then
  300 + AC_DEFINE 'HAVE_'`echo $hdr | tr 'a-z' 'A-Z' | tr './' '_'` 1
  301 + TLOG " (found)"
  302 + rc=0
  303 + else
  304 + TLOG " (not found)"
  305 + rc=1
  306 + fi
  307 + rm -f /tmp/ngc$$.c /tmp/ngc$$
  308 + return $rc
  309 +}
  310 +
  311 +
  312 +#
  313 +# emulate GNU autoconf's AC_CHECK_FUNCS function
  314 +#
  315 +AC_CHECK_FUNCS () {
  316 + AC_PROG_CC
  317 +
  318 +F=$1
  319 +shift
  320 +rm -f /tmp/ngc$$.c
  321 +
  322 +while [ "$1" ]; do
  323 + echo "#include <$1>" >> /tmp/ngc$$.c
  324 + shift
  325 +done
  326 +
  327 + cat >> /tmp/ngc$$.c << EOF
  328 +main()
  329 +{
  330 +
  331 + $F();
  332 +}
  333 +EOF
  334 +
  335 + LOGN "checking for the $F function"
  336 +
  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
  339 + TLOG " (found)"
  340 + rc=0
  341 + else
  342 + echo "offending command was:"
  343 + cat /tmp/ngc$$.c
  344 + echo "$AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $LIBS"
  345 + TLOG " (not found)"
  346 + rc=1
  347 + fi
  348 + rm -f /tmp/ngc$$.c /tmp/ngc$$
  349 + return $rc
  350 +}
  351 +
  352 +
  353 +#
  354 +# check to see if some structure exists
  355 +#
  356 +# usage: AC_CHECK_STRUCT structure {include ...}
  357 +#
  358 +AC_CHECK_STRUCT () {
  359 + AC_PROG_CC
  360 + struct=$1
  361 + shift
  362 +
  363 + rm -f /tmp/ngc$$.c
  364 +
  365 + for include in $*; do
  366 + echo "#include <$include>" >> /tmp/ngc$$.c
  367 + done
  368 +
  369 + cat >> /tmp/ngc$$.c << EOF
  370 +main()
  371 +{
  372 + struct $struct foo;
  373 +}
  374 +EOF
  375 +
  376 + LOGN "checking for struct $struct"
  377 +
  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'`
  380 + TLOG " (found)"
  381 + rc=0
  382 + else
  383 + TLOG " (not found)"
  384 + rc=1
  385 + fi
  386 + rm -f /tmp/ngc$$.c /tmp/ngc$$
  387 + return $rc
  388 +}
  389 +
  390 +
  391 +#
  392 +# check to see if some structure contains a field
  393 +#
  394 +# usage: AC_CHECK_FIELD structure field {include ...}
  395 +#
  396 +AC_CHECK_FIELD () {
  397 + AC_PROG_CC
  398 +
  399 + struct=$1
  400 + field=$2
  401 + shift 2
  402 +
  403 + rm -f /tmp/ngc$$.c
  404 +
  405 + for include in $*;do
  406 + echo "#include <$include>" >> /tmp/ngc$$.c
  407 + done
  408 +
  409 + cat >> /tmp/ngc$$.c << EOF
  410 +main()
  411 +{
  412 + struct $struct foo;
  413 +
  414 + foo.$field;
  415 +}
  416 +EOF
  417 +
  418 + LOGN "checking that struct $struct has a $field field"
  419 +
  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'`
  422 + TLOG " (yes)"
  423 + rc=0
  424 + else
  425 + TLOG " (no)"
  426 + rc=1
  427 + fi
  428 + rm -f /tmp/ngc$$.c /tmp/ngc$$
  429 + return $rc
  430 +}
  431 +
  432 +
  433 +#
  434 +# check that the C compiler works
  435 +#
  436 +AC_PROG_CC () {
  437 + test "$AC_CC" && return 0
  438 +
  439 + cat > /tmp/ngc$$.c << \EOF
  440 +#include <stdio.h>
  441 +main()
  442 +{
  443 + puts("hello, sailor");
  444 +}
  445 +EOF
  446 +
  447 + TLOGN "checking the C compiler"
  448 +
  449 + unset AC_CFLAGS AC_LDFLAGS
  450 +
  451 + if [ "$CC" ] ; then
  452 + AC_CC="$CC"
  453 + elif [ "$WITH_PATH" ]; then
  454 + AC_CC=`acLookFor cc`
  455 + elif [ "`acLookFor cc`" ]; then
  456 + # don't specify the full path if the user is looking in their $PATH
  457 + # for a C compiler.
  458 + AC_CC=cc
  459 + fi
  460 +
  461 + # finally check for POSIX c89
  462 + test "$AC_CC" || AC_CC=`acLookFor c89`
  463 +
  464 + if [ ! "$AC_CC" ]; then
  465 + TLOG " (no C compiler found)"
  466 + $__fail 1
  467 + fi
  468 + echo "checking out the C compiler"
  469 +
  470 + $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c
  471 + status=$?
  472 +
  473 + TLOGN " ($AC_CC)"
  474 + if [ $status -eq 0 ]; then
  475 + TLOG " ok"
  476 +
  477 + # check that the CFLAGS and LDFLAGS aren't bogus
  478 +
  479 + unset AC_CFLAGS AC_LDFLAGS
  480 +
  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}\""
  488 + fi
  489 + else
  490 + AC_CFLAGS=-g
  491 + fi
  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}\""
  499 + fi
  500 + else
  501 + AC_LDFLAGS=${CFLAGS:-"-g"}
  502 + fi
  503 + else
  504 + AC_FAIL " does not compile code properly"
  505 + fi
  506 +
  507 + AC_SUB 'CC' "$AC_CC"
  508 +
  509 + rm -f /tmp/ngc$$ /tmp/ngc$$.c /tmp/ngc$$.o
  510 +
  511 + return $status
  512 +}
  513 +
  514 +
  515 +#
  516 +# acLookFor actually looks for a program, without setting anything.
  517 +#
  518 +acLookFor () {
  519 + path=${AC_PATH:-$ac_default_path}
  520 + case "X$1" in
  521 + X-[rx]) __mode=$1
  522 + shift
  523 + ;;
  524 + *) __mode=-x
  525 + ;;
  526 + esac
  527 + oldifs="$IFS"
  528 + for program in $*; do
  529 + IFS=":"
  530 + for x in $path; do
  531 + if [ $__mode $x/$program -a -f $x/$program ]; then
  532 + echo $x/$program
  533 + break 2
  534 + fi
  535 + done
  536 + done
  537 + IFS="$oldifs"
  538 + unset __mode
  539 +}
  540 +
  541 +
  542 +#
  543 +# check that a program exists and set its path
  544 +#
  545 +MF_PATH_INCLUDE () {
  546 + SYM=$1; shift
  547 +
  548 + case X$1 in
  549 + X-[rx]) __mode=$1
  550 + shift
  551 + ;;
  552 + *) unset __mode
  553 + ;;
  554 + esac
  555 +
  556 + TLOGN "looking for $1"
  557 +
  558 + DEST=`acLookFor $__mode $*`
  559 +
  560 + __sym=`echo "$SYM" | tr '[a-z]' '[A-Z]'`
  561 + if [ "$DEST" ]; then
  562 + TLOG " ($DEST)"
  563 + echo "$1 is $DEST"
  564 + AC_MAK $SYM
  565 + AC_DEFINE PATH_$__sym \""$DEST"\"
  566 + AC_SUB $__sym "$DEST"
  567 + eval CF_$SYM=$DEST
  568 + return 0
  569 + else
  570 + #AC_SUB $__sym ''
  571 + echo "$1 is not found"
  572 + TLOG " (not found)"
  573 + return 1
  574 + fi
  575 +}
  576 +
  577 +
  578 +#
  579 +# AC_INIT starts the ball rolling
  580 +#
  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
  583 +#
  584 +AC_INIT () {
  585 + __config_files="config.cmd config.sub config.h config.mak config.log"
  586 + rm -f $__config_files
  587 + __cwd=`pwd`
  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
  590 +
  591 + # check to see whether to use echo -n or echo ...\c
  592 + #
  593 + echo -n hello > $$
  594 + echo world >> $$
  595 + if grep "helloworld" $$ >/dev/null; then
  596 + ac_echo="echo -n"
  597 + echo "[echo -n] works"
  598 + else
  599 + ac_echo="echo"
  600 + echo 'hello\c' > $$
  601 + echo 'world' >> $$
  602 + if grep "helloworld" $$ >/dev/null; then
  603 + ac_echo_nonl='\c'
  604 + echo "[echo ...\\c] works"
  605 + fi
  606 + fi
  607 + rm -f $$
  608 +
  609 + LOG "Configuring for [$1]"
  610 +
  611 + cat > $__cwd/config.h << EOF
  612 +/*
  613 + * configuration for $1${2:+" ($2)"}, generated `date`
  614 + * by ${LOGNAME:-`whoami`}@`hostname`
  615 + */
  616 +#ifndef $AC_CONFIGURE_FOR
  617 +#define $AC_CONFIGURE_FOR 1
  618 +
  619 +
  620 +EOF
  621 +
  622 + unset __share
  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
  626 + __share=/share
  627 + elif [ -d $AC_PREFIX/share/man/cat$t ]; then
  628 + __share=/share
  629 + fi
  630 + done
  631 + else
  632 + __share=
  633 + fi
  634 +
  635 + if [ -d $AC_PREFIX/libexec ]; then
  636 + __libexec=libexec
  637 + else
  638 + __libexec=lib
  639 + fi
  640 +
  641 +
  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}
  649 +
  650 + AC_PATH=${WITH_PATH:-$PATH}
  651 + AC_PROG_CPP
  652 + AC_PROG_INSTALL
  653 +
  654 + ac_os=`uname -s`
  655 + _os=`echo $ac_os | tr '[a-z]' '[A-Z]'`
  656 + AC_DEFINE OS_$_os 1
  657 + eval OS_${_os}=1
  658 + unset _os
  659 +}
  660 +
  661 +
  662 +#
  663 +# AC_LIBRARY checks to see if a given library exists and contains the
  664 +# given function.
  665 +# usage: AC_LIBRARY function library [alternate ...]
  666 +#
  667 +AC_LIBRARY() {
  668 + SRC=$1
  669 + shift
  670 +
  671 + __acllibs=
  672 + __aclhdrs=
  673 +
  674 + for x in "$@"; do
  675 + case X"$x" in
  676 + X-l*) __acllibs="$__acllibs $x" ;;
  677 + *) __aclhdrs="$__aclhdrs $x" ;;
  678 + esac
  679 + done
  680 +
  681 + # first see if the function can be found in any of the
  682 + # current libraries
  683 + AC_QUIET AC_CHECK_FUNCS $SRC $__aclhdrs && return 0
  684 +
  685 + # then search through the list of libraries
  686 + __libs="$LIBS"
  687 + for x in $__acllibs; do
  688 + LIBS="$__libs $x"
  689 + if AC_QUIET AC_CHECK_FUNCS $SRC $__aclhdrs; then
  690 + AC_LIBS="$AC_LIBS $x"
  691 + return 0
  692 + fi
  693 + done
  694 + return 1
  695 +}
  696 +
  697 +
  698 +#
  699 +# AC_PROG_LEX checks to see if LEX exists, and if it's lex or flex.
  700 +#
  701 +AC_PROG_LEX() {
  702 + TLOGN "looking for lex "
  703 +
  704 + DEST=`acLookFor lex`
  705 + if [ "$DEST" ]; then
  706 + AC_MAK LEX
  707 + AC_DEFINE PATH_LEX \"$DEST\"
  708 + AC_SUB 'LEX' "$DEST"
  709 + echo "lex is $DEST"
  710 + else
  711 + DEST=`acLookFor flex`
  712 + if [ "$DEST" ]; then
  713 + AC_MAK FLEX
  714 + AC_DEFINE 'LEX' \"$DEST\"
  715 + AC_SUB 'LEX', "$DEST"
  716 + echo "lex is $DEST"
  717 + else
  718 + AC_SUB LEX ''
  719 + echo "neither lex or flex found"
  720 + TLOG " (not found)"
  721 + return 1
  722 + fi
  723 + fi
  724 +
  725 + if AC_LIBRARY yywrap -ll -lfl; then
  726 + TLOG "($DEST)"
  727 + return 0
  728 + fi
  729 + TLOG "(no lex library found)"
  730 + return 1
  731 +}
  732 +
  733 +
  734 +#
  735 +# AC_PROG_YACC checks to see if YACC exists, and if it's bison or
  736 +# not.
  737 +#
  738 +AC_PROG_YACC () {
  739 +
  740 + TLOGN "looking for yacc "
  741 +
  742 + DEST=`acLookFor yacc`
  743 + if [ "$DEST" ]; then
  744 + AC_MAK YACC
  745 + AC_DEFINE PATH_YACC \"$DEST\"
  746 + AC_SUB 'YACC' "$DEST"
  747 + TLOG "($DEST)"
  748 + echo "yacc is $DEST"
  749 + else
  750 + DEST=`acLookFor bison`
  751 + if [ "$DEST" ]; then
  752 + AC_MAK BISON
  753 + AC_DEFINE 'YACC' \"$DEST\"
  754 + AC_SUB 'YACC' "$DEST -y"
  755 + echo "yacc is $DEST -y"
  756 + TLOG "($DEST -y)"
  757 + else
  758 + AC_SUB 'YACC' ''
  759 + echo "neither yacc or bison found"
  760 + TLOG " (not found)"
  761 + return 1
  762 + fi
  763 + fi
  764 + return 0
  765 +}
  766 +
  767 +
  768 +#
  769 +# AC_PROG_LN_S checks to see if ln exists, and, if so, if ln -s works
  770 +#
  771 +AC_PROG_LN_S () {
  772 + test "$AC_FIND_PROG" || AC_PROG_FIND
  773 +
  774 + test "$AC_FIND_PROG" || return 1
  775 +
  776 + TLOGN "looking for \"ln -s\""
  777 + DEST=`acLookFor ln`
  778 +
  779 + if [ "$DEST" ]; then
  780 + rm -f /tmp/b$$
  781 + $DEST -s /tmp/a$$ /tmp/b$$
  782 + if [ "`$AC_FIND_PROG /tmp/b$$ -type l -print`" ]; then
  783 + TLOG " ($DEST)"
  784 + echo "$DEST exists, and ln -s works"
  785 + AC_SUB 'LN_S' "$DEST -s"
  786 + rm -f /tmp/b$$
  787 + else
  788 + AC_SUB 'LN_S' ''
  789 + TLOG " ($DEST exists, but -s does not seem to work)"
  790 + echo "$DEST exists, but ln -s doesn't seem to work"
  791 + rm -f /tmp/b$$
  792 + return 1
  793 + fi
  794 + else
  795 + AC_SUB 'LN_S' ''
  796 + echo "ln not found"
  797 + TLOG " (not found)"
  798 + return 1
  799 + fi
  800 +}
  801 +
  802 +
  803 +#
  804 +# AC_PROG_FIND looks for the find program and sets the FIND environment
  805 +# variable
  806 +#
  807 +AC_PROG_FIND () {
  808 + if test -z "$AC_FIND_PROG"; then
  809 + MF_PATH_INCLUDE FIND find
  810 + rc=$?
  811 + AC_FIND_PROG=$DEST
  812 + return $rc
  813 + fi
  814 + return 0
  815 +}
  816 +
  817 +
  818 +#
  819 +# AC_PROG_AWK looks for the awk program and sets the AWK environment
  820 +# variable
  821 +#
  822 +AC_PROG_AWK () {
  823 + if test -z "$AC_AWK_PROG"; then
  824 + MF_PATH_INCLUDE AWK awk
  825 + rc=$?
  826 + AC_AWK_PROG=$DEST
  827 + return $rc
  828 + fi
  829 + return 0
  830 +}
  831 +
  832 +
  833 +#
  834 +# AC_PROG_SED looks for the sed program and sets the SED environment
  835 +# variable
  836 +#
  837 +AC_PROG_SED () {
  838 + if test -z "$AC_SED_PROG"; then
  839 + MF_PATH_INCLUDE SED sed
  840 + rc=$?
  841 + AC_SED_PROG=$DEST
  842 + return $rc
  843 + fi
  844 + return 0
  845 +}
  846 +
  847 +
  848 +#
  849 +# AC_HEADER_SYS_WAIT looks for sys/wait.h
  850 +#
  851 +AC_HEADER_SYS_WAIT () {
  852 + AC_CHECK_HEADERS sys/wait.h || return 1
  853 +}
  854 +
  855 +#
  856 +# AC_TYPE_PID_T checks to see if the pid_t type exists
  857 +#
  858 +AC_TYPE_PID_T () {
  859 + cat > /tmp/pd$$.c << EOF
  860 +#include <sys/types.h>
  861 +main() { pid_t me; }
  862 +EOF
  863 +
  864 + LOGN "checking for pid_t"
  865 +
  866 + if $AC_CC -c /tmp/pd$$.c -o /tmp/pd$$.o; then
  867 + TLOG " (found)"
  868 + rc=0
  869 + else
  870 + echo "typedef int pid_t;" >> $__cwd/config.h
  871 + TLOG " (not found)"
  872 + rc=1
  873 + fi
  874 + rm -f /tmp/pd$$.o /tmp/pd$$.c
  875 + return $rc
  876 +}
  877 +
  878 +
  879 +#
  880 +# AC_C_CONST checks to see if the compiler supports the const keyword
  881 +#
  882 +AC_C_CONST () {
  883 + cat > /tmp/pd$$.c << EOF
  884 +const char me=1;
  885 +EOF
  886 + LOGN "checking for \"const\" keyword"
  887 +
  888 + if $AC_CC -c /tmp/pd$$.c -o /tmp/pd$$.o; then
  889 + TLOG " (yes)"
  890 + rc=0
  891 + else
  892 + AC_DEFINE 'const' '/**/'
  893 + TLOG " (no)"
  894 + rc=1
  895 + fi
  896 + rm -f /tmp/pd$$.o /tmp/pd$$.c
  897 + return $rc
  898 +}
  899 +
  900 +
  901 +#
  902 +# AC_SCALAR_TYPES checks to see if the compiler can generate 2 and 4 byte ints.
  903 +#
  904 +AC_SCALAR_TYPES () {
  905 + cat > /tmp/pd$$.c << EOF
  906 +#include <stdio.h>
  907 +main()
  908 +{
  909 + unsigned long v_long;
  910 + unsigned int v_int;
  911 + unsigned short v_short;
  912 +
  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");
  917 + else
  918 + exit(1);
  919 +
  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");
  924 + else
  925 + exit(2);
  926 + puts("#define BYTE unsigned char");
  927 + exit(0);
  928 +}
  929 +EOF
  930 + rc=1
  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
  934 + rc=0
  935 + fi
  936 + fi
  937 + case "$rc" in
  938 + 0) TLOG "" ;;
  939 + *) TLOG " ** FAILED **" ;;
  940 + esac
  941 + rm -f /tmp/pd$$ /tmp/pd$$.c
  942 +}
  943 +
  944 +
  945 +#
  946 +# AC_OUTPUT generates makefiles from makefile.in's
  947 +#
  948 +AC_OUTPUT () {
  949 + cd $__cwd
  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"
  965 +
  966 + if [ -r config.sub ]; then
  967 + test "$AC_SED_PROG" || AC_PROG_SED
  968 + test "$AC_SED_PROG" || return 1
  969 +
  970 + echo >> config.h
  971 + echo "#endif/* ${AC_CONFIGURE_FOR} */" >> config.h
  972 +
  973 + rm -f config.cmd
  974 + Q=\'
  975 + cat - > config.cmd << EOF
  976 +#! /bin/sh
  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
  978 +EOF
  979 + chmod +x config.cmd
  980 +
  981 + __d=$AC_SRCDIR
  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"
  988 + else
  989 + LOG "WARNING: ${makefile}.in does not exist!"
  990 + fi
  991 + done
  992 + unset __d
  993 +
  994 + else
  995 + echo
  996 + fi
  997 +}
  998 +
  999 +#
  1000 +# AC_CHECK_FLOCK checks to see if flock() exists and if the LOCK_NB argument
  1001 +# works properly.
  1002 +#
  1003 +AC_CHECK_FLOCK() {
  1004 +
  1005 + AC_CHECK_HEADERS sys/types.h sys/file.h fcntl.h
  1006 +
  1007 + cat << EOF > $$.c
  1008 +#include <stdio.h>
  1009 +#include <sys/file.h>
  1010 +#include <sys/types.h>
  1011 +#include <fcntl.h>
  1012 +
  1013 +main()
  1014 +{
  1015 + int x = open("$$.c", O_RDWR, 0666);
  1016 + int y = open("$$.c", O_RDWR, 0666);
  1017 +
  1018 + if (flock(x, LOCK_EX) != 0)
  1019 + exit(1);
  1020 + if (flock(y, LOCK_EX|LOCK_NB) == 0)
  1021 + exit(1);
  1022 + exit(0);
  1023 +}
  1024 +EOF
  1025 +
  1026 + LOGN "checking for flock()"
  1027 + HAS_FLOCK=0
  1028 + if $AC_CC -o flock $$.c ; then
  1029 + if ./flock ; then
  1030 + LOG " (found)"
  1031 + HAS_FLOCK=1
  1032 + AC_DEFINE HAS_FLOCK
  1033 + else
  1034 + LOG " (bad)"
  1035 + fi
  1036 + else
  1037 + LOG " (no)"
  1038 + fi
  1039 +
  1040 + rm -f flock $$.c
  1041 +
  1042 + case "$HAS_FLOCK" in
  1043 + 0) return 1 ;;
  1044 + *) return 0 ;;
  1045 + esac
  1046 +}
  1047 +
  1048 +
  1049 +#
  1050 +# AC_CHECK_RESOLVER finds out whether the berkeley resolver is
  1051 +# present on this system.
  1052 +#
  1053 +AC_CHECK_RESOLVER () {
  1054 + AC_PROG_CC
  1055 +
  1056 + TLOGN "checking for the Berkeley resolver library"
  1057 +
  1058 + cat > /tmp/ngc$$.c << EOF
  1059 +#include <sys/types.h>
  1060 +#include <netinet/in.h>
  1061 +#include <arpa/nameser.h>
  1062 +#include <resolv.h>
  1063 +
  1064 +main()
  1065 +{
  1066 + char bfr[256];
  1067 +
  1068 + res_init();
  1069 + res_query("hello", C_IN, T_A, bfr, sizeof bfr);
  1070 +}
  1071 +EOF
  1072 +
  1073 + # first see if res_init() and res_query() actually exist...
  1074 +
  1075 + if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c; then
  1076 + __extralib=
  1077 + elif $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c -lresolv; then
  1078 + __extralib=-lresolv
  1079 + AC_LIBS="$AC_LIBS -lresolv"
  1080 + else
  1081 + TLOG " (not found)"
  1082 + rm -f /tmp/ngc$$.c
  1083 + return 1
  1084 + fi
  1085 +
  1086 + # if res_init() and res_query() actually exist, check to
  1087 + # see if the HEADER structure is defined ...
  1088 +
  1089 + cat > /tmp/ngc$$.c << EOF
  1090 +#include <sys/types.h>
  1091 +#include <netinet/in.h>
  1092 +#include <arpa/nameser.h>
  1093 +#include <resolv.h>
  1094 +
  1095 +main()
  1096 +{
  1097 + HEADER hhh;
  1098 + res_init();
  1099 +}
  1100 +EOF
  1101 +
  1102 + if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $__extralib; then
  1103 + TLOG " (found)"
  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
  1107 + else
  1108 + TLOG " (broken)"
  1109 + rm -f /tmp/ngc$$.c
  1110 + return 1
  1111 + fi
  1112 + rm -f /tmp/ngc$$.c
  1113 + return 0
  1114 +}
  1115 +
  1116 +
  1117 +#
  1118 +# AC_PROG_INSTALL finds the install program and guesses whether it's a
  1119 +# Berkeley or GNU install program
  1120 +#
  1121 +AC_PROG_INSTALL () {
  1122 +
  1123 + DEST=`acLookFor install`
  1124 +
  1125 + LOGN "checking for install"
  1126 + unset IS_BSD
  1127 + if [ "$DEST" ]; then
  1128 + # BSD install or GNU install? Let's find out...
  1129 + touch /tmp/a$$
  1130 +
  1131 + $DEST /tmp/a$$ /tmp/b$$
  1132 +
  1133 + if test -r /tmp/a$$; then
  1134 + LOG " ($DEST)"
  1135 + else
  1136 + IS_BSD=1
  1137 + LOG " ($DEST) bsd install"
  1138 + fi
  1139 + rm -f /tmp/a$$ /tmp/b$$
  1140 + else