diff --git a/acinclude.m4 b/acinclude.m4 index b8554a299b..4d77c31071 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -60,26 +60,24 @@ AC_DEFUN([AC_LBL_TYPE_SIGNAL], esac]]) dnl -dnl Determine which compiler we're using (cc or gcc) -dnl If using gcc, determine the version number -dnl If using cc, require that it support ansi prototypes -dnl If using gcc, use -O2 (otherwise use -O) -dnl If using cc, explicitly specify /usr/local/include +dnl Do whatever AC_LBL_C_INIT work is necessary before using AC_PROG_CC. dnl -dnl usage: +dnl It appears that newer versions of autoconf (2.64 and later) will, +dnl if you use AC_TRY_COMPILE in a macro, stick AC_PROG_CC at the +dnl beginning of the macro, even if the macro itself calls AC_PROG_CC. +dnl See the "Prerequisite Macros" and "Expanded Before Required" sections +dnl in the Autoconf documentation. dnl -dnl AC_LBL_C_INIT(copt, incls) +dnl This causes a steaming heap of fail in our case, as we were, in +dnl AC_LBL_C_INIT, doing the tests we now do in AC_LBL_C_INIT_BEFORE_CC, +dnl calling AC_PROG_CC, and then doing the tests we now do in +dnl AC_LBL_C_INIT. Now, we run AC_LBL_C_INIT_BEFORE_CC, AC_PROG_CC, +dnl and AC_LBL_C_INIT at the top level. dnl -dnl results: -dnl -dnl $1 (copt set) -dnl $2 (incls set) -dnl CC -dnl LDFLAGS -dnl LBL_CFLAGS -dnl -AC_DEFUN([AC_LBL_C_INIT], +dnl Borrowed from libpcap-1.1.1 by Gregor +AC_DEFUN([AC_LBL_C_INIT_BEFORE_CC], [AC_PREREQ(2.12) + AC_BEFORE([$0], [AC_LBL_C_INIT]) AC_BEFORE([$0], [AC_PROG_CC]) AC_BEFORE([$0], [AC_LBL_FIXINCLUDES]) AC_BEFORE([$0], [AC_LBL_DEVEL]) @@ -108,7 +106,31 @@ AC_DEFUN([AC_LBL_C_INIT], CC=cc export CC fi - AC_PROG_CC +]) + +dnl +dnl Determine which compiler we're using (cc or gcc) +dnl If using gcc, determine the version number +dnl If using cc, require that it support ansi prototypes +dnl If using gcc, use -O2 (otherwise use -O) +dnl If using cc, explicitly specify /usr/local/include +dnl +dnl usage: +dnl +dnl AC_LBL_C_INIT(copt, incls) +dnl +dnl results: +dnl +dnl $1 (copt set) +dnl $2 (incls set) +dnl CC +dnl LDFLAGS +dnl LBL_CFLAGS +dnl +AC_DEFUN([AC_LBL_C_INIT], + [AC_PREREQ(2.12) + AC_BEFORE([$0], [AC_LBL_FIXINCLUDES]) + AC_BEFORE([$0], [AC_LBL_DEVEL]) if test "$GCC" != yes ; then AC_MSG_CHECKING(that $CC handles ansi prototypes) AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes, diff --git a/configure.in b/configure.in index 16c1113a3a..65b30a1448 100644 --- a/configure.in +++ b/configure.in @@ -30,6 +30,8 @@ AC_CANONICAL_SYSTEM #AM_INIT_AUTOMAKE(bro, 0.1.0) AM_INIT_AUTOMAKE(bro, esyscmd([tr -d '\n' < VERSION])) AM_CONFIG_HEADER(config.h) +AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS) +AC_PROG_CC AC_LBL_C_INIT(V_CCOPT, V_INCLS) AM_PROG_LEX @@ -136,6 +138,20 @@ AC_LBL_ENABLE_CHECK([activemapping binpac broccoli brov6 debug \ expire-dfa-states gtk-doc int64 openssl perftools perl \ select-loop shippedpcap broctl cluster nbdns]) +dnl ################################################ +dnl # Writing around broken autoconf +dnl ################################################ +dnl It seems that AC_CHECK_HEADER defines a bash function called +dnl ac_fn_c_check_header_compile in the output when it is first +dnl encountered. While in general a neat idea, this fails, if the +dnl first use of AC_CHECK_HEADER is in an if/else clause. In this +dnl case the function's scope is limited to the enclosing if/els +dnl block and later calls to the function fail (more or less silently) +dnl Solution: we just place a phony AC_CHECK_HEADER call here. +AC_CHECK_HEADER([stdio.h]) +AC_CHECK_HEADERS([stdio.h stdio.h]) + + dnl ################################################ dnl # OpenSSL dnl ################################################ @@ -168,9 +184,9 @@ if test "$use_openssl" = "yes"; then # (CHECK_HEADER doesn't work here) saved_cflags="${CFLAGS}" CFLAGS="${CFLAGS} -I${OPENSSL}/include" - AC_COMPILE_IFELSE([#include ],, + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include ]])],, CFLAGS="${CFLAGS} -I/usr/kerberos/include" - AC_CHECK_HEADER(krb5.h, + AC_CHECK_HEADER([krb5.h], V_INCLS="${V_INCLS} -I/usr/kerberos/include" AC_DEFINE(NEED_KRB5_H,,[Include krb5.h]), use_openssl=no @@ -188,7 +204,7 @@ if test "$use_openssl" = "yes"; then saved_libs="${LIBS}" LIBS="${LIBS} -lssl -lcrypto" AC_MSG_CHECKING([for OpenSSL >= 0.9.7]) - AC_LINK_IFELSE(AC_LANG_PROGRAM([[#include ]], [[OPENSSL_add_all_algorithms_conf();]]), + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[OPENSSL_add_all_algorithms_conf();]])], AC_MSG_RESULT(yes) use_openssl=yes, AC_MSG_RESULT(no) @@ -212,9 +228,9 @@ if test "$use_openssl" = "yes"; then AC_MSG_CHECKING([whether d2i_X509() uses a const unsigned char**]) AC_LANG_PUSH([C++]) AC_COMPILE_IFELSE( - AC_LANG_PROGRAM([[#include ]], + [AC_LANG_PROGRAM([[#include ]], [[const unsigned char** cpp = 0; - X509** x = 0; d2i_X509(x, cpp, 0);]]), + X509** x = 0; d2i_X509(x, cpp, 0);]])], AC_DEFINE(OPENSSL_D2I_X509_USES_CONST_CHAR,,[d2i_x509 uses const char**]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) @@ -288,7 +304,7 @@ freebsd*) darwin*) AC_MSG_CHECKING([if we need to include arpa/nameser_compat.h]) - AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[#include ]], [[HEADER *hdr; int d = NS_IN6ADDRSZ;]]), bro_ns_header_defined=yes, bro_ns_header_defined=no) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[HEADER *hdr; int d = NS_IN6ADDRSZ;]])], bro_ns_header_defined=yes, bro_ns_header_defined=no) # if the header is found, we don't need compatibility if test "x$bro_ns_header_defined" = xyes; then AC_MSG_RESULT(no) @@ -353,14 +369,14 @@ AC_LBL_CHECK_TYPE(u_int16_t, u_short) AC_LBL_CHECK_TYPE(u_int8_t, u_char) AC_HEADER_TIME -AC_CHECK_HEADERS(memory.h netinet/in.h socket.h getopt.h) -AC_CHECK_HEADERS(net/ethernet.h netinet/ether.h netinet/if_ether.h sys/ethernet.h,,, +AC_CHECK_HEADERS([memory.h netinet/in.h socket.h getopt.h]) +AC_CHECK_HEADERS([net/ethernet.h netinet/ether.h netinet/if_ether.h sys/ethernet.h],,, [#include #include #include #include ]) -AC_CHECK_HEADERS(netinet/ip6.h,,, +AC_CHECK_HEADERS([netinet/ip6.h],,, [#include #include #include @@ -416,7 +432,7 @@ if test "$pcap_local" = "NO"; then dnl ################################################ AC_MSG_CHECKING([for pcap_version in libpcap]) AC_LINK_IFELSE( - AC_LANG_PROGRAM([extern char pcap_version[];], [puts(pcap_version);]), + [AC_LANG_PROGRAM([extern char pcap_version[];], [puts(pcap_version);])], AC_MSG_RESULT(yes) AC_DEFINE(PCAP_VERSION_STRING,,[Have a version string in libpcap]), AC_MSG_RESULT(no)) @@ -448,7 +464,7 @@ dnl # AC_MSG_CHECKING([if char_traits defines all methods]) AC_LANG_PUSH([C++]) AC_LINK_IFELSE( - AC_LANG_PROGRAM([[ + [AC_LANG_PROGRAM([[ #include using namespace std; class Foo { }; @@ -456,7 +472,7 @@ class Foo { }; char_traits foo; Foo f; Foo *fp; -foo.assign(&fp, 10, &f);]]), +foo.assign(&fp, 10, &f);]])], AC_MSG_RESULT([yes]) basic_string_works=yes, AC_MSG_RESULT([no]) @@ -575,17 +591,17 @@ else bro_ns_initparse_works=no bro_res_mkquery_works=no - AC_LINK_IFELSE(AC_LANG_PROGRAM([[#include ]], - [[ns_initparse(0,0,0);]]), + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[ns_initparse(0,0,0);]])], bro_ns_initparse_works=yes) - AC_LINK_IFELSE(AC_LANG_PROGRAM([[ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include #include #include #include ]], -[[int (*p)() = res_mkquery]]), bro_res_mkquery_works=yes) +[[int (*p)() = res_mkquery]])], bro_res_mkquery_works=yes) if test $bro_ns_initparse_works = yes && test $bro_res_mkquery_works = yes && test $nbdns = yes; then AC_MSG_RESULT(yes)