Merge sqlite-release(3.20.1) into prerelease-integration
[sqlcipher.git] / configure.ac
blob3d37d9a33f9efe88fc577bee3f66ef15cc468730
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:
7 #    srcdir
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.
13 #    bindir
15 #        The name of the directory where executables should be
16 #        written by the "install" target of the makefile.
18 #    program_prefix
20 #        Add this prefix to the names of all executables that run
21 #        on the target machine.  Default: ""
23 #    ENABLE_SHARED
25 #        True if shared libraries should be generated.
27 #    BUILD_CC
29 #        The name of a command that is used to convert C
30 #        source files into executables that run on the build
31 #        platform.
33 #    BUILD_CFLAGS
35 #        Switches that the build compiler needs in order to construct
36 #        command-line programs.
38 #    BUILD_LIBS
40 #        Libraries that the build compiler needs in order to construct
41 #        command-line programs.
43 #    BUILD_EXEEXT
45 #        The filename extension for executables on the build
46 #        platform.  "" for Unix and ".exe" for Windows.
48 #    TCL_*
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".
61 #    TARGET_READLINE_INC
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.
67 #    TARGET_EXEEXT
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])
88 #########
89 # Programs needed
91 AC_PROG_LIBTOOL
92 AC_PROG_INSTALL
94 #########
95 # Enable large file support (if special flags are necessary)
97 AC_SYS_LARGEFILE
99 #########
100 # Check for needed/wanted data types
101 AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, intptr_t, uint8_t,
102                 uint16_t, uint32_t, uint64_t, uintptr_t])
104 #########
105 # Check for needed/wanted headers
106 AC_CHECK_HEADERS([sys/types.h stdlib.h stdint.h inttypes.h malloc.h])
108 #########
109 # Figure out whether or not we have these functions
111 AC_CHECK_FUNCS([fdatasync gmtime_r isnan localtime_r localtime_s malloc_usable_size strchrnul usleep utime pread pread64 pwrite pwrite64])
113 #########
114 # By default, we use the amalgamation (this may be changed below...)
116 USE_AMALGAMATION=1
118 #########
119 # See whether we can run specific tclsh versions known to work well;
120 # if not, then we fall back to plain tclsh.
121 # TODO: try other versions before falling back?
123 AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.6 tclsh8.5 tclsh], none)
124 if test "$TCLSH_CMD" = "none"; then
125   # If we can't find a local tclsh, then building the amalgamation will fail.
126   # We act as though --disable-amalgamation has been used.
127   echo "Warning: can't find tclsh - defaulting to non-amalgamation build."
128   USE_AMALGAMATION=0
129   TCLSH_CMD="tclsh"
131 AC_SUBST(TCLSH_CMD)
133 AC_ARG_VAR([TCLLIBDIR], [Where to install tcl plugin])
134 if test "x${TCLLIBDIR+set}" != "xset" ; then
135   TCLLIBDIR='$(libdir)'
136   for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}` ; do
137     TCLLIBDIR=$i
138     break
139   done
140   TCLLIBDIR="${TCLLIBDIR}/sqlite3"
143 #########
144 # Set up an appropriate program prefix
146 if test "$program_prefix" = "NONE"; then
147   program_prefix=""
149 AC_SUBST(program_prefix)
151 VERSION=[`cat $srcdir/VERSION | sed 's/^\([0-9]*\.*[0-9]*\).*/\1/'`]
152 AC_MSG_NOTICE(Version set to $VERSION)
153 AC_SUBST(VERSION)
154 RELEASE=`cat $srcdir/VERSION`
155 AC_MSG_NOTICE(Release set to $RELEASE)
156 AC_SUBST(RELEASE)
157 VERSION_NUMBER=[`cat $srcdir/VERSION \
158                            | sed 's/[^0-9]/ /g' \
159                 | awk '{printf "%d%03d%03d",$1,$2,$3}'`]
160 AC_MSG_NOTICE(Version number set to $VERSION_NUMBER)
161 AC_SUBST(VERSION_NUMBER)
163 #########
164 # Locate a compiler for the build machine.  This compiler should
165 # generate command-line programs that run on the build machine.
167 if test x"$cross_compiling" = xno; then
168         BUILD_CC=$CC
169         BUILD_CFLAGS=$CFLAGS
170 else
171         if test "${BUILD_CC+set}" != set; then
172                 AC_CHECK_PROGS(BUILD_CC, gcc cc cl)
173         fi
174         if test "${BUILD_CFLAGS+set}" != set; then
175                 BUILD_CFLAGS="-g"
176         fi
178 AC_SUBST(BUILD_CC)
180 ##########
181 # Do we want to support multithreaded use of sqlite
183 AC_ARG_ENABLE(threadsafe, 
184 AC_HELP_STRING([--disable-threadsafe],[Disable mutexing]),,enable_threadsafe=yes)
185 AC_MSG_CHECKING([whether to support threadsafe operation])
186 if test "$enable_threadsafe" = "no"; then
187   SQLITE_THREADSAFE=0
188   AC_MSG_RESULT([no])
189 else
190   SQLITE_THREADSAFE=1
191   AC_MSG_RESULT([yes])
193 AC_SUBST(SQLITE_THREADSAFE)
195 if test "$SQLITE_THREADSAFE" = "1"; then
196   AC_SEARCH_LIBS(pthread_create, pthread)
197   AC_SEARCH_LIBS(pthread_mutexattr_init, pthread)
200 ##########
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]),
205 crypto_lib=$withval)
206 AC_MSG_CHECKING([for crypto library to use])
207 if test "$crypto_lib" = "none"; then
208   AC_MSG_RESULT([none])
209 else
210   if test "$crypto_lib" = "commoncrypto"; then
211     CFLAGS+=" -DSQLCIPHER_CRYPTO_CC"
212     BUILD_CFLAGS+=" -DSQLCIPHER_CRYPTO_CC"
213           AC_MSG_RESULT([commoncrypto])
214   else
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!"]))
221     else
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!"]))
227     fi
228   fi
231 ##########
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
240   XTHREADCONNECT=''
241   AC_MSG_RESULT([no])
242 else
243   XTHREADCONNECT='-DSQLITE_ALLOW_XTHREAD_CONNECT=1'
244   AC_MSG_RESULT([yes])
246 AC_SUBST(XTHREADCONNECT)
248 ##########
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
255   ALLOWRELEASE=""
256   AC_MSG_RESULT([no])
257 else
258   ALLOWRELEASE="-release `cat $srcdir/VERSION`"
259   AC_MSG_RESULT([yes])
261 AC_SUBST(ALLOWRELEASE)
263 ##########
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
270   never ) 
271     TEMP_STORE=0
272     AC_MSG_RESULT([never])
273   ;;
274   no ) 
275     TEMP_STORE=1
276     AC_MSG_RESULT([no])
277   ;;
278   yes ) 
279      TEMP_STORE=2
280     AC_MSG_RESULT([yes])
281   ;;
282   always ) 
283      TEMP_STORE=3
284     AC_MSG_RESULT([always])
285   ;;
286   * ) 
287     TEMP_STORE=1
288     AC_MSG_RESULT([no])
289   ;;
290 esac
292 AC_SUBST(TEMP_STORE)
294 ###########
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
301   CYGWIN=yes
302   AC_MSG_RESULT(yes)
303 else
304   AC_MSG_RESULT(unknown)
306 if test "$CYGWIN" != "yes"; then
307   AC_CYGWIN
309 if test "$CYGWIN" = "yes"; then
310   BUILD_EXEEXT=.exe
311 else
312   BUILD_EXEEXT=$EXEEXT
314 if test x"$cross_compiling" = xno; then
315   TARGET_EXEEXT=$BUILD_EXEEXT
316 else
317   TARGET_EXEEXT=$config_TARGET_EXEEXT
319 if test "$TARGET_EXEEXT" = ".exe"; then
320   SQLITE_OS_UNIX=0
321   SQLITE_OS_WIN=1
322   CFLAGS="$CFLAGS -DSQLITE_OS_WIN=1"
323 else
324   SQLITE_OS_UNIX=1
325   SQLITE_OS_WIN=0
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)
334 ##########
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)`
352       else
353         AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
354       fi
355     fi
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}`
361         do
362           if test -f "$i/tclConfig.sh" ; then
363             ac_cv_c_tclconfig="$i"
364             break
365           fi
366         done
367       fi
368     fi
370     # On ubuntu 14.10, $auto_path on tclsh is not quite correct.
371     # So try again after applying corrections.
372     if test x"${ac_cv_c_tclconfig}" = x ; then
373       if test x"$cross_compiling" = xno; then
374         for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD} | sed 's,/tcltk/tcl,/tcl,g'`
375         do
376           if test -f "$i/tclConfig.sh" ; then
377             ac_cv_c_tclconfig="$i"
378             break
379           fi
380         done
381       fi
382     fi
384     # Recent versions of Xcode on Macs hid the tclConfig.sh file
385     # in a strange place.
386     if test x"${ac_cv_c_tclconfig}" = x ; then
387       if test x"$cross_compiling" = xno; then
388         for i in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk/usr/lib
389         do
390           if test -f "$i/tclConfig.sh" ; then
391             ac_cv_c_tclconfig="$i"
392             break
393           fi
394         done
395       fi
396     fi
398     # then check for a private Tcl installation
399     if test x"${ac_cv_c_tclconfig}" = x ; then
400       for i in \
401             ../tcl \
402             `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
403             `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
404             `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
405             ../../tcl \
406             `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
407             `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
408             `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
409             ../../../tcl \
410             `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
411             `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
412             `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null`
413       do
414         if test -f "$i/unix/tclConfig.sh" ; then
415           ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
416           break
417         fi
418       done
419     fi
421     # check in a few common install locations
422     if test x"${ac_cv_c_tclconfig}" = x ; then
423       for i in \
424             `ls -d ${libdir} 2>/dev/null` \
425             `ls -d /usr/local/lib 2>/dev/null` \
426             `ls -d /usr/contrib/lib 2>/dev/null` \
427             `ls -d /usr/lib 2>/dev/null`
428       do
429         if test -f "$i/tclConfig.sh" ; then
430            ac_cv_c_tclconfig=`(cd $i; pwd)`
431            break
432         fi
433       done
434     fi
436     # check in a few other private locations
437     if test x"${ac_cv_c_tclconfig}" = x ; then
438       for i in \
439          ${srcdir}/../tcl \
440          `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
441          `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
442          `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null`
443       do
444         if test -f "$i/unix/tclConfig.sh" ; then
445           ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
446           break
447         fi
448       done
449     fi
450   ])
452   if test x"${ac_cv_c_tclconfig}" = x ; then
453     use_tcl=no
454     AC_MSG_WARN(Can't find Tcl configuration definitions)
455     AC_MSG_WARN(*** Without Tcl the regression tests cannot be executed ***)
456     AC_MSG_WARN(*** Consider using --with-tcl=... to define location of Tcl ***)
457   else
458     TCL_BIN_DIR=${ac_cv_c_tclconfig}
459     AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
461     AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
462     if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
463       AC_MSG_RESULT([loading])
464       . $TCL_BIN_DIR/tclConfig.sh
465     else
466       AC_MSG_RESULT([file not found])
467     fi
468     
469     #
470     # If the TCL_BIN_DIR is the build directory (not the install directory),
471     # then set the common variable name to the value of the build variables.
472     # For example, the variable TCL_LIB_SPEC will be set to the value
473     # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
474     # instead of TCL_BUILD_LIB_SPEC since it will work with both an
475     # installed and uninstalled version of Tcl.
476     #
477     
478     if test -f $TCL_BIN_DIR/Makefile ; then
479       TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
480       TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
481       TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
482     fi
483     
484     #
485     # eval is required to do the TCL_DBGX substitution
486     #
487     
488     eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
489     eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
490     eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
491     
492     eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
493     eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
494     eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
495     
496     AC_SUBST(TCL_VERSION)
497     AC_SUBST(TCL_BIN_DIR)
498     AC_SUBST(TCL_SRC_DIR)
499     AC_SUBST(TCL_INCLUDE_SPEC)
500     
501     AC_SUBST(TCL_LIB_FILE)
502     AC_SUBST(TCL_LIB_FLAG)
503     AC_SUBST(TCL_LIB_SPEC)
504     
505     AC_SUBST(TCL_STUB_LIB_FILE)
506     AC_SUBST(TCL_STUB_LIB_FLAG)
507     AC_SUBST(TCL_STUB_LIB_SPEC)
508     AC_SUBST(TCL_SHLIB_SUFFIX)
509   fi
511 if test "${use_tcl}" = "no" ; then
512   HAVE_TCL=""
513 else
514   HAVE_TCL=1
516 AC_SUBST(HAVE_TCL)
518 ##########
519 # Figure out what C libraries are required to compile programs
520 # that use "readline()" library.
522 TARGET_READLINE_LIBS=""
523 TARGET_READLINE_INC=""
524 TARGET_HAVE_READLINE=0
525 TARGET_HAVE_EDITLINE=0
526 AC_ARG_ENABLE([editline],
527         [AC_HELP_STRING([--enable-editline],[enable BSD editline support])],
528         [with_editline=$enableval],
529         [with_editline=auto])
530 AC_ARG_ENABLE([readline],
531         [AC_HELP_STRING([--disable-readline],[disable readline support])],
532         [with_readline=$enableval],
533         [with_readline=auto])
535 if test x"$with_editline" != xno; then
536         sLIBS=$LIBS
537         LIBS=""
538         TARGET_HAVE_EDITLINE=1
539         AC_SEARCH_LIBS(readline,edit,[with_readline=no],[TARGET_HAVE_EDITLINE=0])
540         TARGET_READLINE_LIBS=$LIBS
541         LIBS=$sLIBS
543 if test x"$with_readline" != xno; then
544         found="yes"
546         AC_ARG_WITH([readline-lib],
547                 [AC_HELP_STRING([--with-readline-lib],[specify readline library])],
548                 [with_readline_lib=$withval],
549                 [with_readline_lib="auto"])
550         if test "x$with_readline_lib" = xauto; then
551                 save_LIBS="$LIBS"
552                 LIBS=""
553                 AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap], [term_LIBS="$LIBS"], [term_LIBS=""])
554                 AC_CHECK_LIB([readline], [readline], [TARGET_READLINE_LIBS="-lreadline"], [found="no"])
555                 TARGET_READLINE_LIBS="$TARGET_READLINE_LIBS $term_LIBS"
556                 LIBS="$save_LIBS"
557         else
558                 TARGET_READLINE_LIBS="$with_readline_lib"
559         fi
561         AC_ARG_WITH([readline-inc],
562                 [AC_HELP_STRING([--with-readline-inc],[specify readline include paths])],
563                 [with_readline_inc=$withval],
564                 [with_readline_inc="auto"])
565         if test "x$with_readline_inc" = xauto; then
566                 AC_CHECK_HEADER(readline.h, [found="yes"], [
567                         found="no"
568                         if test "$cross_compiling" != yes; then
569                                 for dir in /usr /usr/local /usr/local/readline /usr/contrib /mingw; do
570                                         for subdir in include include/readline; do
571                                                 AC_CHECK_FILE($dir/$subdir/readline.h, found=yes)
572                                                 if test "$found" = "yes"; then
573                                                         TARGET_READLINE_INC="-I$dir/$subdir"
574                                                         break
575                                                 fi
576                                         done
577                                         test "$found" = "yes" && break
578                                 done
579                         fi
580                 ])
581         else
582                 TARGET_READLINE_INC="$with_readline_inc"
583         fi
585         if test x"$found" = xno; then
586                 TARGET_READLINE_LIBS=""
587                 TARGET_READLINE_INC=""
588                 TARGET_HAVE_READLINE=0
589         else
590                 TARGET_HAVE_READLINE=1
591         fi
594 AC_SUBST(TARGET_READLINE_LIBS)
595 AC_SUBST(TARGET_READLINE_INC)
596 AC_SUBST(TARGET_HAVE_READLINE)
597 AC_SUBST(TARGET_HAVE_EDITLINE)
599 ##########
600 # Figure out what C libraries are required to compile programs
601 # that use "fdatasync()" function.
603 AC_SEARCH_LIBS(fdatasync, [rt])
605 #########
606 # check for debug enabled
607 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain]),
608       [use_debug=$enableval],[use_debug=no])
609 if test "${use_debug}" = "yes" ; then
610   TARGET_DEBUG="-DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0"
611 else
612   TARGET_DEBUG="-DNDEBUG"
614 AC_SUBST(TARGET_DEBUG)
616 #########
617 # See whether we should use the amalgamation to build
618 AC_ARG_ENABLE(amalgamation, AC_HELP_STRING([--disable-amalgamation],
619       [Disable the amalgamation and instead build all files separately]),
620       [use_amalgamation=$enableval],[use_amalgamation=yes])
621 if test "${use_amalgamation}" != "yes" ; then
622   USE_AMALGAMATION=0
624 AC_SUBST(USE_AMALGAMATION)
626 #########
627 # See whether we should allow loadable extensions
628 AC_ARG_ENABLE(load-extension, AC_HELP_STRING([--disable-load-extension],
629       [Disable loading of external extensions]),
630       [use_loadextension=$enableval],[use_loadextension=yes])
631 if test "${use_loadextension}" = "yes" ; then
632   OPT_FEATURE_FLAGS=""
633   AC_SEARCH_LIBS(dlopen, dl)
634 else
635   OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1"
638 ##########
639 # Do we want to support memsys3 and/or memsys5
641 AC_ARG_ENABLE(memsys5, 
642   AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]),
643   [enable_memsys5=yes],[enable_memsys5=no])
644 AC_MSG_CHECKING([whether to support MEMSYS5])
645 if test "${enable_memsys5}" = "yes"; then
646   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS5"
647   AC_MSG_RESULT([yes])
648 else
649   AC_MSG_RESULT([no])
651 AC_ARG_ENABLE(memsys3, 
652   AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]),
653   [enable_memsys3=yes],[enable_memsys3=no])
654 AC_MSG_CHECKING([whether to support MEMSYS3])
655 if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then
656   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS3"
657   AC_MSG_RESULT([yes])
658 else
659   AC_MSG_RESULT([no])
662 #########
663 # See whether we should enable Full Text Search extensions
664 AC_ARG_ENABLE(fts3, AC_HELP_STRING([--enable-fts3],
665       [Enable the FTS3 extension]),
666       [enable_fts3=yes],[enable_fts3=no])
667 if test "${enable_fts3}" = "yes" ; then
668   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS3"
670 AC_ARG_ENABLE(fts4, AC_HELP_STRING([--enable-fts4],
671       [Enable the FTS4 extension]),
672       [enable_fts4=yes],[enable_fts4=no])
673 if test "${enable_fts4}" = "yes" ; then
674   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS4"
675   AC_SEARCH_LIBS([log],[m])
677 AC_ARG_ENABLE(fts5, AC_HELP_STRING([--enable-fts5],
678       [Enable the FTS5 extension]),
679       [enable_fts5=yes],[enable_fts5=no])
680 if test "${enable_fts5}" = "yes" ; then
681   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS5"
682   AC_SEARCH_LIBS([log],[m])
685 #########
686 # See whether we should enable JSON1
687 AC_ARG_ENABLE(json1, AC_HELP_STRING([--enable-json1],
688       [Enable the JSON1 extension]),
689       [enable_json1=yes],[enable_json1=no])
690 if test "${enable_json1}" = "yes" ; then
691   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_JSON1"
694 #########
695 # See whether we should enable RTREE
696 AC_ARG_ENABLE(rtree, AC_HELP_STRING([--enable-rtree],
697       [Enable the RTREE extension]),
698       [enable_rtree=yes],[enable_rtree=no])
699 if test "${enable_rtree}" = "yes" ; then
700   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_RTREE"
703 #########
704 # See whether we should enable the SESSION extension
705 AC_ARG_ENABLE(session, AC_HELP_STRING([--enable-session],
706       [Enable the SESSION extension]),
707       [enable_session=yes],[enable_session=no])
708 if test "${enable_session}" = "yes" ; then
709   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_SESSION"
710   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_PREUPDATE_HOOK"
713 #########
714 # attempt to duplicate any OMITS and ENABLES into the ${OPT_FEATURE_FLAGS} parameter
715 for option in $CFLAGS $CPPFLAGS
717   case $option in
718     -DSQLITE_OMIT*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
719     -DSQLITE_ENABLE*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
720   esac
721 done
722 AC_SUBST(OPT_FEATURE_FLAGS)
725 # attempt to remove any OMITS and ENABLES from the $(CFLAGS) parameter
726 ac_temp_CFLAGS=""
727 for option in $CFLAGS
729   case $option in
730     -DSQLITE_OMIT*) ;;
731     -DSQLITE_ENABLE*) ;;
732     *) ac_temp_CFLAGS="$ac_temp_CFLAGS $option";;
733   esac
734 done
735 CFLAGS=$ac_temp_CFLAGS
738 # attempt to remove any OMITS and ENABLES from the $(CPPFLAGS) parameter
739 ac_temp_CPPFLAGS=""
740 for option in $CPPFLAGS
742   case $option in
743     -DSQLITE_OMIT*) ;;
744     -DSQLITE_ENABLE*) ;;
745     *) ac_temp_CPPFLAGS="$ac_temp_CPPFLAGS $option";;
746   esac
747 done
748 CPPFLAGS=$ac_temp_CPPFLAGS
751 # attempt to remove any OMITS and ENABLES from the $(BUILD_CFLAGS) parameter
752 ac_temp_BUILD_CFLAGS=""
753 for option in $BUILD_CFLAGS
755   case $option in
756     -DSQLITE_OMIT*) ;;
757     -DSQLITE_ENABLE*) ;;
758     *) ac_temp_BUILD_CFLAGS="$ac_temp_BUILD_CFLAGS $option";;
759   esac
760 done
761 BUILD_CFLAGS=$ac_temp_BUILD_CFLAGS
764 #########
765 # See whether we should use GCOV
766 AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov],
767       [Enable coverage testing using gcov]),
768       [use_gcov=$enableval],[use_gcov=no])
769 if test "${use_gcov}" = "yes" ; then
770   USE_GCOV=1
771 else
772   USE_GCOV=0
774 AC_SUBST(USE_GCOV)
777 #########
778 # Output the config header
779 AC_CONFIG_HEADERS(config.h)
781 #########
782 # Generate the output files.
784 AC_SUBST(BUILD_CFLAGS)
785 AC_OUTPUT([
786 Makefile
787 sqlcipher.pc