I am using autoconf v2.72 prerelease. buildconf will fail to produce a valid configure script. I was able to confirm this is not a result of bugs in autoconf, but rather undefined behavior in configure.in and the m4 scripts - there are two major culprits at this time:
1. Heavy usage of case/if conditionals. To let autoconf do its thing, these should be converted to AS_CASE and AS_IF or equivalent. Specifically, what goes wrong is that EGREP_TRADITIONAL (an autoconf internal new in autoconf 2.72+) is initialized in a bare case statement. If the specific case in question is not taken, we miss this initialization. This missed initialization in turn breaks a later invocation of AC_TYPE_UID_T. 2. Unquoted arguments to macros. By not quoting arguments, the script's generation is liable to break at any time due to changes in autotools internals. Quoting insulates from these changes. Please note that buildconf still works with v2.71, and I do not have the ability to test as thoroughly as may be desired. I just wanted to send this with the hopes of it being useful. I only changed a few places to get a successful build. There seem to be many, many more places in the scripts with undefined behavior (unprotected conditionals, unquoted args). I wonder if making CMake functional with Unix systems would be the path of lesser resistance. Index: build/crypto.m4 =================================================================== --- build/crypto.m4 (revision 1903984) +++ build/crypto.m4 (working copy) @@ -174,19 +174,19 @@ if test "$withval" = "yes"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) if test -n "$PKG_CONFIG"; then - nss_CPPFLAGS=`$PKG_CONFIG --cflags-only-I nss` - nss_LDFLAGS=`$PKG_CONFIG --libs nss` - APR_ADDTO(CPPFLAGS, [$nss_CPPFLAGS]) - APR_ADDTO(LDFLAGS, [$nss_LDFLAGS]) + nss_CPPFLAGS=$($PKG_CONFIG --cflags-only-I nss) + nss_LDFLAGS=$($PKG_CONFIG --libs nss) + APR_ADDTO([CPPFLAGS], [$nss_CPPFLAGS]) + APR_ADDTO([LDFLAGS], [$nss_LDFLAGS]) fi nss_have_prerrorh=0 nss_have_nssh=0 nss_have_pk11pubh=0 AC_CHECK_HEADERS(prerror.h, [nss_have_prerrorh=1]) - AC_CHECK_HEADERS(nss/nss.h nss.h, [nss_have_nssh=1]) - AC_CHECK_HEADERS(nss/pk11pub.h pk11pub.h, [nss_have_pk11pubh=1]) - nss_have_headers=${nss_have_prerrorh}${nss_have_nssh}${nss_have_pk11pubh} - AC_CHECK_LIB(nspr4, PR_Initialize, AC_CHECK_LIB(nss3, PK11_CreatePBEV2AlgorithmID, [nss_have_libs=1],,-lnspr4)) + AC_CHECK_HEADERS([nss/nss.h nss.h], [nss_have_nssh=1]) + AC_CHECK_HEADERS([nss/pk11pub.h pk11pub.h], [nss_have_pk11pubh=1]) + nss_have_headers="${nss_have_prerrorh}${nss_have_nssh}${nss_have_pk11pubh}" + AC_CHECK_LIB(nspr4, PR_Initialize, [AC_CHECK_LIB(nss3, PK11_CreatePBEV2AlgorithmID, [nss_have_libs=1],[],-lnspr4)]) if test "$nss_have_headers" = "111" && test "$nss_have_libs" != "0"; then apu_have_nss=1 fi @@ -208,7 +208,7 @@ AC_CHECK_HEADERS(nss/nss.h nss.h, [nss_have_nssh=1]) AC_CHECK_HEADERS(nss/pk11pub.h pk11pub.h, [nss_have_pk11pubh=1]) nss_have_headers=${nss_have_prerrorh}${nss_have_nssh}${nss_have_pk11pubh} - AC_CHECK_LIB(nspr4, PR_Initialize, AC_CHECK_LIB(nss3, PK11_CreatePBEV2AlgorithmID, [nss_have_libs=1],,-lnspr4)) + AC_CHECK_LIB(nspr4, PR_Initialize, [AC_CHECK_LIB(nss3, PK11_CreatePBEV2AlgorithmID, [nss_have_libs=1],,-lnspr4)]) if test "$nss_have_headers" = "111" && test "$nss_have_libs" != "0"; then apu_have_nss=1 fi @@ -251,7 +251,7 @@ [ if test "$withval" = "yes"; then AC_CHECK_HEADERS(CommonCrypto/CommonKeyDerivation.h, [commoncrypto_have_headers=1]) - AC_CHECK_LIB(System, CCKeyDerivationPBKDF, AC_CHECK_LIB(System, CCCryptorCreate, [commoncrypto_have_libs=1])) + AC_CHECK_LIB(System, CCKeyDerivationPBKDF, [AC_CHECK_LIB(System, CCCryptorCreate, [commoncrypto_have_libs=1])]) if test "$commoncrypto_have_headers" != "0" && test "$commoncrypto_have_libs" != "0"; then apu_have_commoncrypto=1 fi @@ -267,7 +267,7 @@ AC_MSG_NOTICE(checking for commoncrypto in $withval) AC_CHECK_HEADERS(CommonCrypto/CommonKeyDerivation.h, [commoncrypto_have_headers=1]) - AC_CHECK_LIB(System, CCKeyDerivationPBKDF, AC_CHECK_LIB(System, CCCryptorCreate, [commoncrypto_have_libs=1])) + AC_CHECK_LIB(System, CCKeyDerivationPBKDF, [AC_CHECK_LIB(System, CCCryptorCreate, [commoncrypto_have_libs=1])]) if test "$commoncrypto_have_headers" != "0" && test "$commoncrypto_have_libs" != "0"; then apu_have_commoncrypto=1 APR_ADDTO(LDFLAGS, [-L$withval/lib]) Index: build/dbd.m4 =================================================================== --- build/dbd.m4 (revision 1903984) +++ build/dbd.m4 (working copy) @@ -255,10 +255,10 @@ old_cppflags="$CPPFLAGS" old_ldflags="$LDFLAGS" - AC_ARG_WITH([sqlite3], APR_HELP_STRING([--with-sqlite3=DIR], [enable sqlite3 DBD driver]), + AC_ARG_WITH([sqlite3], [APR_HELP_STRING([--with-sqlite3=DIR], [enable sqlite3 DBD driver])], [ if test "$withval" = "yes"; then - AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1])) + AC_CHECK_HEADERS(sqlite3.h, [AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1])]) elif test "$withval" = "no"; then : else @@ -269,13 +269,13 @@ APR_ADDTO(LDFLAGS, [$sqlite3_LDFLAGS]) AC_MSG_NOTICE(checking for sqlite3 in $withval) - AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1])) + AC_CHECK_HEADERS(sqlite3.h, [AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1])]) if test "$apu_have_sqlite3" != "0"; then APR_ADDTO(INCLUDES, [-I$withval/include]) fi fi ], [ - AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1])) + AC_CHECK_HEADERS(sqlite3.h, [AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1])]) ]) AC_SUBST(apu_have_sqlite3) @@ -302,7 +302,7 @@ AC_ARG_WITH([sqlite2], APR_HELP_STRING([--with-sqlite2=DIR], [enable sqlite2 DBD driver]), [ if test "$withval" = "yes"; then - AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1])) + AC_CHECK_HEADERS(sqlite.h, [AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1])]) elif test "$withval" = "no"; then : else @@ -313,13 +313,13 @@ APR_ADDTO(LDFLAGS, [$sqlite2_LDFLAGS]) AC_MSG_NOTICE(checking for sqlite2 in $withval) - AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1])) + AC_CHECK_HEADERS(sqlite.h, [AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1])]) if test "$apu_have_sqlite2" != "0"; then APR_ADDTO(INCLUDES, [-I$withval/include]) fi fi ], [ - AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1])) + AC_CHECK_HEADERS(sqlite.h, [AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1])]) ]) AC_SUBST(apu_have_sqlite2) @@ -356,7 +356,7 @@ APR_ADDTO(CPPFLAGS, [$oracle_CPPFLAGS]) - AC_CHECK_HEADERS(oci.h, AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1],[ + AC_CHECK_HEADERS(oci.h, [AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1],[ unset ac_cv_lib_clntsh_OCIEnvCreate oracle_LIBS="-lnnz11" APR_ADDTO(LIBS, [$oracle_LIBS]) @@ -367,7 +367,7 @@ APR_ADDTO(LIBS, [$oracle_LIBS]) AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1]) ]) - ])) + ])]) elif test "$withval" = "no"; then : else @@ -383,7 +383,7 @@ APR_ADDTO(LDFLAGS, [$oracle_LDFLAGS]) AC_MSG_NOTICE(checking for oracle in $withval) - AC_CHECK_HEADERS(oci.h, AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1],[ + AC_CHECK_HEADERS(oci.h, [AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1],[ unset ac_cv_lib_clntsh_OCIEnvCreate oracle_LIBS="-lnnz11" APR_ADDTO(LIBS, [$oracle_LIBS]) @@ -394,7 +394,7 @@ APR_ADDTO(LIBS, [$oracle_LIBS]) AC_CHECK_LIB(clntsh, OCIEnvCreate, [apu_have_oracle=1]) ]) - ])) + ])]) if test "$apu_have_oracle" != "0"; then oracle_LDFLAGS="$oracle_LDFLAGS -R$withval/lib" if test -z "$with_oracle_include"; then @@ -441,9 +441,9 @@ APR_ADDTO(LIBS, [$odbc_LIBS]) fi - AC_CHECK_HEADERS(sql.h, AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1])) + AC_CHECK_HEADERS(sql.h, [AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1])]) if test "$apu_have_odbc" = "0"; then - AC_CHECK_HEADERS(odbc/sql.h, AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1])) + AC_CHECK_HEADERS(odbc/sql.h, [AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1])]) fi if test "$apu_have_odbc" != "0" && test "x$ODBC_CONFIG" != 'x'; then APR_ADDTO(INCLUDES, [$odbc_CPPFLAGS]) @@ -472,9 +472,9 @@ APR_ADDTO(LIBS, [$odbc_LIBS]) AC_MSG_NOTICE(checking for odbc in $withval) - AC_CHECK_HEADERS(sql.h, AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1])) + AC_CHECK_HEADERS(sql.h, [AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1])]) if test "$apu_have_odbc" = "0"; then - AC_CHECK_HEADERS(odbc/sql.h, AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1])) + AC_CHECK_HEADERS(odbc/sql.h, [AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1])]) fi if test "$apu_have_odbc" != "0" && test "x$ODBC_CONFIG" != 'x'; then APR_ADDTO(INCLUDES, [$odbc_CPPFLAGS]) @@ -492,9 +492,9 @@ APR_ADDTO(LIBS, [$odbc_LIBS]) fi - AC_CHECK_HEADERS(sql.h, AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1])) + AC_CHECK_HEADERS(sql.h, [AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1])]) if test "$apu_have_odbc" = "0"; then - AC_CHECK_HEADERS(odbc/sql.h, AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1])) + AC_CHECK_HEADERS(odbc/sql.h, [AC_CHECK_LIB(odbc, SQLAllocHandle, [apu_have_odbc=1])]) fi if test "$apu_have_odbc" != "0" && test "x$ODBC_CONFIG" != 'x'; then APR_ADDTO(INCLUDES, [$odbc_CPPFLAGS]) Index: build/dbm.m4 =================================================================== --- build/dbm.m4 (revision 1903984) +++ build/dbm.m4 (working copy) @@ -557,7 +557,7 @@ [ apu_have_gdbm=0 if test "$withval" = "yes"; then - AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1])) + AC_CHECK_HEADER(gdbm.h, [AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1])]) elif test "$withval" = "no"; then apu_have_gdbm=0 else @@ -567,7 +567,7 @@ LDFLAGS="$LDFLAGS -L$withval/lib " AC_MSG_CHECKING(checking for gdbm in $withval) - AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1])) + AC_CHECK_HEADER(gdbm.h, [AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1])]) if test "$apu_have_gdbm" != "0"; then APR_ADDTO(LDFLAGS, [-L$withval/lib]) APR_ADDTO(INCLUDES, [-I$withval/include]) @@ -615,13 +615,13 @@ dnl db_ndbm_open is what sleepcat's compatibility library actually has in it's lib if test "$apu_want_ndbm" != "0"; then AC_CHECK_HEADER(ndbm.h, - AC_CHECK_LIB(c, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=c], - AC_CHECK_LIB(dbm, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=dbm], - AC_CHECK_LIB(db, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db], - AC_CHECK_LIB(db, __db_ndbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db]) - ) - ) - ) + [AC_CHECK_LIB(c, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=c], + [AC_CHECK_LIB(dbm, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=dbm], + [AC_CHECK_LIB(db, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db], + [AC_CHECK_LIB(db, __db_ndbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db])] + )] + )] + )] ) if test "$apu_have_ndbm" != "0"; then if test "$withval" != "yes"; then Index: build/xml.m4 =================================================================== --- build/xml.m4 (revision 1903984) +++ build/xml.m4 (working copy) @@ -168,7 +168,7 @@ APR_ADDTO(LIBS, [$xml2_LIBS]) fi - AC_CHECK_HEADERS(libxml/parser.h, AC_CHECK_LIB(xml2, xmlCreatePushParserCtxt, [apu_has_libxml2=1])) + AC_CHECK_HEADERS(libxml/parser.h, [AC_CHECK_LIB(xml2, xmlCreatePushParserCtxt, [apu_has_libxml2=1])]) elif test "$withval" != "no"; then AC_PATH_TOOL([XML2_CONFIG],[xml2-config],,[$withval/bin]) if test "x$XML2_CONFIG" != 'x'; then @@ -184,11 +184,11 @@ APR_ADDTO(LIBS, [$xml2_LIBS]) AC_MSG_NOTICE(checking for libxml2 in $withval) - AC_CHECK_HEADERS(libxml/parser.h, AC_CHECK_LIB(xml2, xmlCreatePushParserCtxt, [apu_has_libxml2=1])) + AC_CHECK_HEADERS(libxml/parser.h, [AC_CHECK_LIB(xml2, xmlCreatePushParserCtxt, [apu_has_libxml2=1])]) fi ], [ xml2_LIBS="-lxml2" - AC_CHECK_HEADERS(libxml/parser.h, AC_CHECK_LIB(xml2, xmlCreatePushParserCtxt, [apu_has_libxml2=1])) + AC_CHECK_HEADERS(libxml/parser.h, [AC_CHECK_LIB(xml2, xmlCreatePushParserCtxt, [apu_has_libxml2=1])]) ]) AC_SUBST(apu_has_libxml2) Index: configure.in =================================================================== --- configure.in (revision 1903984) +++ configure.in (working copy) @@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. dnl Use ./buildconf to prepare build files and run autoconf for APR. -AC_PREREQ(2.59) +AC_PREREQ(2.60) AC_INIT(build/apr_common.m4) AC_CONFIG_HEADER(include/arch/unix/apr_private.h) @@ -677,14 +677,13 @@ INSTALL_SUBDIRS="none" OBJECTS_PLATFORM='$(OBJECTS_unix)' -case $host in - i386-ibm-aix* | *-ibm-aix[[1-2]].* | *-ibm-aix3.* | *-ibm-aix4.1 | *-ibm-aix4.1.* | *-ibm-aix4.2 | *-ibm-aix4.2.*) +AS_CASE([ $host ], + [i386-ibm-aix* | *-ibm-aix[[1-2]].* | *-ibm-aix3.* | *-ibm-aix4.1 | *-ibm-aix4.1.* | *-ibm-aix4.2 | *-ibm-aix4.2.*], [ OSDIR="aix" APR_ADDTO(LDFLAGS,-lld) eolstr="\\n" - OBJECTS_PLATFORM='$(OBJECTS_aix)' - ;; - *-os2*) + OBJECTS_PLATFORM='$(OBJECTS_aix)'], + [*-os2*], [ APR_ADDTO(CPPFLAGS,-DOS2) APR_ADDTO(CFLAGS,-Zmt) AC_CHECK_LIB(bsd, random) @@ -693,9 +692,8 @@ eolstr="\\r\\n" file_as_socket="0" proc_mutex_is_global=1 - OBJECTS_PLATFORM='$(OBJECTS_os2)' - ;; - *beos*) + OBJECTS_PLATFORM='$(OBJECTS_os2)'], + [*beos*], [ OSDIR="beos" APR_ADDTO(CPPFLAGS,-DBEOS) enable_threads="system_threads" @@ -712,45 +710,36 @@ *) file_as_socket="0" ;; - esac - ;; - *apple-darwin*) + esac], + [*apple-darwin*], [ ac_cv_func_fdatasync="no" # Mac OS X wrongly reports it has fdatasync() OSDIR="unix" - eolstr="\\n" - ;; - *os390) + eolstr="\\n"], + [*os390], [ OSDIR="os390" OBJECTS_PLATFORM='$(OBJECTS_os390)' - eolstr="\\n" - ;; - *os400) + eolstr="\\n"], + [*os400], [ OSDIR="as400" - eolstr="\\n" - ;; - *mingw*) + eolstr="\\n"], + [*mingw*], [ OSDIR="win32" enable_threads="system_threads" eolstr="\\r\\n" file_as_socket=0 proc_mutex_is_global=1 - OBJECTS_PLATFORM='$(OBJECTS_win32)' - ;; - *cygwin*) + OBJECTS_PLATFORM='$(OBJECTS_win32)'], + [*cygwin*], [ OSDIR="unix" enable_threads="no" - eolstr="\\n" - ;; - *hpux10* ) + eolstr="\\n"], + [*hpux10*], [ enable_threads="no" OSDIR="unix" - eolstr="\\n" - ;; - *) + eolstr="\\n"], + [ OSDIR="unix" - eolstr="\\n" - ;; -esac + eolstr="\\n"]) AC_SUBST(OBJECTS_PLATFORM)