Line 0
Link Here
|
|
|
1 |
# |
2 |
# Makros from http://ac-archive.sourceforge.net |
3 |
# These makros should be used while the ac-archive ebuild is still |
4 |
# masked in Portage |
5 |
# |
6 |
# Used makros: |
7 |
# - ax_path_bdb v1.1 |
8 |
# - ax_compare_versio v1.1 |
9 |
# |
10 |
# The Makros are under this License: |
11 |
# Every Autoconf macro presented on this web site is free software; |
12 |
# you can redistribute it and/or modify it under the terms of the |
13 |
# GNU General Public License as published by the Free Software |
14 |
# Foundation; either version 2, or (at your option) any later version. |
15 |
# |
16 |
# They are distributed in the hope that they will be useful, but |
17 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 |
# GNU General Public License for more details. (You should have |
20 |
# received a copy of the GNU General Public License along with this |
21 |
# program; if not, write to the Free Software Foundation, Inc., |
22 |
# 59 Temple Place -- Suite 330, Boston, MA 02111-1307, USA.) |
23 |
# |
24 |
# As a special exception, the Free Software Foundation gives |
25 |
# unlimited permission to copy, distribute and modify the configure |
26 |
# scripts that are the output of Autoconf. You need not follow the |
27 |
# terms of the GNU General Public License when using or distributing |
28 |
# such scripts, even though portions of the text of Autoconf appear |
29 |
# in them. The GNU General Public License (GPL) does govern all other |
30 |
# use of the material that constitutes the Autoconf program. |
31 |
# |
32 |
# Certain portions of the Autoconf source text are designed to be |
33 |
# copied (in certain cases, depending on the input) into the output |
34 |
# of Autoconf. We call these the "data" portions. The rest of the |
35 |
# Autoconf source text consists of comments plus executable code that |
36 |
# decides which of the data portions to output in any given case. We |
37 |
# call these comments and executable code the "non-data" portions. |
38 |
# Autoconf never copies any of the non-data portions into its output. |
39 |
# |
40 |
# This special exception to the GPL applies to versions of Autoconf |
41 |
# released by the Free Software Foundation. When you make and distribute |
42 |
# a modified version of Autoconf, you may extend this special exception |
43 |
# to the GPL to apply to your modified version as well, *unless* your |
44 |
# modified version has the potential to copy into its output some of the |
45 |
# text that was the non-data portion of the version that you started |
46 |
# with. (In other words, unless your change moves or copies text from |
47 |
# the non-data portions to the data portions.) If your modification has |
48 |
# such potential, you must delete any notice of this special exception |
49 |
# to the GPL from your modified version. |
50 |
# |
51 |
# |
52 |
|
53 |
|
54 |
dnl ######################################################################### |
55 |
AC_DEFUN([AX_COMPARE_VERSION], [ |
56 |
# Used to indicate true or false condition |
57 |
ax_compare_version=false |
58 |
|
59 |
# Convert the two version strings to be compared into a format that |
60 |
# allows a simple string comparison. The end result is that a version |
61 |
# string of the form 1.12.5-r617 will be converted to the form |
62 |
# 0001001200050617. In other words, each number is zero padded to four |
63 |
# digits, and non digits are removed. |
64 |
AS_VAR_PUSHDEF([A],[ax_compare_version_A]) |
65 |
A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ |
66 |
-e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ |
67 |
-e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ |
68 |
-e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ |
69 |
-e 's/[[^0-9]]//g'` |
70 |
|
71 |
AS_VAR_PUSHDEF([B],[ax_compare_version_B]) |
72 |
B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ |
73 |
-e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ |
74 |
-e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ |
75 |
-e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ |
76 |
-e 's/[[^0-9]]//g'` |
77 |
|
78 |
dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary |
79 |
dnl # then the first line is used to determine if the condition is true. |
80 |
dnl # The sed right after the echo is to remove any indented white space. |
81 |
m4_case(m4_tolower($2), |
82 |
[lt],[ |
83 |
ax_compare_version=`echo "x$A |
84 |
x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"` |
85 |
], |
86 |
[gt],[ |
87 |
ax_compare_version=`echo "x$A |
88 |
x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"` |
89 |
], |
90 |
[le],[ |
91 |
ax_compare_version=`echo "x$A |
92 |
x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"` |
93 |
], |
94 |
[ge],[ |
95 |
ax_compare_version=`echo "x$A |
96 |
x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` |
97 |
],[ |
98 |
dnl Split the operator from the subversion count if present. |
99 |
m4_bmatch(m4_substr($2,2), |
100 |
[0],[ |
101 |
# A count of zero means use the length of the shorter version. |
102 |
# Determine the number of characters in A and B. |
103 |
ax_compare_version_len_A=`echo "$A" | awk '{print(length)}'` |
104 |
ax_compare_version_len_B=`echo "$B" | awk '{print(length)}'` |
105 |
|
106 |
# Set A to no more than B's length and B to no more than A's length. |
107 |
A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"` |
108 |
B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"` |
109 |
], |
110 |
[[0-9]+],[ |
111 |
# A count greater than zero means use only that many subversions |
112 |
A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` |
113 |
B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` |
114 |
], |
115 |
[.+],[ |
116 |
AC_WARNING( |
117 |
[illegal OP numeric parameter: $2]) |
118 |
],[]) |
119 |
|
120 |
# Pad zeros at end of numbers to make same length. |
121 |
ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`" |
122 |
B="$B`echo $A | sed 's/./0/g'`" |
123 |
A="$ax_compare_version_tmp_A" |
124 |
|
125 |
# Check for equality or inequality as necessary. |
126 |
m4_case(m4_tolower(m4_substr($2,0,2)), |
127 |
[eq],[ |
128 |
test "x$A" = "x$B" && ax_compare_version=true |
129 |
], |
130 |
[ne],[ |
131 |
test "x$A" != "x$B" && ax_compare_version=true |
132 |
],[ |
133 |
AC_WARNING([illegal OP parameter: $2]) |
134 |
]) |
135 |
]) |
136 |
|
137 |
AS_VAR_POPDEF([A])dnl |
138 |
AS_VAR_POPDEF([B])dnl |
139 |
|
140 |
dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE. |
141 |
if test "$ax_compare_version" = "true" ; then |
142 |
m4_ifvaln([$4],[$4],[:])dnl |
143 |
m4_ifvaln([$5],[else $5])dnl |
144 |
fi |
145 |
]) dnl AX_COMPARE_VERSION |
146 |
|
147 |
|
148 |
dnl ######################################################################### |
149 |
AC_DEFUN([AX_PATH_BDB], [ |
150 |
dnl # Used to indicate success or failure of this function. |
151 |
ax_path_bdb_ok=no |
152 |
|
153 |
# Add --with-bdb-dir option to configure. |
154 |
AC_ARG_WITH([bdb-dir], |
155 |
[AC_HELP_STRING([--with-bdb-dir=DIR], |
156 |
[Berkeley DB installation directory])]) |
157 |
|
158 |
# Check if --with-bdb-dir was specified. |
159 |
if test "x$with_bdb_dir" = "x" ; then |
160 |
# No option specified, so just search the system. |
161 |
AX_PATH_BDB_NO_OPTIONS([$1], [HIGHEST], [ |
162 |
ax_path_bdb_ok=yes |
163 |
]) |
164 |
else |
165 |
# Set --with-bdb-dir option. |
166 |
ax_path_bdb_INC="$with_bdb_dir/include" |
167 |
ax_path_bdb_LIB="$with_bdb_dir/lib" |
168 |
|
169 |
dnl # Save previous environment, and modify with new stuff. |
170 |
ax_path_bdb_save_CPPFLAGS="$CPPFLAGS" |
171 |
CPPFLAGS="-I$ax_path_bdb_INC $CPPFLAGS" |
172 |
|
173 |
ax_path_bdb_save_LDFLAGS=$LDFLAGS |
174 |
LDFLAGS="-L$ax_path_bdb_LIB $LDFLAGS" |
175 |
|
176 |
# Check for specific header file db.h |
177 |
AC_MSG_CHECKING([db.h presence in $ax_path_bdb_INC]) |
178 |
if test -f "$ax_path_bdb_INC/db.h" ; then |
179 |
AC_MSG_RESULT([yes]) |
180 |
# Check for library |
181 |
AX_PATH_BDB_NO_OPTIONS([$1], [ENVONLY], [ |
182 |
ax_path_bdb_ok=yes |
183 |
BDB_CPPFLAGS="-I$ax_path_bdb_INC" |
184 |
BDB_LDFLAGS="-L$ax_path_bdb_LIB" |
185 |
]) |
186 |
else |
187 |
AC_MSG_RESULT([no]) |
188 |
AC_MSG_NOTICE([no usable Berkeley DB not found]) |
189 |
fi |
190 |
|
191 |
dnl # Restore the environment. |
192 |
CPPFLAGS="$ax_path_bdb_save_CPPFLAGS" |
193 |
LDFLAGS="$ax_path_bdb_save_LDFLAGS" |
194 |
|
195 |
fi |
196 |
|
197 |
dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND. |
198 |
if test "$ax_path_bdb_ok" = "yes" ; then |
199 |
m4_ifvaln([$2],[$2],[:])dnl |
200 |
m4_ifvaln([$3],[else $3])dnl |
201 |
fi |
202 |
|
203 |
]) dnl AX_PATH_BDB |
204 |
|
205 |
dnl ######################################################################### |
206 |
dnl Check for berkeley DB of at least MINIMUM-VERSION on system. |
207 |
dnl |
208 |
dnl The OPTION argument determines how the checks occur, and can be one of: |
209 |
dnl |
210 |
dnl HIGHEST - Check both the environment and the default installation |
211 |
dnl directories for Berkeley DB and choose the version that |
212 |
dnl is highest. (default) |
213 |
dnl ENVFIRST - Check the environment first, and if no satisfactory |
214 |
dnl library is found there check the default installation |
215 |
dnl directories for Berkeley DB which is /usr/local/BerkeleyDB* |
216 |
dnl ENVONLY - Check the current environment only. |
217 |
dnl |
218 |
dnl Requires AX_PATH_BDB_PATH_GET_VERSION, AX_PATH_BDB_PATH_FIND_HIGHEST, |
219 |
dnl AX_PATH_BDB_ENV_CONFIRM_LIB, AX_PATH_BDB_ENV_GET_VERSION, and |
220 |
dnl AX_COMPARE_VERSION macros. |
221 |
dnl |
222 |
dnl Result: sets ax_path_bdb_no_options_ok to yes or no |
223 |
dnl sets BDB_LIBS, BDB_CPPFLAGS, BDB_LDFLAGS, BDB_VERSION |
224 |
dnl |
225 |
dnl AX_PATH_BDB_NO_OPTIONS([MINIMUM-VERSION], [OPTION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
226 |
AC_DEFUN([AX_PATH_BDB_NO_OPTIONS], [ |
227 |
dnl # Used to indicate success or failure of this function. |
228 |
ax_path_bdb_no_options_ok=no |
229 |
|
230 |
# Values to add to environment to use Berkeley DB. |
231 |
BDB_VERSION='' |
232 |
BDB_LIBS='' |
233 |
BDB_CPPFLAGS='' |
234 |
BDB_LDFLAGS='' |
235 |
|
236 |
# Check cross compilation here. |
237 |
if test "x$cross_compiling" = "xyes" ; then |
238 |
# If cross compiling, can't use AC_RUN_IFELSE so do these tests. |
239 |
# The AC_PREPROC_IFELSE confirms that db.h is preprocessable, |
240 |
# and extracts the version number from it. |
241 |
AC_MSG_CHECKING([for db.h]) |
242 |
|
243 |
AS_VAR_PUSHDEF([HEADER_VERSION],[ax_path_bdb_no_options_HEADER_VERSION])dnl |
244 |
HEADER_VERSION='' |
245 |
AC_PREPROC_IFELSE([ |
246 |
AC_LANG_SOURCE([[ |
247 |
#include <db.h> |
248 |
AX_PATH_BDB_STUFF DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH |
249 |
]]) |
250 |
],[ |
251 |
# Extract version from preprocessor output. |
252 |
HEADER_VERSION=`eval "$ac_cpp conftest.$ac_ext" 2> /dev/null \ |
253 |
| grep AX_PATH_BDB_STUFF | sed 's/[[^0-9,]]//g;s/,/./g;1q'` |
254 |
],[]) |
255 |
|
256 |
if test "x$HEADER_VERSION" = "x" ; then |
257 |
AC_MSG_RESULT([no]) |
258 |
else |
259 |
AC_MSG_RESULT([$HEADER_VERSION]) |
260 |
|
261 |
# Check that version is high enough. |
262 |
AX_COMPARE_VERSION([$HEADER_VERSION],[ge],[$1],[ |
263 |
# get major and minor version numbers |
264 |
AS_VAR_PUSHDEF([MAJ],[ax_path_bdb_no_options_MAJOR])dnl |
265 |
MAJ=`echo $HEADER_VERSION | sed 's,\..*,,'` |
266 |
AS_VAR_PUSHDEF([MIN],[ax_path_bdb_no_options_MINOR])dnl |
267 |
MIN=`echo $HEADER_VERSION | sed 's,^[[0-9]]*\.,,;s,\.[[0-9]]*$,,'` |
268 |
|
269 |
dnl # Save LIBS. |
270 |
ax_path_bdb_no_options_save_LIBS="$LIBS" |
271 |
|
272 |
# Check that we can link with the library. |
273 |
AC_SEARCH_LIBS([db_version], |
274 |
[db db-$MAJ.$MIN db$MAJ.$MIN db$MAJ$MIN db-$MAJ db$MAJ],[ |
275 |
# Sucessfully found library. |
276 |
ax_path_bdb_no_options_ok=yes |
277 |
BDB_VERSION=$HEADER_VERSION |
278 |
|
279 |
# Extract library from LIBS |
280 |
ax_path_bdb_no_options_LEN=` \ |
281 |
echo "x$ax_path_bdb_no_options_save_LIBS" \ |
282 |
| awk '{print(length)}'` |
283 |
BDB_LIBS=`echo "x$LIBS " \ |
284 |
| sed "s/.\{$ax_path_bdb_no_options_LEN\}\$//;s/^x//;s/ //g"` |
285 |
],[]) |
286 |
|
287 |
dnl # Restore LIBS |
288 |
LIBS="$ax_path_bdb_no_options_save_LIBS" |
289 |
|
290 |
AS_VAR_POPDEF([MAJ])dnl |
291 |
AS_VAR_POPDEF([MIN])dnl |
292 |
]) |
293 |
fi |
294 |
|
295 |
AS_VAR_POPDEF([HEADER_VERSION])dnl |
296 |
else |
297 |
# Not cross compiling. |
298 |
# Check version of Berkeley DB in the current environment. |
299 |
AX_PATH_BDB_ENV_GET_VERSION([ |
300 |
AX_COMPARE_VERSION([$ax_path_bdb_env_get_version_VERSION],[ge],[$1],[ |
301 |
# Found acceptable version in current environment. |
302 |
ax_path_bdb_no_options_ok=yes |
303 |
BDB_VERSION="$ax_path_bdb_env_get_version_VERSION" |
304 |
BDB_LIBS="$ax_path_bdb_env_get_version_LIBS" |
305 |
]) |
306 |
]) |
307 |
|
308 |
# Determine if we need to search /usr/local/BerkeleyDB* |
309 |
ax_path_bdb_no_options_DONE=no |
310 |
if test "x$2" = "xENVONLY" ; then |
311 |
ax_path_bdb_no_options_DONE=yes |
312 |
elif test "x$2" = "xENVFIRST" ; then |
313 |
ax_path_bdb_no_options_DONE=$ax_path_bdb_no_options_ok |
314 |
fi |
315 |
|
316 |
if test "$ax_path_bdb_no_options_DONE" = "no" ; then |
317 |
# Check for highest in /usr/local/BerkeleyDB* |
318 |
AX_PATH_BDB_PATH_FIND_HIGHEST([ |
319 |
if test "$ax_path_bdb_no_options_ok" = "yes" ; then |
320 |
# If we already have an acceptable version use this if higher. |
321 |
AX_COMPARE_VERSION( |
322 |
[$ax_path_bdb_path_find_highest_VERSION],[gt],[$BDB_VERSION]) |
323 |
else |
324 |
# Since we didn't have an acceptable version check if this one is. |
325 |
AX_COMPARE_VERSION( |
326 |
[$ax_path_bdb_path_find_highest_VERSION],[ge],[$1]) |
327 |
fi |
328 |
]) |
329 |
|
330 |
dnl # If result from _AX_COMPARE_VERSION is true we want this version. |
331 |
if test "$ax_compare_version" = "true" ; then |
332 |
ax_path_bdb_no_options_ok=yes |
333 |
BDB_LIBS="-ldb" |
334 |
BDB_CPPFLAGS="-I$ax_path_bdb_path_find_highest_DIR/include" |
335 |
BDB_LDFLAGS="-L$ax_path_bdb_path_find_highest_DIR/lib" |
336 |
BDB_VERSION="$ax_path_bdb_path_find_highest_VERSION" |
337 |
fi |
338 |
fi |
339 |
fi |
340 |
|
341 |
dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND. |
342 |
if test "$ax_path_bdb_no_options_ok" = "yes" ; then |
343 |
AC_MSG_NOTICE([using Berkeley DB version $BDB_VERSION]) |
344 |
AC_DEFINE([HAVE_DB_H],[1], |
345 |
[Define to 1 if you have the <db.h> header file.]) |
346 |
m4_ifvaln([$3],[$3])dnl |
347 |
else |
348 |
AC_MSG_NOTICE([no Berkeley DB version $1 or higher found]) |
349 |
m4_ifvaln([$4],[$4])dnl |
350 |
fi |
351 |
]) dnl AX_PATH_BDB_NO_OPTIONS |
352 |
|
353 |
dnl ######################################################################### |
354 |
dnl Check the default installation directory for Berkeley DB which is |
355 |
dnl of the form /usr/local/BerkeleyDB* for the highest version. |
356 |
dnl |
357 |
dnl Result: sets ax_path_bdb_path_find_highest_ok to yes or no, |
358 |
dnl sets ax_path_bdb_path_find_highest_VERSION to version, |
359 |
dnl sets ax_path_bdb_path_find_highest_DIR to directory. |
360 |
dnl |
361 |
dnl AX_PATH_BDB_PATH_FIND_HIGHEST([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
362 |
AC_DEFUN([AX_PATH_BDB_PATH_FIND_HIGHEST], [ |
363 |
dnl # Used to indicate success or failure of this function. |
364 |
ax_path_bdb_path_find_highest_ok=no |
365 |
|
366 |
AS_VAR_PUSHDEF([VERSION],[ax_path_bdb_path_find_highest_VERSION])dnl |
367 |
VERSION='' |
368 |
|
369 |
ax_path_bdb_path_find_highest_DIR='' |
370 |
|
371 |
# find highest verison in default install directory for Berkeley DB |
372 |
AS_VAR_PUSHDEF([CURDIR],[ax_path_bdb_path_find_highest_CURDIR])dnl |
373 |
AS_VAR_PUSHDEF([CUR_VERSION],[ax_path_bdb_path_get_version_VERSION])dnl |
374 |
|
375 |
for CURDIR in `ls -d /usr/local/BerkeleyDB* 2> /dev/null` |
376 |
do |
377 |
AX_PATH_BDB_PATH_GET_VERSION([$CURDIR],[ |
378 |
AX_COMPARE_VERSION([$CUR_VERSION],[gt],[$VERSION],[ |
379 |
ax_path_bdb_path_find_highest_ok=yes |
380 |
ax_path_bdb_path_find_highest_DIR="$CURDIR" |
381 |
VERSION="$CUR_VERSION" |
382 |
]) |
383 |
]) |
384 |
done |
385 |
|
386 |
AS_VAR_POPDEF([VERSION])dnl |
387 |
AS_VAR_POPDEF([CUR_VERSION])dnl |
388 |
AS_VAR_POPDEF([CURDIR])dnl |
389 |
|
390 |
dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND. |
391 |
if test "$ax_path_bdb_path_find_highest_ok" = "yes" ; then |
392 |
m4_ifvaln([$1],[$1],[:])dnl |
393 |
m4_ifvaln([$2],[else $2])dnl |
394 |
fi |
395 |
|
396 |
]) dnl AX_PATH_BDB_PATH_FIND_HIGHEST |
397 |
|
398 |
dnl ######################################################################### |
399 |
dnl Checks for Berkeley DB in specified directory's lib and include |
400 |
dnl subdirectories. |
401 |
dnl |
402 |
dnl Result: sets ax_path_bdb_path_get_version_ok to yes or no, |
403 |
dnl sets ax_path_bdb_path_get_version_VERSION to version. |
404 |
dnl |
405 |
dnl AX_PATH_BDB_PATH_GET_VERSION(BDB-DIR, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
406 |
AC_DEFUN([AX_PATH_BDB_PATH_GET_VERSION], [ |
407 |
dnl # Used to indicate success or failure of this function. |
408 |
ax_path_bdb_path_get_version_ok=no |
409 |
|
410 |
# Indicate status of checking for Berkeley DB header. |
411 |
AC_MSG_CHECKING([in $1/include for db.h]) |
412 |
ax_path_bdb_path_get_version_got_header=no |
413 |
test -f "$1/include/db.h" && ax_path_bdb_path_get_version_got_header=yes |
414 |
AC_MSG_RESULT([$ax_path_bdb_path_get_version_got_header]) |
415 |
|
416 |
# Indicate status of checking for Berkeley DB library. |
417 |
AC_MSG_CHECKING([in $1/lib for library -ldb]) |
418 |
|
419 |
ax_path_bdb_path_get_version_VERSION='' |
420 |
|
421 |
if test -d "$1/include" && test -d "$1/lib" && |
422 |
test "$ax_path_bdb_path_get_version_got_header" = "yes" ; then |
423 |
dnl # save and modify environment |
424 |
ax_path_bdb_path_get_version_save_CPPFLAGS="$CPPFLAGS" |
425 |
CPPFLAGS="-I$1/include $CPPFLAGS" |
426 |
|
427 |
ax_path_bdb_path_get_version_save_LIBS="$LIBS" |
428 |
LIBS="$LIBS -ldb" |
429 |
|
430 |
ax_path_bdb_path_get_version_save_LDFLAGS="$LDFLAGS" |
431 |
LDFLAGS="-L$1/lib $LDFLAGS" |
432 |
|
433 |
# Compile and run a program that compares the version defined in |
434 |
# the header file with a version defined in the library function |
435 |
# db_version. |
436 |
AC_RUN_IFELSE([ |
437 |
AC_LANG_SOURCE([[ |
438 |
#include <stdio.h> |
439 |
#include <db.h> |
440 |
int main(int argc,char **argv) |
441 |
{ |
442 |
int major,minor,patch; |
443 |
db_version(&major,&minor,&patch); |
444 |
if (argc > 1) |
445 |
printf("%d.%d.%d\n",DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH); |
446 |
if (DB_VERSION_MAJOR == major && DB_VERSION_MINOR == minor && |
447 |
DB_VERSION_PATCH == patch) |
448 |
return 0; |
449 |
else |
450 |
return 1; |
451 |
} |
452 |
]]) |
453 |
],[ |
454 |
# Program compiled and ran, so get version by adding argument. |
455 |
ax_path_bdb_path_get_version_VERSION=`./conftest$ac_exeext x` |
456 |
ax_path_bdb_path_get_version_ok=yes |
457 |
],[],[]) |
458 |
|
459 |
dnl # restore environment |
460 |
CPPFLAGS="$ax_path_bdb_path_get_version_save_CPPFLAGS" |
461 |
LIBS="$ax_path_bdb_path_get_version_save_LIBS" |
462 |
LDFLAGS="$ax_path_bdb_path_get_version_save_LDFLAGS" |
463 |
fi |
464 |
|
465 |
dnl # Finally, execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND. |
466 |
if test "$ax_path_bdb_path_get_version_ok" = "yes" ; then |
467 |
AC_MSG_RESULT([$ax_path_bdb_path_get_version_VERSION]) |
468 |
m4_ifvaln([$2],[$2])dnl |
469 |
else |
470 |
AC_MSG_RESULT([no]) |
471 |
m4_ifvaln([$3],[$3])dnl |
472 |
fi |
473 |
]) dnl AX_PATH_BDB_PATH_GET_VERSION |
474 |
|
475 |
############################################################################# |
476 |
dnl Checks if version of library and header match specified version. |
477 |
dnl Only meant to be used by AX_PATH_BDB_ENV_GET_VERSION macro. |
478 |
dnl |
479 |
dnl Requires AX_COMPARE_VERSION macro. |
480 |
dnl |
481 |
dnl Result: sets ax_path_bdb_env_confirm_lib_ok to yes or no. |
482 |
dnl |
483 |
dnl AX_PATH_BDB_ENV_CONFIRM_LIB(VERSION, [LIBNAME]) |
484 |
AC_DEFUN([AX_PATH_BDB_ENV_CONFIRM_LIB], [ |
485 |
dnl # Used to indicate success or failure of this function. |
486 |
ax_path_bdb_env_confirm_lib_ok=no |
487 |
|
488 |
dnl # save and modify environment to link with library LIBNAME |
489 |
ax_path_bdb_env_confirm_lib_save_LIBS="$LIBS" |
490 |
LIBS="$LIBS $2" |
491 |
|
492 |
# Compile and run a program that compares the version defined in |
493 |
# the header file with a version defined in the library function |
494 |
# db_version. |
495 |
AC_RUN_IFELSE([ |
496 |
AC_LANG_SOURCE([[ |
497 |
#include <stdio.h> |
498 |
#include <db.h> |
499 |
int main(int argc,char **argv) |
500 |
{ |
501 |
int major,minor,patch; |
502 |
db_version(&major,&minor,&patch); |
503 |
if (argc > 1) |
504 |
printf("%d.%d.%d\n",DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH); |
505 |
if (DB_VERSION_MAJOR == major && DB_VERSION_MINOR == minor && |
506 |
DB_VERSION_PATCH == patch) |
507 |
return 0; |
508 |
else |
509 |
return 1; |
510 |
} |
511 |
]]) |
512 |
],[ |
513 |
# Program compiled and ran, so get version by giving an argument, |
514 |
# which will tell the program to print the output. |
515 |
ax_path_bdb_env_confirm_lib_VERSION=`./conftest$ac_exeext x` |
516 |
|
517 |
# If the versions all match up, indicate success. |
518 |
AX_COMPARE_VERSION([$ax_path_bdb_env_confirm_lib_VERSION],[eq],[$1],[ |
519 |
ax_path_bdb_env_confirm_lib_ok=yes |
520 |
]) |
521 |
],[],[]) |
522 |
|
523 |
dnl # restore environment |
524 |
LIBS="$ax_path_bdb_env_confirm_lib_save_LIBS" |
525 |
|
526 |
]) dnl AX_PATH_BDB_ENV_CONFIRM_LIB |
527 |
|
528 |
############################################################################# |
529 |
dnl Finds the version and library name for Berkeley DB in the |
530 |
dnl current environment. Tries many different names for library. |
531 |
dnl |
532 |
dnl Requires AX_PATH_BDB_ENV_CONFIRM_LIB macro. |
533 |
dnl |
534 |
dnl Result: set ax_path_bdb_env_get_version_ok to yes or no, |
535 |
dnl set ax_path_bdb_env_get_version_VERSION to the version found, |
536 |
dnl and ax_path_bdb_env_get_version_LIBNAME to the library name. |
537 |
dnl |
538 |
dnl AX_PATH_BDB_ENV_GET_VERSION([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
539 |
AC_DEFUN([AX_PATH_BDB_ENV_GET_VERSION], [ |
540 |
dnl # Used to indicate success or failure of this function. |
541 |
ax_path_bdb_env_get_version_ok=no |
542 |
|
543 |
ax_path_bdb_env_get_version_VERSION='' |
544 |
ax_path_bdb_env_get_version_LIBS='' |
545 |
|
546 |
AS_VAR_PUSHDEF([HEADER_VERSION],[ax_path_bdb_env_get_version_HEADER_VERSION])dnl |
547 |
AS_VAR_PUSHDEF([TEST_LIBNAME],[ax_path_bdb_env_get_version_TEST_LIBNAME])dnl |
548 |
|
549 |
# Indicate status of checking for Berkeley DB library. |
550 |
AC_MSG_CHECKING([for db.h]) |
551 |
|
552 |
# Compile and run a program that determines the Berkeley DB version |
553 |
# in the header file db.h. |
554 |
HEADER_VERSION='' |
555 |
AC_RUN_IFELSE([ |
556 |
AC_LANG_SOURCE([[ |
557 |
#include <stdio.h> |
558 |
#include <db.h> |
559 |
int main(int argc,char **argv) |
560 |
{ |
561 |
if (argc > 1) |
562 |
printf("%d.%d.%d\n",DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH); |
563 |
return 0; |
564 |
} |
565 |
]]) |
566 |
],[ |
567 |
# Program compiled and ran, so get version by adding an argument. |
568 |
HEADER_VERSION=`./conftest$ac_exeext x` |
569 |
AC_MSG_RESULT([$HEADER_VERSION]) |
570 |
],[AC_MSG_RESULT([no])],[AC_MSG_RESULT([no])]) |
571 |
|
572 |
# Have header version, so try to find corresponding library. |
573 |
# Looks for library names in the order: |
574 |
# nothing, db, db-X.Y, dbX.Y, dbXY, db-X, dbX |
575 |
# and stops when it finds the first one that matches the version |
576 |
# of the header file. |
577 |
if test "x$HEADER_VERSION" != "x" ; then |
578 |
AC_MSG_CHECKING([for library containing Berkeley DB $HEADER_VERSION]) |
579 |
|
580 |
AS_VAR_PUSHDEF([MAJOR],[ax_path_bdb_env_get_version_MAJOR])dnl |
581 |
AS_VAR_PUSHDEF([MINOR],[ax_path_bdb_env_get_version_MINOR])dnl |
582 |
|
583 |
# get major and minor version numbers |
584 |
MAJOR=`echo $HEADER_VERSION | sed 's,\..*,,'` |
585 |
MINOR=`echo $HEADER_VERSION | sed 's,^[[0-9]]*\.,,;s,\.[[0-9]]*$,,'` |
586 |
|
587 |
# see if it is already specified in LIBS |
588 |
TEST_LIBNAME='' |
589 |
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME]) |
590 |
|
591 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then |
592 |
# try format "db" |
593 |
TEST_LIBNAME='-ldb' |
594 |
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME]) |
595 |
fi |
596 |
|
597 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then |
598 |
# try format "db-X.Y" |
599 |
TEST_LIBNAME="-ldb-${MAJOR}.$MINOR" |
600 |
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME]) |
601 |
fi |
602 |
|
603 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then |
604 |
# try format "dbX.Y" |
605 |
TEST_LIBNAME="-ldb${MAJOR}.$MINOR" |
606 |
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME]) |
607 |
fi |
608 |
|
609 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then |
610 |
# try format "dbXY" |
611 |
TEST_LIBNAME="-ldb$MAJOR$MINOR" |
612 |
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME]) |
613 |
fi |
614 |
|
615 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then |
616 |
# try format "db-X" |
617 |
TEST_LIBNAME="-ldb-$MAJOR" |
618 |
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME]) |
619 |
fi |
620 |
|
621 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then |
622 |
# try format "dbX" |
623 |
TEST_LIBNAME="-ldb$MAJOR" |
624 |
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME]) |
625 |
fi |
626 |
|
627 |
dnl # Found a valid library. |
628 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "yes" ; then |
629 |
if test "x$TEST_LIBNAME" = "x" ; then |
630 |
AC_MSG_RESULT([none required]) |
631 |
else |
632 |
AC_MSG_RESULT([$TEST_LIBNAME]) |
633 |
fi |
634 |
ax_path_bdb_env_get_version_VERSION="$HEADER_VERSION" |
635 |
ax_path_bdb_env_get_version_LIBS="$TEST_LIBNAME" |
636 |
ax_path_bdb_env_get_version_ok=yes |
637 |
else |
638 |
AC_MSG_RESULT([no]) |
639 |
fi |
640 |
|
641 |
AS_VAR_POPDEF([MAJOR])dnl |
642 |
AS_VAR_POPDEF([MINOR])dnl |
643 |
fi |
644 |
|
645 |
AS_VAR_POPDEF([HEADER_VERSION])dnl |
646 |
AS_VAR_POPDEF([TEST_LIBNAME])dnl |
647 |
|
648 |
dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND. |
649 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "yes" ; then |
650 |
m4_ifvaln([$1],[$1],[:])dnl |
651 |
m4_ifvaln([$2],[else $2])dnl |
652 |
fi |
653 |
|
654 |
]) dnl BDB_ENV_GET_VERSION |
655 |
|
656 |
############################################################################# |
657 |
|
658 |
|