summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac34
1 files changed, 23 insertions, 11 deletions
diff --git a/configure.ac b/configure.ac
index a2267b8671..298c113407 100644
--- a/configure.ac
+++ b/configure.ac
@@ -707,18 +707,30 @@ AC_SUBST(TROUSERS_LIB)
AM_MISSING_PROG([AUTOGEN], [autogen])
included_libopts=no
+
if test "$enable_tools" != "no" || test "$enable_doc" != "no"; then
- AC_MSG_CHECKING([whether autogen is recent enough])
- if $PKG_CONFIG --atleast-version=41.1.16 autoopts 2>&1 >/dev/null; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- AC_MSG_WARN([[
-***
-*** autogen not found. Will not link against system libopts.
-*** ]])
- dnl simulate specifying option on the command line
- enable_local_libopts=yes
+ dnl If we have autogen-generated files in src/, check if those
+ dnl files are compatible with the system libopts.
+ dnl
+ dnl Note that this check doesn't take into account of
+ dnl --enable-local-libopts and --with-autoopts-config, because
+ dnl those options are handled later in LIBOPTS_CHECK below.
+ if test -f "${srcdir}/src/cli-args.h"; then
+ v=`grep '^#define AO_TEMPLATE_VERSION [0-9]*' "${srcdir}/src/cli-args.h" | sed 's/.* //'`
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="`$PKG_CONFIG --cflags-only-I autoopts` $CFLAGS"
+ dnl The test is taken from:
+ dnl http://git.savannah.gnu.org/cgit/autogen.git/tree/autoopts/tpl/opthead.tlib#n60
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
+ #include <autoopts/options.h>],[
+ #if ($v < OPTIONS_MINIMUM_VERSION) \
+ || ($v > OPTIONS_STRUCT_VERSION)
+ #error "template version mismatches autoopts/options.h header"
+ #endif
+])],,
+ dnl simulate specifying option on the command line
+ enable_local_libopts=yes)
+ CFLAGS="$save_CFLAGS"
fi
LIBOPTS_CHECK([src/libopts])
if test "$NEED_LIBOPTS_DIR" = "true";then