2 # The build process allows for using a cross-compiler. But the default
3 # action is to target the same platform that we are running on. The
4 # configure script needs to discover the following properties of the
5 # build and target systems:
9 # The is the name of the directory that contains the
10 # "configure" shell script. All source files are
11 # located relative to this directory.
15 # The name of the directory where executables should be
16 # written by the "install" target of the makefile.
20 # Add this prefix to the names of all executables that run
21 # on the target machine. Default: ""
25 # True if shared libraries should be generated.
29 # The name of a command that is used to convert C
30 # source files into executables that run on the build
35 # Switches that the build compiler needs in order to construct
36 # command-line programs.
40 # Libraries that the build compiler needs in order to construct
41 # command-line programs.
45 # The filename extension for executables on the build
46 # platform. "" for Unix and ".exe" for Windows.
50 # Lots of values are read in from the tclConfig.sh script,
51 # if that script is available. This values are used for
52 # constructing and installing the TCL extension.
54 # TARGET_READLINE_LIBS
56 # This is the library directives passed to the target linker
57 # that cause the executable to link against the readline library.
58 # This might be a switch like "-lreadline" or pathnames of library
59 # file like "../../src/libreadline.a".
63 # This variables define the directory that contain header
64 # files for the readline library. If the compiler is able
65 # to find <readline.h> on its own, then this can be blank.
69 # The filename extension for executables on the
70 # target platform. "" for Unix and ".exe" for windows.
72 # The generated configure script will make an attempt to guess
73 # at all of the above parameters. You can override any of
74 # the guesses by setting the environment variable named
75 # "config_AAAA" where "AAAA" is the name of the parameter
76 # described above. (Exception: srcdir cannot be set this way.)
77 # If you have a file that sets one or more of these environment
78 # variables, you can invoke configure as follows:
80 # configure --with-hints=FILE
82 # where FILE is the name of the file that sets the environment
83 # variables. FILE should be an absolute pathname.
85 # This configure.in file is easy to reuse on other projects. Just
86 # change the argument to AC_INIT(). And disable any features that
87 # you don't need (for example BLT) by erasing or commenting out
88 # the corresponding code.
90 AC_INIT(sqlite, m4_esyscmd([cat VERSION | tr -d '\n']))
92 dnl Make sure the local VERSION file matches this configure script
93 sqlite_version_sanity_check=`cat $srcdir/VERSION | tr -d '\n'`
94 if test "$PACKAGE_VERSION" != "$sqlite_version_sanity_check" ; then
95 AC_MSG_ERROR([configure script is out of date:
96 configure \$PACKAGE_VERSION = $PACKAGE_VERSION
97 top level VERSION file = $sqlite_version_sanity_check
98 please regen with autoconf])
101 dnl Put the RCS revision string after AC_INIT so that it will also
102 dnl show in in configure.
103 # The following RCS revision string applies to configure.in
114 # Enable large file support (if special flags are necessary)
119 # Check for needed/wanted data types
120 AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, intptr_t, uint8_t,
121 uint16_t, uint32_t, uint64_t, uintptr_t])
124 # Check for needed/wanted headers
125 AC_CHECK_HEADERS([sys/types.h stdlib.h stdint.h inttypes.h malloc.h])
128 # Figure out whether or not we have these functions
130 AC_CHECK_FUNCS([usleep fdatasync localtime_r gmtime_r localtime_s utime malloc_usable_size])
133 # By default, we use the amalgamation (this may be changed below...)
138 # See whether we can run specific tclsh versions known to work well;
139 # if not, then we fall back to plain tclsh.
140 # TODO: try other versions before falling back?
142 AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.5 tclsh], none)
143 if test "$TCLSH_CMD" = "none"; then
144 # If we can't find a local tclsh, then building the amalgamation will fail.
145 # We act as though --disable-amalgamation has been used.
146 echo "Warning: can't find tclsh - defaulting to non-amalgamation build."
152 AC_ARG_VAR([TCLLIBDIR], [Where to install tcl plugin])
153 if test "x${TCLLIBDIR+set}" != "xset" ; then
154 TCLLIBDIR='$(libdir)'
155 for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}` ; do
159 TCLLIBDIR="${TCLLIBDIR}/sqlite3"
164 # Set up an appropriate program prefix
166 if test "$program_prefix" = "NONE"; then
169 AC_SUBST(program_prefix)
171 VERSION=[`cat $srcdir/VERSION | sed 's/^\([0-9]*\.*[0-9]*\).*/\1/'`]
172 AC_MSG_NOTICE(Version set to $VERSION)
174 RELEASE=`cat $srcdir/VERSION`
175 AC_MSG_NOTICE(Release set to $RELEASE)
177 VERSION_NUMBER=[`cat $srcdir/VERSION \
178 | sed 's/[^0-9]/ /g' \
179 | awk '{printf "%d%03d%03d",$1,$2,$3}'`]
180 AC_MSG_NOTICE(Version number set to $VERSION_NUMBER)
181 AC_SUBST(VERSION_NUMBER)
184 # Check to see if the --with-hints=FILE option is used. If there is none,
185 # then check for a files named "$host.hints" and ../$hosts.hints where
186 # $host is the hostname of the build system. If still no hints are
187 # found, try looking in $system.hints and ../$system.hints where
188 # $system is the result of uname -s.
191 AC_HELP_STRING([--with-hints=FILE],[Read configuration options from FILE]),
193 if test "$hints" = ""; then
194 host=`hostname | sed 's/\..*//'`
195 if test -r $host.hints; then
198 if test -r ../$host.hints; then
203 if test "$hints" = ""; then
205 if test -r $sys.hints; then
208 if test -r ../$sys.hints; then
213 if test "$hints" != ""; then
214 AC_MSG_RESULT(reading hints from $hints)
219 # Locate a compiler for the build machine. This compiler should
220 # generate command-line programs that run on the build machine.
222 if test x"$cross_compiling" = xno; then
226 if test "${BUILD_CC+set}" != set; then
227 AC_CHECK_PROGS(BUILD_CC, gcc cc cl)
229 if test "${BUILD_CFLAGS+set}" != set; then
236 # Do we want to support multithreaded use of sqlite
238 AC_ARG_ENABLE(threadsafe,
239 AC_HELP_STRING([--enable-threadsafe],[Support threadsafe operation]),,enable_threadsafe=yes)
240 AC_MSG_CHECKING([whether to support threadsafe operation])
241 if test "$enable_threadsafe" = "no"; then
248 AC_SUBST(SQLITE_THREADSAFE)
250 if test "$SQLITE_THREADSAFE" = "1"; then
251 AC_SEARCH_LIBS(pthread_create, pthread)
255 # Do we want to allow a connection created in one thread to be used
256 # in another thread. This does not work on many Linux systems (ex: RedHat 9)
257 # due to bugs in the threading implementations. This is thus off by default.
259 AC_ARG_ENABLE(cross-thread-connections,
260 AC_HELP_STRING([--enable-cross-thread-connections],[Allow connection sharing across threads]),,enable_xthreadconnect=no)
261 AC_MSG_CHECKING([whether to allow connections to be shared across threads])
262 if test "$enable_xthreadconnect" = "no"; then
266 XTHREADCONNECT='-DSQLITE_ALLOW_XTHREAD_CONNECT=1'
269 AC_SUBST(XTHREADCONNECT)
272 # Do we want to support release
274 AC_ARG_ENABLE(releasemode,
275 AC_HELP_STRING([--enable-releasemode],[Support libtool link to release mode]),,enable_releasemode=no)
276 AC_MSG_CHECKING([whether to support shared library linked as release mode or not])
277 if test "$enable_releasemode" = "no"; then
281 ALLOWRELEASE="-release `cat $srcdir/VERSION`"
284 AC_SUBST(ALLOWRELEASE)
287 # Do we want temporary databases in memory
289 AC_ARG_ENABLE(tempstore,
290 AC_HELP_STRING([--enable-tempstore],[Use an in-ram database for temporary tables (never,no,yes,always)]),,enable_tempstore=no)
291 AC_MSG_CHECKING([whether to use an in-ram database for temporary tables])
292 case "$enable_tempstore" in
295 AC_MSG_RESULT([never])
307 AC_MSG_RESULT([always])
318 # Lots of things are different if we are compiling for Windows using
319 # the CYGWIN environment. So check for that special case and handle
320 # things accordingly.
322 AC_MSG_CHECKING([if executables have the .exe suffix])
323 if test "$config_BUILD_EXEEXT" = ".exe"; then
327 AC_MSG_RESULT(unknown)
329 if test "$CYGWIN" != "yes"; then
332 if test "$CYGWIN" = "yes"; then
337 if test x"$cross_compiling" = xno; then
338 TARGET_EXEEXT=$BUILD_EXEEXT
340 TARGET_EXEEXT=$config_TARGET_EXEEXT
342 if test "$TARGET_EXEEXT" = ".exe"; then
343 if test $OS2_SHELL ; then
347 CFLAGS="$CFLAGS -DSQLITE_OS_OS2=1"
352 CFLAGS="$CFLAGS -DSQLITE_OS_WIN=1"
358 CFLAGS="$CFLAGS -DSQLITE_OS_UNIX=1"
361 AC_SUBST(BUILD_EXEEXT)
362 AC_SUBST(SQLITE_OS_UNIX)
363 AC_SUBST(SQLITE_OS_WIN)
364 AC_SUBST(SQLITE_OS_OS2)
365 AC_SUBST(TARGET_EXEEXT)
368 # Figure out all the parameters needed to compile against Tcl.
370 # This code is derived from the SC_PATH_TCLCONFIG and SC_LOAD_TCLCONFIG
371 # macros in the in the tcl.m4 file of the standard TCL distribution.
372 # Those macros could not be used directly since we have to make some
373 # minor changes to accomodate systems that do not have TCL installed.
375 AC_ARG_ENABLE(tcl, AC_HELP_STRING([--disable-tcl],[do not build TCL extension]),
376 [use_tcl=$enableval],[use_tcl=yes])
377 if test "${use_tcl}" = "yes" ; then
378 AC_ARG_WITH(tcl, AC_HELP_STRING([--with-tcl=DIR],[directory containing tcl configuration (tclConfig.sh)]), with_tclconfig=${withval})
379 AC_MSG_CHECKING([for Tcl configuration])
380 AC_CACHE_VAL(ac_cv_c_tclconfig,[
381 # First check to see if --with-tcl was specified.
382 if test x"${with_tclconfig}" != x ; then
383 if test -f "${with_tclconfig}/tclConfig.sh" ; then
384 ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
386 AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
390 # Start autosearch by asking tclsh
391 if test x"${ac_cv_c_tclconfig}" = x ; then
392 if test x"$cross_compiling" = xno; then
393 for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}`
395 if test -f "$i/tclConfig.sh" ; then
396 ac_cv_c_tclconfig="$i"
403 # then check for a private Tcl installation
404 if test x"${ac_cv_c_tclconfig}" = x ; then
407 `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
408 `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
409 `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
411 `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
412 `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
413 `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
415 `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
416 `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
417 `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null`
419 if test -f "$i/unix/tclConfig.sh" ; then
420 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
426 # check in a few common install locations
427 if test x"${ac_cv_c_tclconfig}" = x ; then
429 `ls -d ${libdir} 2>/dev/null` \
430 `ls -d /usr/local/lib 2>/dev/null` \
431 `ls -d /usr/contrib/lib 2>/dev/null` \
432 `ls -d /usr/lib 2>/dev/null`
434 if test -f "$i/tclConfig.sh" ; then
435 ac_cv_c_tclconfig=`(cd $i; pwd)`
441 # check in a few other private locations
442 if test x"${ac_cv_c_tclconfig}" = x ; then
445 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
446 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
447 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null`
449 if test -f "$i/unix/tclConfig.sh" ; then
450 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
457 if test x"${ac_cv_c_tclconfig}" = x ; then
459 AC_MSG_WARN(Can't find Tcl configuration definitions)
460 AC_MSG_WARN(*** Without Tcl the regression tests cannot be executed ***)
461 AC_MSG_WARN(*** Consider using --with-tcl=... to define location of Tcl ***)
463 TCL_BIN_DIR=${ac_cv_c_tclconfig}
464 AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
466 AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
467 if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
468 AC_MSG_RESULT([loading])
469 . $TCL_BIN_DIR/tclConfig.sh
471 AC_MSG_RESULT([file not found])
475 # If the TCL_BIN_DIR is the build directory (not the install directory),
476 # then set the common variable name to the value of the build variables.
477 # For example, the variable TCL_LIB_SPEC will be set to the value
478 # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
479 # instead of TCL_BUILD_LIB_SPEC since it will work with both an
480 # installed and uninstalled version of Tcl.
483 if test -f $TCL_BIN_DIR/Makefile ; then
484 TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
485 TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
486 TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
490 # eval is required to do the TCL_DBGX substitution
493 eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
494 eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
495 eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
497 eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
498 eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
499 eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
501 AC_SUBST(TCL_VERSION)
502 AC_SUBST(TCL_BIN_DIR)
503 AC_SUBST(TCL_SRC_DIR)
504 AC_SUBST(TCL_INCLUDE_SPEC)
506 AC_SUBST(TCL_LIB_FILE)
507 AC_SUBST(TCL_LIB_FLAG)
508 AC_SUBST(TCL_LIB_SPEC)
510 AC_SUBST(TCL_STUB_LIB_FILE)
511 AC_SUBST(TCL_STUB_LIB_FLAG)
512 AC_SUBST(TCL_STUB_LIB_SPEC)
515 if test "${use_tcl}" = "no" ; then
523 # Figure out what C libraries are required to compile programs
524 # that use "readline()" library.
526 TARGET_READLINE_LIBS=""
527 TARGET_READLINE_INC=""
528 TARGET_HAVE_READLINE=0
529 AC_ARG_ENABLE([readline],
530 [AC_HELP_STRING([--disable-readline],[disable readline support [default=detect]])],
531 [with_readline=$enableval],
532 [with_readline=auto])
534 if test x"$with_readline" != xno; then
537 AC_ARG_WITH([readline-lib],
538 [AC_HELP_STRING([--with-readline-lib],[specify readline library])],
539 [with_readline_lib=$withval],
540 [with_readline_lib="auto"])
541 if test "x$with_readline_lib" = xauto; then
544 AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap], [term_LIBS="$LIBS"], [term_LIBS=""])
545 AC_CHECK_LIB([readline], [readline], [TARGET_READLINE_LIBS="-lreadline"], [found="no"])
546 TARGET_READLINE_LIBS="$TARGET_READLINE_LIBS $term_LIBS"
549 TARGET_READLINE_LIBS="$with_readline_lib"
552 AC_ARG_WITH([readline-inc],
553 [AC_HELP_STRING([--with-readline-inc],[specify readline include paths])],
554 [with_readline_inc=$withval],
555 [with_readline_inc="auto"])
556 if test "x$with_readline_inc" = xauto; then
557 AC_CHECK_HEADER(readline.h, [found="yes"], [
559 if test "$cross_compiling" != yes; then
560 for dir in /usr /usr/local /usr/local/readline /usr/contrib /mingw; do
561 for subdir in include include/readline; do
562 AC_CHECK_FILE($dir/$subdir/readline.h, found=yes)
563 if test "$found" = "yes"; then
564 TARGET_READLINE_INC="-I$dir/$subdir"
568 test "$found" = "yes" && break
573 TARGET_READLINE_INC="$with_readline_inc"
576 if test x"$found" = xno; then
577 TARGET_READLINE_LIBS=""
578 TARGET_READLINE_INC=""
579 TARGET_HAVE_READLINE=0
581 TARGET_HAVE_READLINE=1
585 AC_SUBST(TARGET_READLINE_LIBS)
586 AC_SUBST(TARGET_READLINE_INC)
587 AC_SUBST(TARGET_HAVE_READLINE)
590 # Figure out what C libraries are required to compile programs
591 # that use "fdatasync()" function.
593 AC_SEARCH_LIBS(fdatasync, [rt])
596 # check for debug enabled
597 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain]),
598 [use_debug=$enableval],[use_debug=no])
599 if test "${use_debug}" = "yes" ; then
600 TARGET_DEBUG="-DSQLITE_DEBUG=1"
602 TARGET_DEBUG="-DNDEBUG"
604 AC_SUBST(TARGET_DEBUG)
607 # See whether we should use the amalgamation to build
608 AC_ARG_ENABLE(amalgamation, AC_HELP_STRING([--disable-amalgamation],
609 [Disable the amalgamation and instead build all files separately]),
610 [use_amalgamation=$enableval],[use_amalgamation=yes])
611 if test "${use_amalgamation}" != "yes" ; then
614 AC_SUBST(USE_AMALGAMATION)
617 # See whether we should allow loadable extensions
618 AC_ARG_ENABLE(load-extension, AC_HELP_STRING([--enable-load-extension],
619 [Enable loading of external extensions]),
620 [use_loadextension=$enableval],[use_loadextension=no])
621 if test "${use_loadextension}" = "yes" ; then
623 AC_SEARCH_LIBS(dlopen, dl)
625 OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1"
629 # attempt to duplicate any OMITS and ENABLES into the $(OPT_FEATURE_FLAGS) parameter
630 for option in $CFLAGS $CPPFLAGS
633 -DSQLITE_OMIT*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
634 -DSQLITE_ENABLE*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
637 AC_SUBST(OPT_FEATURE_FLAGS)
640 # attempt to remove any OMITS and ENABLES from the $(CFLAGS) parameter
642 for option in $CFLAGS
647 *) ac_temp_CFLAGS="$ac_temp_CFLAGS $option";;
650 CFLAGS=$ac_temp_CFLAGS
653 # attempt to remove any OMITS and ENABLES from the $(CPPFLAGS) parameter
655 for option in $CPPFLAGS
660 *) ac_temp_CPPFLAGS="$ac_temp_CPPFLAGS $option";;
663 CPPFLAGS=$ac_temp_CPPFLAGS
666 # attempt to remove any OMITS and ENABLES from the $(BUILD_CFLAGS) parameter
667 ac_temp_BUILD_CFLAGS=""
668 for option in $BUILD_CFLAGS
673 *) ac_temp_BUILD_CFLAGS="$ac_temp_BUILD_CFLAGS $option";;
676 BUILD_CFLAGS=$ac_temp_BUILD_CFLAGS
680 # See whether we should use GCOV
681 AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov],
682 [Enable coverage testing using gcov]),
683 [use_gcov=$enableval],[use_gcov=no])
684 if test "${use_gcov}" = "yes" ; then
693 # Output the config header
694 AC_CONFIG_HEADERS(config.h)
697 # Generate the output files.
699 AC_SUBST(BUILD_CFLAGS)