# yee ole top level info stuff AM_INIT_AUTOMAKE(logtool,1.3.1) # make sure we got a C compiler and set $(CC) AM_PROG_CC_STDC # process this file with autoconf to produce a configure script. AC_INIT(src/logtool.c) # Checks for programs. AC_PROG_CC # our default --prefix AC_PREFIX_DEFAULT(/usr) # We want the sysconfdir to be /etc/logtool unless the user explicitly specified otherwise AC_SUBST(sysconfdir) if test "`echo "$sysconfdir" | grep "prefix"`" ; then sysconfdir=`echo $sysconfdir/logtool | sed s/'${prefix}'/""/g` else sysconfdir=$sysconfdir fi # monkey business for install (why doesn't configure do this sanely by default? why? AC_PROG_INSTALL AC_SUBST(installprog) installprog="$INSTALL" AC_SUBST(version) version=1.3.1 # a bunch of stuff we're going to replace for our Makefile.in so it makes some sense. AC_SUBST(INCLUDES) AC_SUBST(DB_INCLUDES) AC_SUBST(DB_LIBS) AC_SUBST(DB_OBJS) AC_SUBST(DB_FILE) AC_SUBST(DB_PATH) # by default, we want to use --with-gdbm - try to autodetect it DB_OBJS="" DB_LIBS="" DB_FILE="" DB_INCLUDES="" AC_CHECK_HEADERS(gdbm.h, [ AC_CHECK_LIB(gdbm, gdbm_open, [ DB_OBJS="db_gdbm.o" DB_LIBS="-lgdbm" DB_FILE="/tmp/iphost.gdbm" DB_INCLUDES="" ], [ AC_MSG_WARN([Could not autodetect GDBM: perhaps you need to use --with-gdbm=]) ]) ], []) # our resolver stuff AC_ARG_WITH(resolver, [ --without-resolver Build without the IP address resolution modules ], [ if test "$withval" = "no" ; then AC_DEFINE(NO_RESOLVER) NO_RESOLVER="yes" fi ]) # our optional args AC_ARG_WITH(dnsdb, [ --with-dnsdb=/path/file Specify a file to use for DNS name caching other than the default of /tmp/iphost.gdbm. ], [ if test "$withval" = "yes" ; then AC_MSG_ERROR([Fatal Error: you must supply a path and filename as a value.]) else DB_FILE="`echo "$withval" | sed -e 's/:/ /g'`" if test -d $DB_FILE ; then AC_MSG_ERROR([Fatal Error: you may not specify a directory as a filename.]) fi if test -f $DB_FILE ; then echo "WARNING: $DB_FILE already exists!" sleep 5 fi fi ]) AC_ARG_WITH(gdbm, [ --with-gdbm Build the DNS caching module to use GNU's GDBM databse library. (enabled by default if -lgdbm can be found). ], [ if test "$withval" = "no" ; then DB_INCLUDES="" DB_LIBS="" DB_OBJS="" else AC_DEFINE(WE_USE_GDBM) DB_LIBS="-lgdbm" DB_OBJS="db_gdbm.o" DB_PATH="" DB_INCLUDES="" DB_PATH=`echo "$withval" | sed -e 's/:/ /g'` if test "$DB_PATH" != "yes" ; then DB_INCLUDES="-I../$DB_PATH" DB_LIBS="-L../$DB_PATH -lgdbm" else DB_INCLUDES="$DB_INCLUDES" DB_LIBS="-lgdbm" fi DB_OBJS="db_gdbm.o" AC_CHECK_HEADERS(gdbm.h, [], [AC_MSG_ERROR([Fatal Error: missing header file gdbm.h])]) AC_CHECK_LIB(gdbm, gdbm_open, [], [AC_MSG_ERROR([Fatal Error: cannot link with -lgdbm])]) fi ], [ DB_OBJS="$DB_OBJS" ]) AC_PROG_LN_S AC_PROG_MAKE_SET AC_HEADER_STDC dnl Checks for header files. AC_CHECK_HEADERS(unistd.h sysexits.h regex.h time.h, [ ], [ AC_MSG_ERROR([Fatal Error: required header file missing.]) ]) # -lnsl -lm AC_CHECK_FUNCS(inet_addr, [], [ AC_CHECK_LIB(nsl, inet_addr, [ LIBS="-lnsl $LIBS" ], [ AC_CHECK_LIB(m, inet_addr, [ LIBS="-lm $LIBS" ], [ AC_MSG_WARN([Warning: unable to find inet_addr - resolver disabled]) AC_DEFINE(NO_RESOLVER) NO_RESOLVER="yes" ]) ]) ]) AC_CHECK_FUNCS(gethostbyaddr, [], [ AC_CHECK_LIB(nsl, gethostbyaddr, [ tvar="`echo $LIBS | grep lnsl`" if test "$tavr" != "" ; then LIBS="-lnsl $LIBS" fi ], [ AC_CHECK_LIB(m, gethostbyaddr, [ tvar="`echo $LIBS | grep lm`" if test "$tavr" != "" ; then LIBS="-lm $LIBS" fi ], [ AC_MSG_WARN([Warning: unable to find gethostbyaddr - resolver disabled]) AC_DEFINE(NO_RESOLVER) NO_RESOLVER="yes" ]) ]) ] []) dnl this isn't a fatal error, as we can use our own copy (we hope :) AC_CHECK_HEADERS(getopt.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_SIZE_T dnl Checks for library functions. AC_CHECK_FUNCS(strncasecmp, [], [ AC_MSG_ERROR([Fatal Error: strncasecmp not available]) ]) AC_CHECK_FUNCS(regcomp regexec regfree, [], [ AC_MSG_ERROR([Fatal Error: regex library functions nonstandard/incomplete]) ]) AC_CHECK_FUNCS(setenv, [ AC_DEFINE(HAVE_SETENV) ], []) if test "$NO_RESOLVER" = "yes" ; then DB_OBJS="" DB_LIBS="" DB_INCLUDES="" DB_FILE="" fi if test "$DB_OBJS" = "db_gdbm.o" ; then AC_DEFINE(WE_USE_GDBM) fi AC_CONFIG_HEADER(config.h) AC_OUTPUT(logtool.spec src/config.h src/Makefile Makefile conf/logtool.conf doc/logtool.1 doc/logtool.txt) echo " Build was configured as follows: Prefix: $prefix Configuration files wil be placed in: $sysconfdir Binaries will be placed in: $prefix/bin Using this install program: $installprog We will use the following compiler: $CC With the following CFLAGS: $CFLAGS With the following DEFS: $DEFS With the following LIBS: $LIBS Using the following DB libraries: $DB_OBJS $DB_LIBS $DB_INCLUDES And the following DB_FILE placement: $DB_FILE"