upload http
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / srclib / apr-util / build / dbm.m4
1 dnl
2 dnl DBM module
3 dnl
4
5
6 dnl   APU_LIB_BERKELEY_DB(major, minor, patch, places, headers, libnames)
7 dnl
8 dnl   Search for a useable version of Berkeley DB in a number of
9 dnl   common places.  The installed DB must be no older than the
10 dnl   version given by MAJOR, MINOR, and PATCH.  All of these
11 dnl   arguments are allowed to be '-1', indicating we don't care.
12 dnl   PLACES is a list of places to search for a Berkeley DB
13 dnl   installation.  HEADERS is a list of headers to try.  LIBNAMES
14 dnl   is a list of names of the library to attempt to link against,
15 dnl   typically 'db' and 'db4'.
16 dnl
17 dnl   If we find a useable version, set CPPFLAGS and LIBS as
18 dnl   appropriate, and set the shell variable `apu_have_db' to
19 dnl   `1', and apu_db_lib to the matching lib name, and apu_db_header
20 dnl   to the header to use.  Otherwise, set `apu_have_db' to `0'.
21 dnl
22 dnl   This macro also checks for the `--with-berkeley-db=PATH' flag;
23 dnl   if given, the macro will use the PATH specified, and the
24 dnl   configuration script will die if it can't find the library.  If
25 dnl   the user gives the `--without-berkeley-db' flag, the entire
26 dnl   search is skipped.
27 dnl
28 dnl   We cache the results of individual searches under particular
29 dnl   prefixes, not the overall result of whether we found Berkeley
30 dnl   DB.  That way, the user can re-run the configure script with
31 dnl   different --with-berkeley-db switch values, without interference
32 dnl   from the cache.
33
34
35 AC_DEFUN(APU_CHECK_BERKELEY_DB, [
36   bdb_version=$1
37   if test "$2" != "-1"; then
38     bdb_version="$bdb_version.$2"
39     if test "$3" != "-1"; then
40       bdb_version="$bdb_version.$3"
41     fi
42   fi
43   bdb_places=$4
44   bdb_default_search_headers=$5
45   bdb_default_search_lib_names=$6
46
47   apu_have_db=0
48
49   # Save the original values of the flags we tweak.
50   apu_check_lib_save_libs="$LIBS"
51   apu_check_lib_save_ldflags="$LDFLAGS"
52   apu_check_lib_save_cppflags="$CPPFLAGS"
53
54   # The variable `found' is the prefix under which we've found
55   # Berkeley DB, or `not' if we haven't found it anywhere yet.
56   found=not
57   for bdb_place in $bdb_places; do
58
59     LDFLAGS="$apu_check_lib_save_ldflags"
60     CPPFLAGS="$apu_check_lib_save_cppflags"
61     case "$bdb_place" in
62       "std" )
63         description="the standard places"
64       ;;
65       *":"* )
66         header="`echo $bdb_place | sed -e 's/:.*$//'`"
67         lib="`echo $bdb_place | sed -e 's/^.*://'`"
68         CPPFLAGS="$CPPFLAGS -I$header"
69         LDFLAGS="$LDFLAGS -L$lib"
70         description="$header and $lib"
71       ;;
72       * )
73         if test -d $bdb_place; then
74           LDFLAGS="$LDFLAGS -L$bdb_place/lib"
75           CPPFLAGS="$CPPFLAGS -I$bdb_place/include"
76         else
77           AC_MSG_CHECKING([for Berkeley DB $bdb_version in $bdb_place])
78           AC_MSG_RESULT([directory not found])
79           continue
80         fi
81         description="$bdb_place"
82       ;;
83     esac
84
85     # Since there is no AC_MSG_NOTICE in autoconf 2.13, we use this
86     # trick to display a message instead.
87     AC_MSG_CHECKING([for Berkeley DB $bdb_version in $description])
88     AC_MSG_RESULT()
89
90     for bdb_libname in $bdb_default_search_lib_names; do
91       for bdb_header in $bdb_default_search_headers; do
92         # Clear the header cache variable for each location
93         changequote(,)
94         cache_id="`echo ac_cv_header_${bdb_header} \
95                  | sed -e 's/[^a-zA-Z0-9_]/_/g'`"
96         changequote([,])
97         unset $cache_id
98         AC_CHECK_HEADER([$bdb_header], [
99           if test "$1" = "3" -o "$1" = "4"; then
100             # We generate a separate cache variable for each prefix and libname
101             # we search under.  That way, we avoid caching information that
102             # changes if the user runs `configure' with a different set of
103             # switches.
104             changequote(,)
105             cache_id="`echo apu_cv_check_berkeley_db_$1_$2_$3_${bdb_header}_${bdb_libname}_in_${bdb_place} \
106                      | sed -e 's/[^a-zA-Z0-9_]/_/g'`"
107             changequote([,])
108
109             AC_MSG_CHECKING([for -l$bdb_libname])
110             dnl We can't use AC_CACHE_CHECK here, because that won't print out
111             dnl the value of the computed cache variable properly.
112             AC_CACHE_VAL($cache_id,
113               [
114                 APU_TRY_BERKELEY_DB($1, $2, $3, $bdb_header, $bdb_libname)
115                 eval "$cache_id=$apu_try_berkeley_db"
116               ])
117             result="`eval echo '$'$cache_id`"
118             AC_MSG_RESULT($result)
119           elif test "$1" = "1"; then
120             AC_CHECK_LIB($bdb_libname,
121               dbopen,
122               [result=yes],
123               [result=no]
124             )
125           elif test "$1" = "2"; then
126             AC_CHECK_LIB($bdb_libname,
127               db_open,
128               [result=yes],
129               [result=no]
130             )
131           fi
132         ], [result="no"])
133         
134         # If we found it, no need to search any more.
135         if test "$result" = "yes"; then
136           found="$bdb_place"
137           break
138         fi
139       done
140       test "$found" != "not" && break
141     done
142     test "$found" != "not" && break
143   done
144
145   # Restore the original values of the flags we tweak.
146   LDFLAGS="$apu_check_lib_save_ldflags"
147   CPPFLAGS="$apu_check_lib_save_cppflags"
148
149   case "$found" in
150   "not")
151     apu_have_db=0
152     ;;
153   "std")
154     apu_db_header=$bdb_header
155     apu_db_lib=$bdb_libname
156     apu_have_db=1
157     ;;
158   *":"*)
159     header="`echo $found | sed -e 's/:.*$//'`"
160     lib="`echo $found | sed -e 's/^.*://'`"
161
162     APR_ADDTO(APRUTIL_INCLUDES, [-I$header])
163     APR_ADDTO(APRUTIL_LDFLAGS, [-L$lib])
164     apu_db_header=$bdb_header
165     apu_db_lib=$bdb_libname
166     apu_have_db=1
167     ;;
168   *)
169     APR_ADDTO(APRUTIL_INCLUDES, [-I$found/include])
170     APR_ADDTO(APRUTIL_LDFLAGS, [-L$found/lib])
171     apu_db_header=$bdb_header
172     apu_db_lib=$bdb_libname
173     apu_have_db=1
174     ;;
175   esac
176 ])
177
178
179 dnl   APU_TRY_BERKELEY_DB(major, minor, patch, header, libname)
180 dnl
181 dnl   A subroutine of APU_CHECK_BERKELEY_DB.
182 dnl
183 dnl   Check that a new-enough version of Berkeley DB is installed.
184 dnl   "New enough" means no older than the version given by MAJOR,
185 dnl   MINOR, and PATCH.  The result of the test is not cached; no
186 dnl   messages are printed.  Use HEADER as the header file to include.
187 dnl   Use LIBNAME as the library to link against.
188 dnl   (e.g. LIBNAME should usually be "db" or "db4".)
189 dnl
190 dnl   Set the shell variable `apu_try_berkeley_db' to `yes' if we found
191 dnl   an appropriate version installed, or `no' otherwise.
192 dnl
193 dnl   This macro uses the Berkeley DB library function `db_version' to
194 dnl   find the version.  If the library installed doesn't have this
195 dnl   function, then this macro assumes it is too old.
196
197 dnl   NOTE: This is pretty messed up.  It seems that the FreeBSD port of
198 dnl   Berkeley DB 4 puts the header file in /usr/local/include/db4, but the
199 dnl   database library in /usr/local/lib, as libdb4.[a|so].  There is no
200 dnl   /usr/local/include/db.h.  So if you check for /usr/local first, you'll
201 dnl   get the old header file from /usr/include, and the new library from
202 dnl   /usr/local/lib.  Disaster.  Thus this test compares the version constants
203 dnl   in the db.h header with the ones returned by db_version().
204
205
206 AC_DEFUN(APU_TRY_BERKELEY_DB,
207   [
208     apu_try_berkeley_db_save_libs="$LIBS"
209
210     apu_check_berkeley_db_major=$1
211     apu_check_berkeley_db_minor=$2
212     apu_check_berkeley_db_patch=$3
213     apu_try_berkeley_db_header=$4
214     apu_try_berkeley_db_libname=$5
215
216     LIBS="$LIBS -l$apu_try_berkeley_db_libname"
217     AC_TRY_RUN(
218       [
219 #include <stdlib.h>
220 #include <stdio.h>
221 #include <$apu_try_berkeley_db_header>
222 main ()
223 {
224   int major, minor, patch;
225
226   db_version(&major, &minor, &patch);
227
228   /* Sanity check: ensure that db.h constants actually match the db library */
229   if (major != DB_VERSION_MAJOR
230       || minor != DB_VERSION_MINOR
231       || patch != DB_VERSION_PATCH)
232     exit (1);
233
234   /* Run-time check:  ensure the library claims to be the correct version. */
235
236   if ($apu_check_berkeley_db_major != -1) {
237     if (major < $apu_check_berkeley_db_major)
238       exit (1);
239     if (major > $apu_check_berkeley_db_major)
240       exit (0);
241   }
242
243   if ($apu_check_berkeley_db_minor != -1) {
244     if (minor < $apu_check_berkeley_db_minor)
245       exit (1);
246     if (minor > $apu_check_berkeley_db_minor)
247       exit (0);
248   }
249
250   if ($apu_check_berkeley_db_patch == -1
251       || patch >= $apu_check_berkeley_db_patch)
252     exit (0);
253   else
254     exit (1);
255 }
256       ],
257       [apu_try_berkeley_db=yes],
258       [apu_try_berkeley_db=no],
259       [apu_try_berkeley_db=yes]
260     )
261
262     LIBS="$apu_try_berkeley_db_save_libs"
263   ]
264 )
265
266
267 dnl
268 dnl APU_CHECK_DB1: is DB1 present?
269 dnl
270 dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
271 dnl
272 AC_DEFUN(APU_CHECK_DB1, [
273   places=$1
274   if test -z "$places"; then
275     places="std"
276   fi
277   APU_CHECK_BERKELEY_DB(1, 0, 0,
278     "$places",
279     "db1/db.h db.h",
280     "db1"
281   )
282   if test "$apu_have_db" = "1"; then
283     apu_db_version=1
284   fi
285 ])
286
287
288 dnl
289 dnl APU_CHECK_DB185: is DB1.85 present?
290 dnl
291 dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
292 dnl
293 dnl NB: BerkelyDB v2 and above can be compiled in 1.85 mode
294 dnl which has a libdb not libdb1 or libdb185
295 AC_DEFUN(APU_CHECK_DB185, [
296   places=$1
297   if test -z "$places"; then
298     places="std"
299   fi
300   APU_CHECK_BERKELEY_DB(1, -1, -1,
301     "$places",
302     "db_185.h",
303     "db"
304   )
305   if test "$apu_have_db" = "1"; then
306     apu_db_version=185
307   fi
308 ])
309
310
311 dnl
312 dnl APU_CHECK_DB2: is DB2 present?
313 dnl
314 dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
315 dnl
316 AC_DEFUN(APU_CHECK_DB2, [
317   places=$1
318   if test -z "$places"; then
319     places="std"
320   fi
321   APU_CHECK_BERKELEY_DB(2, -1, -1,
322     "$places",
323     "db2/db.h db.h",
324     "db2 db"
325   )
326   if test "$apu_have_db" = "1"; then
327     apu_db_version=2
328   fi
329 ])
330
331
332 dnl
333 dnl APU_CHECK_DB3: is DB3 present?
334 dnl
335 dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
336 dnl
337 AC_DEFUN(APU_CHECK_DB3, [
338   places=$1
339   if test -z "$places"; then
340     places="std"
341   fi
342   APU_CHECK_BERKELEY_DB(3, -1, -1,
343     "$places",
344     "db3/db.h db.h",
345     "db3 db"
346   )
347   if test "$apu_have_db" = "1"; then
348     apu_db_version=3
349   fi
350 ])
351
352
353 dnl
354 dnl APU_CHECK_DB4: is DB4 present?
355 dnl
356 dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
357 dnl
358 AC_DEFUN(APU_CHECK_DB4, [
359   places=$1
360   if test -z "$places"; then
361     places="std /usr/local /usr/local/BerkeleyDB.4.0 /boot/home/config"
362   fi
363   APU_CHECK_BERKELEY_DB("4", "0", "-1",
364     "$places",
365     "db4/db.h db.h",
366     "db-4.0 db4 db"
367   )
368   if test "$apu_have_db" = "1"; then
369     apu_db_version=4
370   fi
371 ])
372
373
374 dnl
375 dnl APU_CHECK_DB41: is DB4.1 present?
376 dnl
377 dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
378 dnl
379 AC_DEFUN(APU_CHECK_DB41, [
380   places=$1
381   if test -z "$places"; then
382     places="std /usr/local /usr/local/BerkeleyDB.4.1 /boot/home/config"
383   fi
384   APU_CHECK_BERKELEY_DB("4", "1", "-1",
385     "$places",
386     "db41/db.h db4/db.h db.h",
387     "db-4.1 db41 db4 db"
388   )
389   if test "$apu_have_db" = "1"; then
390     apu_db_version=4
391   fi
392 ])
393
394
395 dnl
396 dnl APU_CHECK_DB42: is DB4.2 present?
397 dnl
398 dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
399 dnl
400 AC_DEFUN(APU_CHECK_DB42, [
401   places=$1
402   if test -z "$places"; then
403     places="std /usr/local /usr/local/BerkeleyDB.4.2 /boot/home/config"
404   fi
405   APU_CHECK_BERKELEY_DB("4", "2", "-1",
406     "$places",
407     "db42/db.h db4/db.h db.h",
408     "db-4.2 db42 db4 db"
409   )
410   if test "$apu_have_db" = "1"; then
411     apu_db_version=4
412   fi
413 ])
414 dnl
415 dnl APU_CHECK_DB43: is DB4.3 present?
416 dnl
417 dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
418 dnl
419 AC_DEFUN(APU_CHECK_DB43, [
420   places=$1
421   if test -z "$places"; then
422     places="std /usr/local/BerkeleyDB.4.3 /boot/home/config"
423   fi
424   APU_CHECK_BERKELEY_DB("4", "3", "-1",
425     "$places",
426     "db43/db.h db4/db.h db.h",
427     "db-4.3 db4-4.3 db43 db4 db"
428   )
429   if test "$apu_have_db" = "1"; then
430     apu_db_version=4
431   fi
432 ])
433 dnl
434 dnl APU_CHECK_DB44: is DB4.4 present?
435 dnl
436 dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
437 dnl
438 AC_DEFUN([APU_CHECK_DB44], [
439   places=$1
440   if test -z "$places"; then
441     places="std /usr/local/BerkeleyDB.4.4 /boot/home/config"
442   fi
443   APU_CHECK_BERKELEY_DB("4", "4", "-1",
444     "$places",
445     "db44/db.h db4/db.h db.h",
446     "db-4.4 db4-4.4 db44 db4 db"
447   )
448   if test "$apu_have_db" = "1"; then
449     apu_db_version=4
450   fi
451 ])
452 dnl
453 dnl APU_CHECK_DB45: is DB4.5 present?
454 dnl
455 dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
456 dnl
457 AC_DEFUN([APU_CHECK_DB45], [
458   places=$1
459   if test -z "$places"; then
460     places="std /usr/local/BerkeleyDB.4.5 /boot/home/config"
461   fi
462   APU_CHECK_BERKELEY_DB("4", "5", "-1",
463     "$places",
464     "db45/db.h db4/db.h db.h",
465     "db-4.5 db4-4.5 db45 db4 db"
466   )
467   if test "$apu_have_db" = "1"; then
468     apu_db_version=4
469   fi
470 ])
471 dnl
472 dnl APU_CHECK_DB46: is DB4.6 present?
473 dnl
474 dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
475 dnl
476 AC_DEFUN([APU_CHECK_DB46], [
477   places=$1
478   if test -z "$places"; then
479     places="std /usr/local/BerkeleyDB.4.6 /boot/home/config"
480   fi
481   APU_CHECK_BERKELEY_DB("4", "6", "-1",
482     "$places",
483     "db46/db.h db4/db.h db.h",
484     "db-4.6 db4-4.6 db46 db4 db"
485   )
486   if test "$apu_have_db" = "1"; then
487     apu_db_version=4
488   fi
489 ])
490 dnl
491 dnl APU_CHECK_DB47: is DB4.7 present?
492 dnl
493 dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
494 dnl
495 AC_DEFUN([APU_CHECK_DB47], [
496   places=$1
497   if test -z "$places"; then
498     places="std /usr/local/BerkeleyDB.4.7 /boot/home/config"
499   fi
500   APU_CHECK_BERKELEY_DB("4", "7", "-1",
501     "$places",
502     "db47/db.h db4/db.h db.h",
503     "db-4.7 db4-4.7 db47 db4 db"
504   )
505   if test "$apu_have_db" = "1"; then
506     apu_db_version=4
507   fi
508 ])
509 dnl
510 dnl APU_CHECK_DB48: is DB4.8 present?
511 dnl
512 dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
513 dnl
514 AC_DEFUN([APU_CHECK_DB48], [
515   places=$1
516   if test -z "$places"; then
517     places="std /usr/local/BerkeleyDB.4.8 /boot/home/config"
518   fi
519   APU_CHECK_BERKELEY_DB("4", "8", "-1",
520     "$places",
521     "db48/db.h db4/db.h db.h",
522     "db-4.8 db4-4.8 db48 db4 db"
523   )
524   if test "$apu_have_db" = "1"; then
525     apu_db_version=4
526   fi
527 ])
528
529 AC_DEFUN(APU_CHECK_DB, [
530   requested=$1
531   check_places=$2
532
533   case "$requested" in
534   db)
535     APU_CHECK_DB_ALL("$check_places")
536     if test "$apu_have_db" = "0"; then
537       AC_MSG_ERROR(Berkeley db requested, but not found)
538     fi
539     ;;
540   db1)
541     APU_CHECK_DB1("$check_places")
542     if test "$apu_db_version" != "1"; then
543       AC_MSG_ERROR(Berkeley db1 not found)
544     fi
545     ;;
546   db185)
547     APU_CHECK_DB185("$check_places")
548     if test "$apu_db_version" != "185"; then
549       AC_MSG_ERROR(Berkeley db185 not found)
550     fi
551     ;;
552   db2)
553     APU_CHECK_DB2("$check_places")
554     if test "$apu_db_version" != "2"; then
555       AC_MSG_ERROR(Berkeley db2 not found)
556     fi
557     ;;
558   db3)
559     APU_CHECK_DB3("$check_places")
560     if test "$apu_db_version" != "3"; then
561       AC_MSG_ERROR(Berkeley db3 not found)
562     fi
563     ;;
564   db4)
565     APU_CHECK_DB4("$check_places")
566     if test "$apu_db_version" != "4"; then
567       AC_MSG_ERROR(Berkeley db4 not found)
568     fi
569     ;;
570   db41)
571     APU_CHECK_DB41("$check_places")
572     if test "$apu_db_version" != "4"; then
573       AC_MSG_ERROR(Berkeley db4 not found)
574     fi
575     ;;
576   db42)
577     APU_CHECK_DB42("$check_places")
578     if test "$apu_db_version" != "4"; then
579       AC_MSG_ERROR(Berkeley db4 not found)
580     fi
581     ;;
582   db43)
583     APU_CHECK_DB43("$check_places")
584     if test "$apu_db_version" != "4"; then
585       AC_MSG_ERROR(Berkeley db4 not found)
586     fi
587     ;;
588   db44)
589     APU_CHECK_DB44("$check_places")
590     if test "$apu_db_version" != "4"; then
591       AC_MSG_ERROR(Berkeley db4 not found)
592     fi
593     ;;
594   db45)
595     APU_CHECK_DB45("$check_places")
596     if test "$apu_db_version" != "4"; then
597       AC_MSG_ERROR(Berkeley db4 not found)
598     fi
599     ;;
600   db46)
601     APU_CHECK_DB46("$check_places")
602     if test "$apu_db_version" != "4"; then
603       AC_MSG_ERROR(Berkeley db4 not found)
604     fi
605     ;;
606   db47)
607     APU_CHECK_DB47("$check_places")
608     if test "$apu_db_version" != "4"; then
609       AC_MSG_ERROR(Berkeley db4 not found)
610     fi
611     ;;
612   db48)
613     APU_CHECK_DB48("$check_places")
614     if test "$apu_db_version" != "4"; then
615       AC_MSG_ERROR(Berkeley db4 not found)
616     fi
617     ;;
618   default)
619     APU_CHECK_DB_ALL("$check_places")
620     ;;
621   esac
622 ])
623
624 dnl
625 dnl APU_CHECK_DB_ALL: Try all Berkeley DB versions, from 4.8 to 1.
626 dnl
627 AC_DEFUN(APU_CHECK_DB_ALL, [
628   all_places=$1
629  
630   APU_CHECK_DB48("$all_places")
631   if test "$apu_db_version" != "4"; then
632     APU_CHECK_DB47("$all_places")
633     if test "$apu_db_version" != "4"; then
634       APU_CHECK_DB46("$all_places")
635       if test "$apu_db_version" != "4"; then
636         APU_CHECK_DB45("$all_places")
637         if test "$apu_db_version" != "4"; then
638           APU_CHECK_DB44("$all_places")
639           if test "$apu_db_version" != "4"; then
640             APU_CHECK_DB43("$all_places")
641             if test "$apu_db_version" != "4"; then
642               APU_CHECK_DB42("$all_places")
643               if test "$apu_db_version" != "4"; then
644                 APU_CHECK_DB41("$all_places")
645                 if test "$apu_db_version" != "4"; then
646                   APU_CHECK_DB4("$all_places")
647                   if test "$apu_db_version" != "4"; then
648                     APU_CHECK_DB3("$all_places")
649                     if test "$apu_db_version" != "3"; then
650                       APU_CHECK_DB2("$all_places")
651                       if test "$apu_db_version" != "2"; then
652                         APU_CHECK_DB1("$all_places")
653                         if test "$apu_db_version" != "1"; then
654                           APU_CHECK_DB185("$all_places")
655                         fi
656                       fi
657                     fi
658                   fi
659                 fi
660               fi
661             fi
662           fi
663         fi
664       fi
665     fi
666   fi
667   AC_MSG_CHECKING(for Berkeley DB)
668   if test "$apu_have_db" = "1"; then
669     AC_MSG_RESULT(found db$apu_db_version)
670   else
671     AC_MSG_RESULT(not found)
672   fi
673 ])
674
675
676 dnl
677 dnl APU_CHECK_DBM: see what kind of DBM backend to use for apr_dbm.
678 dnl
679 AC_DEFUN(APU_CHECK_DBM, [
680   apu_use_sdbm=0
681   apu_use_ndbm=0
682   apu_use_gdbm=0
683   apu_use_db=0
684   dnl it's in our codebase
685   apu_have_sdbm=1
686   apu_have_gdbm=0
687   apu_have_ndbm=0
688   apu_have_db=0
689
690   apu_db_header=db.h                # default so apu_select_dbm.h is syntactically correct
691   apu_db_version=0
692
693   AC_ARG_WITH(dbm, [
694     --with-dbm=DBM          choose the DBM type to use.
695       DBM={sdbm,gdbm,ndbm,db,db1,db185,db2,db3,db4,db41,db42,db43,db44,db45,db46,db47,db48}
696   ], [
697     if test "$withval" = "yes"; then
698       AC_MSG_ERROR([--with-dbm needs to specify a DBM type to use.
699         One of: sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4, db41, db42, db43, db44, db45, db46, db47, db48])
700     fi
701     requested="$withval"
702   ], [
703     requested=default
704   ])
705
706   dnl We don't pull in GDBM unless the user asks for it, since it's GPL
707   AC_ARG_WITH([gdbm], [
708     --with-gdbm=DIR          specify GDBM location
709   ], [
710     apu_have_gdbm=0
711     if test "$withval" = "yes"; then
712       AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1]))
713     elif test "$withval" = "no"; then
714       apu_have_gdbm=0
715     else
716       CPPFLAGS="-I$withval/include"
717       LIBS="-L$withval/lib "
718
719       AC_MSG_CHECKING(checking for gdbm in $withval)
720       AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1]))
721       if test "$apu_have_gdbm" != "0"; then
722         APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
723         APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
724       fi
725     fi
726   ])
727
728   AC_ARG_WITH([ndbm], [
729     --with-ndbm=PATH 
730       Find the NDBM header and library in \`PATH/include' and 
731       \`PATH/lib'.  If PATH is of the form \`HEADER:LIB', then search 
732       for header files in HEADER, and the library in LIB.  If you omit
733       the \`=PATH' part completely, the configure script will search
734       for NDBM in a number of standard places.
735   ], [
736     apu_have_ndbm=0
737     if test "$withval" = "yes"; then
738       AC_MSG_CHECKING(checking for ndbm in the usual places)
739       apu_want_ndbm=1
740       NDBM_INC=""
741       NDBM_LDFLAGS=""
742     elif test "$withval" = "no"; then
743       apu_want_ndbm=0
744     else
745       apu_want_ndbm=1
746       case "$withval" in
747         *":"*)
748           NDBM_INC="-I`echo $withval |sed -e 's/:.*$//'`"
749           NDBM_LDFLAGS="-L`echo $withval |sed -e 's/^.*://'`"
750           AC_MSG_CHECKING(checking for ndbm includes with $NDBM_INC libs with $NDBM_LDFLAGS )
751         ;;
752         *)
753           NDBM_INC="-I$withval/include"
754           NDBM_LDFLAGS="-L$withval/lib"
755           AC_MSG_CHECKING(checking for ndbm includes in $withval)
756         ;;
757       esac
758     fi
759
760     save_cppflags="$CPPFLAGS"
761     save_ldflags="$LDFLAGS"
762     CPPFLAGS="$CPPFLAGS $NDBM_INC"
763     LDFLAGS="$LDFLAGS $NDBM_LDFLAGS"
764     dnl db_ndbm_open is what sleepcat's compatibility library actually has in it's lib
765     if test "$apu_want_ndbm" != "0"; then
766       AC_CHECK_HEADER(ndbm.h, 
767         AC_CHECK_LIB(c, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=c],
768           AC_CHECK_LIB(dbm, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=dbm],
769             AC_CHECK_LIB(db, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db],
770               AC_CHECK_LIB(db, __db_ndbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db])
771             )
772           )
773         )
774       )
775       if test "$apu_have_ndbm" != "0";  then
776         if test "$withval" != "yes"; then
777           APR_ADDTO(APRUTIL_INCLUDES, [$NDBM_INC])
778           APR_ADDTO(APRUTIL_LDFLAGS, [$NDBM_LDFLAGS])
779         fi
780       elif test "$withval" != "yes"; then
781         AC_ERROR( NDBM not found in the specified directory)
782       fi
783     fi
784     CPPFLAGS="$save_cppflags"
785     LDFLAGS="$save_ldflags"
786   ], [
787     dnl don't check it no one has asked us for it
788     apu_have_ndbm=0
789   ])
790
791
792   if test -n "$apu_db_xtra_libs"; then
793     saveddbxtralibs="$LIBS"
794     LIBS="$apu_db_xtra_libs $LIBS"
795   fi
796
797   dnl We're going to try to find the highest version of Berkeley DB supported.
798   dnl
799   dnl Note that we only do this if the user requested it, since the Sleepycat
800   dnl license is viral and requires distribution of source along with programs
801   dnl that use it.
802   AC_ARG_WITH([berkeley-db], [
803     --with-berkeley-db=PATH
804       Find the Berkeley DB header and library in \`PATH/include' and
805       \`PATH/lib'.  If PATH is of the form \`HEADER:LIB', then search
806       for header files in HEADER, and the library in LIB.  If you omit
807       the \`=PATH' part completely, the configure script will search
808       for Berkeley DB in a number of standard places.
809   ], [
810     if test "$withval" = "yes"; then
811       apu_want_db=1
812       user_places=""
813     elif test "$withval" = "no"; then
814       apu_want_db=0
815     else
816       apu_want_db=1
817       user_places="$withval"
818     fi
819
820     if test "$apu_want_db" != "0"; then
821       APU_CHECK_DB($requested, $user_places)
822       if test "$apu_have_db" = "0"; then
823         AC_ERROR(Berkeley DB not found.)
824       fi
825     fi 
826   ])
827
828   if test -n "$apu_db_xtra_libs"; then
829     LIBS="$saveddbxtralibs"
830   fi
831
832   case "$requested" in
833     sdbm)
834       apu_use_sdbm=1
835       apu_default_dbm=sdbm
836       ;;
837     gdbm)
838       apu_use_gdbm=1
839       apu_default_dbm=gdbm
840       ;;
841     ndbm)
842       apu_use_ndbm=1
843       apu_default_dbm=ndbm
844       ;;
845     db)
846       apu_use_db=1
847       apu_default_dbm=db
848       ;;
849     db1)
850       apu_use_db=1
851       apu_default_dbm=db1
852       ;;
853     db185)
854       apu_use_db=1
855       apu_default_dbm=db185
856       ;;
857     db2)
858       apu_use_db=1
859       apu_default_dbm=db2
860       ;;
861     db3)
862       apu_use_db=1
863       apu_default_dbm=db3
864       ;;
865     db4)
866       apu_use_db=1
867       apu_default_dbm=db4
868       ;;
869     db41)
870       apu_use_db=1
871       apu_default_dbm=db4
872       ;;
873     db42)
874       apu_use_db=1
875       apu_default_dbm=db4
876       ;;
877     db43)
878       apu_use_db=1
879       apu_default_dbm=db4
880       ;;
881     db44)
882       apu_use_db=1
883       apu_default_dbm=db4
884       ;;
885     db45)
886       apu_use_db=1
887       apu_default_dbm=db4
888       ;;
889     db46)
890       apu_use_db=1
891       apu_default_dbm=db4
892       ;;
893     db47)
894       apu_use_db=1
895       apu_default_dbm=db4
896       ;;
897     db48)
898       apu_use_db=1
899       apu_default_dbm=db4
900       ;;
901     default)
902       dnl ### use more sophisticated DBMs for the default?
903       apu_default_dbm="sdbm (default)"
904       apu_use_sdbm=1
905       ;;
906     *)
907       AC_MSG_ERROR([--with-dbm=$look_for is an unknown DBM type.
908         Use one of: sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4, db41, db42, db43, db44, db45, db46, db47, db48])
909       ;;
910   esac
911
912   dnl Yes, it'd be nice if we could collate the output in an order
913   dnl so that the AC_MSG_CHECKING would be output before the actual
914   dnl checks, but it isn't happening now.
915   AC_MSG_CHECKING(for default DBM)
916   AC_MSG_RESULT($apu_default_dbm)
917
918   AC_SUBST(apu_use_sdbm)
919   AC_SUBST(apu_use_gdbm)
920   AC_SUBST(apu_use_ndbm)
921   AC_SUBST(apu_use_db)
922
923   AC_SUBST(apu_have_sdbm)
924   AC_SUBST(apu_have_gdbm)
925   AC_SUBST(apu_have_ndbm)
926   AC_SUBST(apu_have_db)
927   AC_SUBST(apu_db_header)
928   AC_SUBST(apu_db_version)
929
930   dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
931   dnl we know the library is there.
932   if test "$apu_have_gdbm" = "1"; then
933     APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lgdbm])
934     APR_ADDTO(APRUTIL_LIBS,[-lgdbm])
935   fi
936
937   if test "$apu_have_ndbm" = "1"; then
938     APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l$apu_ndbm_lib])
939     APR_ADDTO(APRUTIL_LIBS,[-l$apu_ndbm_lib])
940   fi
941
942   if test "$apu_have_db" = "1"; then
943     APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l$apu_db_lib])
944     APR_ADDTO(APRUTIL_LIBS,[-l$apu_db_lib])
945     if test -n "apu_db_xtra_libs"; then
946       APR_ADDTO(APRUTIL_EXPORT_LIBS,[$apu_db_xtra_libs])
947       APR_ADDTO(APRUTIL_LIBS,[$apu_db_xtra_libs])
948     fi
949   fi
950 ])
951