/[mcrypt]/mcrypt/libmcrypt.m4
ViewVC logotype

Contents of /mcrypt/libmcrypt.m4

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Tue Oct 1 11:14:29 2002 UTC (19 years, 2 months ago) by nmav
Branch: MAIN
CVS Tags: mcrypt_2_6_3, mcrypt_2_6_4, HEAD
Added large file support, based on patch by Keven Belanger <kbelanger@logicon.ca>

1 dnl Autoconf macros for libmcrypt
2 dnl $id$
3
4 # This script detects libmcrypt version and defines
5 # LIBMCRYPT_CFLAGS, LIBMCRYPT_LIBS
6 # and LIBMCRYPT24 or LIBMCRYPT22 depending on libmcrypt version
7 # found.
8
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
13
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
16 dnl
17 AC_DEFUN(AM_PATH_LIBMCRYPT,
18 [dnl
19 dnl Get the cflags and libraries from the libmcrypt-config script
20 dnl
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="")
24
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
29 fi
30 fi
31
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)
35 no_libmcrypt=""
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
39 AC_TRY_RUN([
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string.h>
43 #include <mcrypt.h>
44
45 int
46 main ()
47 {
48 #if MCRYPT_API_VERSION <= 19991015
49 /* version 2.2 */
50 return 0;
51 #else
52 /* version 2.4 */
53 return 1;
54 #endif /* 19991015 */
55 }
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"
60 fi
61 LIBMCRYPT_CFLAGS="${TTINCLUDE}"
62 LIBMCRYPT_LIBS="${TTLIBS} -lmcrypt"
63 AC_DEFINE(LIBMCRYPT22, 1, [have libmcrypt 2.2])
64
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"
69 fi
70 LIBMCRYPT_CFLAGS="${TTINCLUDE}"
71 LIBMCRYPT_LIBS="${TTLIBS} -lmcrypt -lltdl ${LIBADD_DL}"
72 AC_DEFINE(LIBMCRYPT24, 1, [have libmcrypt 2.4]))
73 else
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, 1, [have libmcrypt 2.4])
79 fi
80
81 ac_save_CFLAGS="$CFLAGS"
82 ac_save_LIBS="$LIBS"
83 CFLAGS="$CFLAGS $LIBMCRYPT_CFLAGS"
84 LIBS="$LIBS $LIBMCRYPT_LIBS"
85
86 dnl
87 dnl Now check if the installed libmcrypt is sufficiently new. Also sanity
88 dnl checks the results of libmcrypt-config to some extent
89 dnl
90 rm -f conf.libmcrypttest
91 AC_TRY_RUN([
92 #include <stdio.h>
93 #include <stdlib.h>
94 #include <string.h>
95 #include <mcrypt.h>
96
97 #define TWO "2.2"
98
99 int
100 main ()
101 {
102 #if MCRYPT_API_VERSION <= 20010201
103
104 #if MCRYPT_API_VERSION <= 19991015
105 /* version 2.2 */
106 int x = mcrypt_get_key_size(MCRYPT_TWOFISH_128);
107 system ("touch conf.libmcrypttest");
108
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");
113 return 1;
114 }
115 return 0;
116 #else
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);
121
122 return 0;
123 #endif /* 19991015 */
124
125 #else
126
127 system ("touch conf.libmcrypttest");
128
129 if( strcmp( mcrypt_check_version(NULL), "$libmcrypt_config_version" ) )
130 {
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");
141 }
142 else if ( strcmp(mcrypt_check_version(NULL), LIBMCRYPT_VERSION ) )
143 {
144 printf("\n*** LIBMCRYPT header file (version %s) does not match\n", LIBMCRYPT_VERSION);
145 printf("*** library (version %s)\n", mcrypt_check_version(NULL) );
146 }
147 else
148 {
149 if ( mcrypt_check_version( "$min_libmcrypt_version" ) )
150 {
151 return 0;
152 }
153 else
154 {
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");
160 printf("*** \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");
168 }
169 }
170 return 1;
171
172 #endif /* 20010201 */
173
174 }
175 ],, no_libmcrypt=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
176 CFLAGS="$ac_save_CFLAGS"
177 LIBS="$ac_save_LIBS"
178
179
180 if test "x$no_libmcrypt" = x ; then
181 AC_MSG_RESULT(yes)
182 ifelse([$2], , :, [$2])
183 else
184 if test -f conf.libmcrypttest ; then
185 :
186 else
187 AC_MSG_RESULT(no)
188 fi
189
190 if test -f conf.libmcrypttest ; then
191 :
192 else
193 echo "*** Could not run libmcrypt test program, checking why..."
194 CFLAGS="$CFLAGS $LIBMCRYPT_CFLAGS"
195 LIBS="$LIBS $LIBMCRYPT_LIBS"
196 AC_TRY_LINK([
197 #include <stdio.h>
198 #include <stdlib.h>
199 #include <string.h>
200 #include <mcrypt.h>
201 ], [
202 #if MCRYPT_API_VERSION <= 20010201
203
204 #if MCRYPT_API_VERSION <= 19991015
205 /* version 2.2 */
206 int x = mcrypt_get_key_size(MCRYPT_TWOFISH_128);
207 return 0;
208 #else
209 /* version 2.4 before 11 */
210 MCRYPT td = mcrypt_module_open("twofish", NULL, "cbc", NULL);
211 mcrypt_module_close(td);
212 return 0;
213 #endif /* 19991015 */
214 #else
215
216 return !!mcrypt_check_version(NULL);
217
218 #endif /* 20010201 */
219
220 ],
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"
227 echo "***"
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"
230 echo "***" ],
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"
236 LIBS="$ac_save_LIBS"
237 fi
238
239 LIBMCRYPT_CFLAGS=""
240 LIBMCRYPT_LIBS=""
241 ifelse([$3], , :, [$3])
242 fi
243 rm -f conf.libmcrypttest
244 AC_SUBST(LIBMCRYPT_CFLAGS)
245 AC_SUBST(LIBMCRYPT_LIBS)
246 ])
247
248 dnl *-*wedit:notab*-* Please keep this as the last line.

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26