1 |
dnl Autoconf macros for libmcrypt |
2 |
dnl $id$ |
3 |
|
4 |
# Modified for LIBMCRYPT -- nmav |
5 |
# Configure paths for LIBGCRYPT |
6 |
# Shamelessly stolen from the one of XDELTA by Owen Taylor |
7 |
# Werner Koch 99-12-09 |
8 |
|
9 |
dnl AM_PATH_LIBMCRYPT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) |
10 |
dnl Test for libmcrypt, and define LIBMCRYPT_CFLAGS and LIBMCRYPT_LIBS |
11 |
dnl |
12 |
AC_DEFUN(AM_PATH_LIBMCRYPT, |
13 |
[dnl |
14 |
dnl Get the cflags and libraries from the libmcrypt-config script |
15 |
dnl |
16 |
AC_ARG_WITH(libmcrypt-prefix, |
17 |
[ --with-libmcrypt-prefix=PFX Prefix where libmcrypt is installed (optional)], |
18 |
libmcrypt_config_prefix="$withval", libmcrypt_config_prefix="") |
19 |
|
20 |
if test x$libmcrypt_config_prefix != x ; then |
21 |
libmcrypt_config_args="$libmcrypt_config_args --prefix=$libmcrypt_config_prefix" |
22 |
if test x${LIBMCRYPT_CONFIG+set} != xset ; then |
23 |
LIBMCRYPT_CONFIG=$libmcrypt_config_prefix/bin/libmcrypt-config |
24 |
fi |
25 |
fi |
26 |
|
27 |
AC_PATH_PROG(LIBMCRYPT_CONFIG, libmcrypt-config, no) |
28 |
min_libmcrypt_version=ifelse([$1], ,0.1.0,$1) |
29 |
AC_MSG_CHECKING(for libmcrypt - version >= $min_libmcrypt_version) |
30 |
no_libmcrypt="" |
31 |
if test "$LIBMCRYPT_CONFIG" = "no" ; then |
32 |
no_libmcrypt=yes |
33 |
else |
34 |
LIBMCRYPT_CFLAGS=`$LIBMCRYPT_CONFIG $libmcrypt_config_args --cflags` |
35 |
LIBMCRYPT_LIBS=`$LIBMCRYPT_CONFIG $libmcrypt_config_args --libs` |
36 |
libmcrypt_config_version=`$LIBMCRYPT_CONFIG $libmcrypt_config_args --version` |
37 |
|
38 |
|
39 |
ac_save_CFLAGS="$CFLAGS" |
40 |
ac_save_LIBS="$LIBS" |
41 |
CFLAGS="$CFLAGS $LIBMCRYPT_CFLAGS" |
42 |
LIBS="$LIBS $LIBMCRYPT_LIBS" |
43 |
dnl |
44 |
dnl Now check if the installed libmcrypt is sufficiently new. Also sanity |
45 |
dnl checks the results of libmcrypt-config to some extent |
46 |
dnl |
47 |
rm -f conf.libmcrypttest |
48 |
AC_TRY_RUN([ |
49 |
#include <stdio.h> |
50 |
#include <stdlib.h> |
51 |
#include <string.h> |
52 |
#include <mcrypt.h> |
53 |
|
54 |
int |
55 |
main () |
56 |
{ |
57 |
#if MCRYPT_API_VERSION <= 20010201 |
58 |
printf("\n*** An old version of libmcrypt was found. Please upgrade at least to 2.4.10\n"); |
59 |
return 1; |
60 |
#endif |
61 |
system ("touch conf.libmcrypttest"); |
62 |
|
63 |
if( strcmp( mcrypt_check_version(NULL), "$libmcrypt_config_version" ) ) |
64 |
{ |
65 |
printf("\n*** 'libmcrypt-config --version' returned %s, but LIBMCRYPT (%s)\n", |
66 |
"$libmcrypt_config_version", mcrypt_check_version(NULL) ); |
67 |
printf("*** was found! If libmcrypt-config was correct, then it is best\n"); |
68 |
printf("*** to remove the old version of LIBMCRYPT. You may also be able to fix the error\n"); |
69 |
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); |
70 |
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); |
71 |
printf("*** required on your system.\n"); |
72 |
printf("*** If libmcrypt-config was wrong, set the environment variable LIBMCRYPT_CONFIG\n"); |
73 |
printf("*** to point to the correct copy of libmcrypt-config, and remove the file config.cache\n"); |
74 |
printf("*** before re-running configure\n"); |
75 |
} |
76 |
else if ( strcmp(mcrypt_check_version(NULL), LIBMCRYPT_VERSION ) ) |
77 |
{ |
78 |
printf("\n*** LIBMCRYPT header file (version %s) does not match\n", LIBMCRYPT_VERSION); |
79 |
printf("*** library (version %s)\n", mcrypt_check_version(NULL) ); |
80 |
} |
81 |
else |
82 |
{ |
83 |
if ( mcrypt_check_version( "$min_libmcrypt_version" ) ) |
84 |
{ |
85 |
return 0; |
86 |
} |
87 |
else |
88 |
{ |
89 |
printf("no\n*** An old version of LIBMCRYPT (%s) was found.\n", |
90 |
mcrypt_check_version(NULL) ); |
91 |
printf("*** You need a version of LIBMCRYPT newer than %s. The latest version of\n", |
92 |
"$min_libmcrypt_version" ); |
93 |
printf("*** LIBMCRYPT is always available from ftp://mcrypt.hellug.gr/pub/mcrypt.\n"); |
94 |
printf("*** \n"); |
95 |
printf("*** If you have already installed a sufficiently new version, this error\n"); |
96 |
printf("*** probably means that the wrong copy of the libmcrypt-config shell script is\n"); |
97 |
printf("*** being found. The easiest way to fix this is to remove the old version\n"); |
98 |
printf("*** of LIBMCRYPT, but you can also set the LIBMCRYPT_CONFIG environment to point to the\n"); |
99 |
printf("*** correct copy of libmcrypt-config. (In this case, you will have to\n"); |
100 |
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); |
101 |
printf("*** so that the correct libraries are found at run-time))\n"); |
102 |
} |
103 |
} |
104 |
return 1; |
105 |
} |
106 |
],, no_libmcrypt=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) |
107 |
CFLAGS="$ac_save_CFLAGS" |
108 |
LIBS="$ac_save_LIBS" |
109 |
fi |
110 |
|
111 |
if test "x$no_libmcrypt" = x ; then |
112 |
AC_MSG_RESULT(yes) |
113 |
ifelse([$2], , :, [$2]) |
114 |
else |
115 |
if test -f conf.libmcrypttest ; then |
116 |
: |
117 |
else |
118 |
AC_MSG_RESULT(no) |
119 |
fi |
120 |
if test "$LIBMCRYPT_CONFIG" = "no" ; then |
121 |
echo "*** The libmcrypt-config script installed by LIBMCRYPT could not be found" |
122 |
echo "*** If LIBMCRYPT was installed in PREFIX, make sure PREFIX/bin is in" |
123 |
echo "*** your path, or set the LIBMCRYPT_CONFIG environment variable to the" |
124 |
echo "*** full path to libmcrypt-config." |
125 |
else |
126 |
if test -f conf.libmcrypttest ; then |
127 |
: |
128 |
else |
129 |
echo "*** Could not run libmcrypt test program, checking why..." |
130 |
CFLAGS="$CFLAGS $LIBMCRYPT_CFLAGS" |
131 |
LIBS="$LIBS $LIBMCRYPT_LIBS" |
132 |
AC_TRY_LINK([ |
133 |
#include <stdio.h> |
134 |
#include <stdlib.h> |
135 |
#include <string.h> |
136 |
#include <mcrypt.h> |
137 |
], [ return !!mcrypt_check_version(NULL); ], |
138 |
[ echo "*** The test program compiled, but did not run. This usually means" |
139 |
echo "*** that the run-time linker is not finding LIBMCRYPT or finding the wrong" |
140 |
echo "*** version of LIBMCRYPT. If it is not finding LIBMCRYPT, you'll need to set your" |
141 |
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" |
142 |
echo "*** to the installed location Also, make sure you have run ldconfig if that" |
143 |
echo "*** is required on your system" |
144 |
echo "***" |
145 |
echo "*** If you have an old version installed, it is best to remove it, although" |
146 |
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" |
147 |
echo "***" ], |
148 |
[ echo "*** The test program failed to compile or link. See the file config.log for the" |
149 |
echo "*** exact error that occured. This usually means LIBMCRYPT was incorrectly installed" |
150 |
echo "*** or that you have moved LIBMCRYPT since it was installed. In the latter case, you" |
151 |
echo "*** may want to edit the libmcrypt-config script: $LIBMCRYPT_CONFIG" ]) |
152 |
CFLAGS="$ac_save_CFLAGS" |
153 |
LIBS="$ac_save_LIBS" |
154 |
fi |
155 |
fi |
156 |
LIBMCRYPT_CFLAGS="" |
157 |
LIBMCRYPT_LIBS="" |
158 |
ifelse([$3], , :, [$3]) |
159 |
fi |
160 |
AC_SUBST(LIBMCRYPT_CFLAGS) |
161 |
AC_SUBST(LIBMCRYPT_LIBS) |
162 |
]) |
163 |
|
164 |
dnl *-*wedit:notab*-* Please keep this as the last line. |