~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to build/ac-macros/berkeley-db.m4

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl   SVN_LIB_BERKELEY_DB(major, minor, patch)
 
2
dnl
 
3
dnl   Compare if the DB provided by APR-UTIL is no older than the
 
4
dnl   version given by MAJOR, MINOR, and PATCH.
 
5
dnl
 
6
dnl   If we find a useable version, set the shell variable
 
7
dnl   `svn_lib_berkeley_db' to `yes'.  Otherwise, set `svn_lib_berkeley_db'
 
8
dnl   to `no'.
 
9
dnl
 
10
dnl   This macro also checks for the `--with-berkeley-db=PATH' flag;
 
11
dnl   if given, the macro will use the PATH specified, and the
 
12
dnl   configuration script will die if it can't find the library.  If
 
13
dnl   the user gives the `--without-berkeley-db' flag, the entire
 
14
dnl   search is skipped.
 
15
 
 
16
 
 
17
AC_DEFUN(SVN_LIB_BERKELEY_DB,
 
18
[
 
19
  db_version=$1.$2.$3
 
20
  dnl  Process the `with-berkeley-db' switch.  We set `status' to one
 
21
  dnl  of the following values:
 
22
  dnl    `required' --- the user specified that they did want to use
 
23
  dnl        Berkeley DB, so abort the configuration if we cannot find it.
 
24
  dnl    `try-link' --- See if APR-UTIL supplies the correct DB version;
 
25
  dnl        if it doesn't, just do not build the bdb based filesystem.
 
26
  dnl    `skip' --- Do not look for Berkeley DB, and do not build the
 
27
  dnl        bdb based filesystem.
 
28
  dnl
 
29
  dnl  Finding it is defined as doing a runtime check against the db
 
30
  dnl  that is supplied by APR-UTIL.
 
31
  dnl  Assuming `status' is not `skip', we do a runtime check against the db
 
32
  dnl  that is supplied by APR-UTIL.
 
33
  dnl
 
34
  dnl  Since APR-UTIL uses --with-berkeley-db as well, and we pass it
 
35
  dnl  through when APR-UTIL is in the tree, we also accept a place spec
 
36
  dnl  as argument, and handle that case specifically.
 
37
  dnl
 
38
  dnl  A `place spec' is either:
 
39
  dnl    - a directory prefix P, indicating we should look for headers in
 
40
  dnl      P/include and libraries in P/lib, or
 
41
  dnl    - a string of the form `HEADER:LIB', indicating that we should look
 
42
  dnl      for headers in HEADER and libraries in LIB.
 
43
 
 
44
  AC_ARG_WITH(berkeley-db,
 
45
  [  --with-berkeley-db=PATH
 
46
                          The Subversion Berkeley DB based filesystem library 
 
47
                          requires Berkeley DB $db_version or newer.  If you
 
48
                          specify `--without-berkeley-db', that library will
 
49
                          not be built.  Otherwise, the configure script builds
 
50
                          that library if and only if APR-UTIL is linked
 
51
                          against a new enough version of Berkeley DB.
 
52
 
 
53
                          If and only if you are building APR-UTIL as part of
 
54
                          the Subversion build process, you may help APR-UTIL
 
55
                          to find the correct Berkeley DB installation by
 
56
                          passing a PATH to this option, to cause APR-UTIL to
 
57
                          look for the Berkeley DB header and library in
 
58
                          `PATH/include' and `PATH/lib'.  If PATH is of the
 
59
                          form `HEADER:LIB', then search for header files in
 
60
                          HEADER, and the library in LIB.  If you omit the
 
61
                          `=PATH' part completely, the configure script will
 
62
                          search for Berkeley DB in a number of standard
 
63
                          places.],
 
64
  [
 
65
    if test "$withval" = "no"; then
 
66
      status=skip
 
67
    else
 
68
      apu_db_version="`$apu_config --db-version`"
 
69
      if test $? -ne 0; then
 
70
        AC_MSG_ERROR([Can't determine whether apr-util is linked against a
 
71
                      proper version of Berkeley DB.])
 
72
      fi
 
73
 
 
74
      if test "$withval" = "yes"; then
 
75
        if test "$apu_db_version" != "4"; then
 
76
          AC_MSG_ERROR([APR-UTIL wasn't linked against Berkeley DB 4,
 
77
                        while the fs component is required.  Reinstall
 
78
                        APR-UTIL with the appropiate options.])
 
79
        fi
 
80
        
 
81
        status=required
 
82
 
 
83
      elif test "$apu_found" != "reconfig"; then
 
84
        if test "$apu_db_version" != 4; then
 
85
          AC_MSG_ERROR([APR-UTIL was installed independently, it won't be
 
86
                        possible to use the specified Berkeley DB: $withval])
 
87
        fi
 
88
 
 
89
        AC_MSG_WARN([APR-UTIL may or may not be using the specified
 
90
                     Berkeley DB at `$withval'.  Using the Berkeley DB
 
91
                     supplied by APR-UTIL.])
 
92
 
 
93
        status=required
 
94
      fi
 
95
    fi
 
96
  ],
 
97
  [
 
98
    # No --with-berkeley-db option:
 
99
    #
 
100
    # Check if APR-UTIL is providing the correct Berkeley DB version
 
101
    # for us.
 
102
    #
 
103
    apu_db_version="`$apu_config --db-version`"
 
104
    if test $? -ne 0; then
 
105
      AC_MSG_WARN([Detected older version of APR-UTIL, trying to determine
 
106
                   whether apr-util is linked against Berkeley DB
 
107
                   $db_version])
 
108
      status=try-link
 
109
    elif test "$apu_db_version" != "4"; then
 
110
      status=skip
 
111
    else
 
112
      status=try-link
 
113
    fi
 
114
  ])
 
115
 
 
116
  if test "$status" = "skip"; then
 
117
    svn_lib_berkeley_db=no
 
118
  else
 
119
    AC_MSG_CHECKING([for availability of Berkeley DB])
 
120
    SVN_LIB_BERKELEY_DB_TRY($1, $2, $3)
 
121
    if test "$svn_have_berkeley_db" = "yes"; then
 
122
      AC_MSG_RESULT([yes])
 
123
      svn_lib_berkeley_db=yes
 
124
    else
 
125
      AC_MSG_RESULT([no])
 
126
      svn_lib_berkeley_db=no
 
127
      if test "$status" = "required"; then
 
128
        AC_MSG_ERROR([Berkeley DB $db_version wasn't found.])
 
129
      fi
 
130
    fi
 
131
  fi
 
132
])
 
133
 
 
134
 
 
135
dnl   SVN_LIB_BERKELEY_DB_TRY(major, minor, patch)
 
136
dnl
 
137
dnl   A subroutine of SVN_LIB_BERKELEY_DB.
 
138
dnl
 
139
dnl   Check that a new-enough version of Berkeley DB is installed.
 
140
dnl   "New enough" means no older than the version given by MAJOR,
 
141
dnl   MINOR, and PATCH.  The result of the test is not cached; no
 
142
dnl   messages are printed.
 
143
dnl
 
144
dnl   Set the shell variable `svn_have_berkeley_db' to `yes' if we found
 
145
dnl   an appropriate version via APR-UTIL, or `no' otherwise.
 
146
dnl
 
147
dnl   This macro uses the Berkeley DB library function `db_version' to
 
148
dnl   find the version.  If the library linked to APR-UTIL doesn't have this
 
149
dnl   function, then this macro assumes it is too old.
 
150
 
 
151
dnl NOTE: This is pretty messed up.  It seems that the FreeBSD port of
 
152
dnl Berkeley DB 4 puts the header file in /usr/local/include/db4, but the
 
153
dnl database library in /usr/local/lib, as libdb4.[a|so].  There is no
 
154
dnl /usr/local/include/db.h.  So if you check for /usr/local first, you'll
 
155
dnl get the old header file from /usr/include, and the new library from
 
156
dnl /usr/local/lib.  Disaster.  Thus this test compares the version constants
 
157
dnl in the db.h header with the ones returned by db_version().
 
158
 
 
159
 
 
160
AC_DEFUN(SVN_LIB_BERKELEY_DB_TRY,
 
161
  [
 
162
    svn_lib_berkeley_db_try_save_cppflags="$CPPFLAGS"
 
163
    svn_lib_berkeley_db_try_save_libs="$LIBS"
 
164
 
 
165
    svn_check_berkeley_db_major=$1
 
166
    svn_check_berkeley_db_minor=$2
 
167
    svn_check_berkeley_db_patch=$3
 
168
 
 
169
    # Extract only the -ldb.* flag from the libs supplied by apu-config
 
170
    # Otherwise we get bit by the fact that expat might not be built yet
 
171
    # Or that it resides in a non-standard location which we would have
 
172
    # to compensate with using something like -R`$apu_config --prefix`/lib.
 
173
    #
 
174
    svn_apu_bdb_lib=["`$apu_config --libs | sed -e 's/.*\(-ldb[^ ]*\).*/\1/'`"]
 
175
 
 
176
    CPPFLAGS="$SVN_APRUTIL_INCLUDES $CPPFLAGS" 
 
177
    LIBS="`$apu_config --ldflags` $svn_apu_bdb_lib $LIBS"
 
178
 
 
179
    AC_TRY_RUN(
 
180
      [
 
181
#include <stdlib.h>
 
182
#define APU_WANT_DB
 
183
#include <apu_want.h>
 
184
 
 
185
int main ()
 
186
{
 
187
  int major, minor, patch;
 
188
 
 
189
  db_version (&major, &minor, &patch);
 
190
 
 
191
  /* Sanity check: ensure that db.h constants actually match the db library */
 
192
  if (major != DB_VERSION_MAJOR
 
193
      || minor != DB_VERSION_MINOR
 
194
      || patch != DB_VERSION_PATCH)
 
195
    exit (1);
 
196
 
 
197
  /* Run-time check:  ensure the library claims to be the correct version. */
 
198
 
 
199
  if (major < $svn_check_berkeley_db_major)
 
200
    exit (1);
 
201
  if (major > $svn_check_berkeley_db_major)
 
202
    exit (0);
 
203
 
 
204
  if (minor < $svn_check_berkeley_db_minor)
 
205
    exit (1);
 
206
  if (minor > $svn_check_berkeley_db_minor)
 
207
    exit (0);
 
208
 
 
209
  if (patch >= $svn_check_berkeley_db_patch)
 
210
    exit (0);
 
211
  else
 
212
    exit (1);
 
213
}
 
214
      ],
 
215
      [svn_have_berkeley_db=yes],
 
216
      [svn_have_berkeley_db=no],
 
217
      [svn_have_berkeley_db=yes]
 
218
    )
 
219
 
 
220
  CPPFLAGS="$svn_lib_berkeley_db_try_save_cppflags"
 
221
  LIBS="$svn_lib_berkeley_db_try_save_libs"
 
222
  ]
 
223
)