# # # delete "m4/botan.m4" # # delete "m4/idna.m4" # # delete "m4/lua.m4" # # delete "m4/pcre.m4" # # delete "m4/sqlite.m4" # # add_file "m4/library.m4" # content [d7f50a4e511ae1cbd2739a7124788c1689944571] # # patch "Makefile.am" # from [f5d25d295ce2bd1d3e1b6d5843bb313f47bf85ad] # to [1fa5708e37b84429937048bcf960fff5c77064d3] # # patch "configure.ac" # from [e27653ba44e893769adda20d2893066c5794a40b] # to [aae3bef08059b5d8294c7f7a3fe5db9fb2afcc98] # ============================================================ --- m4/library.m4 d7f50a4e511ae1cbd2739a7124788c1689944571 +++ m4/library.m4 d7f50a4e511ae1cbd2739a7124788c1689944571 @@ -0,0 +1,238 @@ +# Encapsulation of all the logic required to probe for monotone's +# dependent libraries. + +# This is more complicated than it ought to be because (a) we can +# assume that each of these libraries installs either a .pc file or a +# *-config executable, but which one may vary across versions and +# installations, and (b) we can't count on the .pc file, or the +# *-config executable, to have the same name in all versions or +# installations! + +# All is not lost, however; we _can_ count on the .pc file or *-config +# executable to have a basename that matches the Perl regular +# expression /^(lib)?\Q${libname}\E(-?[0-9.]+)?(\.pc|-config)$/i, +# where ${libname} is the short name of the library. Thus, we can +# enumerate all the possibilities for any given library. This is easy +# for *-config executables (iterate over $PATH) and slightly trickier +# for .pc files (iterate over PKG_CONFIG_PATH, but also we have to +# determine pkg-config's built-in path, which is nontrivial) + +# Internal-use-only subroutine. +AC_DEFUN([MTN_FULL_PKG_CONFIG_PATH], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +# The dummy "pkg-config" package is guaranteed to exist. +if test -n "$PKG_CONFIG"; then + mtn__full_pkg_config_path=`$PKG_CONFIG --debug pkg-config 2>&1 | + sed -ne "/^Scanning directory '/{; s///; s/'$//; p;}" | + tr "$as_nl" ':' | sed 's/:$//'` + #AC_MSG_NOTICE([detected pkg-config path: $mtn__full_pkg_config_path]) +fi +]) + +# MTN_CHECK_MODULE(libname, version, validator) +# +# Probe for LIBNAME, trying first pkg-config, then a *-config program, +# and failing that, a total guess (no special -I or -L switches, +# -llibname). If VERSION is not empty, it is a >= constraint passed +# to pkg-config (but not otherwise enforced). +# +# Whatever we come up with, validate it by attempting to +# compile and link VALIDATOR, which should be an AC_LANG_PROGRAM invocation +# that tries to include library headers and call functions. VALIDATOR may +# perform compile-time version checks, but may not perform runtime tests. +# +# Like PKG_CHECK_MODULES, will set substitution variables named +# "libname_CFLAGS" and "libname_LIBS". + +AC_DEFUN([MTN_CHECK_MODULE], +[AC_REQUIRE([MTN_FULL_PKG_CONFIG_PATH]) +AC_REQUIRE([AC_PROG_EGREP]) +AC_REQUIRE([AC_PROG_AWK]) + +# Probe for the $1 library. +_notfound=true +_verreq=m4_if([$2],[],[],[" >= $2"]) + +# First test for user overrides. This should work even if pkg-config +# isn't installed. The use of + instead of :+ is deliberate; the user +# should be able to tell us that no flags are required. +# (PKG_CHECK_MODULES gets this wrong!) +if test x${$1[]_CFLAGS+set} = xset || test x${$1[]_LIBS+set} = xset; then + AC_MSG_CHECKING([for $1]) + AC_MSG_RESULT([user specified]) + _notfound=false +fi + +if $_notfound; then +# Second, try a "naive" search for the unqualified package name. This +# also ensures that the ARG_VARs for the desired library are sane. +PKG_CHECK_MODULES([$1], [$1$_verreq], + [_notfound=false], + [:]) +fi + +# Third, try looking for alternative names known to pkg-config for +# the library. +if $_notfound; then + _save_IFS="$IFS" + IFS=":" + set fnord $mtn__full_pkg_config_path + shift + IFS="$_save_IFS" + + for pkgcfgdir; do + echo $pkgcfgdir/*$1*.pc + done | tr ' ' "$as_nl" | + $EGREP '/(lib)?$1(-?@<:@0-9.@:>@+)?\.pc$' > conftest.candpc + + echo "$as_me: candidate .pc files are:" >&AS_MESSAGE_LOG_FD + sed 's/^/| /' conftest.candpc >&AS_MESSAGE_LOG_FD + for f in `cat conftest.candpc`; do + c=`AS_BASENAME([$f])` + c=`expr X"$c" : 'X\(.*\)\.pc'` + AC_MSG_CHECKING([for $1 using $c.pc]) + + pkg_failed=no + _PKG_CONFIG([$1][_CFLAGS], [cflags], [$c$_verreq]) + _PKG_CONFIG([$1][_LIBS], [libs], [$c$_verreq]) + if test $pkg_failed = no; then + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + _notfound=false + break + else + AC_MSG_RESULT([no]) + fi + done +fi + +# Fourth, try -config binaries. +if $_notfound; then + _save_IFS="$IFS" + IFS=":" + set fnord $PATH + shift + IFS="$_save_IFS" + + for pathdir; do + echo $pathdir/*$1*-config + done | tr ' ' "$as_nl" | + $EGREP '/(lib)?$1(-?@<:@0-9.@:>@+)?-config$' > conftest.candcfg + + echo "$as_me: candidate -config programs are:" >&AS_MESSAGE_LOG_FD + sed 's/^/| /' conftest.candcfg >&AS_MESSAGE_LOG_FD + for f in `cat conftest.candcfg`; do + n=`AS_BASENAME([$c])` + AC_MSG_CHECKING([for $1 using $n]) + if _ccflg=`$c --cflags 2>&AS_MESSAGE_LOG_FD` && + _clibs=`$c --libs 2>&AS_MESSAGE_LOG_FD` + then + $1[]_CFLAGS="$_ccflg" + $1[]_LIBS="$_clibs" + AC_MSG_RESULT([yes]) + notfound=false + break + else + AC_MSG_RESULT([no]) + fi + done +fi + +if $_notfound; then + AC_MSG_CHECKING([for $1]) + AC_MSG_RESULT([not found; guessing]) + $1[]_CFLAGS= + $1[]_LIBS=-l$1 +fi + +m4_if([$3],[],[], [ +AC_MSG_CHECKING([whether $1 is usable]) +save_LIBS="$LIBS" +save_CPPFLAGS="$CPPFLAGS" +LIBS="$LIBS ${$1[]_LIBS}" +CPPFLAGS="$CPPFLAGS ${$1[]_CFLAGS}" +AC_LINK_IFELSE([$3], [_libusable=yes], [_libusable=no]) +LIBS="$save_LIBS" +CPPFLAGS="$save_CPPFLAGS" +AC_MSG_RESULT($_libusable) +if test $_libusable = no; then + AC_MSG_NOTICE([*** $1[]_CFLAGS=${$1[]_CFLAGS}]) + AC_MSG_NOTICE([*** $1[]_LIBS=${$1[]_LIBS}]) + AC_MSG_FAILURE([Must be able to compile and link programs against $1.]) +fi +]) + +rm -f conftest.candcfg conftest.candpc +]) + +# Checks for specific libraries that can be probed this way. + +AC_DEFUN([MTN_FIND_BOTAN], +[MTN_CHECK_MODULE([botan], [1.6.3], + [AC_LANG_PROGRAM( + [#include + #if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,6,3) + #error too old + #endif + #if BOTAN_VERSION_CODE == BOTAN_VERSION_CODE_FOR(1,7,14) + #error version 1.7.14 is not usable for monotone + #endif], + [Botan::LibraryInitializer li;]) + ]) +]) + +AC_DEFUN([MTN_FIND_IDNA], +[MTN_CHECK_MODULE([idn], , + [AC_LANG_PROGRAM( + [#include ], + [const char *e = idna_strerror(IDNA_SUCCESS);]) + ]) +]) + +AC_DEFUN([MTN_FIND_LUA], +[MTN_CHECK_MODULE([lua], [5.1], + [AC_LANG_PROGRAM( + [#ifdef __cplusplus + #include + #else + #include + #include + #include + #endif + #if LUA_VERSION_NUM < 501 + #error out of date + #endif], + [lua_State *st = luaL_newstate();]) + ]) +]) + +AC_DEFUN([MTN_FIND_PCRE], +[MTN_CHECK_MODULE([pcre], [7.6], + [AC_LANG_PROGRAM( + [#include + #if PCRE_MAJOR < 7 || (PCRE_MAJOR == 7 && PCRE_MINOR < 6) + #error out of date + #endif], + [const char *e; + int dummy; + int o; + /* Make sure some definitions are present. */ + dummy = PCRE_NEWLINE_CR; + dummy = PCRE_DUPNAMES; + pcre *re = pcre_compile("foo", 0, &e, &o, 0);]) + ]) +]) + +AC_DEFUN([MTN_FIND_SQLITE], +[MTN_CHECK_MODULE([sqlite], [3.3], + [AC_LANG_PROGRAM( + [#include + #if SQLITE_VERSION_NUMBER < 3003000 + #error out of date + #endif], + [sqlite3 *st; + sqlite3_open("testfile.db", &st); + sqlite3_close(st);]) + ]) +]) ============================================================ --- Makefile.am f5d25d295ce2bd1d3e1b6d5843bb313f47bf85ad +++ Makefile.am 1fa5708e37b84429937048bcf960fff5c77064d3 @@ -222,10 +222,10 @@ EXTERNAL_CPPFLAGS = $(pcre_CFLAGS) $(bot SUFFIXES = .gch EXTERNAL_CPPFLAGS = $(pcre_CFLAGS) $(botan_CFLAGS) \ - $(lua_CFLAGS) $(sqlite3_CFLAGS) $(libidn_CFLAGS) + $(lua_CFLAGS) $(sqlite_CFLAGS) $(idn_CFLAGS) EXTERNAL_LIBS = $(BOOSTLIBS) $(LIBICONV) $(LIBINTL) \ - $(pcre_LIBS) $(botan_LIBS) $(lua_LIBS) $(sqlite3_LIBS) \ - $(libidn_LIBS) + $(pcre_LIBS) $(botan_LIBS) $(lua_LIBS) $(sqlite_LIBS) \ + $(idn_LIBS) mtn_CPPFLAGS = $(EXTERNAL_CPPFLAGS) mtn_CXXFLAGS = $(PCH_FLAGS) ============================================================ --- configure.ac e27653ba44e893769adda20d2893066c5794a40b +++ configure.ac aae3bef08059b5d8294c7f7a3fe5db9fb2afcc98 @@ -45,7 +45,6 @@ AC_PROG_CXX # Checks for programs. AC_PROG_CXX -AC_PROG_CXXCPP AC_PROG_CXX_WARNINGS AC_PROG_CXX_PCH @@ -56,7 +55,7 @@ dnl Note 2: if you *don't* put AM_ICONV dnl used to generate link-time references to gettext functions. This dnl is the only remaining use of the C compiler in the entire package. dnl Note 2: if you *don't* put AM_ICONV in here then AM_GNU_GETTEXT -dnl thinks it needs to stick -liconv in LIBS! +dnl thinks it needs to stick -liconv in LIBS, even when iconv is in libc! AC_LANG([C]) AM_ICONV @@ -134,12 +133,4 @@ AC_CHECK_FUNCS([__cxa_current_exception_ AC_CHECK_FUNCS([__cxa_current_exception_type __cxa_demangle dirfd \ fstatat mkdtemp mmap putenv setenv strptime unsetenv]) -# allow compiling with different flags/optimisation -# for monotone versus libs, useful for testing. -# only makes sense if CFLAGS="" or CXXFLAGS="" -AC_SUBST(MONOTONE_CFLAGS) -AC_SUBST(MONOTONE_CXXFLAGS) -AC_SUBST(LIB3RDPARTY_CFLAGS) -AC_SUBST(LIB3RDPARTY_CXXFLAGS) - AC_OUTPUT