[tests] Tidy up forknotify.py
[bitcoinplatinum.git] / build-aux / m4 / bitcoin_find_bdb48.m4
blobb9bf7bf46e54971d3f0f3b9353a707fce3ddb4a3
1 dnl Copyright (c) 2013-2015 The Bitcoin Core developers
2 dnl Distributed under the MIT software license, see the accompanying
3 dnl file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 AC_DEFUN([BITCOIN_FIND_BDB48],[
6   AC_ARG_VAR(BDB_CFLAGS, [C compiler flags for BerkeleyDB, bypasses autodetection])
7   AC_ARG_VAR(BDB_LIBS, [Linker flags for BerkeleyDB, bypasses autodetection])
9   if test "x$BDB_CFLAGS" = "x"; then
10     AC_MSG_CHECKING([for Berkeley DB C++ headers])
11     BDB_CPPFLAGS=
12     bdbpath=X
13     bdb48path=X
14     bdbdirlist=
15     for _vn in 4.8 48 4 5 5.3 ''; do
16       for _pfx in b lib ''; do
17         bdbdirlist="$bdbdirlist ${_pfx}db${_vn}"
18       done
19     done
20     for searchpath in $bdbdirlist ''; do
21       test -n "${searchpath}" && searchpath="${searchpath}/"
22       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
23         #include <${searchpath}db_cxx.h>
24       ]],[[
25         #if !((DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 8) || DB_VERSION_MAJOR > 4)
26           #error "failed to find bdb 4.8+"
27         #endif
28       ]])],[
29         if test "x$bdbpath" = "xX"; then
30           bdbpath="${searchpath}"
31         fi
32       ],[
33         continue
34       ])
35       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
36         #include <${searchpath}db_cxx.h>
37       ]],[[
38         #if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8)
39           #error "failed to find bdb 4.8"
40         #endif
41       ]])],[
42         bdb48path="${searchpath}"
43         break
44       ],[])
45     done
46     if test "x$bdbpath" = "xX"; then
47       AC_MSG_RESULT([no])
48       AC_MSG_ERROR([libdb_cxx headers missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
49     elif test "x$bdb48path" = "xX"; then
50       BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx)
51       AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 4.8])],[
52         AC_MSG_WARN([Found Berkeley DB other than 4.8; wallets opened by this build will not be portable!])
53       ],[
54         AC_MSG_ERROR([Found Berkeley DB other than 4.8, required for portable wallets (--with-incompatible-bdb to ignore or --disable-wallet to disable wallet functionality)])
55       ])
56     else
57       BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb48path}],db_cxx)
58       bdbpath="${bdb48path}"
59     fi
60   else
61     BDB_CPPFLAGS=${BDB_CFLAGS}
62   fi
63   AC_SUBST(BDB_CPPFLAGS)
64   
65   if test "x$BDB_LIBS" = "x"; then
66     # TODO: Ideally this could find the library version and make sure it matches the headers being used
67     for searchlib in db_cxx-4.8 db_cxx; do
68       AC_CHECK_LIB([$searchlib],[main],[
69         BDB_LIBS="-l${searchlib}"
70         break
71       ])
72     done
73     if test "x$BDB_LIBS" = "x"; then
74         AC_MSG_ERROR([libdb_cxx missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
75     fi
76   fi
77   AC_SUBST(BDB_LIBS)