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