Add BSD license file
[platform/upstream/db4.git] / dist / configure.ac
1 # $Id$
2 # Process this file with autoconf to produce a configure script.
3
4 PACKAGE=db
5 AC_INIT(Berkeley DB, __EDIT_DB_VERSION__,
6         [Oracle Technology Network Berkeley DB forum],
7         db-__EDIT_DB_VERSION__)
8 AC_CONFIG_SRCDIR([../db/db.c])
9 AC_CONFIG_HEADERS([db_config.h:config.hin])
10
11 AC_CONFIG_MACRO_DIR([aclocal])
12
13 # Configure setup.
14 AC_CANONICAL_HOST()
15 AC_ARG_PROGRAM()
16
17 # Don't build in the top-level or dist directories.
18 AC_MSG_CHECKING(if building in the top-level or dist directories)
19 if [ test -d db_archive -o -f configure.ac ] ; then
20         AC_MSG_RESULT(yes)
21         AC_MSG_ERROR([\
22 Berkeley DB should not be built in the top-level or "dist" directories. \
23 Change directory to the build_unix directory and run ../dist/configure \
24 from there.])
25
26 fi
27 AC_MSG_RESULT(no)
28
29 # Substitution variables.
30 AC_SUBST(ADDITIONAL_INCS)
31 AC_SUBST(ADDITIONAL_LANG)
32 AC_SUBST(ADDITIONAL_OBJS)
33 AC_SUBST(ADDITIONAL_PROGS)
34 AC_SUBST(BUILD_TARGET)
35 AC_SUBST(CFLAGS)
36 AC_SUBST(CONFIGURATION_ARGS)
37 AC_SUBST(CONFIGURATION_PATH)
38 AC_SUBST(CPPFLAGS)
39 AC_SUBST(CRYPTO_OBJS)
40 AC_SUBST(CXX)
41 AC_SUBST(CXXFLAGS)
42 AC_SUBST(DB_CONST)
43 AC_SUBST(DB_PROTO1)
44 AC_SUBST(DB_PROTO2)
45 AC_SUBST(DEFAULT_LIB)
46 AC_SUBST(DEFAULT_LIB_CXX)
47 AC_SUBST(DEFAULT_LIB_STL)
48 AC_SUBST(INSTALLER)
49 AC_SUBST(INSTALL_LIBS)
50 AC_SUBST(INSTALL_TARGET)
51 AC_SUBST(JAR)
52 AC_SUBST(JAVACFLAGS)
53 AC_SUBST(LDFLAGS)
54 AC_SUBST(LIBCSO_LIBS)
55 AC_SUBST(LIBJSO_LIBS)
56 AC_SUBST(LIBS)
57 AC_SUBST(LIBSO_LIBS)
58 AC_SUBST(LIBTOOL)
59 AC_SUBST(LIBTSO_LIBS)
60 AC_SUBST(LIBTSO_MODSUFFIX)
61 AC_SUBST(LIBTSO_MODULE)
62 AC_SUBST(LIBXSO_LIBS)
63 AC_SUBST(MAKEFILE_CC)
64 AC_SUBST(MAKEFILE_CCLINK)
65 AC_SUBST(MAKEFILE_CXX)
66 AC_SUBST(MAKEFILE_CXXLINK)
67 AC_SUBST(MAKEFILE_SOLINK)
68 AC_SUBST(MAKEFILE_XSOLINK)
69 AC_SUBST(OSDIR)
70 AC_SUBST(PATH_SEPARATOR)
71 AC_SUBST(POSTLINK)
72 AC_SUBST(REPLACEMENT_OBJS)
73 AC_SUBST(RPC_CLIENT_OBJS)
74 AC_SUBST(RPC_SERVER_H)
75 AC_SUBST(SOFLAGS)
76 AC_SUBST(SWIGCFLAGS)
77 AC_SUBST(TEST_LIBS)
78 AC_SUBST(db_int_def)
79 AC_SUBST(o)
80
81 # The Windows public header has two extra symbols we need to remove.
82 AC_SUBST(platform_header)
83 AC_SUBST(platform_footer)
84
85 # Set the default installation location.
86 AC_PREFIX_DEFAULT(/usr/local/BerkeleyDB.__EDIT_DB_VERSION_MAJOR__.__EDIT_DB_VERSION_MINOR__)
87
88 # Configure the version information.
89 AC_SUBST(DB_VERSION_MAJOR)
90 DB_VERSION_MAJOR="__EDIT_DB_VERSION_MAJOR__"
91 AC_SUBST(DB_VERSION_MINOR)
92 DB_VERSION_MINOR="__EDIT_DB_VERSION_MINOR__"
93 AC_SUBST(DB_VERSION_PATCH)
94 DB_VERSION_PATCH="__EDIT_DB_VERSION_PATCH__"
95 AC_SUBST(DB_VERSION_STRING)
96 DB_VERSION_STRING='"__EDIT_DB_VERSION_STRING__"'
97 AC_SUBST(DB_VERSION_UNIQUE_NAME)
98
99 # Process all options before using them.
100 AM_OPTIONS_SET
101
102 # Set some #defines based on configuration options.
103 if test "$db_cv_diagnostic" = "yes"; then
104         AC_DEFINE(DIAGNOSTIC)
105         AH_TEMPLATE(DIAGNOSTIC,
106     [Define to 1 if you want a version with run-time diagnostic checking.])
107 fi
108 if test "$db_cv_debug_rop" = "yes"; then
109         AC_DEFINE(DEBUG_ROP)
110         AH_TEMPLATE(DEBUG_ROP,
111     [Define to 1 if you want a version that logs read operations.])
112 fi
113 if test "$db_cv_debug_wop" = "yes"; then
114         AC_DEFINE(DEBUG_WOP)
115         AH_TEMPLATE(DEBUG_WOP,
116     [Define to 1 if you want a version that logs write operations.])
117 fi
118 if test "$db_cv_umrw" = "yes"; then
119         AC_DEFINE(UMRW)
120         AH_TEMPLATE(UMRW,
121     [Define to 1 to mask harmless uninitialized memory read/writes.])
122
123 fi
124 if test "$db_cv_test" = "yes"; then
125         AC_DEFINE(CONFIG_TEST)
126         AH_TEMPLATE(CONFIG_TEST,
127     [Define to 1 if you want to build a version for running the test suite.])
128 fi
129
130 AH_TEMPLATE(HAVE_UPGRADE_SUPPORT,
131     [Define to 1 if port includes historic database upgrade support.])
132 AC_DEFINE(HAVE_UPGRADE_SUPPORT)
133
134 # Check for programs used in building and installation.
135 AM_PROGRAMS_SET
136 AC_PROG_INSTALL
137
138 BUILD_TARGET="library_build"
139 INSTALL_TARGET="library_install"
140
141 # Respect the environment LIBS settings
142 LIBSO_LIBS="$LIBS"
143
144 # This is where we handle stuff that autoconf can't handle: compiler,
145 # preprocessor and load flags, libraries that the standard tests don't
146 # look for.
147 #
148 # There are additional libraries we need for some compiler/architecture
149 # combinations.
150 #
151 # Some architectures require DB to be compiled with special flags and/or
152 # libraries for threaded applications
153 #
154 # The makefile CC may be different than the CC used in config testing,
155 # because the makefile CC may be set to use $(LIBTOOL).
156 #
157 # Don't override anything if it's already set from the environment.
158 optimize_debug="-O"
159 case "$host_os" in
160 aix4.3.*|aix[[56]]*)
161         case "$host_os" in
162         aix4.3.*)
163                 CPPFLAGS="$CPPFLAGS -D_LINUX_SOURCE_COMPAT";;
164         esac
165         # IBM's XLC compilers (at least versions 7/8/9) generate incorrect code
166         # when ordinary optimization is enabled because they make strong
167         # assumptions about the types held at each memory location, and some
168         # Berkeley DB code violates those assumptions.  [#16141]
169         optimize_debug="-O2 -qalias=noansi"
170         CC=${CC-"xlc_r"}
171         CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"
172         LDFLAGS="$LDFLAGS -Wl,-brtl";;
173 bsdi3*) CC=${CC-"shlicc2"}
174         LIBSO_LIBS="$LIBSO_LIBS -lipc";;
175 cygwin*)
176         CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -D_REENTRANT";;
177 freebsd*)
178         CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"
179         LDFLAGS="$LDFLAGS -pthread";;
180 gnu*|k*bsd*-gnu|linux*)
181         CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -D_REENTRANT";;
182 hpux*)  CPPFLAGS="$CPPFLAGS -D_REENTRANT";;
183 irix*)  optimize_debug="-O2"
184         CPPFLAGS="$CPPFLAGS -D_SGI_MP_SOURCE";;
185 mpeix*) CPPFLAGS="$CPPFLAGS -D_POSIX_SOURCE -D_SOCKET_SOURCE"
186         LIBSO_LIBS="$LIBSO_LIBS -lsocket -lsvipc";;
187 osf*)   CPPFLAGS="$CPPFLAGS -pthread";;
188 *qnx*)  qnx_build="yes"
189         AC_DEFINE(HAVE_QNX)
190         AH_TEMPLATE(HAVE_QNX, [Define to 1 if building on QNX.]);;
191 solaris*)
192         CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS ";;
193 esac
194
195 # If the user wants a debugging environment, change any compiler optimization
196 # flags to -g.  We used to add -g to the -O compiler flags, but compilers are
197 # good enough at code re-organization that debugging with -O no longer works.
198 # If you want to compile with a different set of flags, specify CFLAGS in the
199 # environment before configuring.
200 if test "$db_cv_debug" = "yes"; then
201         AC_DEFINE(DEBUG)
202         AH_TEMPLATE(DEBUG, [Define to 1 if you want a debugging version.])
203
204         optimize_debug="-g"
205 fi
206
207 # Set CFLAGS/CXXFLAGS.  We MUST set the flags before we call autoconf
208 # compiler configuration macros, because if we don't, they set CFLAGS
209 # to no optimization and -g, which isn't what we want.
210 CFLAGS=${CFLAGS-$optimize_debug}
211 CXXFLAGS=${CXXFLAGS-"$CFLAGS"}
212
213 # The default compiler is cc (NOT gcc), the default CFLAGS is as specified
214 # above, NOT what is set by AC_PROG_CC, as it won't set optimization flags
215 # for any compiler other than gcc.
216 AC_PROG_CC(cc gcc)
217
218 # We know what compiler we're going to use, now.  Set per-compiler flags.
219 if test "$GCC" = "yes"; then
220         # Use -O3 if we're using gcc, unless we're doing a small build, in
221         # which case we use -Os alone.  The code size for -O3 is quite a
222         # bit larger than -O2: a compromise is "-Os -finline-functions",
223         # it's smaller and explicitly inlining the functions helps Berkeley
224         # DB.
225         CFLAGS="$CFLAGS "
226         if test "$db_cv_smallbuild" = "yes"; then
227                 CFLAGS=`echo "$CFLAGS" | sed 's/-O /-Os /g'`
228         else
229                 CFLAGS=`echo "$CFLAGS" | sed 's/-O /-O3 /g'`
230         fi
231 else
232         case "$host_os" in
233         hpux11.0*)      ;;
234         hpux11*)        CPPFLAGS="$CPPFLAGS -mt";;
235         esac
236 fi
237
238 # Check for "const" and "inline" keywords.
239 AC_C_CONST
240 AC_C_INLINE
241
242 # We use prototypes and the keyword "const" in db.h which doesn't include
243 # db_config.h, so we have to figure out what to do there.
244 #
245 # There is an autoconf AC_C_PROTOTYPES macro, but as all it does is define
246 # db_config.h variables, it doesn't help us.
247 #
248 # We don't have much choice, we look at internal autoconf variables.
249 if test "$ac_cv_c_const" != "yes"; then
250         DB_CONST="#define const"
251 fi
252
253 # Clear __P, some other systems use it too.
254 DB_PROTO1="#undef __P"
255 if test "$ac_cv_prog_cc_c89" = "no"; then
256         DB_PROTO2="#define      __P(protos)     ()"
257 else
258         DB_PROTO2="#define      __P(protos)     protos"
259 fi
260
261 # Because of shared library building, the ${CC} used for config tests
262 # may be different than the ${CC} we want to put in the Makefile.
263 # The latter is known as ${MAKEFILE_CC} in this script.
264 MAKEFILE_CC="${CC}"
265 MAKEFILE_CCLINK="${CC}"
266 MAKEFILE_CXX="nocxx"
267 MAKEFILE_CXXLINK="nocxx"
268
269 # See if we need the C++ compiler at all.  If so, we'd like to find one that
270 # interoperates with the C compiler we chose.  Since we prefered cc over gcc,
271 # we'll also prefer the vendor's compiler over g++/gcc.  If we're wrong, the
272 # user can set CC and CXX in their environment before running configure.
273 #
274 # AC_PROG_CXX sets CXX, but it uses $CXX and $CCC (in that order) as its
275 # first choices.
276 if test "$db_cv_cxx" = "yes"; then
277         if test "$GCC" != "yes"; then
278                 case "$host_os" in
279                 aix*)           AC_CHECK_TOOL(CCC, xlC_r)
280                                 LIBXSO_LIBS="-lC_r $LIBXSO_LIBS"
281                                 LIBSO_LIBS="-lC_r $LIBSO_LIBS";;
282                 hpux*)          AC_CHECK_TOOL(CCC, aCC);;
283                 irix*)          AC_CHECK_TOOL(CCC, CC);;
284                 osf*)           AC_CHECK_TOOL(CCC, cxx)
285                                 CXXFLAGS="$CXXFLAGS -D__USE_STD_IOSTREAM"
286                                 test -d /usr/include.dtk &&
287                                     CXXFLAGS="$CXXFLAGS -I/usr/include.dtk";;
288                 solaris*)       AC_CHECK_TOOL(CCC, CC);;
289                 esac
290         fi
291         AC_PROG_CXX
292         ###### WORKAROUND: SEE SR #7938
293         AC_PROG_CXXCPP
294         ###############################
295         AC_CXX_STDHEADERS
296         MAKEFILE_CXX="${CXX}"
297         MAKEFILE_CXXLINK="${CXX}"
298 fi
299
300 # Do some gcc specific configuration.
301 AC_GCC_CONFIG1
302
303 # We need the -Kthread/-pthread flag when compiling on SCO/Caldera's UnixWare
304 # and OpenUNIX releases.  We can't make the test until we know which compiler
305 # we're using.
306 case "$host_os" in
307 sysv5UnixWare*|sysv5OpenUNIX8*)
308         if test "$GCC" == "yes"; then
309                 CPPFLAGS="$CPPFLAGS -pthread"
310                 LDFLAGS="$LDFLAGS -pthread"
311         else
312                 CPPFLAGS="$CPPFLAGS -Kthread"
313                 LDFLAGS="$LDFLAGS -Kthread"
314         fi;;
315 esac
316
317 # Export our compiler preferences for the libtool configuration.
318 export CC CCC
319 CCC=CXX
320
321 # Libtool configuration.
322 AC_PROG_LIBTOOL
323
324 SOFLAGS="-rpath \$(libdir)"
325
326 # Set SOSUFFIX and friends
327 SOSUFFIX_CONFIG
328 MODSUFFIX_CONFIG
329 JMODSUFFIX_CONFIG
330
331 LIBTOOL="./libtool"
332
333 INSTALLER="\$(LIBTOOL) --mode=install cp -p"
334
335 MAKEFILE_CC="\$(LIBTOOL) --mode=compile ${MAKEFILE_CC}"
336 MAKEFILE_SOLINK="\$(LIBTOOL) --mode=link ${MAKEFILE_CCLINK} -avoid-version"
337 MAKEFILE_CCLINK="\$(LIBTOOL) --mode=link ${MAKEFILE_CCLINK}"
338 MAKEFILE_CXX="\$(LIBTOOL) --mode=compile ${MAKEFILE_CXX}"
339 MAKEFILE_XSOLINK="\$(LIBTOOL) --mode=link ${MAKEFILE_CXXLINK} -avoid-version"
340 MAKEFILE_CXXLINK="\$(LIBTOOL) --mode=link ${MAKEFILE_CXXLINK}"
341
342
343 case "$host_os" in
344 cygwin* | mingw*)
345         MAKEFILE_SOLINK="$MAKEFILE_SOLINK -no-undefined"
346         MAKEFILE_XSOLINK="$MAKEFILE_XSOLINK -no-undefined";;
347 esac
348
349 case "$host_os" in
350     darwin*)
351         LIBTSO_MODULE=""
352         LIBTSO_MODSUFFIX=".dylib";;
353     *qnx*)
354         LIBTSO_MODULE=""
355         LIBTSO_MODSUFFIX=$MODSUFFIX;;
356     *)
357         LIBTSO_MODULE="-module"
358         LIBTSO_MODSUFFIX=$MODSUFFIX;;
359 esac
360
361 # C API.
362 if test "$enable_shared" = "no"; then
363         DEFAULT_LIB="\$(libdb_version)"
364         POSTLINK=": "
365         o=".o"
366 else
367         DEFAULT_LIB="\$(libso_target)"
368         POSTLINK="\$(LIBTOOL) --mode=execute true"
369         o=".lo"
370 fi
371 INSTALL_LIBS="$DEFAULT_LIB"
372 if test "$enable_static" = "yes"; then
373         INSTALL_LIBS="$INSTALL_LIBS \$(libdb)"
374 fi
375
376 # Optional C++ API.
377 if test "$db_cv_cxx" = "yes"; then
378         if test "$enable_shared" = "no"; then
379                 DEFAULT_LIB_CXX="\$(libcxx_version)"
380         fi
381         if test "$enable_shared" = "yes"; then
382                 DEFAULT_LIB_CXX="\$(libxso_target)"
383         fi
384         INSTALL_LIBS="$INSTALL_LIBS $DEFAULT_LIB_CXX"
385         if test "$enable_static" = "yes"; then
386                 INSTALL_LIBS="$INSTALL_LIBS \$(libcxx)"
387         fi
388 fi
389
390 # Optional Java API.
391 if test "$db_cv_java" = "yes"; then
392         # Java requires shared libraries.
393         if test "$enable_shared" = "no"; then
394                 AC_MSG_ERROR([Java requires shared libraries])
395         fi
396
397         # A classpath that includes . is needed to check for Java
398         # Since Cygwin uses Windows' javac, we need Windows path separators
399         case "$host_os" in 
400         cygwin*)        CLASSPATH=".;$CLASSPATH";;
401         *)              CLASSPATH=".:$CLASSPATH";;
402         esac
403         export CLASSPATH
404         AC_PROG_JAVAC
405         AC_PROG_JAR
406         AC_PROG_JAVA
407         AC_JNI_INCLUDE_DIR
408
409         AC_MSG_CHECKING(java version)
410         case "$JAVA" in
411         *kaffe* )
412                 JAVA_VERSION=`$JAVA -version 2>&1 |
413                         sed -e '/Java Version:/!d' -e 's/.*Java Version: \([[^  ]]*\)[[         ]]*/\1/'` ;;
414         * )     JAVA_VERSION=`$JAVA -version 2>&1 |
415                         sed -e '/ version /!d' -e 's/.*"\(.*\)".*/\1/'` ;;
416         esac
417         AC_MSG_RESULT($JAVA_VERSION)
418         case "$JAVA_VERSION" in
419         1.[[3456789]]* | 1.[[1-9]][[0-9]]* | [[23456789]]* ) ;;
420         * )
421                 AC_MSG_ERROR([Java version 1.3 or higher required, got $JAVA_VERSION]) ;;
422         esac
423
424         # Because of the code that SWIG generates to cast between pointers and
425         # integers, we need to add the flag "-fno-strict-aliasing" to the gcc
426         # command line when compiling the JNI code.  This is documented in
427         # [#14953] and at http://www.swig.org/Doc1.3/Java.html
428         if test "${GCC}" = "yes"; then
429                 SWIGCFLAGS="-fno-strict-aliasing"
430         fi
431
432         for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS
433         do
434                 CPPFLAGS="$CPPFLAGS -I$JNI_INCLUDE_DIR"
435         done
436
437         ADDITIONAL_LANG="$ADDITIONAL_LANG java"
438         INSTALL_LIBS="$INSTALL_LIBS \$(libjso_target)"
439 else
440         JAVAC=nojavac
441 fi
442
443 # MinGW support.
444 if test "$db_cv_mingw" = "yes"; then
445         OSDIR=os_windows
446         PATH_SEPARATOR="\\\\/:"
447
448         AC_DEFINE(DB_WIN32)
449         AC_DEFINE(STDC_HEADERS)
450 else
451         OSDIR=os
452         PATH_SEPARATOR="/"
453         AC_DEFINE(HAVE_SYSTEM_INCLUDE_FILES)
454 fi
455
456 # Optional STL API.
457 if test "$db_cv_stl" = "yes"; then
458         AC_CXX_SUPPORTS_TEMPLATES
459         AC_CXX_WSTRING
460         AX_TLS
461         if test "$enable_shared" = "no"; then
462                 DEFAULT_LIB_STL="\$(libstl_version)"
463         fi
464         if test "$enable_shared" = "yes"; then
465                 DEFAULT_LIB_STL="\$(libstlso_target)"
466         fi
467         ADDITIONAL_INCS="dbstl_common.h dbstl_set.h dbstl_vector.h dbstl_exception.h dbstl_map.h dbstl_utility.h dbstl_dbc.h dbstl_dbt.h dbstl_base_iterator.h dbstl_container.h dbstl_element_ref.h dbstl_inner_utility.h dbstl_resource_manager.h $ADDITIONAL_INCS"
468         INSTALL_LIBS="$INSTALL_LIBS $DEFAULT_LIB_STL"
469         if test "$enable_static" = "yes"; then
470                 INSTALL_LIBS="$INSTALL_LIBS \$(libstl)"
471         fi
472 fi
473
474 # Checks for include files, structures, C types.
475 AC_HEADER_STAT
476 AC_HEADER_TIME
477 AC_HEADER_DIRENT
478 AC_CHECK_HEADERS(execinfo.h sys/select.h sys/socket.h sys/time.h)
479 AC_CHECK_MEMBERS([struct stat.st_blksize])
480 AM_TYPES
481
482 AC_CACHE_CHECK([for ANSI C exit success/failure values], db_cv_exit_defines, [
483 AC_TRY_COMPILE([#include <stdlib.h>], return (EXIT_SUCCESS);,
484     [db_cv_exit_defines=yes], [db_cv_exit_defines=no])])
485 if test "$db_cv_exit_defines" = "yes"; then
486         AC_DEFINE(HAVE_EXIT_SUCCESS)
487         AH_TEMPLATE(HAVE_EXIT_SUCCESS,
488             [Define to 1 if platform has EXIT_SUCCESS/EXIT_FAILURE #defines.])
489 fi
490
491 AC_CACHE_CHECK([for getopt optreset variable], db_cv_optreset, [
492 AC_TRY_LINK([#include <unistd.h>], extern int optreset; optreset = 1;,
493     [db_cv_optreset=yes], [db_cv_optreset=no])])
494 if test "$db_cv_optreset" = "yes"; then
495         AC_DEFINE(HAVE_GETOPT_OPTRESET)
496         AH_TEMPLATE(HAVE_GETOPT_OPTRESET,
497             [Define to 1 if getopt supports the optreset variable.])
498 fi
499
500 # Check for mutexes.
501 # We do this first because it changes $LIBSO_LIBS.
502 AM_DEFINE_MUTEXES
503
504 # Check for native (system call or instruction set) support for
505 # atomic increment, decrement, and compare & exchange.
506 AM_DEFINE_ATOMIC
507
508 # Test for various functions/libraries -- do tests that change library values
509 # first.
510 #
511 # Update LIBS, so we're testing against the current list of libraries.
512 LIBS="$LIBSO_LIBS"
513
514 # The yield function on Solaris is almost certainly pthread_yield (LWP threads
515 # or POSIX pthreads), or thr_yield (UI threads).  There's an outside chance it
516 # is sched_yield() though, only available in -lrt on Solaris.
517 AC_SEARCH_LIBS(sched_yield, rt)
518
519 # The Berkeley DB library calls fdatasync, only available in -lrt on Solaris.
520 AC_SEARCH_LIBS(fdatasync, rt)
521
522 AC_SEARCH_LIBS(getaddrinfo, nsl socket)
523 AC_SEARCH_LIBS(hstrerror, resolv)
524
525 # Those tests updated LIBS, update our internal list.
526 LIBSO_LIBS="$LIBS"
527
528 # !!!
529 # We could be more exact about whether these libraries are needed, but don't
530 # bother -- if they exist, we load them, it's only the test programs anyway.
531 AC_HAVE_LIBRARY(m, TEST_LIBS="$TEST_LIBS -lm")
532 AC_HAVE_LIBRARY(nsl, TEST_LIBS="$TEST_LIBS -lnsl")
533 AC_HAVE_LIBRARY(socket, TEST_LIBS="$TEST_LIBS -lsocket")
534
535 # Checks for system functions for which we have replacements.
536 #
537 # The only portable getcwd call is getcwd(char *, size_t), where the
538 # buffer is non-NULL -- Solaris can't handle a NULL buffer, and they
539 # deleted getwd().
540 AC_REPLACE_FUNCS(\
541         abort atoi atol getcwd getenv getopt isalpha isdigit isprint\
542         isspace memcmp memcpy memmove printf qsort raise rand strcasecmp\
543         strcat strchr strdup strerror strncat strncmp strrchr strsep\
544         strtol strtoul)
545
546 # Check for system functions we optionally use.
547 AC_CHECK_FUNCS(\
548         _fstati64 backtrace backtrace_symbols directio fchmod fclose\
549         fcntl fdatasync fgetc fgets fopen fwrite getgid\
550         getrusage getuid hstrerror mprotect pstat_getdynamic\
551         pthread_self pthread_yield random sched_yield select setgid setuid\
552         sigaction snprintf stat sysconf vsnprintf yield)
553
554 AC_TIMERS
555
556 # Ftruncate.
557 # We've run into a problem with ftruncate on Alpha/Tru64, the issue is that
558 # after a truncate the last page of the file mmaps as all zeros.  So just don't
559 # use ftruncate.
560 case "$host_os" in
561 osf*)
562         AC_MSG_WARN(
563             [ftruncate ignored on $host_os-$host_vendor.]);;
564 *)
565         AC_CHECK_FUNCS(ftruncate);;
566 esac
567
568 # Pread/pwrite.
569 # HP-UX has pread/pwrite, but it doesn't work with largefile support.
570 # NCR's version of System V R 4.3 has pread/pwrite symbols, but no support.
571 case "$host_os-$host_vendor" in
572 hpux*|sysv4.3*-ncr)
573         AC_MSG_WARN(
574             [pread/pwrite interfaces ignored on $host_os-$host_vendor.]);;
575 *)
576         AC_CHECK_FUNCS(pread pwrite);;
577 esac
578
579 # Check for getaddrinfo; do the test explicitly instead of using AC_CHECK_FUNCS
580 # because <netdb.h> isn't a standard include file.
581 AC_CACHE_CHECK([for getaddrinfo], db_cv_getaddrinfo, [
582 AC_TRY_LINK([
583 #include <sys/types.h>
584 #include <netdb.h>], [
585         getaddrinfo(0, 0, 0, 0);
586 ], [db_cv_getaddrinfo=yes], [db_cv_getaddrinfo=no])])
587 if test "$db_cv_getaddrinfo" = "yes"; then
588         AC_DEFINE(HAVE_GETADDRINFO)
589         AH_TEMPLATE(HAVE_GETADDRINFO,
590             [Define to 1 if you have the `getaddrinfo' function.])
591 fi
592
593 # Check for the fcntl F_SETFD flag to deny child process access to file
594 # descriptors.
595 AC_CACHE_CHECK([for fcntl/F_SETFD], db_cv_fcntl_f_setfd, [
596 AC_TRY_LINK([
597 #include <sys/types.h>
598 #include <fcntl.h>], [
599         fcntl(1, F_SETFD, 1);
600 ], [db_cv_fcntl_f_setfd=yes], [db_cv_fcntl_f_setfd=no])])
601 if test "$db_cv_fcntl_f_setfd" = "yes"; then
602         AC_DEFINE(HAVE_FCNTL_F_SETFD)
603         AH_TEMPLATE(HAVE_FCNTL_F_SETFD,
604     [Define to 1 if fcntl/F_SETFD denies child access to file descriptors.])
605 fi
606
607 # A/UX has a broken getopt(3).
608 case "$host_os" in
609 aux*)   AC_LIBOBJ([getopt]);;
610 esac
611
612 # Linux has a broken O_DIRECT flag, but you can't detect it at configure time.
613 # Linux and SGI require buffer alignment we may not match, otherwise writes
614 # will fail.  Default to not using the O_DIRECT flag.
615 if test "$db_cv_o_direct" = "yes"; then
616         AC_CACHE_CHECK([for open/O_DIRECT], db_cv_open_o_direct, [
617         AC_TRY_LINK([
618         #include <sys/types.h>
619         #include <fcntl.h>], [
620                 open("a", O_RDONLY | O_DIRECT, 0);
621         ], [db_cv_open_o_direct=yes], [db_cv_open_o_direct=no])])
622         if test \
623             "$db_cv_o_direct" = "yes" -a "$db_cv_open_o_direct" = "yes"; then
624                 AC_DEFINE(HAVE_O_DIRECT)
625                 AH_TEMPLATE(HAVE_O_DIRECT,
626                     [Define to 1 if you have the O_DIRECT flag.])
627         fi
628 fi
629
630 # Check for largefile support.
631 AC_SYS_LARGEFILE
632
633 # Figure out how to create shared regions.
634 #
635 # First, we look for mmap.
636 #
637 # BSD/OS has mlock(2), but it doesn't work until the 4.1 release.
638 #
639 # Nextstep (version 3.3) apparently supports mmap(2) (the mmap symbol
640 # is defined in the C library) but does not support munmap(2).  Don't
641 # try to use mmap if we can't find munmap.
642 #
643 # Ultrix has mmap(2), but it doesn't work.
644 mmap_ok=no
645 case "$host_os" in
646 bsdi3*|bsdi4.0)
647         AC_MSG_WARN([mlock(2) interface ignored on $host_os-$host_vendor.])
648         mmap_ok=yes
649         AC_CHECK_FUNCS(mmap munmap, , mmap_ok=no);;
650 ultrix*)
651         AC_MSG_WARN([mmap(2) interface ignored on $host_os-$host_vendor.]);;
652 *)
653         mmap_ok=yes
654         AC_CHECK_FUNCS(mlock munlock)
655         AC_CHECK_FUNCS(mmap munmap, , mmap_ok=no);;
656 esac
657
658 # Second, we look for shmget.
659 #
660 # SunOS has the shmget(2) interfaces, but there appears to be a missing
661 # #include <debug/debug.h> file, so we ignore them.
662 shmget_ok=no
663 case "$host_os" in
664 sunos*)
665         AC_MSG_WARN([shmget(2) interface ignored on $host_os-$host_vendor.]);;
666 *)
667         shmget_ok=yes
668         AC_CHECK_FUNCS(shmget, , shmget_ok=no)
669
670         # Check for shmctl to lock down shared memory segments.
671         AC_CACHE_CHECK([for shmctl], db_cv_shmctl_shm_lock, [
672         AC_TRY_LINK([
673 #include <sys/types.h>
674 #include <sys/ipc.h>
675 #include <sys/shm.h>
676 #include <stdio.h>], [
677                 shmctl(0, SHM_LOCK, NULL);
678         ], [db_cv_shmctl_shm_lock=yes], [db_cv_shmctl_shm_lock=no])])
679         if test "$db_cv_shmctl_shm_lock" = "yes"; then
680                 AC_DEFINE(HAVE_SHMCTL_SHM_LOCK)
681                 AH_TEMPLATE(HAVE_SHMCTL_SHM_LOCK,
682             [Define to 1 if shmctl/SHM_LOCK locks down shared memory segments.])
683         fi;;
684 esac
685
686 # We require either mmap/munmap(2) or shmget(2).
687 if test "$mmap_ok" = "no" -a "$shmget_ok" = "no"; then
688         AC_MSG_WARN([Neither mmap/munmap(2) or shmget(2) library functions.])
689 fi
690
691 # Optional RPC client/server.
692 if test "$db_cv_rpc" = "yes"; then
693         AM_RPC_CONFIGURE
694 fi
695
696 # Optional Tcl support.
697 if test "$db_cv_tcl" = "yes"; then
698         AM_TCL_LOAD
699 fi
700
701 # Optional sequence code.
702 AM_SEQUENCE_CONFIGURE
703
704 # Optional DB 1.85 compatibility API.
705 if test "$db_cv_compat185" = "yes"; then
706         ADDITIONAL_INCS="db_185.h $ADDITIONAL_INCS"
707
708         ADDITIONAL_OBJS="db185${o} $ADDITIONAL_OBJS"
709 fi
710
711 # Optional utilities.
712 if test "$db_cv_dump185" = "yes"; then
713         ADDITIONAL_PROGS="db_dump185 $ADDITIONAL_PROGS"
714 fi
715
716 # You can disable pieces of functionality to save space.
717 #
718 # Btree is always configured: it is the standard method, and Hash off-page
719 # duplicates require it.
720 ADDITIONAL_OBJS="$ADDITIONAL_OBJS \$(BTREE_OBJS)"
721
722 # Compression can be disabled.
723 if test "$db_cv_build_compression" = "yes"; then
724         AC_DEFINE(HAVE_COMPRESSION)
725         AH_TEMPLATE(HAVE_COMPRESSION, [Define to 1 if building compression support.])
726 fi
727
728 # Partitioning can be disabled.
729 if test "$db_cv_build_partition" = "yes"; then
730         AC_DEFINE(HAVE_PARTITION)
731         AH_TEMPLATE(HAVE_PARTITION, [Define to 1 if building partitioned database support.])
732 fi
733
734 # Hash can be disabled.
735 if test "$db_cv_build_hash" = "yes"; then
736         AC_DEFINE(HAVE_HASH)
737         AH_TEMPLATE(HAVE_HASH, [Define to 1 if building Hash access method.])
738         ADDITIONAL_OBJS="$ADDITIONAL_OBJS \$(HASH_OBJS)"
739         if test "$db_cv_build_verify" = "yes"; then
740                 ADDITIONAL_OBJS="$ADDITIONAL_OBJS \$(HASH_VRFY_OBJS)"
741         fi
742 else
743         ADDITIONAL_OBJS="$ADDITIONAL_OBJS hash_stub${o}"
744 fi
745
746 # Queue can be disabled.
747 if test "$db_cv_build_queue" = "yes"; then
748         AC_DEFINE(HAVE_QUEUE)
749         AH_TEMPLATE(HAVE_QUEUE, [Define to 1 if building Queue access method.])
750         ADDITIONAL_OBJS="$ADDITIONAL_OBJS \$(QUEUE_OBJS)"
751         if test "$db_cv_build_verify" = "yes"; then
752                 ADDITIONAL_OBJS="$ADDITIONAL_OBJS \$(QUEUE_VRFY_OBJS)"
753         fi
754 else
755         ADDITIONAL_OBJS="$ADDITIONAL_OBJS qam_stub${o}"
756 fi
757
758 # Replication can be disabled.
759 if test "$db_cv_build_replication" = "yes"; then
760         AC_DEFINE(HAVE_REPLICATION)
761         AH_TEMPLATE(HAVE_REPLICATION,
762             [Define to 1 if building replication support.])
763         ADDITIONAL_OBJS="$ADDITIONAL_OBJS \$(REP_OBJS)"
764
765         # If we're building replication and detected POSIX threads, build the
766         # replication manager.
767         AH_TEMPLATE(HAVE_REPLICATION_THREADS,
768             [Define to 1 if building the Berkeley DB replication framework.])
769
770         if test "$ac_cv_header_pthread_h" = yes; then
771                 AC_DEFINE(HAVE_REPLICATION_THREADS)
772
773                 # Solaris requires the socket and nsl libraries to build the
774                 # replication manager.  Don't add nsl regardless of the OS,
775                 # it causes RPC to fail on AIX 4.3.3.
776                 case "$host_os" in
777                 solaris*)
778                         AC_HAVE_LIBRARY(nsl, LIBSO_LIBS="$LIBSO_LIBS -lnsl")
779                         AC_HAVE_LIBRARY(socket,
780                             LIBSO_LIBS="$LIBSO_LIBS -lsocket");;
781                 esac
782                 ADDITIONAL_OBJS="$ADDITIONAL_OBJS \$(REPMGR_OBJS)"
783         else
784                 ADDITIONAL_OBJS="$ADDITIONAL_OBJS repmgr_stub${o}"
785         fi
786 else
787         ADDITIONAL_OBJS="$ADDITIONAL_OBJS rep_stub${o} repmgr_stub${o}"
788 fi
789
790 # The statistics code can be disabled.
791 if test "$db_cv_build_statistics" = "yes"; then
792         AC_DEFINE(HAVE_STATISTICS)
793         AH_TEMPLATE(HAVE_STATISTICS,
794             [Define to 1 if building statistics support.])
795 fi
796
797 # The verification code can be disabled.
798 if test "$db_cv_build_verify" = "yes"; then
799         AC_DEFINE(HAVE_VERIFY)
800         AH_TEMPLATE(HAVE_VERIFY,
801             [Define to 1 if building access method verification support.])
802         ADDITIONAL_OBJS="$ADDITIONAL_OBJS \$(BTREE_VRFY_OBJS)"
803 else
804         ADDITIONAL_OBJS="$ADDITIONAL_OBJS db_vrfy_stub${o}"
805 fi
806
807 # The crypto code can be disabled.
808 if test -d "$srcdir/../crypto" -a "$db_cv_build_cryptography" = "yes"; then
809         AC_DEFINE(HAVE_CRYPTO)
810         AH_TEMPLATE(HAVE_CRYPTO,
811     [Define to 1 if Berkeley DB release includes strong cryptography.])
812
813         CRYPTO_OBJS="\$(CRYPTO_OBJS)"
814 else
815         CRYPTO_OBJS="crypto_stub${o}"
816 fi
817
818 # The mutex code can be disabled, and if there aren't any mutexes, then there's
819 # no reason to include the locking code.
820 if test "$db_cv_build_mutexsupport" = "yes"; then
821         ADDITIONAL_OBJS="$ADDITIONAL_OBJS \$(LOCK_OBJS) \$(MUTEX_OBJS)"
822 else
823         ADDITIONAL_OBJS="$ADDITIONAL_OBJS lock_stub${o} mut_stub${o}"
824 fi
825
826 # If DIAGNOSTIC is defined, include the log print routines in the library
827 # itself, various diagnostic modes use them.
828 if test "$db_cv_diagnostic" = "yes"; then
829         ADDITIONAL_OBJS="$ADDITIONAL_OBJS \$(PRINT_OBJS)"
830 fi
831
832 # If building for QNX, we need additional OS files.
833 if test "$qnx_build" = "yes"; then
834         ADDITIONAL_OBJS="$ADDITIONAL_OBJS os_qnx_fsync${o} os_qnx_open${o}"
835 fi
836
837 # We need to add the additional object files into the Makefile with the correct
838 # suffix.  We can't use $LTLIBOBJS itself, because that variable has $U encoded
839 # in it for automake, and that's not what we want.  See SR #7227 for additional
840 # information.
841 #
842 # XXX: I'm not sure this is correct.
843 REPLACEMENT_OBJS=`echo "$LIB@&t@OBJS" |
844                 sed "s,\.[[^.]]* ,$o ,g;s,\.[[^.]]*$,$o,"`
845
846 # This is necessary so that .o files in LIBOBJS are also built via
847 # the ANSI2KNR-filtering rules.
848 LIB@&t@OBJS=`echo "$LIB@&t@OBJS" |
849                 sed 's,\.[[^.]]* ,$U&,g;s,\.[[^.]]*$,$U&,'`
850 LTLIBOBJS=`echo "$LIB@&t@OBJS" |
851                 sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
852 AC_SUBST(LTLIBOBJS)
853
854 # Initial output file list.
855 CREATE_LIST="Makefile \
856     db_cxx.h:$srcdir/../dbinc/db_cxx.in \
857     db_int.h:$srcdir/../dbinc/db_int.in \
858     clib_port.h:$srcdir/../dist/clib_port.in \
859     include.tcl:$srcdir/../test/include.tcl"
860
861 # Create the db.h file from a source file, a list of global function
862 # prototypes, and, if configured for unique names, a list of #defines
863 # to do DB_VERSION_UNIQUE_NAME substitution.
864 if test "$db_cv_uniquename" = "yes"; then
865         CREATE_LIST="$CREATE_LIST \
866         db.h:$srcdir/../dbinc/db.in:$srcdir/../dbinc_auto/api_flags.in:$srcdir/../dbinc_auto/ext_def.in:$srcdir/../dbinc_auto/ext_prot.in"
867 else
868         CREATE_LIST="$CREATE_LIST \
869         db.h:$srcdir/../dbinc/db.in:$srcdir/../dbinc_auto/api_flags.in:$srcdir/../dbinc_auto/ext_prot.in"
870 fi
871
872 # If configured for unique names, create the db_int_uext.h file (which
873 # does the DB_VERSION_UNIQUE_NAME substitution), which is included by
874 # the db_int.h file.
875 if test "$db_cv_uniquename" = "yes"; then
876         CREATE_LIST="$CREATE_LIST \
877         db_int_def.h:$srcdir/../dbinc_auto/int_def.in"
878         db_int_def='#include "db_int_def.h"'
879 fi
880
881 # Create the db_185.h and db185_int.h files from source files, a list of
882 # global function prototypes, and, if configured for unique names, a list
883 # of #defines to do DB_VERSION_UNIQUE_NAME substitution.
884 if test "$db_cv_compat185" = "yes"; then
885         if test "$db_cv_uniquename" = "yes"; then
886                 CREATE_LIST="$CREATE_LIST \
887                 db_185.h:$srcdir/../dbinc/db_185.in:$srcdir/../dbinc_auto/ext_185_def.in:$srcdir/../dbinc_auto/ext_185_prot.in \
888                 db185_int.h:$srcdir/../db185/db185_int.in:$srcdir/../dbinc_auto/ext_185_def.in:$srcdir/../dbinc_auto/ext_185_prot.in"
889         else
890                 CREATE_LIST="$CREATE_LIST \
891                 db_185.h:$srcdir/../dbinc/db_185.in:$srcdir/../dbinc_auto/ext_185_prot.in \
892                 db185_int.h:$srcdir/../db185/db185_int.in:$srcdir/../dbinc_auto/ext_185_prot.in"
893         fi
894 fi
895
896 if test "$db_cv_stl" = "yes"; then
897         CREATE_LIST="$CREATE_LIST \
898         dbstl_common.h:$srcdir/../stl/dbstl_common.in"
899 fi
900
901 AC_CONFIG_FILES($CREATE_LIST)
902 AC_OUTPUT