bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* gc: fix configuration with --with-libgcrypt
@ 2019-08-24  9:12 Bruno Haible
  2019-08-25  0:25 ` Paul Eggert
  0 siblings, 1 reply; 3+ messages in thread
From: Bruno Haible @ 2019-08-24  9:12 UTC (permalink / raw)
  To: bug-gnulib

When I run

$ ./gnulib-tool --create-testdir --dir=../testdir1 --single-configure crypto/gc-sha1 crypto/gc-md2 crypto/gc-md4 crypto/gc-md5 crypto/gc-rijndael crypto/gc-sm3
$ cd ../testdir1
$ ./configure --with-libgcrypt

the configuration always fails with

configure: error: libgcrypt not found

The cause is that the macro AM_PATH_LIBGCRYPT is not found in gnulib.

Paul and Karl: If you agree, can we add a $LIBGCRYPT to config/srclist.txt?


2019-08-24  Bruno Haible  <bruno@clisp.org>

	gc: Fix configuration with --with-libgcrypt.
	* m4/libgcrypt.m4: New file, copied from libgcrypt/src/libgcrypt.m4.
	* modules/crypto/gc (Files): Add it.
	* m4/gc.m4 (gl_GC): Assume AM_PATH_LIBGCRYPT is defined.

diff --git a/m4/libgcrypt.m4 b/m4/libgcrypt.m4
new file mode 100644
index 0000000..37dfbea
--- /dev/null
+++ b/m4/libgcrypt.m4
@@ -0,0 +1,167 @@
+# libgcrypt.m4 - Autoconf macros to detect libgcrypt
+# Copyright (C) 2002, 2003, 2004, 2011, 2014, 2018 g10 Code GmbH
+#
+# This file is free software; as a special exception the author gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+#
+# This file is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# Last-changed: 2018-11-13
+
+
+dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION,
+dnl                   [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS.
+dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed
+dnl with the API version to also check the API compatibility. Example:
+dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed
+dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1.  Using
+dnl this features allows to prevent build against newer versions of libgcrypt
+dnl with a changed API.
+dnl
+dnl If a prefix option is not used, the config script is first
+dnl searched in $SYSROOT/bin and then along $PATH.  If the used
+dnl config script does not match the host specification the script
+dnl is added to the gpg_config_script_warn variable.
+dnl
+AC_DEFUN([AM_PATH_LIBGCRYPT],
+[ AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_ARG_WITH(libgcrypt-prefix,
+            AC_HELP_STRING([--with-libgcrypt-prefix=PFX],
+                           [prefix where LIBGCRYPT is installed (optional)]),
+     libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="")
+  if test x"${LIBGCRYPT_CONFIG}" = x ; then
+     if test x"${libgcrypt_config_prefix}" != x ; then
+        LIBGCRYPT_CONFIG="${libgcrypt_config_prefix}/bin/libgcrypt-config"
+     fi
+  fi
+
+  use_gpgrt_config=""
+  if test x"${LIBGCRYPT_CONFIG}" = x -a x"$GPGRT_CONFIG" != x -a "$GPGRT_CONFIG" != "no"; then
+    if $GPGRT_CONFIG libgcrypt --exists; then
+      LIBGCRYPT_CONFIG="$GPGRT_CONFIG libgcrypt"
+      AC_MSG_NOTICE([Use gpgrt-config as libgcrypt-config])
+      use_gpgrt_config=yes
+    fi
+  fi
+  if test -z "$use_gpgrt_config"; then
+    if test x"${LIBGCRYPT_CONFIG}" = x ; then
+      case "${SYSROOT}" in
+         /*)
+           if test -x "${SYSROOT}/bin/libgcrypt-config" ; then
+             LIBGCRYPT_CONFIG="${SYSROOT}/bin/libgcrypt-config"
+           fi
+           ;;
+         '')
+           ;;
+          *)
+           AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
+           ;;
+      esac
+    fi
+    AC_PATH_PROG(LIBGCRYPT_CONFIG, libgcrypt-config, no)
+  fi
+
+  tmp=ifelse([$1], ,1:1.2.0,$1)
+  if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
+     req_libgcrypt_api=`echo "$tmp"     | sed 's/\(.*\):\(.*\)/\1/'`
+     min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
+  else
+     req_libgcrypt_api=0
+     min_libgcrypt_version="$tmp"
+  fi
+
+  AC_MSG_CHECKING(for LIBGCRYPT - version >= $min_libgcrypt_version)
+  ok=no
+  if test "$LIBGCRYPT_CONFIG" != "no" ; then
+    req_major=`echo $min_libgcrypt_version | \
+               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+    req_minor=`echo $min_libgcrypt_version | \
+               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+    req_micro=`echo $min_libgcrypt_version | \
+               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
+    if test -z "$use_gpgrt_config"; then
+      libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version`
+    else
+      libgcrypt_config_version=`$LIBGCRYPT_CONFIG --modversion`
+    fi
+    major=`echo $libgcrypt_config_version | \
+               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
+    minor=`echo $libgcrypt_config_version | \
+               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
+    micro=`echo $libgcrypt_config_version | \
+               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
+    if test "$major" -gt "$req_major"; then
+        ok=yes
+    else
+        if test "$major" -eq "$req_major"; then
+            if test "$minor" -gt "$req_minor"; then
+               ok=yes
+            else
+               if test "$minor" -eq "$req_minor"; then
+                   if test "$micro" -ge "$req_micro"; then
+                     ok=yes
+                   fi
+               fi
+            fi
+        fi
+    fi
+  fi
+  if test $ok = yes; then
+    AC_MSG_RESULT([yes ($libgcrypt_config_version)])
+  else
+    AC_MSG_RESULT(no)
+  fi
+  if test $ok = yes; then
+     # If we have a recent libgcrypt, we should also check that the
+     # API is compatible
+     if test "$req_libgcrypt_api" -gt 0 ; then
+        if test -z "$use_gpgrt_config"; then
+           tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0`
+	else
+           tmp=`$LIBGCRYPT_CONFIG --variable=api_version 2>/dev/null || echo 0`
+	fi
+        if test "$tmp" -gt 0 ; then
+           AC_MSG_CHECKING([LIBGCRYPT API version])
+           if test "$req_libgcrypt_api" -eq "$tmp" ; then
+             AC_MSG_RESULT([okay])
+           else
+             ok=no
+             AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp])
+           fi
+        fi
+     fi
+  fi
+  if test $ok = yes; then
+    LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags`
+    LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs`
+    ifelse([$2], , :, [$2])
+    if test -z "$use_gpgrt_config"; then
+      libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none`
+    else
+      libgcrypt_config_host=`$LIBGCRYPT_CONFIG --variable=host 2>/dev/null || echo none`
+    fi
+    if test x"$libgcrypt_config_host" != xnone ; then
+      if test x"$libgcrypt_config_host" != x"$host" ; then
+  AC_MSG_WARN([[
+***
+*** The config script "$LIBGCRYPT_CONFIG" was
+*** built for $libgcrypt_config_host and thus may not match the
+*** used host $host.
+*** You may want to use the configure option --with-libgcrypt-prefix
+*** to specify a matching config script or use \$SYSROOT.
+***]])
+        gpg_config_script_warn="$gpg_config_script_warn libgcrypt"
+      fi
+    fi
+  else
+    LIBGCRYPT_CFLAGS=""
+    LIBGCRYPT_LIBS=""
+    ifelse([$3], , :, [$3])
+  fi
+  AC_SUBST(LIBGCRYPT_CFLAGS)
+  AC_SUBST(LIBGCRYPT_LIBS)
+])
diff --git a/modules/crypto/gc b/modules/crypto/gc
index 339cb81..f9f9253 100644
--- a/modules/crypto/gc
+++ b/modules/crypto/gc
@@ -6,6 +6,7 @@ lib/gc.h
 lib/gc-libgcrypt.c
 lib/gc-gnulib.c
 m4/gc.m4
+m4/libgcrypt.m4
 
 Depends-on:
 havelib
diff --git a/m4/gc.m4 b/m4/gc.m4
index 683d52f..954459a 100644
--- a/m4/gc.m4
+++ b/m4/gc.m4
@@ -1,4 +1,4 @@
-# gc.m4 serial 10
+# gc.m4 serial 11
 dnl Copyright (C) 2005-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -14,9 +14,8 @@ AC_DEFUN([gl_GC],
     # gc-libgcrypt.c will fail on startup if we don't have
     # version 1.4.4 or later, so test for it early. */
     gl_good_gcrypt=no
-    m4_ifdef([AM_PATH_LIBGCRYPT],
-      [AM_PATH_LIBGCRYPT([1.4.4], [gl_good_gcrypt=yes],
-        [AC_MSG_ERROR([libgcrypt is too old])])])
+    AM_PATH_LIBGCRYPT([1.4.4], [gl_good_gcrypt=yes],
+     [AC_MSG_ERROR([libgcrypt is too old])])
     if test "x$gl_good_gcrypt" != xno; then
       AC_LIB_HAVE_LINKFLAGS([gcrypt], [gpg-error], [#include <gcrypt.h>])
     else



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: gc: fix configuration with --with-libgcrypt
  2019-08-24  9:12 gc: fix configuration with --with-libgcrypt Bruno Haible
@ 2019-08-25  0:25 ` Paul Eggert
  2019-11-18 12:10   ` Bruno Haible
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Eggert @ 2019-08-25  0:25 UTC (permalink / raw)
  To: bug-gnulib

Bruno Haible wrote:
> Paul and Karl: If you agree, can we add a $LIBGCRYPT to config/srclist.txt?

We like keeping files in sync; that's what config/srclist.txt is for. So I'm all 
for this, and expect Karl will be too.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gc: fix configuration with --with-libgcrypt
  2019-08-25  0:25 ` Paul Eggert
@ 2019-11-18 12:10   ` Bruno Haible
  0 siblings, 0 replies; 3+ messages in thread
From: Bruno Haible @ 2019-11-18 12:10 UTC (permalink / raw)
  To: bug-gnulib, Karl Berry; +Cc: Paul Eggert

Paul Eggert wrote on 2019-08-24:
> Bruno Haible wrote:
> > Paul and Karl: If you agree, can we add a $LIBGCRYPT to config/srclist.txt?
> 
> We like keeping files in sync; that's what config/srclist.txt is for. So I'm all 
> for this, and expect Karl will be too.

Done as follows. Karl, you will need to checkout libgcrypt (from
https://github.com/gpg/libgcrypt.git) before the next autoupdate.


2019-11-18  Bruno Haible  <bruno@clisp.org>

	gc: Mirror libgcrypt.m4 from libgcrypt.
	* config/srclistvars.sh (LIBGCRYPT): New variable.
	* config/srclist.txt: Use it to fetch m4/libgcrypt.m4.

diff --git a/config/srclist.txt b/config/srclist.txt
index 4a3a5a7..55d574a 100644
--- a/config/srclist.txt
+++ b/config/srclist.txt
@@ -185,6 +185,8 @@ $LIBCSRC time/mktime-internal.h		lib
 #$LIBCSRC sysdeps/unix/sysv/gethostname.c	lib gpl
 #$LIBCSRC sysdeps/unix/utime.c			lib gpl
 
+$LIBGCRYPT src/libgcrypt.m4			m4
+
 # Now derived from concatenation of separate .c files in glibc.
 # See argz.mk for details.
 #$LIBTOOL libltdl/argz.c			lib gpl
diff --git a/config/srclistvars.sh b/config/srclistvars.sh
index b24a8ef..00f5294 100755
--- a/config/srclistvars.sh
+++ b/config/srclistvars.sh
@@ -33,5 +33,6 @@ esac
 : ${GNUSTANDARDS=../gnustandards}
 : ${GNUWWWLICENSES=../www/www/licenses}
 : ${LIBCSRC=../libc}
+: ${LIBGCRYPT=../libgcrypt}
 : ${LIBTOOL=../libtool}
 : ${TEXINFOTEX=../../ftp.gnu.org/gnu/texinfo}



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-18 12:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-24  9:12 gc: fix configuration with --with-libgcrypt Bruno Haible
2019-08-25  0:25 ` Paul Eggert
2019-11-18 12:10   ` Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).