1dnl -------------------------------------------------------- -*- autoconf -*-
2dnl Licensed to the Apache Software Foundation (ASF) under one or more
3dnl contributor license agreements.  See the NOTICE file distributed with
4dnl this work for additional information regarding copyright ownership.
5dnl The ASF licenses this file to You under the Apache License, Version 2.0
6dnl (the "License"); you may not use this file except in compliance with
7dnl the License.  You may obtain a copy of the License at
8dnl
9dnl     http://www.apache.org/licenses/LICENSE-2.0
10dnl
11dnl Unless required by applicable law or agreed to in writing, software
12dnl distributed under the License is distributed on an "AS IS" BASIS,
13dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14dnl See the License for the specific language governing permissions and
15dnl limitations under the License.
16
17
18dnl
19dnl DBM module
20dnl
21
22dnl   APU_LIB_BERKELEY_DB(major, minor, patch, places, headers, libnames)
23dnl
24dnl   Search for a useable version of Berkeley DB in a number of
25dnl   common places.  The installed DB must be no older than the
26dnl   version given by MAJOR, MINOR, and PATCH.  All of these
27dnl   arguments are allowed to be '-1', indicating we don't care.
28dnl   PLACES is a list of places to search for a Berkeley DB
29dnl   installation.  HEADERS is a list of headers to try.  LIBNAMES
30dnl   is a list of names of the library to attempt to link against,
31dnl   typically 'db' and 'db4'.
32dnl
33dnl   If we find a useable version, set CPPFLAGS and LIBS as
34dnl   appropriate, and set the shell variable `apu_have_db' to
35dnl   `1', and apu_db_lib to the matching lib name, and apu_db_header
36dnl   to the header to use.  Otherwise, set `apu_have_db' to `0'.
37dnl
38dnl   This macro also checks for the `--with-berkeley-db=PATH' flag;
39dnl   if given, the macro will use the PATH specified, and the
40dnl   configuration script will die if it can't find the library.  If
41dnl   the user gives the `--without-berkeley-db' flag, the entire
42dnl   search is skipped.
43dnl
44dnl   We cache the results of individual searches under particular
45dnl   prefixes, not the overall result of whether we found Berkeley
46dnl   DB.  That way, the user can re-run the configure script with
47dnl   different --with-berkeley-db switch values, without interference
48dnl   from the cache.
49
50
51AC_DEFUN([APU_CHECK_BERKELEY_DB], [
52  bdb_version=$1
53  if test "$2" != "-1"; then
54    bdb_version="$bdb_version.$2"
55    if test "$3" != "-1"; then
56      bdb_version="$bdb_version.$3"
57    fi
58  fi
59  bdb_places=$4
60  bdb_default_search_headers=$5
61  bdb_default_search_lib_names=$6
62
63  apu_have_db=0
64
65  # Save the original values of the flags we tweak.
66  apu_check_lib_save_libs="$LIBS"
67  apu_check_lib_save_ldflags="$LDFLAGS"
68  apu_check_lib_save_cppflags="$CPPFLAGS"
69
70  # The variable `found' is the prefix under which we've found
71  # Berkeley DB, or `not' if we haven't found it anywhere yet.
72  found=not
73  for bdb_place in $bdb_places; do
74
75    LDFLAGS="$apu_check_lib_save_ldflags"
76    CPPFLAGS="$apu_check_lib_save_cppflags"
77    case "$bdb_place" in
78      "std" )
79        description="the standard places"
80      ;;
81      *":"* )
82        header="`echo $bdb_place | sed -e 's/:.*$//'`"
83        lib="`echo $bdb_place | sed -e 's/^.*://'`"
84        CPPFLAGS="$CPPFLAGS -I$header"
85        LDFLAGS="$LDFLAGS -L$lib"
86        description="$header and $lib"
87      ;;
88      * )
89        if test -d $bdb_place; then
90          LDFLAGS="$LDFLAGS -L$bdb_place/lib"
91          CPPFLAGS="$CPPFLAGS -I$bdb_place/include"
92        else
93          AC_MSG_CHECKING([for Berkeley DB $bdb_version in $bdb_place])
94          AC_MSG_RESULT([directory not found])
95          continue
96        fi
97        description="$bdb_place"
98      ;;
99    esac
100
101    # Since there is no AC_MSG_NOTICE in autoconf 2.13, we use this
102    # trick to display a message instead.
103    AC_MSG_CHECKING([for Berkeley DB $bdb_version in $description])
104    AC_MSG_RESULT()
105
106    for bdb_libname in $bdb_default_search_lib_names; do
107      for bdb_header in $bdb_default_search_headers; do
108        # Clear the header cache variable for each location
109        changequote(,)
110        cache_id="`echo ac_cv_header_${bdb_header} \
111                 | sed -e 's/[^a-zA-Z0-9_]/_/g'`"
112        changequote([,])
113        unset $cache_id
114        AC_CHECK_HEADER([$bdb_header], [
115          if test "$1" = "3" -o "$1" = "4" -o "$1" = "5"; then
116            # We generate a separate cache variable for each prefix and libname
117            # we search under.  That way, we avoid caching information that
118            # changes if the user runs `configure' with a different set of
119            # switches.
120            changequote(,)
121            cache_id="`echo apu_cv_check_berkeley_db_$1_$2_$3_${bdb_header}_${bdb_libname}_in_${bdb_place} \
122                     | sed -e 's/[^a-zA-Z0-9_]/_/g'`"
123            changequote([,])
124
125            AC_MSG_CHECKING([for -l$bdb_libname])
126            dnl We can't use AC_CACHE_CHECK here, because that won't print out
127            dnl the value of the computed cache variable properly.
128            AC_CACHE_VAL($cache_id,
129              [
130                APU_TRY_BERKELEY_DB($1, $2, $3, $bdb_header, $bdb_libname)
131                eval "$cache_id=$apu_try_berkeley_db"
132              ])
133            result="`eval echo '$'$cache_id`"
134            AC_MSG_RESULT($result)
135          elif test "$1" = "1"; then
136            AC_CHECK_LIB($bdb_libname,
137              dbopen,
138              [result=yes],
139              [result=no]
140            )
141          elif test "$1" = "2"; then
142            AC_CHECK_LIB($bdb_libname,
143              db_open,
144              [result=yes],
145              [result=no]
146            )
147          fi
148        ], [result="no"])
149        
150        # If we found it, no need to search any more.
151        if test "$result" = "yes"; then
152          found="$bdb_place"
153          break
154        fi
155      done
156      test "$found" != "not" && break
157    done
158    test "$found" != "not" && break
159  done
160
161  # Restore the original values of the flags we tweak.
162  LDFLAGS="$apu_check_lib_save_ldflags"
163  CPPFLAGS="$apu_check_lib_save_cppflags"
164
165  case "$found" in
166  "not")
167    apu_have_db=0
168    ;;
169  "std")
170    apu_db_header=$bdb_header
171    apu_db_lib=$bdb_libname
172    apu_have_db=1
173    ;;
174  *":"*)
175    header="`echo $found | sed -e 's/:.*$//'`"
176    lib="`echo $found | sed -e 's/^.*://'`"
177
178    APR_ADDTO(APRUTIL_INCLUDES, [-I$header])
179    APR_ADDTO(APRUTIL_LDFLAGS, [-L$lib])
180    apu_db_header=$bdb_header
181    apu_db_lib=$bdb_libname
182    apu_have_db=1
183    ;;
184  *)
185    APR_ADDTO(APRUTIL_INCLUDES, [-I$found/include])
186    APR_ADDTO(APRUTIL_LDFLAGS, [-L$found/lib])
187    apu_db_header=$bdb_header
188    apu_db_lib=$bdb_libname
189    apu_have_db=1
190    ;;
191  esac
192])
193
194
195dnl   APU_TRY_BERKELEY_DB(major, minor, patch, header, libname)
196dnl
197dnl   A subroutine of APU_CHECK_BERKELEY_DB.
198dnl
199dnl   Check that a new-enough version of Berkeley DB is installed.
200dnl   "New enough" means no older than the version given by MAJOR,
201dnl   MINOR, and PATCH.  The result of the test is not cached; no
202dnl   messages are printed.  Use HEADER as the header file to include.
203dnl   Use LIBNAME as the library to link against.
204dnl   (e.g. LIBNAME should usually be "db" or "db4".)
205dnl
206dnl   Set the shell variable `apu_try_berkeley_db' to `yes' if we found
207dnl   an appropriate version installed, or `no' otherwise.
208dnl
209dnl   This macro uses the Berkeley DB library function `db_version' to
210dnl   find the version.  If the library installed doesn't have this
211dnl   function, then this macro assumes it is too old.
212
213dnl   NOTE: This is pretty messed up.  It seems that the FreeBSD port of
214dnl   Berkeley DB 4 puts the header file in /usr/local/include/db4, but the
215dnl   database library in /usr/local/lib, as libdb4.[a|so].  There is no
216dnl   /usr/local/include/db.h.  So if you check for /usr/local first, you'll
217dnl   get the old header file from /usr/include, and the new library from
218dnl   /usr/local/lib.  Disaster.  Thus this test compares the version constants
219dnl   in the db.h header with the ones returned by db_version().
220
221
222AC_DEFUN([APU_TRY_BERKELEY_DB],
223  [
224    apu_try_berkeley_db_save_libs="$LIBS"
225
226    apu_check_berkeley_db_major=$1
227    apu_check_berkeley_db_minor=$2
228    apu_check_berkeley_db_patch=$3
229    apu_try_berkeley_db_header=$4
230    apu_try_berkeley_db_libname=$5
231
232    LIBS="$LIBS -l$apu_try_berkeley_db_libname"
233    AC_TRY_RUN(
234      [
235#include <stdlib.h>
236#include <stdio.h>
237#include <$apu_try_berkeley_db_header>
238main ()
239{
240  int major, minor, patch;
241
242  db_version(&major, &minor, &patch);
243
244  /* Sanity check: ensure that db.h constants actually match the db library */
245  if (major != DB_VERSION_MAJOR
246      || minor != DB_VERSION_MINOR
247      || patch != DB_VERSION_PATCH)
248    exit (1);
249
250  /* Run-time check:  ensure the library claims to be the correct version. */
251
252  if ($apu_check_berkeley_db_major != -1) {
253    if (major < $apu_check_berkeley_db_major)
254      exit (1);
255    if (major > $apu_check_berkeley_db_major)
256      exit (0);
257  }
258
259  if ($apu_check_berkeley_db_minor != -1) {
260    if (minor < $apu_check_berkeley_db_minor)
261      exit (1);
262    if (minor > $apu_check_berkeley_db_minor)
263      exit (0);
264  }
265
266  if ($apu_check_berkeley_db_patch == -1
267      || patch >= $apu_check_berkeley_db_patch)
268    exit (0);
269  else
270    exit (1);
271}
272      ],
273      [apu_try_berkeley_db=yes],
274      [apu_try_berkeley_db=no],
275      [apu_try_berkeley_db=yes]
276    )
277
278    LIBS="$apu_try_berkeley_db_save_libs"
279  ]
280)
281
282
283dnl
284dnl APU_CHECK_DB1: is DB1 present?
285dnl
286dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
287dnl
288AC_DEFUN([APU_CHECK_DB1], [
289  places=$1
290  if test -z "$places"; then
291    places="std"
292  fi
293  APU_CHECK_BERKELEY_DB(1, 0, 0,
294    "$places",
295    "db1/db.h db.h",
296    "db1"
297  )
298  if test "$apu_have_db" = "1"; then
299    apu_db_version=1
300  fi
301])
302
303
304dnl
305dnl APU_CHECK_DB185: is DB1.85 present?
306dnl
307dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
308dnl
309dnl NB: BerkelyDB v2 and above can be compiled in 1.85 mode
310dnl which has a libdb not libdb1 or libdb185
311AC_DEFUN([APU_CHECK_DB185], [
312  places=$1
313  if test -z "$places"; then
314    places="std"
315  fi
316  APU_CHECK_BERKELEY_DB(1, -1, -1,
317    "$places",
318    "db_185.h",
319    "db"
320  )
321  if test "$apu_have_db" = "1"; then
322    apu_db_version=185
323  fi
324])
325
326
327dnl
328dnl APU_CHECK_DB2: is DB2 present?
329dnl
330dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
331dnl
332AC_DEFUN([APU_CHECK_DB2], [
333  places=$1
334  if test -z "$places"; then
335    places="std"
336  fi
337  APU_CHECK_BERKELEY_DB(2, -1, -1,
338    "$places",
339    "db2/db.h db.h",
340    "db2 db"
341  )
342  if test "$apu_have_db" = "1"; then
343    apu_db_version=2
344  fi
345])
346
347
348dnl
349dnl APU_CHECK_DB3: is DB3 present?
350dnl
351dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
352dnl
353AC_DEFUN([APU_CHECK_DB3], [
354  places=$1
355  if test -z "$places"; then
356    places="std"
357  fi
358  APU_CHECK_BERKELEY_DB(3, -1, -1,
359    "$places",
360    "db3/db.h db.h",
361    "db3 db"
362  )
363  if test "$apu_have_db" = "1"; then
364    apu_db_version=3
365  fi
366])
367
368
369dnl
370dnl APU_CHECK_DBXY: is DBX.Y present?
371dnl
372dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
373dnl
374AC_DEFUN([APU_CHECK_DBXY], [
375  places=$1
376  db_major=$2
377  db_minor=$3
378  if test -z "$places"; then
379    places="std /usr/local /usr/local/BerkeleyDB.${db_major}.${db_minor} /boot/home/config"
380  fi
381  APU_CHECK_BERKELEY_DB("${db_major}", "${db_minor}", "-1",
382    "$places",
383    "db${db_major}${db_minor}/db.h db${db_major}/db.h db.h",
384    "db-${db_major}.${db_minor} db${db_major}-${db_major}.${db_minor} db${db_major}${db_minor} db-${db_major} db${db_major} db"
385  )
386  if test "$apu_have_db" = "1"; then
387    apu_db_version=${db_major}
388  fi
389])
390
391
392AC_DEFUN([APU_CHECK_DB], [
393  requested=$1
394  check_places=$2
395
396  case "$requested" in
397  db)
398    APU_CHECK_DB_ALL("$check_places")
399    if test "$apu_have_db" = "0"; then
400      AC_MSG_ERROR(Berkeley db requested, but not found)
401    fi
402    ;;
403  db1)
404    APU_CHECK_DB1("$check_places")
405    if test "$apu_db_version" != "1"; then
406      AC_MSG_ERROR(Berkeley db1 not found)
407    fi
408    ;;
409  db185)
410    APU_CHECK_DB185("$check_places")
411    if test "$apu_db_version" != "185"; then
412      AC_MSG_ERROR(Berkeley db185 not found)
413    fi
414    ;;
415  db2)
416    APU_CHECK_DB2("$check_places")
417    if test "$apu_db_version" != "2"; then
418      AC_MSG_ERROR(Berkeley db2 not found)
419    fi
420    ;;
421  db3)
422    APU_CHECK_DB3("$check_places")
423    if test "$apu_db_version" != "3"; then
424      AC_MSG_ERROR(Berkeley db3 not found)
425    fi
426    ;;
427  db[[45]][[0-9]])
428    db_major=`echo "$requested" | sed -e 's/db//' -e 's/.$//'`
429    db_minor=`echo "$requested" | sed -e 's/db//' -e 's/.//'`
430    APU_CHECK_DBXY("$check_places", "$db_major", "$db_minor")
431    if test "$apu_db_version" != "$db_major"; then
432      AC_MSG_ERROR(Berkeley db$db_major not found)
433    fi
434    ;;
435  db[[45]])
436    db_major=`echo "$requested" | sed -e 's/db//'`
437    # Start version search at version x.9
438    db_minor=9
439    while [[ $db_minor -ge 0 ]]
440    do
441      APU_CHECK_DBXY("$check_places", "$db_major", "$db_minor")
442      if test "$apu_have_db" = "1"; then
443        break
444      fi
445      db_minor=`expr $db_minor - 1`
446    done
447    if test "$apu_db_version" != "$db_major"; then
448      AC_MSG_ERROR(Berkeley db$db_major not found)
449    fi
450    ;;
451  default)
452    APU_CHECK_DB_ALL("$check_places")
453    ;;
454  esac
455])
456
457dnl
458dnl APU_CHECK_DB_ALL: Try all Berkeley DB versions, from 5.X to 1.
459dnl
460AC_DEFUN([APU_CHECK_DB_ALL], [
461  all_places=$1
462
463  # Start version search at version 5.9
464  db_version=59
465  while [[ $db_version -ge 40 ]]
466  do
467    db_major=`echo $db_version | sed -e 's/.$//'`
468    db_minor=`echo $db_version | sed -e 's/.//'`
469    APU_CHECK_DBXY("$all_places", "$db_major", "$db_minor")
470    if test "$apu_have_db" = "1"; then
471      break
472    fi
473    db_version=`expr $db_version - 1`
474  done
475  if test "$apu_have_db" = "0"; then
476    APU_CHECK_DB3("$all_places")
477  fi
478  if test "$apu_have_db" = "0"; then
479    APU_CHECK_DB2("$all_places")
480  fi
481  if test "$apu_have_db" = "0"; then
482    APU_CHECK_DB1("$all_places")
483  fi
484  if test "$apu_have_db" = "0"; then
485    APU_CHECK_DB185("$all_places")
486  fi
487  AC_MSG_CHECKING(for Berkeley DB)
488  if test "$apu_have_db" = "1"; then
489    AC_MSG_RESULT(found db$apu_db_version)
490  else
491    AC_MSG_RESULT(not found)
492  fi
493])
494
495
496dnl
497dnl APU_CHECK_DBM: see what kind of DBM backend to use for apr_dbm.
498dnl
499AC_DEFUN([APU_CHECK_DBM], [
500  apu_use_sdbm=0
501  apu_use_ndbm=0
502  apu_use_gdbm=0
503  apu_use_db=0
504  dnl it's in our codebase
505  apu_have_sdbm=1
506  apu_have_gdbm=0
507  apu_have_ndbm=0
508  apu_have_db=0
509
510  apu_db_header=db.h                # default so apu_select_dbm.h is syntactically correct
511  apu_db_version=0
512
513  # Maximum supported version announced in help string.
514  # Although we search for all versions up to 5.9,
515  # we should only include existing versions in our
516  # help string.
517  db_max_version=53
518  db_min_version=41
519  dbm_list="sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4"
520  db_version="$db_min_version"
521  while [[ $db_version -le $db_max_version ]]
522  do
523    dbm_list="$dbm_list, db$db_version"
524    db_version=`expr $db_version + 1`
525  done
526
527  AC_ARG_WITH(dbm, [APR_HELP_STRING([--with-dbm=DBM], [choose the DBM type to use.
528      DBM={sdbm,gdbm,ndbm,db,db1,db185,db2,db3,db4,db4X,db5X} for some X=0,...,9])],
529  [
530    if test "$withval" = "yes"; then
531      AC_MSG_ERROR([--with-dbm needs to specify a DBM type to use.
532        One of: $dbm_list])
533    fi
534    requested="$withval"
535  ], [
536    requested=default
537  ])
538
539  dnl We don't pull in GDBM unless the user asks for it, since it's GPL
540  AC_ARG_WITH([gdbm], [APR_HELP_STRING([--with-gdbm=DIR], [enable GDBM support])],
541  [
542    apu_have_gdbm=0
543    if test "$withval" = "yes"; then
544      AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1]))
545    elif test "$withval" = "no"; then
546      apu_have_gdbm=0
547    else
548      saved_cppflags="$CPPFLAGS"
549      saved_ldflags="$LDFLAGS"
550      CPPFLAGS="$CPPFLAGS -I$withval/include"
551      LDFLAGS="$LDFLAGS -L$withval/lib "
552
553      AC_MSG_CHECKING(checking for gdbm in $withval)
554      AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1]))
555      if test "$apu_have_gdbm" != "0"; then
556        APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
557        APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
558      fi
559      CPPFLAGS="$saved_cppflags"
560      LDFLAGS="$saved_ldflags"
561    fi
562  ])
563
564  AC_ARG_WITH([ndbm], [APR_HELP_STRING([--with-ndbm=PATH], [
565      Find the NDBM header and library in `PATH/include' and 
566      `PATH/lib'.  If PATH is of the form `HEADER:LIB', then search 
567      for header files in HEADER, and the library in LIB.  If you omit
568      the `=PATH' part completely, the configure script will search
569      for NDBM in a number of standard places.])],
570  [
571    apu_have_ndbm=0
572    if test "$withval" = "yes"; then
573      AC_MSG_CHECKING(checking for ndbm in the usual places)
574      apu_want_ndbm=1
575      NDBM_INC=""
576      NDBM_LDFLAGS=""
577    elif test "$withval" = "no"; then
578      apu_want_ndbm=0
579    else
580      apu_want_ndbm=1
581      case "$withval" in
582        *":"*)
583          NDBM_INC="-I`echo $withval |sed -e 's/:.*$//'`"
584          NDBM_LDFLAGS="-L`echo $withval |sed -e 's/^.*://'`"
585          AC_MSG_CHECKING(checking for ndbm includes with $NDBM_INC libs with $NDBM_LDFLAGS )
586        ;;
587        *)
588          NDBM_INC="-I$withval/include"
589          NDBM_LDFLAGS="-L$withval/lib"
590          AC_MSG_CHECKING(checking for ndbm includes in $withval)
591        ;;
592      esac
593    fi
594
595    save_cppflags="$CPPFLAGS"
596    save_ldflags="$LDFLAGS"
597    CPPFLAGS="$CPPFLAGS $NDBM_INC"
598    LDFLAGS="$LDFLAGS $NDBM_LDFLAGS"
599    dnl db_ndbm_open is what sleepcat's compatibility library actually has in it's lib
600    if test "$apu_want_ndbm" != "0"; then
601      AC_CHECK_HEADER(ndbm.h, 
602        AC_CHECK_LIB(c, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=c],
603          AC_CHECK_LIB(dbm, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=dbm],
604            AC_CHECK_LIB(db, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db],
605              AC_CHECK_LIB(db, __db_ndbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db])
606            )
607          )
608        )
609      )
610      if test "$apu_have_ndbm" != "0";  then
611        if test "$withval" != "yes"; then
612          APR_ADDTO(APRUTIL_INCLUDES, [$NDBM_INC])
613          APR_ADDTO(APRUTIL_LDFLAGS, [$NDBM_LDFLAGS])
614        fi
615      elif test "$withval" != "yes"; then
616        AC_ERROR( NDBM not found in the specified directory)
617      fi
618    fi
619    CPPFLAGS="$save_cppflags"
620    LDFLAGS="$save_ldflags"
621  ], [
622    dnl don't check it no one has asked us for it
623    apu_have_ndbm=0
624  ])
625
626
627  if test -n "$apu_db_xtra_libs"; then
628    saveddbxtralibs="$LIBS"
629    LIBS="$apu_db_xtra_libs $LIBS"
630  fi
631
632  dnl We're going to try to find the highest version of Berkeley DB supported.
633  dnl
634  dnl Note that we only do this if the user requested it, since the Sleepycat
635  dnl license is viral and requires distribution of source along with programs
636  dnl that use it.
637  AC_ARG_WITH([berkeley-db], [APR_HELP_STRING([--with-berkeley-db=PATH],
638      [Find the Berkeley DB header and library in `PATH/include' and
639      `PATH/lib'.  If PATH is of the form `HEADER:LIB', then search
640      for header files in HEADER, and the library in LIB.  If you omit
641      the `=PATH' part completely, the configure script will search
642      for Berkeley DB in a number of standard places.])],
643  [
644    if test "$withval" = "yes"; then
645      apu_want_db=1
646      user_places=""
647    elif test "$withval" = "no"; then
648      apu_want_db=0
649    else
650      apu_want_db=1
651      user_places="$withval"
652    fi
653
654    if test "$apu_want_db" != "0"; then
655      APU_CHECK_DB($requested, $user_places)
656      if test "$apu_have_db" = "0"; then
657        AC_ERROR(Berkeley DB not found.)
658      fi
659    fi 
660  ])
661
662  if test -n "$apu_db_xtra_libs"; then
663    LIBS="$saveddbxtralibs"
664  fi
665
666  case "$requested" in
667    sdbm | gdbm | ndbm | db)
668      eval "apu_use_$requested=1"
669      apu_default_dbm=$requested
670      ;;
671    db185 | db[[12345]])
672      apu_use_db=1
673      apu_default_dbm=$requested
674      ;;
675    db[[45]][[0-9]])
676      apu_use_db=1
677      apu_default_dbm=`echo $requested | sed -e 's/.$//'`
678      ;;
679    default)
680      dnl ### use more sophisticated DBMs for the default?
681      apu_default_dbm="sdbm (default)"
682      apu_use_sdbm=1
683      ;;
684    *)
685      AC_MSG_ERROR([--with-dbm=$requested is an unknown DBM type.
686        Use one of: $dbm_list])
687      ;;
688  esac
689
690  dnl Yes, it'd be nice if we could collate the output in an order
691  dnl so that the AC_MSG_CHECKING would be output before the actual
692  dnl checks, but it isn't happening now.
693  AC_MSG_CHECKING(for default DBM)
694  AC_MSG_RESULT($apu_default_dbm)
695
696  AC_SUBST(apu_use_sdbm)
697  AC_SUBST(apu_use_gdbm)
698  AC_SUBST(apu_use_ndbm)
699  AC_SUBST(apu_use_db)
700
701  AC_SUBST(apu_have_sdbm)
702  AC_SUBST(apu_have_gdbm)
703  AC_SUBST(apu_have_ndbm)
704  AC_SUBST(apu_have_db)
705  AC_SUBST(apu_db_header)
706  AC_SUBST(apu_db_version)
707
708  if test "$apu_have_db" = "1"; then
709    APR_ADDTO(LDADD_dbm_db, [-l$apu_db_lib])
710    if test -n "apu_db_xtra_libs"; then
711      APR_ADDTO(LDADD_dbm_db, [$apu_db_xtra_libs])
712    fi
713  fi
714
715  dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
716  dnl we know the library is there.
717  if test "$apu_have_gdbm" = "1"; then
718    APR_ADDTO(LDADD_dbm_gdbm, [-lgdbm])
719  fi
720
721  if test "$apu_have_ndbm" = "1"; then
722    APR_ADDTO(LDADD_dbm_ndbm, [-l$apu_ndbm_lib])
723  fi
724
725  AC_SUBST(LDADD_dbm_db)
726  AC_SUBST(LDADD_dbm_gdbm)
727  AC_SUBST(LDADD_dbm_ndbm)
728])
729
730