1 dnl Autoconf macros for libmcrypt
4 # This script detects libmcrypt version and defines
5 # LIBMCRYPT_CFLAGS, LIBMCRYPT_LIBS
6 # and LIBMCRYPT24 or LIBMCRYPT22 depending on libmcrypt version
9 # Modified for LIBMCRYPT -- nmav
10 # Configure paths for LIBGCRYPT
11 # Shamelessly stolen from the one of XDELTA by Owen Taylor
12 # Werner Koch 99-12-09
14 dnl AM_PATH_LIBMCRYPT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
15 dnl Test for libmcrypt, and define LIBMCRYPT_CFLAGS and LIBMCRYPT_LIBS
17 AC_DEFUN(AM_PATH_LIBMCRYPT,
19 dnl Get the cflags and libraries from the libmcrypt-config script
21 AC_ARG_WITH(libmcrypt-prefix,
22 [ --with-libmcrypt-prefix=PFX Prefix where libmcrypt is installed (optional)],
23 libmcrypt_config_prefix="$withval", libmcrypt_config_prefix="")
25 if test x$libmcrypt_config_prefix != x ; then
26 libmcrypt_config_args="$libmcrypt_config_args --prefix=$libmcrypt_config_prefix"
27 if test x${LIBMCRYPT_CONFIG+set} != xset ; then
28 LIBMCRYPT_CONFIG=$libmcrypt_config_prefix/bin/libmcrypt-config
32 AC_PATH_PROG(LIBMCRYPT_CONFIG, libmcrypt-config, no)
33 min_libmcrypt_version=ifelse([$1], ,2.4.0,$1)
34 AC_MSG_CHECKING(for libmcrypt - version >= $min_libmcrypt_version)
36 if test "$LIBMCRYPT_CONFIG" = "no" ; then
37 dnl libmcrypt-config was not found (pre 2.4.11 versions)
38 dnl Try to detect libmcrypt version
48 #if MCRYPT_API_VERSION <= 19991015
56 ], libmcrypt_config_version="2.2.0"
57 if test x$libmcrypt_config_prefix != x ; then
58 TTLIBS="-L${libmcrypt_config_prefix}/libs"
59 TTINCLUDE="-I${libmcrypt_config_prefix}/include"
61 LIBMCRYPT_CFLAGS="${TTINCLUDE}"
62 LIBMCRYPT_LIBS="${TTLIBS} -lmcrypt"
63 AC_DEFINE(LIBMCRYPT22)
65 , libmcrypt_config_version="2.4.0"
66 if test x$libmcrypt_config_prefix != x ; then
67 TTLIBS="-L${libmcrypt_config_prefix}/libs"
68 TTINCLUDE="-I${libmcrypt_config_prefix}/include"
70 LIBMCRYPT_CFLAGS="${TTINCLUDE}"
71 LIBMCRYPT_LIBS="${TTLIBS} -lmcrypt -lltdl ${LIBADD_DL}"
72 AC_DEFINE(LIBMCRYPT24))
74 dnl libmcrypt-config was found
75 LIBMCRYPT_CFLAGS=`$LIBMCRYPT_CONFIG $libmcrypt_config_args --cflags`
76 LIBMCRYPT_LIBS=`$LIBMCRYPT_CONFIG $libmcrypt_config_args --libs`
77 libmcrypt_config_version=`$LIBMCRYPT_CONFIG $libmcrypt_config_args --version`
78 AC_DEFINE(LIBMCRYPT24)
81 ac_save_CFLAGS="$CFLAGS"
83 CFLAGS="$CFLAGS $LIBMCRYPT_CFLAGS"
84 LIBS="$LIBS $LIBMCRYPT_LIBS"
87 dnl Now check if the installed libmcrypt is sufficiently new. Also sanity
88 dnl checks the results of libmcrypt-config to some extent
90 rm -f conf.libmcrypttest
102 #if MCRYPT_API_VERSION <= 20010201
104 #if MCRYPT_API_VERSION <= 19991015
106 int x = mcrypt_get_key_size(MCRYPT_TWOFISH_128);
107 system ("touch conf.libmcrypttest");
109 if( strncmp( TWO, "$min_libmcrypt_version", strlen(TWO))) {
110 printf("\n*** Requested libmcrypt %s, but LIBMCRYPT (%s)\n",
111 "$min_libmcrypt_version", TWO );
112 printf("*** was found!\n");
117 /* version 2.4 before 11 */
118 MCRYPT td = mcrypt_module_open("twofish", NULL, "cbc", NULL);
119 system ("touch conf.libmcrypttest");
120 mcrypt_module_close(td);
123 #endif /* 19991015 */
127 system ("touch conf.libmcrypttest");
129 if( strcmp( mcrypt_check_version(NULL), "$libmcrypt_config_version" ) )
131 printf("\n*** 'libmcrypt-config --version' returned %s, but LIBMCRYPT (%s)\n",
132 "$libmcrypt_config_version", mcrypt_check_version(NULL) );
133 printf("*** was found! If libmcrypt-config was correct, then it is best\n");
134 printf("*** to remove the old version of LIBMCRYPT. You may also be able to fix the error\n");
135 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
136 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
137 printf("*** required on your system.\n");
138 printf("*** If libmcrypt-config was wrong, set the environment variable LIBMCRYPT_CONFIG\n");
139 printf("*** to point to the correct copy of libmcrypt-config, and remove the file config.cache\n");
140 printf("*** before re-running configure\n");
142 else if ( strcmp(mcrypt_check_version(NULL), LIBMCRYPT_VERSION ) )
144 printf("\n*** LIBMCRYPT header file (version %s) does not match\n", LIBMCRYPT_VERSION);
145 printf("*** library (version %s)\n", mcrypt_check_version(NULL) );
149 if ( mcrypt_check_version( "$min_libmcrypt_version" ) )
155 printf("no\n*** An old version of LIBMCRYPT (%s) was found.\n",
156 mcrypt_check_version(NULL) );
157 printf("*** You need a version of LIBMCRYPT newer than %s. The latest version of\n",
158 "$min_libmcrypt_version" );
159 printf("*** LIBMCRYPT is always available from ftp://mcrypt.hellug.gr/pub/mcrypt.\n");
161 printf("*** If you have already installed a sufficiently new version, this error\n");
162 printf("*** probably means that the wrong copy of the libmcrypt-config shell script is\n");
163 printf("*** being found. The easiest way to fix this is to remove the old version\n");
164 printf("*** of LIBMCRYPT, but you can also set the LIBMCRYPT_CONFIG environment to point to the\n");
165 printf("*** correct copy of libmcrypt-config. (In this case, you will have to\n");
166 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
167 printf("*** so that the correct libraries are found at run-time))\n");
172 #endif /* 20010201 */
175 ],, no_libmcrypt=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
176 CFLAGS="$ac_save_CFLAGS"
180 if test "x$no_libmcrypt" = x ; then
182 ifelse([$2], , :, [$2])
184 if test -f conf.libmcrypttest ; then
190 if test -f conf.libmcrypttest ; then
193 echo "*** Could not run libmcrypt test program, checking why..."
194 CFLAGS="$CFLAGS $LIBMCRYPT_CFLAGS"
195 LIBS="$LIBS $LIBMCRYPT_LIBS"
202 #if MCRYPT_API_VERSION <= 20010201
204 #if MCRYPT_API_VERSION <= 19991015
206 int x = mcrypt_get_key_size(MCRYPT_TWOFISH_128);
209 /* version 2.4 before 11 */
210 MCRYPT td = mcrypt_module_open("twofish", NULL, "cbc", NULL);
211 mcrypt_module_close(td);
213 #endif /* 19991015 */
216 return !!mcrypt_check_version(NULL);
218 #endif /* 20010201 */
221 [ echo "*** The test program compiled, but did not run. This usually means"
222 echo "*** that the run-time linker is not finding LIBMCRYPT or finding the wrong"
223 echo "*** version of LIBMCRYPT. If it is not finding LIBMCRYPT, you'll need to set your"
224 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
225 echo "*** to the installed location Also, make sure you have run ldconfig if that"
226 echo "*** is required on your system"
228 echo "*** If you have an old version installed, it is best to remove it, although"
229 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
231 [ echo "*** The test program failed to compile or link. See the file config.log for the"
232 echo "*** exact error that occured. This usually means LIBMCRYPT was incorrectly installed"
233 echo "*** or that you have moved LIBMCRYPT since it was installed. In the latter case, you"
234 echo "*** may want to edit the libmcrypt-config script: $LIBMCRYPT_CONFIG" ])
235 CFLAGS="$ac_save_CFLAGS"
241 ifelse([$3], , :, [$3])
243 rm -f conf.libmcrypttest
244 AC_SUBST(LIBMCRYPT_CFLAGS)
245 AC_SUBST(LIBMCRYPT_LIBS)
248 dnl *-*wedit:notab*-* Please keep this as the last line.