1 dnl Autoconf macros for libgcrypt
4 # Configure paths for LIBGCRYPT
5 # Shamelessly stolen from the one of XDELTA by Owen Taylor
8 dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
9 dnl Test for libgcrypt, and define GCRYPT_CFLAGS and GCRYPT_LIBS
11 AC_DEFUN(AM_PATH_LIBGCRYPT,
13 dnl Get the cflags and libraries from the libgcrypt-config script
15 AC_ARG_WITH(libgcrypt-prefix,
16 [ --with-libgcrypt-prefix=PFX Prefix where libgcrypt is installed (optional)],
17 libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="")
18 AC_ARG_ENABLE(libgcrypttest,
19 [ --disable-libgcrypttest Do not try to compile and run a test libgcrypt program],
20 , enable_libgcrypttest=yes)
22 if test x$libgcrypt_config_prefix != x ; then
23 libgcrypt_config_args="$libgcrypt_config_args --prefix=$libgcrypt_config_prefix"
24 if test x${LIBGCRYPT_CONFIG+set} != xset ; then
25 LIBGCRYPT_CONFIG=$libgcrypt_config_prefix/bin/libgcrypt-config
29 AC_PATH_PROG(LIBGCRYPT_CONFIG, libgcrypt-config, no)
30 min_libgcrypt_version=ifelse([$1], ,1.1.0,$1)
31 AC_MSG_CHECKING(for libgcrypt - version >= $min_libgcrypt_version)
33 if test "$LIBGCRYPT_CONFIG" = "no" ; then
36 LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG $libgcrypt_config_args --cflags`
37 LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG $libgcrypt_config_args --libs`
38 libgcrypt_config_version=`$LIBGCRYPT_CONFIG $libgcrypt_config_args --version`
39 if test "x$enable_libgcrypttest" = "xyes" ; then
40 ac_save_CFLAGS="$CFLAGS"
42 CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS"
43 LIBS="$LIBS $LIBGCRYPT_LIBS"
45 dnl Now check if the installed libgcrypt is sufficiently new. Also sanity
46 dnl checks the results of libgcrypt-config to some extent
48 rm -f conf.libgcrypttest
58 system ("touch conf.libgcrypttest");
60 if( strcmp( gcry_check_version(NULL), "$libgcrypt_config_version" ) )
62 printf("\n*** 'libgcrypt-config --version' returned %s, but LIBGCRYPT (%s)\n",
63 "$libgcrypt_config_version", gcry_check_version(NULL) );
64 printf("*** was found! If libgcrypt-config was correct, then it is best\n");
65 printf("*** to remove the old version of LIBGCRYPT. You may also be able to fix the error\n");
66 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
67 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
68 printf("*** required on your system.\n");
69 printf("*** If libgcrypt-config was wrong, set the environment variable LIBGCRYPT_CONFIG\n");
70 printf("*** to point to the correct copy of libgcrypt-config, and remove the file config.cache\n");
71 printf("*** before re-running configure\n");
73 else if ( strcmp(gcry_check_version(NULL), GCRYPT_VERSION ) )
75 printf("\n*** LIBGCRYPT header file (version %s) does not match\n", GCRYPT_VERSION);
76 printf("*** library (version %s)\n", gcry_check_version(NULL) );
80 if ( gcry_check_version( "$min_libgcrypt_version" ) )
86 printf("no\n*** An old version of LIBGCRYPT (%s) was found.\n",
87 gcry_check_version(NULL) );
88 printf("*** You need a version of LIBGCRYPT newer than %s. The latest version of\n",
89 "$min_libgcrypt_version" );
90 printf("*** LIBGCRYPT is always available from ftp://ftp.gnupg.org/pub/libgcrypt/gnupg.\n");
91 printf("*** (It is distributed along with GnuPG).\n");
93 printf("*** If you have already installed a sufficiently new version, this error\n");
94 printf("*** probably means that the wrong copy of the libgcrypt-config shell script is\n");
95 printf("*** being found. The easiest way to fix this is to remove the old version\n");
96 printf("*** of LIBGCRYPT, but you can also set the LIBGCRYPT_CONFIG environment to point to the\n");
97 printf("*** correct copy of libgcrypt-config. (In this case, you will have to\n");
98 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
99 printf("*** so that the correct libraries are found at run-time))\n");
104 ],, no_libgcrypt=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
105 CFLAGS="$ac_save_CFLAGS"
109 if test "x$no_libgcrypt" = x ; then
111 ifelse([$2], , :, [$2])
113 if test -f conf.libgcrypttest ; then
118 if test "$LIBGCRYPT_CONFIG" = "no" ; then
119 echo "*** The libgcrypt-config script installed by LIBGCRYPT could not be found"
120 echo "*** If LIBGCRYPT was installed in PREFIX, make sure PREFIX/bin is in"
121 echo "*** your path, or set the LIBGCRYPT_CONFIG environment variable to the"
122 echo "*** full path to libgcrypt-config."
124 if test -f conf.libgcrypttest ; then
127 echo "*** Could not run libgcrypt test program, checking why..."
128 CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS"
129 LIBS="$LIBS $LIBGCRYPT_LIBS"
135 ], [ return !!gcry_check_version(NULL); ],
136 [ echo "*** The test program compiled, but did not run. This usually means"
137 echo "*** that the run-time linker is not finding LIBGCRYPT or finding the wrong"
138 echo "*** version of LIBGCRYPT. If it is not finding LIBGCRYPT, you'll need to set your"
139 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
140 echo "*** to the installed location Also, make sure you have run ldconfig if that"
141 echo "*** is required on your system"
143 echo "*** If you have an old version installed, it is best to remove it, although"
144 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
146 [ echo "*** The test program failed to compile or link. See the file config.log for the"
147 echo "*** exact error that occured. This usually means LIBGCRYPT was incorrectly installed"
148 echo "*** or that you have moved LIBGCRYPT since it was installed. In the latter case, you"
149 echo "*** may want to edit the libgcrypt-config script: $LIBGCRYPT_CONFIG" ])
150 CFLAGS="$ac_save_CFLAGS"
156 ifelse([$3], , :, [$3])
158 AC_SUBST(LIBGCRYPT_CFLAGS)
159 AC_SUBST(LIBGCRYPT_LIBS)
160 rm -f conf.libgcrypttest
163 dnl *-*wedit:notab*-* Please keep this as the last line.