dnl Process this file with autoconf to produce a configure script. AC_INIT(crawl.c) AC_CONFIG_SRCDIR(crawl.c) AC_CANONICAL_SYSTEM AM_INIT_AUTOMAKE(crawl, 0.4) AM_CONFIG_HEADER(config.h) dnl Initialize prefix. if test "$prefix" = "NONE"; then prefix="/usr/local" fi dnl Checks for programs. AC_PROG_CC AC_PROG_INSTALL dnl solaris sux. AC_MSG_CHECKING(if we may use "-I/usr/include") case "$target" in *-*-solaris*|*-*-sunos*) USRINCLUDE="" AC_MSG_RESULT(no) ;; *-*-linux*) USRINCLUDE="" AC_MSG_RESULT(no) ;; *) USRINCLUDE="-I/usr/include/" AC_MSG_RESULT(yes) ;; esac AC_SUBST(USRINCLUDE) dnl Checks for libraries. dnl Checks for libevent AC_MSG_CHECKING(for libevent) AC_ARG_WITH(libevent, [ --with-libevent=DIR use libevent build directory], [ case "$withval" in yes|no) AC_MSG_RESULT(no) ;; *) AC_MSG_RESULT($withval) if test -f $withval/event.h -a -f $withval/libevent.a; then owd=`pwd` if cd $withval; then withval=`pwd`; cd $owd; fi EVENTINC="-I$withval" EVENTLIB="-L$withval -levent" else AC_ERROR(event.h or libevent.a not found in $withval) fi ;; esac ], [ if test -f ${prefix}/include/event.h; then EVENTINC="-I${prefix}/include" EVENTLIB="-L${prefix}/lib -levent" elif test -f /usr/include/event/event.h; then EVENTINC="-I/usr/include/event" EVENTLIB="-levent" elif test -f /usr/include/event.h; then EVENTLIB="-levent" else AC_MSG_RESULT(no) AC_ERROR(libevent not found) fi AC_MSG_RESULT(yes) ] ) AC_SUBST(EVENTINC) AC_SUBST(EVENTLIB) dnl Checks for Berkeley DB AC_MSG_CHECKING(for Berkeley DB with 1.85 compatibility) AC_ARG_WITH(db, [ --with-db=DIR use Berkeley DB (with --enable-compat185) in DIR], [ case "$withval" in yes|no) AC_MSG_RESULT(no) ;; *) AC_MSG_RESULT($withval) if test -f $withval/build_unix/db_185.h -a \ -f $withval/build_unix/libdb.a; then owd=`pwd` if cd $withval; then withval=`pwd`; cd $owd; fi AC_DEFINE(HAVE_DB_185_H, 1, [Define if your libdb has 1.85 compat]) DBINC="-I$withval/build_unix" DBLIB="-L$withval/build_unix -ldb" elif test -f $withval/dist/db_185.h -a \ -f $withval/dist/libdb.a; then owd=`pwd` if cd $withval; then withval=`pwd`; cd $owd; fi AC_DEFINE(HAVE_DB_185_H, 1, [Define if your libdb has 1.85 compat]) DBINC="-I$withval/dist" DBLIB="-L$withval/dist -ldb" elif test -f $withval/include/db_185.h -a \ -f $withval/lib/libdb.a; then owd=`pwd` if cd $withval; then withval=`pwd`; cd $owd; fi AC_DEFINE(HAVE_DB_185_H, 1, [Define if your libdb has 1.85 compat]) DBINC="-I$withval/include" DBLIB="-L$withval/lib -ldb" else AC_ERROR(db_185.h or libdb.a not found in $withval or not configured with --enable-compat185) fi ;; esac ], [ for dir in ${prefix}/BerkeleyDB.3.1 ${prefix}/BerkeleyDB.3.0 \ ${prefix}/BerkeleyDB ${prefix}/db ${prefix}; do if test -f ${dir}/include/db_185.h; then AC_DEFINE(HAVE_DB_185_H, 1, [Define if your libdb has 1.85 compat]) DBINC="-I${dir}/include" DBLIB="-L${dir}/lib -ldb" have_db=yes break elif test -f ${dir}/include/db.h; then AC_DEFINE(HAVE_DB_H, 1, [Define if your system has libdb]) DBINC="-I${dir}/include" DBLIB="-L${dir}/lib -ldb" have_db=yes break fi done if test "x$have_db" = "x"; then if test -f /usr/local/include/db41/db_185.h; then AC_DEFINE(HAVE_DB_185_H, 1, [Define if your libdb has 1.85 compat]) DBINC="-I/usr/local/include/db41" DBLIB="-ldb41" have_db=yes elif test -f /usr/include/db_185.h; then AC_DEFINE(HAVE_DB_185_H, 1, [Define if your libdb has 1.85 compat]) DBLIB="-ldb" have_db=yes elif test -f /usr/include/db.h; then AC_DEFINE(HAVE_DB_H, 1, [Define if your system has libdb]) have_db=yes fi fi if test "x$have_db" = "x"; then AC_ERROR(Berkeley DB with 1.85 compatibility not found) fi AC_MSG_RESULT(yes) ] ) AC_SUBST(DBINC) AC_SUBST(DBLIB) dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(libgen.h unistd.h sys/time.h sys/queue.h) if test "x$ac_cv_header_sys_queue_h" = "xyes"; then AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h) AC_EGREP_CPP(yes, [ #include #ifdef TAILQ_FOREACH yes #endif ], [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_TAILQFOREACH, 1, [Define if queue.h defines TAILQFOREEACH]) ], AC_MSG_RESULT(no) ) fi if test "x$ac_cv_header_sys_queue_h" = "xyes"; then AC_MSG_CHECKING(for LIST_FIRST in sys/queue.h) AC_EGREP_CPP(yes, [ #include #ifdef LIST_FIRST yes #endif ], [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_LISTFIRST,1, [Define if queue.h has LISTFIRST]) ], AC_MSG_RESULT(no) ) fi dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_SIZE_T AC_CHECK_TYPE(u_int64_t, unsigned long long) AC_CHECK_TYPE(u_int32_t, unsigned int) AC_CHECK_TYPE(u_int16_t, unsigned short) AC_CHECK_TYPE(u_int8_t, unsigned char) AC_HEADER_TIME dnl XXX - Solaris sux. AC_CHECK_LIB(socket, socket) dnl Checks for library functions. AC_CHECK_FUNCS(gettimeofday memmove memset strcasecmp strchr strdup strncasecmp) AC_REPLACE_FUNCS(basename dirname getaddrinfo strlcat strlcpy strsep inet_aton) if test "x$ac_cv_func_basename" = "xyes"; then AC_MSG_CHECKING(for working basename) AC_TRY_RUN( #include #include int main(int argc, char **argv) { char *name = "solaris/sucks"; char *p; int len = strlen(name); p = basename(name); exit(len != strlen(name)); }, AC_MSG_RESULT(yes), [ AC_MSG_RESULT(no) AC_LIBOBJ([basename]) ], AC_MSG_RESULT(yes)) fi if test "x$ac_cv_func_dirname" = "xyes"; then AC_MSG_CHECKING(for working dirname) AC_TRY_RUN( #include #include int main(int argc, char **argv) { char *name = "solaris/sucks"; char *p; int len = strlen(name); p = dirname(name); exit(len != strlen(name)); }, AC_MSG_RESULT(yes), [ AC_MSG_RESULT(no) AC_LIBOBJ([dirname]) ], AC_MSG_RESULT(yes)) fi needmd5=no AC_MSG_CHECKING([for md5 in libc]) AC_TRY_LINK([ #include #include ],[ MD5_CTX ctx; MD5Init(&ctx); MD5Update(&ctx, "a", 1); MD5Final((void *)0, &ctx); ], AC_MSG_RESULT([yes]), [AC_MSG_RESULT([no]) needmd5=yes]) if test $needmd5 = yes; then AC_LIBOBJ([md5]) fi neederr=no AC_CHECK_FUNCS(warnx, , [neederr=yes]) if test $neederr = yes; then AC_LIBOBJ([err]) fi AC_MSG_CHECKING([for struct addrinfo in netdb.h]) AC_EGREP_HEADER(addrinfo, netdb.h, [ AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1, [Define if struct addrinfo exists]) AC_MSG_RESULT([yes])], AC_MSG_RESULT([no]) ) AC_MSG_CHECKING([for socklen_t]) AC_TRY_COMPILE([ #include #include ], [socklen_t x;], AC_MSG_RESULT([yes]), [AC_MSG_RESULT([no]) AC_DEFINE(socklen_t, int, [Define to int if socklen_t does not exist])] ) AC_MSG_CHECKING([for NI_MAXSERV]) AC_TRY_COMPILE([ #include #include #include ], [char x[NI_MAXSERV];], AC_MSG_RESULT([yes]), [AC_MSG_RESULT([no]) AC_DEFINE(NI_MAXSERV, 32, [Define to 32 if NI_MAXSERV does not exist])] ) AC_MSG_CHECKING([for timeradd in sys/time.h]) AC_EGREP_CPP(yes, [ #include #ifdef timeradd yes #endif ], [ AC_DEFINE(HAVE_TIMERADD, 1, [Define if your system has timeradd]) AC_MSG_RESULT([yes])], AC_MSG_RESULT([no]) ) AC_OUTPUT(Makefile)