dbm.m4 23 KB

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