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 # This configure.in file is easy to reuse on other projects. Just
73 # change the argument to AC_INIT(). And disable any features that
74 # you don't need (for example BLT) by erasing or commenting out
75 # the corresponding code.
77 AC_INIT(sqlcipher, m4_esyscmd([cat VERSION | tr -d '\n']))
79 dnl Make sure the local VERSION file matches this configure script
80 sqlite_version_sanity_check=`cat $srcdir/VERSION | tr -d '\n'`
81 if test "$PACKAGE_VERSION" != "$sqlite_version_sanity_check" ; then
82 AC_MSG_ERROR([configure script is out of date:
83 configure \$PACKAGE_VERSION = $PACKAGE_VERSION
84 top level VERSION file = $sqlite_version_sanity_check
85 please regen with autoconf])
96 # Enable large file support (if special flags are necessary)
101 # Check for needed/wanted data types
102 AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, intptr_t, uint8_t,
103 uint16_t, uint32_t, uint64_t, uintptr_t])
106 # Check for needed/wanted headers
107 AC_CHECK_HEADERS([sys/types.h stdlib.h stdint.h inttypes.h malloc.h])
110 # Figure out whether or not we have these functions
112 AC_CHECK_FUNCS([fdatasync gmtime_r isnan localtime_r localtime_s malloc_usable_size strchrnul usleep utime])
115 # By default, we use the amalgamation (this may be changed below...)
120 # See whether we can run specific tclsh versions known to work well;
121 # if not, then we fall back to plain tclsh.
122 # TODO: try other versions before falling back?
124 AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.6 tclsh8.5 tclsh], none)
125 if test "$TCLSH_CMD" = "none"; then
126 # If we can't find a local tclsh, then building the amalgamation will fail.
127 # We act as though --disable-amalgamation has been used.
128 echo "Warning: can't find tclsh - defaulting to non-amalgamation build."
134 AC_ARG_VAR([TCLLIBDIR], [Where to install tcl plugin])
135 if test "x${TCLLIBDIR+set}" != "xset" ; then
136 TCLLIBDIR='$(libdir)'
137 for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}` ; do
141 TCLLIBDIR="${TCLLIBDIR}/sqlite3"
145 # Set up an appropriate program prefix
147 if test "$program_prefix" = "NONE"; then
150 AC_SUBST(program_prefix)
152 VERSION=[`cat $srcdir/VERSION | sed 's/^\([0-9]*\.*[0-9]*\).*/\1/'`]
153 AC_MSG_NOTICE(Version set to $VERSION)
155 RELEASE=`cat $srcdir/VERSION`
156 AC_MSG_NOTICE(Release set to $RELEASE)
158 VERSION_NUMBER=[`cat $srcdir/VERSION \
159 | sed 's/[^0-9]/ /g' \
160 | awk '{printf "%d%03d%03d",$1,$2,$3}'`]
161 AC_MSG_NOTICE(Version number set to $VERSION_NUMBER)
162 AC_SUBST(VERSION_NUMBER)
165 # Locate a compiler for the build machine. This compiler should
166 # generate command-line programs that run on the build machine.
168 if test x"$cross_compiling" = xno; then
172 if test "${BUILD_CC+set}" != set; then
173 AC_CHECK_PROGS(BUILD_CC, gcc cc cl)
175 if test "${BUILD_CFLAGS+set}" != set; then
182 # Do we want to support multithreaded use of sqlite
184 AC_ARG_ENABLE(threadsafe,
185 AC_HELP_STRING([--disable-threadsafe],[Disable mutexing]),,enable_threadsafe=yes)
186 AC_MSG_CHECKING([whether to support threadsafe operation])
187 if test "$enable_threadsafe" = "no"; then
194 AC_SUBST(SQLITE_THREADSAFE)
196 if test "$SQLITE_THREADSAFE" = "1"; then
197 AC_SEARCH_LIBS(pthread_create, pthread)
201 # Which crypto library do we use
203 AC_ARG_WITH([crypto-lib],
204 AC_HELP_STRING([--with-crypto-lib],[Specify which crypto library to use]),
206 AC_MSG_CHECKING([for crypto library to use])
207 if test "$crypto_lib" = "none"; then
208 AC_MSG_RESULT([none])
210 if test "$crypto_lib" = "commoncrypto"; then
211 CFLAGS+=" -DSQLCIPHER_CRYPTO_CC"
212 BUILD_CFLAGS+=" -DSQLCIPHER_CRYPTO_CC"
213 AC_MSG_RESULT([commoncrypto])
215 if test "$crypto_lib" = "libtomcrypt"; then
216 CFLAGS+=" -DSQLCIPHER_CRYPTO_LIBTOMCRYPT"
217 BUILD_CFLAGS+=" -DSQLCIPHER_CRYPTO_LIBTOMCRYPT"
218 AC_MSG_RESULT([libtomcrypt])
219 AC_CHECK_LIB([tomcrypt], [register_cipher], ,
220 AC_MSG_ERROR([Library crypto not found. Install libtomcrypt!"]))
222 CFLAGS+=" -DSQLCIPHER_CRYPTO_OPENSSL"
223 BUILD_CFLAGS+=" -DSQLCIPHER_CRYPTO_OPENSSL"
224 AC_MSG_RESULT([openssl])
225 AC_CHECK_LIB([crypto], [HMAC_Init_ex], ,
226 AC_MSG_ERROR([Library crypto not found. Install openssl!"]))
232 # Do we want to allow a connection created in one thread to be used
233 # in another thread. This does not work on many Linux systems (ex: RedHat 9)
234 # due to bugs in the threading implementations. This is thus off by default.
236 AC_ARG_ENABLE(cross-thread-connections,
237 AC_HELP_STRING([--enable-cross-thread-connections],[Allow connection sharing across threads]),,enable_xthreadconnect=no)
238 AC_MSG_CHECKING([whether to allow connections to be shared across threads])
239 if test "$enable_xthreadconnect" = "no"; then
243 XTHREADCONNECT='-DSQLITE_ALLOW_XTHREAD_CONNECT=1'
246 AC_SUBST(XTHREADCONNECT)
249 # Do we want to support release
251 AC_ARG_ENABLE(releasemode,
252 AC_HELP_STRING([--enable-releasemode],[Support libtool link to release mode]),,enable_releasemode=no)
253 AC_MSG_CHECKING([whether to support shared library linked as release mode or not])
254 if test "$enable_releasemode" = "no"; then
258 ALLOWRELEASE="-release `cat $srcdir/VERSION`"
261 AC_SUBST(ALLOWRELEASE)
264 # Do we want temporary databases in memory
266 AC_ARG_ENABLE(tempstore,
267 AC_HELP_STRING([--enable-tempstore],[Use an in-ram database for temporary tables (never,no,yes,always)]),,enable_tempstore=no)
268 AC_MSG_CHECKING([whether to use an in-ram database for temporary tables])
269 case "$enable_tempstore" in
272 AC_MSG_RESULT([never])
284 AC_MSG_RESULT([always])
295 # Lots of things are different if we are compiling for Windows using
296 # the CYGWIN environment. So check for that special case and handle
297 # things accordingly.
299 AC_MSG_CHECKING([if executables have the .exe suffix])
300 if test "$config_BUILD_EXEEXT" = ".exe"; then
304 AC_MSG_RESULT(unknown)
306 if test "$CYGWIN" != "yes"; then
309 if test "$CYGWIN" = "yes"; then
314 if test x"$cross_compiling" = xno; then
315 TARGET_EXEEXT=$BUILD_EXEEXT
317 TARGET_EXEEXT=$config_TARGET_EXEEXT
319 if test "$TARGET_EXEEXT" = ".exe"; then
322 CFLAGS="$CFLAGS -DSQLITE_OS_WIN=1"
326 CFLAGS="$CFLAGS -DSQLITE_OS_UNIX=1"
329 AC_SUBST(BUILD_EXEEXT)
330 AC_SUBST(SQLITE_OS_UNIX)
331 AC_SUBST(SQLITE_OS_WIN)
332 AC_SUBST(TARGET_EXEEXT)
335 # Figure out all the parameters needed to compile against Tcl.
337 # This code is derived from the SC_PATH_TCLCONFIG and SC_LOAD_TCLCONFIG
338 # macros in the in the tcl.m4 file of the standard TCL distribution.
339 # Those macros could not be used directly since we have to make some
340 # minor changes to accomodate systems that do not have TCL installed.
342 AC_ARG_ENABLE(tcl, AC_HELP_STRING([--disable-tcl],[do not build TCL extension]),
343 [use_tcl=$enableval],[use_tcl=yes])
344 if test "${use_tcl}" = "yes" ; then
345 AC_ARG_WITH(tcl, AC_HELP_STRING([--with-tcl=DIR],[directory containing tcl configuration (tclConfig.sh)]), with_tclconfig=${withval})
346 AC_MSG_CHECKING([for Tcl configuration])
347 AC_CACHE_VAL(ac_cv_c_tclconfig,[
348 # First check to see if --with-tcl was specified.
349 if test x"${with_tclconfig}" != x ; then
350 if test -f "${with_tclconfig}/tclConfig.sh" ; then
351 ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
353 AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
357 # Start autosearch by asking tclsh
358 if test x"${ac_cv_c_tclconfig}" = x ; then
359 if test x"$cross_compiling" = xno; then
360 for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}`
362 if test -f "$i/tclConfig.sh" ; then
363 ac_cv_c_tclconfig="$i"
370 # then check for a private Tcl installation
371 if test x"${ac_cv_c_tclconfig}" = x ; then
374 `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
375 `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
376 `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
378 `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
379 `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
380 `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
382 `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
383 `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
384 `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null`
386 if test -f "$i/unix/tclConfig.sh" ; then
387 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
393 # check in a few common install locations
394 if test x"${ac_cv_c_tclconfig}" = x ; then
396 `ls -d ${libdir} 2>/dev/null` \
397 `ls -d /usr/local/lib 2>/dev/null` \
398 `ls -d /usr/contrib/lib 2>/dev/null` \
399 `ls -d /usr/lib 2>/dev/null`
401 if test -f "$i/tclConfig.sh" ; then
402 ac_cv_c_tclconfig=`(cd $i; pwd)`
408 # check in a few other private locations
409 if test x"${ac_cv_c_tclconfig}" = x ; then
412 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
413 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
414 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null`
416 if test -f "$i/unix/tclConfig.sh" ; then
417 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
424 if test x"${ac_cv_c_tclconfig}" = x ; then
426 AC_MSG_WARN(Can't find Tcl configuration definitions)
427 AC_MSG_WARN(*** Without Tcl the regression tests cannot be executed ***)
428 AC_MSG_WARN(*** Consider using --with-tcl=... to define location of Tcl ***)
430 TCL_BIN_DIR=${ac_cv_c_tclconfig}
431 AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
433 AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
434 if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
435 AC_MSG_RESULT([loading])
436 . $TCL_BIN_DIR/tclConfig.sh
438 AC_MSG_RESULT([file not found])
442 # If the TCL_BIN_DIR is the build directory (not the install directory),
443 # then set the common variable name to the value of the build variables.
444 # For example, the variable TCL_LIB_SPEC will be set to the value
445 # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
446 # instead of TCL_BUILD_LIB_SPEC since it will work with both an
447 # installed and uninstalled version of Tcl.
450 if test -f $TCL_BIN_DIR/Makefile ; then
451 TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
452 TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
453 TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
457 # eval is required to do the TCL_DBGX substitution
460 eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
461 eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
462 eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
464 eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
465 eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
466 eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
468 AC_SUBST(TCL_VERSION)
469 AC_SUBST(TCL_BIN_DIR)
470 AC_SUBST(TCL_SRC_DIR)
471 AC_SUBST(TCL_INCLUDE_SPEC)
473 AC_SUBST(TCL_LIB_FILE)
474 AC_SUBST(TCL_LIB_FLAG)
475 AC_SUBST(TCL_LIB_SPEC)
477 AC_SUBST(TCL_STUB_LIB_FILE)
478 AC_SUBST(TCL_STUB_LIB_FLAG)
479 AC_SUBST(TCL_STUB_LIB_SPEC)
482 if test "${use_tcl}" = "no" ; then
490 # Figure out what C libraries are required to compile programs
491 # that use "readline()" library.
493 TARGET_READLINE_LIBS=""
494 TARGET_READLINE_INC=""
495 TARGET_HAVE_READLINE=0
496 AC_ARG_ENABLE([readline],
497 [AC_HELP_STRING([--disable-readline],[disable readline support [default=detect]])],
498 [with_readline=$enableval],
499 [with_readline=auto])
501 if test x"$with_readline" != xno; then
504 AC_ARG_WITH([readline-lib],
505 [AC_HELP_STRING([--with-readline-lib],[specify readline library])],
506 [with_readline_lib=$withval],
507 [with_readline_lib="auto"])
508 if test "x$with_readline_lib" = xauto; then
511 AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap], [term_LIBS="$LIBS"], [term_LIBS=""])
512 AC_CHECK_LIB([readline], [readline], [TARGET_READLINE_LIBS="-lreadline"], [found="no"])
513 TARGET_READLINE_LIBS="$TARGET_READLINE_LIBS $term_LIBS"
516 TARGET_READLINE_LIBS="$with_readline_lib"
519 AC_ARG_WITH([readline-inc],
520 [AC_HELP_STRING([--with-readline-inc],[specify readline include paths])],
521 [with_readline_inc=$withval],
522 [with_readline_inc="auto"])
523 if test "x$with_readline_inc" = xauto; then
524 AC_CHECK_HEADER(readline.h, [found="yes"], [
526 if test "$cross_compiling" != yes; then
527 for dir in /usr /usr/local /usr/local/readline /usr/contrib /mingw; do
528 for subdir in include include/readline; do
529 AC_CHECK_FILE($dir/$subdir/readline.h, found=yes)
530 if test "$found" = "yes"; then
531 TARGET_READLINE_INC="-I$dir/$subdir"
535 test "$found" = "yes" && break
540 TARGET_READLINE_INC="$with_readline_inc"
543 if test x"$found" = xno; then
544 TARGET_READLINE_LIBS=""
545 TARGET_READLINE_INC=""
546 TARGET_HAVE_READLINE=0
548 TARGET_HAVE_READLINE=1
552 AC_SUBST(TARGET_READLINE_LIBS)
553 AC_SUBST(TARGET_READLINE_INC)
554 AC_SUBST(TARGET_HAVE_READLINE)
557 # Figure out what C libraries are required to compile programs
558 # that use "fdatasync()" function.
560 AC_SEARCH_LIBS(fdatasync, [rt])
563 # check for debug enabled
564 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain]),
565 [use_debug=$enableval],[use_debug=no])
566 if test "${use_debug}" = "yes" ; then
567 TARGET_DEBUG="-DSQLITE_DEBUG=1"
569 TARGET_DEBUG="-DNDEBUG"
571 AC_SUBST(TARGET_DEBUG)
574 # See whether we should use the amalgamation to build
575 AC_ARG_ENABLE(amalgamation, AC_HELP_STRING([--disable-amalgamation],
576 [Disable the amalgamation and instead build all files separately]),
577 [use_amalgamation=$enableval],[use_amalgamation=yes])
578 if test "${use_amalgamation}" != "yes" ; then
581 AC_SUBST(USE_AMALGAMATION)
584 # See whether we should allow loadable extensions
585 AC_ARG_ENABLE(load-extension, AC_HELP_STRING([--disable-load-extension],
586 [Disable loading of external extensions]),
587 [use_loadextension=$enableval],[use_loadextension=yes])
588 if test "${use_loadextension}" = "yes" ; then
590 AC_SEARCH_LIBS(dlopen, dl)
592 OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1"
596 # attempt to duplicate any OMITS and ENABLES into the $(OPT_FEATURE_FLAGS) parameter
597 for option in $CFLAGS $CPPFLAGS
600 -DSQLITE_OMIT*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
601 -DSQLITE_ENABLE*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
604 AC_SUBST(OPT_FEATURE_FLAGS)
607 # attempt to remove any OMITS and ENABLES from the $(CFLAGS) parameter
609 for option in $CFLAGS
614 *) ac_temp_CFLAGS="$ac_temp_CFLAGS $option";;
617 CFLAGS=$ac_temp_CFLAGS
620 # attempt to remove any OMITS and ENABLES from the $(CPPFLAGS) parameter
622 for option in $CPPFLAGS
627 *) ac_temp_CPPFLAGS="$ac_temp_CPPFLAGS $option";;
630 CPPFLAGS=$ac_temp_CPPFLAGS
633 # attempt to remove any OMITS and ENABLES from the $(BUILD_CFLAGS) parameter
634 ac_temp_BUILD_CFLAGS=""
635 for option in $BUILD_CFLAGS
640 *) ac_temp_BUILD_CFLAGS="$ac_temp_BUILD_CFLAGS $option";;
643 BUILD_CFLAGS=$ac_temp_BUILD_CFLAGS
647 # See whether we should use GCOV
648 AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov],
649 [Enable coverage testing using gcov]),
650 [use_gcov=$enableval],[use_gcov=no])
651 if test "${use_gcov}" = "yes" ; then
660 # Output the config header
661 AC_CONFIG_HEADERS(config.h)
664 # Generate the output files.
666 AC_SUBST(BUILD_CFLAGS)