summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaiki Ueno <dueno@redhat.com>2019-01-04 16:53:18 +0100
committerDaiki Ueno <dueno@redhat.com>2019-01-04 17:15:53 +0100
commita58ed7431f91eb3fa53861e1006242d74e7060ba (patch)
treec4e6a65fda0d74112b722b342af021bbdb049d17
parentb978a25de5ef06754bf94bdfb2e6442b7fb6f1fa (diff)
downloadgnutls-tmp-libopts-check.tar.gz
configure.ac: check libopts version more strictlytmp-libopts-check
As the libopts API is not forward compatible, it was not sufficient to check the minimum version of the library, but also need to check the maximum version, which is embedded in the generated files we bundle. Signed-off-by: Daiki Ueno <dueno@redhat.com>
-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