~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr-util/build/dbm.m4

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl -------------------------------------------------------- -*- autoconf -*-
 
2
dnl Copyright 2002-2005 The Apache Software Foundation or its licensors, as
 
3
dnl applicable.
 
4
dnl
 
5
dnl Licensed under the Apache License, Version 2.0 (the "License");
 
6
dnl you may not use this file except in compliance with the License.
 
7
dnl You may obtain a copy of the License at
 
8
dnl
 
9
dnl     http://www.apache.org/licenses/LICENSE-2.0
 
10
dnl
 
11
dnl Unless required by applicable law or agreed to in writing, software
 
12
dnl distributed under the License is distributed on an "AS IS" BASIS,
 
13
dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
dnl See the License for the specific language governing permissions and
 
15
dnl limitations under the License.
 
16
 
 
17
 
 
18
dnl
 
19
dnl DBM module
 
20
dnl
 
21
 
 
22
dnl   APU_LIB_BERKELEY_DB(major, minor, patch, places, headers, libnames)
 
23
dnl
 
24
dnl   Search for a useable version of Berkeley DB in a number of
 
25
dnl   common places.  The installed DB must be no older than the
 
26
dnl   version given by MAJOR, MINOR, and PATCH.  All of these
 
27
dnl   arguments are allowed to be '-1', indicating we don't care.
 
28
dnl   PLACES is a list of places to search for a Berkeley DB
 
29
dnl   installation.  HEADERS is a list of headers to try.  LIBNAMES
 
30
dnl   is a list of names of the library to attempt to link against,
 
31
dnl   typically 'db' and 'db4'.
 
32
dnl
 
33
dnl   If we find a useable version, set CPPFLAGS and LIBS as
 
34
dnl   appropriate, and set the shell variable `apu_have_db' to
 
35
dnl   `1', and apu_db_lib to the matching lib name, and apu_db_header
 
36
dnl   to the header to use.  Otherwise, set `apu_have_db' to `0'.
 
37
dnl
 
38
dnl   This macro also checks for the `--with-berkeley-db=PATH' flag;
 
39
dnl   if given, the macro will use the PATH specified, and the
 
40
dnl   configuration script will die if it can't find the library.  If
 
41
dnl   the user gives the `--without-berkeley-db' flag, the entire
 
42
dnl   search is skipped.
 
43
dnl
 
44
dnl   We cache the results of individual searches under particular
 
45
dnl   prefixes, not the overall result of whether we found Berkeley
 
46
dnl   DB.  That way, the user can re-run the configure script with
 
47
dnl   different --with-berkeley-db switch values, without interference
 
48
dnl   from the cache.
 
49
 
 
50
 
 
51
AC_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"; 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
 
 
195
dnl   APU_TRY_BERKELEY_DB(major, minor, patch, header, libname)
 
196
dnl
 
197
dnl   A subroutine of APU_CHECK_BERKELEY_DB.
 
198
dnl
 
199
dnl   Check that a new-enough version of Berkeley DB is installed.
 
200
dnl   "New enough" means no older than the version given by MAJOR,
 
201
dnl   MINOR, and PATCH.  The result of the test is not cached; no
 
202
dnl   messages are printed.  Use HEADER as the header file to include.
 
203
dnl   Use LIBNAME as the library to link against.
 
204
dnl   (e.g. LIBNAME should usually be "db" or "db4".)
 
205
dnl
 
206
dnl   Set the shell variable `apu_try_berkeley_db' to `yes' if we found
 
207
dnl   an appropriate version installed, or `no' otherwise.
 
208
dnl
 
209
dnl   This macro uses the Berkeley DB library function `db_version' to
 
210
dnl   find the version.  If the library installed doesn't have this
 
211
dnl   function, then this macro assumes it is too old.
 
212
 
 
213
dnl   NOTE: This is pretty messed up.  It seems that the FreeBSD port of
 
214
dnl   Berkeley DB 4 puts the header file in /usr/local/include/db4, but the
 
215
dnl   database library in /usr/local/lib, as libdb4.[a|so].  There is no
 
216
dnl   /usr/local/include/db.h.  So if you check for /usr/local first, you'll
 
217
dnl   get the old header file from /usr/include, and the new library from
 
218
dnl   /usr/local/lib.  Disaster.  Thus this test compares the version constants
 
219
dnl   in the db.h header with the ones returned by db_version().
 
220
 
 
221
 
 
222
AC_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 <stdio.h>
 
236
#include <$apu_try_berkeley_db_header>
 
237
main ()
 
238
{
 
239
  int major, minor, patch;
 
240
 
 
241
  db_version(&major, &minor, &patch);
 
242
 
 
243
  /* Sanity check: ensure that db.h constants actually match the db library */
 
244
  if (major != DB_VERSION_MAJOR
 
245
      || minor != DB_VERSION_MINOR
 
246
      || patch != DB_VERSION_PATCH)
 
247
    exit (1);
 
248
 
 
249
  /* Run-time check:  ensure the library claims to be the correct version. */
 
250
 
 
251
  if ($apu_check_berkeley_db_major != -1) {
 
252
    if (major < $apu_check_berkeley_db_major)
 
253
      exit (1);
 
254
    if (major > $apu_check_berkeley_db_major)
 
255
      exit (0);
 
256
  }
 
257
 
 
258
  if ($apu_check_berkeley_db_minor != -1) {
 
259
    if (minor < $apu_check_berkeley_db_minor)
 
260
      exit (1);
 
261
    if (minor > $apu_check_berkeley_db_minor)
 
262
      exit (0);
 
263
  }
 
264
 
 
265
  if ($apu_check_berkeley_db_patch == -1
 
266
      || patch >= $apu_check_berkeley_db_patch)
 
267
    exit (0);
 
268
  else
 
269
    exit (1);
 
270
}
 
271
      ],
 
272
      [apu_try_berkeley_db=yes],
 
273
      [apu_try_berkeley_db=no],
 
274
      [apu_try_berkeley_db=yes]
 
275
    )
 
276
 
 
277
    LIBS="$apu_try_berkeley_db_save_libs"
 
278
  ]
 
279
)
 
280
 
 
281
 
 
282
dnl
 
283
dnl APU_CHECK_DB1: is DB1 present?
 
284
dnl
 
285
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
 
286
dnl
 
287
AC_DEFUN([APU_CHECK_DB1], [
 
288
  places=$1
 
289
  if test -z "$places"; then
 
290
    places="std"
 
291
  fi
 
292
  APU_CHECK_BERKELEY_DB(1, 0, 0,
 
293
    "$places",
 
294
    "db1/db.h db.h",
 
295
    "db1"
 
296
  )
 
297
  if test "$apu_have_db" = "1"; then
 
298
    apu_db_version=1
 
299
  fi
 
300
])
 
301
 
 
302
 
 
303
dnl
 
304
dnl APU_CHECK_DB185: is DB1.85 present?
 
305
dnl
 
306
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
 
307
dnl
 
308
dnl NB: BerkelyDB v2 and above can be compiled in 1.85 mode
 
309
dnl which has a libdb not libdb1 or libdb185
 
310
AC_DEFUN([APU_CHECK_DB185], [
 
311
  places=$1
 
312
  if test -z "$places"; then
 
313
    places="std"
 
314
  fi
 
315
  APU_CHECK_BERKELEY_DB(1, -1, -1,
 
316
    "$places",
 
317
    "db_185.h",
 
318
    "db"
 
319
  )
 
320
  if test "$apu_have_db" = "1"; then
 
321
    apu_db_version=185
 
322
  fi
 
323
])
 
324
 
 
325
 
 
326
dnl
 
327
dnl APU_CHECK_DB2: is DB2 present?
 
328
dnl
 
329
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
 
330
dnl
 
331
AC_DEFUN([APU_CHECK_DB2], [
 
332
  places=$1
 
333
  if test -z "$places"; then
 
334
    places="std"
 
335
  fi
 
336
  APU_CHECK_BERKELEY_DB(2, -1, -1,
 
337
    "$places",
 
338
    "db2/db.h db.h",
 
339
    "db2 db"
 
340
  )
 
341
  if test "$apu_have_db" = "1"; then
 
342
    apu_db_version=2
 
343
  fi
 
344
])
 
345
 
 
346
 
 
347
dnl
 
348
dnl APU_CHECK_DB3: is DB3 present?
 
349
dnl
 
350
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
 
351
dnl
 
352
AC_DEFUN([APU_CHECK_DB3], [
 
353
  places=$1
 
354
  if test -z "$places"; then
 
355
    places="std"
 
356
  fi
 
357
  APU_CHECK_BERKELEY_DB(3, -1, -1,
 
358
    "$places",
 
359
    "db3/db.h db.h",
 
360
    "db3 db"
 
361
  )
 
362
  if test "$apu_have_db" = "1"; then
 
363
    apu_db_version=3
 
364
  fi
 
365
])
 
366
 
 
367
 
 
368
dnl
 
369
dnl APU_CHECK_DB4: is DB4 present?
 
370
dnl
 
371
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
 
372
dnl
 
373
AC_DEFUN([APU_CHECK_DB4], [
 
374
  places=$1
 
375
  if test -z "$places"; then
 
376
    places="std /usr/local /usr/local/BerkeleyDB.4.0 /boot/home/config"
 
377
  fi
 
378
  APU_CHECK_BERKELEY_DB("4", "0", "-1",
 
379
    "$places",
 
380
    "db4/db.h db.h",
 
381
    "db-4.0 db4 db"
 
382
  )
 
383
  if test "$apu_have_db" = "1"; then
 
384
    apu_db_version=4
 
385
  fi
 
386
])
 
387
 
 
388
 
 
389
dnl
 
390
dnl APU_CHECK_DB41: is DB4.1 present?
 
391
dnl
 
392
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
 
393
dnl
 
394
AC_DEFUN([APU_CHECK_DB41], [
 
395
  places=$1
 
396
  if test -z "$places"; then
 
397
    places="std /usr/local /usr/local/BerkeleyDB.4.1 /boot/home/config"
 
398
  fi
 
399
  APU_CHECK_BERKELEY_DB("4", "1", "-1",
 
400
    "$places",
 
401
    "db41/db.h db4/db.h db.h",
 
402
    "db-4.1 db41 db4 db"
 
403
  )
 
404
  if test "$apu_have_db" = "1"; then
 
405
    apu_db_version=4
 
406
  fi
 
407
])
 
408
 
 
409
 
 
410
dnl
 
411
dnl APU_CHECK_DB42: is DB4.2 present?
 
412
dnl
 
413
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
 
414
dnl
 
415
AC_DEFUN([APU_CHECK_DB42], [
 
416
  places=$1
 
417
  if test -z "$places"; then
 
418
    places="std /usr/local /usr/local/BerkeleyDB.4.2 /boot/home/config"
 
419
  fi
 
420
  APU_CHECK_BERKELEY_DB("4", "2", "-1",
 
421
    "$places",
 
422
    "db42/db.h db4/db.h db.h",
 
423
    "db-4.2 db42 db4 db"
 
424
  )
 
425
  if test "$apu_have_db" = "1"; then
 
426
    apu_db_version=4
 
427
  fi
 
428
])
 
429
dnl
 
430
dnl APU_CHECK_DB43: is DB4.3 present?
 
431
dnl
 
432
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
 
433
dnl
 
434
AC_DEFUN([APU_CHECK_DB43], [
 
435
  places=$1
 
436
  if test -z "$places"; then
 
437
    places="std /usr/local/BerkeleyDB.4.3 /boot/home/config"
 
438
  fi
 
439
  APU_CHECK_BERKELEY_DB("4", "3", "-1",
 
440
    "$places",
 
441
    "db43/db.h db4/db.h db.h",
 
442
    "db-4.3 db4-4.3 db43 db4 db"
 
443
  )
 
444
  if test "$apu_have_db" = "1"; then
 
445
    apu_db_version=4
 
446
  fi
 
447
])
 
448
dnl
 
449
dnl APU_CHECK_DB44: is DB4.4 present?
 
450
dnl
 
451
dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version
 
452
dnl
 
453
AC_DEFUN([APU_CHECK_DB44], [
 
454
  places=$1
 
455
  if test -z "$places"; then
 
456
    places="std /usr/local/BerkeleyDB.4.4 /boot/home/config"
 
457
  fi
 
458
  APU_CHECK_BERKELEY_DB("4", "4", "-1",
 
459
    "$places",
 
460
    "db44/db.h db4/db.h db.h",
 
461
    "db-4.4 db4-4.4 db44 db4 db"
 
462
  )
 
463
  if test "$apu_have_db" = "1"; then
 
464
    apu_db_version=4
 
465
  fi
 
466
])
 
467
 
 
468
 
 
469
AC_DEFUN([APU_CHECK_DB], [
 
470
  requested=$1
 
471
  check_places=$2
 
472
 
 
473
  case "$requested" in
 
474
  db)
 
475
    APU_CHECK_DB_ALL("$check_places")
 
476
    if test "$apu_have_db" = "0"; then
 
477
      AC_MSG_ERROR(Berkeley db requested, but not found)
 
478
    fi
 
479
    ;;
 
480
  db1)
 
481
    APU_CHECK_DB1("$check_places")
 
482
    if test "$apu_db_version" != "1"; then
 
483
      AC_MSG_ERROR(Berkeley db1 not found)
 
484
    fi
 
485
    ;;
 
486
  db185)
 
487
    APU_CHECK_DB185("$check_places")
 
488
    if test "$apu_db_version" != "185"; then
 
489
      AC_MSG_ERROR(Berkeley db185 not found)
 
490
    fi
 
491
    ;;
 
492
  db2)
 
493
    APU_CHECK_DB2("$check_places")
 
494
    if test "$apu_db_version" != "2"; then
 
495
      AC_MSG_ERROR(Berkeley db2 not found)
 
496
    fi
 
497
    ;;
 
498
  db3)
 
499
    APU_CHECK_DB3("$check_places")
 
500
    if test "$apu_db_version" != "3"; then
 
501
      AC_MSG_ERROR(Berkeley db3 not found)
 
502
    fi
 
503
    ;;
 
504
  db4)
 
505
    APU_CHECK_DB4("$check_places")
 
506
    if test "$apu_db_version" != "4"; then
 
507
      AC_MSG_ERROR(Berkeley db4 not found)
 
508
    fi
 
509
    ;;
 
510
  db41)
 
511
    APU_CHECK_DB41("$check_places")
 
512
    if test "$apu_db_version" != "4"; then
 
513
      AC_MSG_ERROR(Berkeley db4 not found)
 
514
    fi
 
515
    ;;
 
516
  db42)
 
517
    APU_CHECK_DB42("$check_places")
 
518
    if test "$apu_db_version" != "4"; then
 
519
      AC_MSG_ERROR(Berkeley db4 not found)
 
520
    fi
 
521
    ;;
 
522
  db43)
 
523
    APU_CHECK_DB43("$check_places")
 
524
    if test "$apu_db_version" != "4"; then
 
525
      AC_MSG_ERROR(Berkeley db4 not found)
 
526
    fi
 
527
    ;;
 
528
  db44)
 
529
    APU_CHECK_DB44("$check_places")
 
530
    if test "$apu_db_version" != "4"; then
 
531
      AC_MSG_ERROR(Berkeley db4 not found)
 
532
    fi
 
533
    ;;
 
534
  default)
 
535
    APU_CHECK_DB_ALL("$check_places")
 
536
    ;;
 
537
  esac
 
538
])
 
539
 
 
540
dnl
 
541
dnl APU_CHECK_DB_ALL: Try all Berkeley DB versions, from 4.3 to 1.
 
542
dnl
 
543
AC_DEFUN([APU_CHECK_DB_ALL], [
 
544
  all_places=$1
 
545
 
 
546
  APU_CHECK_DB44("$all_places")
 
547
  if test "$apu_db_version" != "4"; then
 
548
    APU_CHECK_DB43("$all_places")
 
549
    if test "$apu_db_version" != "4"; then
 
550
      APU_CHECK_DB42("$all_places")
 
551
      if test "$apu_db_version" != "4"; then
 
552
        APU_CHECK_DB41("$all_places")
 
553
        if test "$apu_db_version" != "4"; then
 
554
          APU_CHECK_DB4("$all_places")
 
555
          if test "$apu_db_version" != "4"; then
 
556
            APU_CHECK_DB3("$all_places")
 
557
            if test "$apu_db_version" != "3"; then
 
558
              APU_CHECK_DB2("$all_places")
 
559
              if test "$apu_db_version" != "2"; then
 
560
                APU_CHECK_DB1("$all_places")
 
561
                if test "$apu_db_version" != "1"; then
 
562
                  APU_CHECK_DB185("$all_places")
 
563
                fi
 
564
              fi
 
565
            fi
 
566
          fi
 
567
        fi
 
568
      fi
 
569
    fi
 
570
  fi
 
571
  AC_MSG_CHECKING(for Berkeley DB)
 
572
  if test "$apu_have_db" = "1"; then
 
573
    AC_MSG_RESULT(found db$apu_db_version)
 
574
  else
 
575
    AC_MSG_RESULT(not found)
 
576
  fi
 
577
])
 
578
 
 
579
 
 
580
dnl
 
581
dnl APU_CHECK_DBM: see what kind of DBM backend to use for apr_dbm.
 
582
dnl
 
583
AC_DEFUN([APU_CHECK_DBM], [
 
584
  apu_use_sdbm=0
 
585
  apu_use_ndbm=0
 
586
  apu_use_gdbm=0
 
587
  apu_use_db=0
 
588
  dnl it's in our codebase
 
589
  apu_have_sdbm=1
 
590
  apu_have_gdbm=0
 
591
  apu_have_ndbm=0
 
592
  apu_have_db=0
 
593
 
 
594
  apu_db_header=db.h                # default so apu_select_dbm.h is syntactically correct
 
595
  apu_db_version=0
 
596
 
 
597
  AC_ARG_WITH(dbm, [
 
598
    --with-dbm=DBM          choose the DBM type to use.
 
599
      DBM={sdbm,gdbm,ndbm,db,db1,db185,db2,db3,db4,db41,db42,db43,db44}
 
600
  ], [
 
601
    if test "$withval" = "yes"; then
 
602
      AC_MSG_ERROR([--with-dbm needs to specify a DBM type to use.
 
603
        One of: sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4, db41, db42, db43, db44])
 
604
    fi
 
605
    requested="$withval"
 
606
  ], [
 
607
    requested=default
 
608
  ])
 
609
 
 
610
  dnl We don't pull in GDBM unless the user asks for it, since it's GPL
 
611
  AC_ARG_WITH([gdbm], [
 
612
    --with-gdbm=DIR          specify GDBM location
 
613
  ], [
 
614
    apu_have_gdbm=0
 
615
    if test "$withval" = "yes"; then
 
616
      AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1]))
 
617
    elif test "$withval" = "no"; then
 
618
      apu_have_gdbm=0
 
619
    else
 
620
      CPPFLAGS="-I$withval/include"
 
621
      LIBS="-L$withval/lib "
 
622
 
 
623
      AC_MSG_CHECKING(checking for gdbm in $withval)
 
624
      AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1]))
 
625
      if test "$apu_have_gdbm" != "0"; then
 
626
        APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
 
627
        APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
 
628
      fi
 
629
    fi
 
630
  ])
 
631
 
 
632
  AC_ARG_WITH([ndbm], [
 
633
    --with-ndbm=PATH 
 
634
      Find the NDBM header and library in \`PATH/include' and 
 
635
      \`PATH/lib'.  If PATH is of the form \`HEADER:LIB', then search 
 
636
      for header files in HEADER, and the library in LIB.  If you omit
 
637
      the \`=PATH' part completely, the configure script will search
 
638
      for NDBM in a number of standard places.
 
639
  ], [
 
640
    apu_have_ndbm=0
 
641
    if test "$withval" = "yes"; then
 
642
      AC_MSG_CHECKING(checking for ndbm in the usual places)
 
643
      apu_want_ndbm=1
 
644
      NDBM_INC=""
 
645
      NDBM_LDFLAGS=""
 
646
    elif test "$withval" = "no"; then
 
647
      apu_want_ndbm=0
 
648
    else
 
649
      apu_want_ndbm=1
 
650
      case "$withval" in
 
651
        *":"*)
 
652
          NDBM_INC="-I`echo $withval |sed -e 's/:.*$//'`"
 
653
          NDBM_LDFLAGS="-L`echo $withval |sed -e 's/^.*://'`"
 
654
          AC_MSG_CHECKING(checking for ndbm includes with $NDBM_INC libs with $NDBM_LDFLAGS )
 
655
        ;;
 
656
        *)
 
657
          NDBM_INC="-I$withval/include"
 
658
          NDBM_LDFLAGS="-L$withval/lib"
 
659
          AC_MSG_CHECKING(checking for ndbm includes in $withval)
 
660
        ;;
 
661
      esac
 
662
    fi
 
663
 
 
664
    save_cppflags="$CPPFLAGS"
 
665
    save_ldflags="$LDFLAGS"
 
666
    CPPFLAGS="$CPPFLAGS $NDBM_INC"
 
667
    LDFLAGS="$LDFLAGS $NDBM_LDFLAGS"
 
668
    dnl db_ndbm_open is what sleepcat's compatibility library actually has in it's lib
 
669
    if test "$apu_want_ndbm" != "0"; then
 
670
      AC_CHECK_HEADER(ndbm.h, 
 
671
        AC_CHECK_LIB(c, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=c],
 
672
          AC_CHECK_LIB(dbm, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=dbm],
 
673
            AC_CHECK_LIB(db, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db],
 
674
              AC_CHECK_LIB(db, __db_ndbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db])
 
675
            )
 
676
          )
 
677
        )
 
678
      )
 
679
      if test "$apu_have_ndbm" != "0";  then
 
680
        if test "$withval" != "yes"; then
 
681
          APR_ADDTO(APRUTIL_INCLUDES, [$NDBM_INC])
 
682
          APR_ADDTO(APRUTIL_LDFLAGS, [$NDBM_LDFLAGS])
 
683
        fi
 
684
      elif test "$withval" != "yes"; then
 
685
        AC_ERROR( NDBM not found in the specified directory)
 
686
      fi
 
687
    fi
 
688
    CPPFLAGS="$save_cppflags"
 
689
    LDFLAGS="$save_ldflags"
 
690
  ], [
 
691
    dnl don't check it no one has asked us for it
 
692
    apu_have_ndbm=0
 
693
  ])
 
694
 
 
695
 
 
696
  if test -n "$apu_db_xtra_libs"; then
 
697
    saveddbxtralibs="$LIBS"
 
698
    LIBS="$apu_db_xtra_libs $LIBS"
 
699
  fi
 
700
 
 
701
  dnl We're going to try to find the highest version of Berkeley DB supported.
 
702
  dnl
 
703
  dnl Note that we only do this if the user requested it, since the Sleepycat
 
704
  dnl license is viral and requires distribution of source along with programs
 
705
  dnl that use it.
 
706
  AC_ARG_WITH([berkeley-db], [
 
707
    --with-berkeley-db=PATH
 
708
      Find the Berkeley DB header and library in \`PATH/include' and
 
709
      \`PATH/lib'.  If PATH is of the form \`HEADER:LIB', then search
 
710
      for header files in HEADER, and the library in LIB.  If you omit
 
711
      the \`=PATH' part completely, the configure script will search
 
712
      for Berkeley DB in a number of standard places.
 
713
  ], [
 
714
    if test "$withval" = "yes"; then
 
715
      apu_want_db=1
 
716
      user_places=""
 
717
    elif test "$withval" = "no"; then
 
718
      apu_want_db=0
 
719
    else
 
720
      apu_want_db=1
 
721
      user_places="$withval"
 
722
    fi
 
723
 
 
724
    if test "$apu_want_db" != "0"; then
 
725
      APU_CHECK_DB($requested, $user_places)
 
726
      if test "$apu_have_db" = "0"; then
 
727
        AC_ERROR(Berkeley DB not found.)
 
728
      fi
 
729
    fi 
 
730
  ])
 
731
 
 
732
  if test -n "$apu_db_xtra_libs"; then
 
733
    LIBS="$saveddbxtralibs"
 
734
  fi
 
735
 
 
736
  case "$requested" in
 
737
    sdbm)
 
738
      apu_use_sdbm=1
 
739
      apu_default_dbm=sdbm
 
740
      ;;
 
741
    gdbm)
 
742
      apu_use_gdbm=1
 
743
      apu_default_dbm=gdbm
 
744
      ;;
 
745
    ndbm)
 
746
      apu_use_ndbm=1
 
747
      apu_default_dbm=ndbm
 
748
      ;;
 
749
    db)
 
750
      apu_use_db=1
 
751
      apu_default_dbm=db
 
752
      ;;
 
753
    db1)
 
754
      apu_use_db=1
 
755
      apu_default_dbm=db1
 
756
      ;;
 
757
    db185)
 
758
      apu_use_db=1
 
759
      apu_default_dbm=db185
 
760
      ;;
 
761
    db2)
 
762
      apu_use_db=1
 
763
      apu_default_dbm=db2
 
764
      ;;
 
765
    db3)
 
766
      apu_use_db=1
 
767
      apu_default_dbm=db3
 
768
      ;;
 
769
    db4)
 
770
      apu_use_db=1
 
771
      apu_default_dbm=db4
 
772
      ;;
 
773
    db41)
 
774
      apu_use_db=1
 
775
      apu_default_dbm=db4
 
776
      ;;
 
777
    db42)
 
778
      apu_use_db=1
 
779
      apu_default_dbm=db4
 
780
      ;;
 
781
    db43)
 
782
      apu_use_db=1
 
783
      apu_default_dbm=db4
 
784
      ;;
 
785
    db44)
 
786
      apu_use_db=1
 
787
      apu_default_dbm=db4
 
788
      ;;
 
789
    default)
 
790
      dnl ### use more sophisticated DBMs for the default?
 
791
      apu_default_dbm="sdbm (default)"
 
792
      apu_use_sdbm=1
 
793
      ;;
 
794
    *)
 
795
      AC_MSG_ERROR([--with-dbm=$look_for is an unknown DBM type.
 
796
        Use one of: sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4, db41, db42, db43, db44])
 
797
      ;;
 
798
  esac
 
799
 
 
800
  dnl Yes, it'd be nice if we could collate the output in an order
 
801
  dnl so that the AC_MSG_CHECKING would be output before the actual
 
802
  dnl checks, but it isn't happening now.
 
803
  AC_MSG_CHECKING(for default DBM)
 
804
  AC_MSG_RESULT($apu_default_dbm)
 
805
 
 
806
  AC_SUBST(apu_use_sdbm)
 
807
  AC_SUBST(apu_use_gdbm)
 
808
  AC_SUBST(apu_use_ndbm)
 
809
  AC_SUBST(apu_use_db)
 
810
 
 
811
  AC_SUBST(apu_have_sdbm)
 
812
  AC_SUBST(apu_have_gdbm)
 
813
  AC_SUBST(apu_have_ndbm)
 
814
  AC_SUBST(apu_have_db)
 
815
  AC_SUBST(apu_db_header)
 
816
  AC_SUBST(apu_db_version)
 
817
 
 
818
  dnl Since we have already done the AC_CHECK_LIB tests, if we have it, 
 
819
  dnl we know the library is there.
 
820
  if test "$apu_have_gdbm" = "1"; then
 
821
    APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lgdbm])
 
822
    APR_ADDTO(APRUTIL_LIBS,[-lgdbm])
 
823
  fi
 
824
 
 
825
  if test "$apu_have_ndbm" = "1"; then
 
826
    APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l$apu_ndbm_lib])
 
827
    APR_ADDTO(APRUTIL_LIBS,[-l$apu_ndbm_lib])
 
828
  fi
 
829
 
 
830
  if test "$apu_have_db" = "1"; then
 
831
    APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l$apu_db_lib])
 
832
    APR_ADDTO(APRUTIL_LIBS,[-l$apu_db_lib])
 
833
    if test -n "apu_db_xtra_libs"; then
 
834
      APR_ADDTO(APRUTIL_EXPORT_LIBS,[$apu_db_xtra_libs])
 
835
      APR_ADDTO(APRUTIL_LIBS,[$apu_db_xtra_libs])
 
836
    fi
 
837
  fi
 
838
])
 
839