Merge sqlite-release(3.29.0) into prerelease-integration
[sqlcipher.git] / configure.ac
blobf13ea6a6bb554b43c29a0c8a0527332239ace718
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.7 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]))
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       if test "$crypto_lib" = "nss"; then
223         CFLAGS+=" -DSQLCIPHER_CRYPTO_NSS"
224         BUILD_CFLAGS+=" -DSQLCIPHER_CRYPTO_NSS"
225         AC_MSG_RESULT([nss3])
226         AC_CHECK_LIB([nss3], [PK11_Decrypt], ,
227                      AC_MSG_ERROR([Library crypto not found. Install nss!"]))
228       else
229         CFLAGS+=" -DSQLCIPHER_CRYPTO_OPENSSL"
230         BUILD_CFLAGS+=" -DSQLCIPHER_CRYPTO_OPENSSL"
231               AC_MSG_RESULT([openssl])
232         AC_CHECK_LIB([crypto], [HMAC_Init_ex], ,
233                      AC_MSG_ERROR([Library crypto not found. Install openssl!"]))
234       fi
235     fi
236   fi
239 ##########
240 # Do we want to allow a connection created in one thread to be used
241 # in another thread.  This does not work on many Linux systems (ex: RedHat 9)
242 # due to bugs in the threading implementations.  This is thus off by default.
244 AC_ARG_ENABLE(cross-thread-connections, 
245 AC_HELP_STRING([--enable-cross-thread-connections],[Allow connection sharing across threads]),,enable_xthreadconnect=no)
246 AC_MSG_CHECKING([whether to allow connections to be shared across threads])
247 if test "$enable_xthreadconnect" = "no"; then
248   XTHREADCONNECT=''
249   AC_MSG_RESULT([no])
250 else
251   XTHREADCONNECT='-DSQLITE_ALLOW_XTHREAD_CONNECT=1'
252   AC_MSG_RESULT([yes])
254 AC_SUBST(XTHREADCONNECT)
256 ##########
257 # Do we want to support release
259 AC_ARG_ENABLE(releasemode, 
260 AC_HELP_STRING([--enable-releasemode],[Support libtool link to release mode]),,enable_releasemode=no)
261 AC_MSG_CHECKING([whether to support shared library linked as release mode or not])
262 if test "$enable_releasemode" = "no"; then
263   ALLOWRELEASE=""
264   AC_MSG_RESULT([no])
265 else
266   ALLOWRELEASE="-release `cat $srcdir/VERSION`"
267   AC_MSG_RESULT([yes])
269 AC_SUBST(ALLOWRELEASE)
271 ##########
272 # Do we want temporary databases in memory
274 AC_ARG_ENABLE(tempstore, 
275 AC_HELP_STRING([--enable-tempstore],[Use an in-ram database for temporary tables (never,no,yes,always)]),,enable_tempstore=no)
276 AC_MSG_CHECKING([whether to use an in-ram database for temporary tables])
277 case "$enable_tempstore" in
278   never ) 
279     TEMP_STORE=0
280     AC_MSG_RESULT([never])
281   ;;
282   no ) 
283     TEMP_STORE=1
284     AC_MSG_RESULT([no])
285   ;;
286   yes ) 
287      TEMP_STORE=2
288     AC_MSG_RESULT([yes])
289   ;;
290   always ) 
291      TEMP_STORE=3
292     AC_MSG_RESULT([always])
293   ;;
294   * ) 
295     TEMP_STORE=1
296     AC_MSG_RESULT([no])
297   ;;
298 esac
300 AC_SUBST(TEMP_STORE)
302 ###########
303 # Lots of things are different if we are compiling for Windows using
304 # the CYGWIN environment.  So check for that special case and handle
305 # things accordingly.
307 AC_MSG_CHECKING([if executables have the .exe suffix])
308 if test "$config_BUILD_EXEEXT" = ".exe"; then
309   CYGWIN=yes
310   AC_MSG_RESULT(yes)
311 else
312   AC_MSG_RESULT(unknown)
314 if test "$CYGWIN" != "yes"; then
315   AC_CYGWIN
317 if test "$CYGWIN" = "yes"; then
318   BUILD_EXEEXT=.exe
319 else
320   BUILD_EXEEXT=$EXEEXT
322 if test x"$cross_compiling" = xno; then
323   TARGET_EXEEXT=$BUILD_EXEEXT
324 else
325   TARGET_EXEEXT=$config_TARGET_EXEEXT
327 if test "$TARGET_EXEEXT" = ".exe"; then
328   SQLITE_OS_UNIX=0
329   SQLITE_OS_WIN=1
330   CFLAGS="$CFLAGS -DSQLITE_OS_WIN=1"
331 else
332   SQLITE_OS_UNIX=1
333   SQLITE_OS_WIN=0
334   CFLAGS="$CFLAGS -DSQLITE_OS_UNIX=1"
337 AC_SUBST(BUILD_EXEEXT)
338 AC_SUBST(SQLITE_OS_UNIX)
339 AC_SUBST(SQLITE_OS_WIN)
340 AC_SUBST(TARGET_EXEEXT)
342 ##########
343 # Figure out all the parameters needed to compile against Tcl.
345 # This code is derived from the SC_PATH_TCLCONFIG and SC_LOAD_TCLCONFIG
346 # macros in the in the tcl.m4 file of the standard TCL distribution.
347 # Those macros could not be used directly since we have to make some
348 # minor changes to accomodate systems that do not have TCL installed.
350 AC_ARG_ENABLE(tcl, AC_HELP_STRING([--disable-tcl],[do not build TCL extension]),
351       [use_tcl=$enableval],[use_tcl=yes])
352 if test "${use_tcl}" = "yes" ; then
353   AC_ARG_WITH(tcl, AC_HELP_STRING([--with-tcl=DIR],[directory containing tcl configuration (tclConfig.sh)]), with_tclconfig=${withval})
354   AC_MSG_CHECKING([for Tcl configuration])
355   AC_CACHE_VAL(ac_cv_c_tclconfig,[
356     # First check to see if --with-tcl was specified.
357     if test x"${with_tclconfig}" != x ; then
358       if test -f "${with_tclconfig}/tclConfig.sh" ; then
359         ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
360       else
361         AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
362       fi
363     fi
365     # Start autosearch by asking tclsh
366     if test x"${ac_cv_c_tclconfig}" = x ; then
367       if test x"$cross_compiling" = xno; then
368         for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}`
369         do
370           if test -f "$i/tclConfig.sh" ; then
371             ac_cv_c_tclconfig="$i"
372             break
373           fi
374         done
375       fi
376     fi
378     # On ubuntu 14.10, $auto_path on tclsh is not quite correct.
379     # So try again after applying corrections.
380     if test x"${ac_cv_c_tclconfig}" = x ; then
381       if test x"$cross_compiling" = xno; then
382         for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD} | sed 's,/tcltk/tcl,/tcl,g'`
383         do
384           if test -f "$i/tclConfig.sh" ; then
385             ac_cv_c_tclconfig="$i"
386             break
387           fi
388         done
389       fi
390     fi
392     # Recent versions of Xcode on Macs hid the tclConfig.sh file
393     # in a strange place.
394     if test x"${ac_cv_c_tclconfig}" = x ; then
395       if test x"$cross_compiling" = xno; then
396         for i in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk/usr/lib
397         do
398           if test -f "$i/tclConfig.sh" ; then
399             ac_cv_c_tclconfig="$i"
400             break
401           fi
402         done
403       fi
404     fi
406     # then check for a private Tcl installation
407     if test x"${ac_cv_c_tclconfig}" = x ; then
408       for i in \
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             ../../tcl \
414             `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
415             `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
416             `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
417             ../../../tcl \
418             `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
419             `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
420             `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null`
421       do
422         if test -f "$i/unix/tclConfig.sh" ; then
423           ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
424           break
425         fi
426       done
427     fi
429     # check in a few common install locations
430     if test x"${ac_cv_c_tclconfig}" = x ; then
431       for i in \
432             `ls -d ${libdir} 2>/dev/null` \
433             `ls -d /usr/local/lib 2>/dev/null` \
434             `ls -d /usr/contrib/lib 2>/dev/null` \
435             `ls -d /usr/lib 2>/dev/null`
436       do
437         if test -f "$i/tclConfig.sh" ; then
438            ac_cv_c_tclconfig=`(cd $i; pwd)`
439            break
440         fi
441       done
442     fi
444     # check in a few other private locations
445     if test x"${ac_cv_c_tclconfig}" = x ; then
446       for i in \
447          ${srcdir}/../tcl \
448          `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
449          `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
450          `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null`
451       do
452         if test -f "$i/unix/tclConfig.sh" ; then
453           ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
454           break
455         fi
456       done
457     fi
458   ])
460   if test x"${ac_cv_c_tclconfig}" = x ; then
461     use_tcl=no
462     AC_MSG_WARN(Can't find Tcl configuration definitions)
463     AC_MSG_WARN(*** Without Tcl the regression tests cannot be executed ***)
464     AC_MSG_WARN(*** Consider using --with-tcl=... to define location of Tcl ***)
465   else
466     TCL_BIN_DIR=${ac_cv_c_tclconfig}
467     AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
469     AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
470     if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
471       AC_MSG_RESULT([loading])
472       . $TCL_BIN_DIR/tclConfig.sh
473     else
474       AC_MSG_RESULT([file not found])
475     fi
476     
477     #
478     # If the TCL_BIN_DIR is the build directory (not the install directory),
479     # then set the common variable name to the value of the build variables.
480     # For example, the variable TCL_LIB_SPEC will be set to the value
481     # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
482     # instead of TCL_BUILD_LIB_SPEC since it will work with both an
483     # installed and uninstalled version of Tcl.
484     #
485     
486     if test -f $TCL_BIN_DIR/Makefile ; then
487       TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
488       TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
489       TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
490     fi
491     
492     #
493     # eval is required to do the TCL_DBGX substitution
494     #
495     
496     eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
497     eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
498     eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
499     
500     eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
501     eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
502     eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
503     
504     AC_SUBST(TCL_VERSION)
505     AC_SUBST(TCL_BIN_DIR)
506     AC_SUBST(TCL_SRC_DIR)
507     AC_SUBST(TCL_INCLUDE_SPEC)
508     
509     AC_SUBST(TCL_LIB_FILE)
510     AC_SUBST(TCL_LIB_FLAG)
511     AC_SUBST(TCL_LIB_SPEC)
512     
513     AC_SUBST(TCL_STUB_LIB_FILE)
514     AC_SUBST(TCL_STUB_LIB_FLAG)
515     AC_SUBST(TCL_STUB_LIB_SPEC)
516     AC_SUBST(TCL_SHLIB_SUFFIX)
517   fi
519 if test "${use_tcl}" = "no" ; then
520   HAVE_TCL=""
521 else
522   HAVE_TCL=1
524 AC_SUBST(HAVE_TCL)
526 ##########
527 # Figure out what C libraries are required to compile programs
528 # that use "readline()" library.
530 TARGET_READLINE_LIBS=""
531 TARGET_READLINE_INC=""
532 TARGET_HAVE_READLINE=0
533 TARGET_HAVE_EDITLINE=0
534 AC_ARG_ENABLE([editline],
535         [AC_HELP_STRING([--enable-editline],[enable BSD editline support])],
536         [with_editline=$enableval],
537         [with_editline=auto])
538 AC_ARG_ENABLE([readline],
539         [AC_HELP_STRING([--disable-readline],[disable readline support])],
540         [with_readline=$enableval],
541         [with_readline=auto])
543 if test x"$with_editline" != xno; then
544         sLIBS=$LIBS
545         LIBS=""
546         TARGET_HAVE_EDITLINE=1
547         AC_SEARCH_LIBS(readline,edit,[with_readline=no],[TARGET_HAVE_EDITLINE=0])
548         TARGET_READLINE_LIBS=$LIBS
549         LIBS=$sLIBS
551 if test x"$with_readline" != xno; then
552         found="yes"
554         AC_ARG_WITH([readline-lib],
555                 [AC_HELP_STRING([--with-readline-lib],[specify readline library])],
556                 [with_readline_lib=$withval],
557                 [with_readline_lib="auto"])
558         if test "x$with_readline_lib" = xauto; then
559                 save_LIBS="$LIBS"
560                 LIBS=""
561                 AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap], [term_LIBS="$LIBS"], [term_LIBS=""])
562                 AC_CHECK_LIB([readline], [readline], [TARGET_READLINE_LIBS="-lreadline"], [found="no"])
563                 TARGET_READLINE_LIBS="$TARGET_READLINE_LIBS $term_LIBS"
564                 LIBS="$save_LIBS"
565         else
566                 TARGET_READLINE_LIBS="$with_readline_lib"
567         fi
569         AC_ARG_WITH([readline-inc],
570                 [AC_HELP_STRING([--with-readline-inc],[specify readline include paths])],
571                 [with_readline_inc=$withval],
572                 [with_readline_inc="auto"])
573         if test "x$with_readline_inc" = xauto; then
574                 AC_CHECK_HEADER(readline.h, [found="yes"], [
575                         found="no"
576                         if test "$cross_compiling" != yes; then
577                                 for dir in /usr /usr/local /usr/local/readline /usr/contrib /mingw; do
578                                         for subdir in include include/readline; do
579                                                 AC_CHECK_FILE($dir/$subdir/readline.h, found=yes)
580                                                 if test "$found" = "yes"; then
581                                                         TARGET_READLINE_INC="-I$dir/$subdir"
582                                                         break
583                                                 fi
584                                         done
585                                         test "$found" = "yes" && break
586                                 done
587                         fi
588                 ])
589         else
590                 TARGET_READLINE_INC="$with_readline_inc"
591         fi
593         if test x"$found" = xno; then
594                 TARGET_READLINE_LIBS=""
595                 TARGET_READLINE_INC=""
596                 TARGET_HAVE_READLINE=0
597         else
598                 TARGET_HAVE_READLINE=1
599         fi
602 AC_SUBST(TARGET_READLINE_LIBS)
603 AC_SUBST(TARGET_READLINE_INC)
604 AC_SUBST(TARGET_HAVE_READLINE)
605 AC_SUBST(TARGET_HAVE_EDITLINE)
607 ##########
608 # Figure out what C libraries are required to compile programs
609 # that use "fdatasync()" function.
611 AC_SEARCH_LIBS(fdatasync, [rt])
613 #########
614 # check for debug enabled
615 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain]))
616 if test "${enable_debug}" = "yes" ; then
617   TARGET_DEBUG="-DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0"
618 else
619   TARGET_DEBUG="-DNDEBUG"
621 AC_SUBST(TARGET_DEBUG)
623 #########
624 # See whether we should use the amalgamation to build
625 AC_ARG_ENABLE(amalgamation, AC_HELP_STRING([--disable-amalgamation],
626       [Disable the amalgamation and instead build all files separately]))
627 if test "${enable_amalgamation}" == "no" ; then
628   USE_AMALGAMATION=0
630 AC_SUBST(USE_AMALGAMATION)
632 #########
633 # Look for zlib.  Only needed by extensions and by the sqlite3.exe shell
634 AC_CHECK_HEADERS(zlib.h)
635 AC_SEARCH_LIBS(deflate, z, [HAVE_ZLIB="-DSQLITE_HAVE_ZLIB=1"], [HAVE_ZLIB=""])
636 AC_SUBST(HAVE_ZLIB)
638 #########
639 # See whether we should allow loadable extensions
640 AC_ARG_ENABLE(load-extension, AC_HELP_STRING([--disable-load-extension],
641       [Disable loading of external extensions]),,[enable_load_extension=yes])
642 if test "${enable_load_extension}" = "yes" ; then
643   OPT_FEATURE_FLAGS=""
644   AC_SEARCH_LIBS(dlopen, dl)
645 else
646   OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1"
649 ##########
650 # Do we want to support memsys3 and/or memsys5
652 AC_ARG_ENABLE(memsys5, 
653   AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]))
654 AC_MSG_CHECKING([whether to support MEMSYS5])
655 if test "${enable_memsys5}" = "yes"; then
656   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS5"
657   AC_MSG_RESULT([yes])
658 else
659   AC_MSG_RESULT([no])
661 AC_ARG_ENABLE(memsys3, 
662   AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]))
663 AC_MSG_CHECKING([whether to support MEMSYS3])
664 if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then
665   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS3"
666   AC_MSG_RESULT([yes])
667 else
668   AC_MSG_RESULT([no])
671 #########
672 # See whether we should enable Full Text Search extensions
673 AC_ARG_ENABLE(fts3, AC_HELP_STRING([--enable-fts3],
674       [Enable the FTS3 extension]))
675 if test "${enable_fts3}" = "yes" ; then
676   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS3"
678 AC_ARG_ENABLE(fts4, AC_HELP_STRING([--enable-fts4],
679       [Enable the FTS4 extension]))
680 if test "${enable_fts4}" = "yes" ; then
681   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS4"
682   AC_SEARCH_LIBS([log],[m])
684 AC_ARG_ENABLE(fts5, AC_HELP_STRING([--enable-fts5],
685       [Enable the FTS5 extension]))
686 if test "${enable_fts5}" = "yes" ; then
687   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS5"
688   AC_SEARCH_LIBS([log],[m])
691 #########
692 # See whether we should enable JSON1
693 AC_ARG_ENABLE(json1, AC_HELP_STRING([--enable-json1],[Enable the JSON1 extension]))
694 if test "${enable_json1}" = "yes" ; then
695   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_JSON1"
698 #########
699 # See whether we should enable the LIMIT clause on UPDATE and DELETE
700 # statements.
701 AC_ARG_ENABLE(update-limit, AC_HELP_STRING([--enable-update-limit],
702       [Enable the UPDATE/DELETE LIMIT clause]))
703 if test "${enable_udlimit}" = "yes" ; then
704   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT"
707 #########
708 # See whether we should enable GEOPOLY
709 AC_ARG_ENABLE(geopoly, AC_HELP_STRING([--enable-geopoly],
710       [Enable the GEOPOLY extension]),
711       [enable_geopoly=yes],[enable_geopoly=no])
712 if test "${enable_geopoly}" = "yes" ; then
713   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_GEOPOLY"
714   enable_rtree=yes
717 #########
718 # See whether we should enable RTREE
719 AC_ARG_ENABLE(rtree, AC_HELP_STRING([--enable-rtree],
720       [Enable the RTREE extension]))
721 if test "${enable_rtree}" = "yes" ; then
722   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_RTREE"
725 #########
726 # See whether we should enable the SESSION extension
727 AC_ARG_ENABLE(session, AC_HELP_STRING([--enable-session],
728       [Enable the SESSION extension]))
729 if test "${enable_session}" = "yes" ; then
730   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_SESSION"
731   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_PREUPDATE_HOOK"
734 #########
735 # attempt to duplicate any OMITS and ENABLES into the ${OPT_FEATURE_FLAGS} parameter
736 for option in $CFLAGS $CPPFLAGS
738   case $option in
739     -DSQLITE_OMIT*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
740     -DSQLITE_ENABLE*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
741   esac
742 done
743 AC_SUBST(OPT_FEATURE_FLAGS)
746 # attempt to remove any OMITS and ENABLES from the $(CFLAGS) parameter
747 ac_temp_CFLAGS=""
748 for option in $CFLAGS
750   case $option in
751     -DSQLITE_OMIT*) ;;
752     -DSQLITE_ENABLE*) ;;
753     *) ac_temp_CFLAGS="$ac_temp_CFLAGS $option";;
754   esac
755 done
756 CFLAGS=$ac_temp_CFLAGS
759 # attempt to remove any OMITS and ENABLES from the $(CPPFLAGS) parameter
760 ac_temp_CPPFLAGS=""
761 for option in $CPPFLAGS
763   case $option in
764     -DSQLITE_OMIT*) ;;
765     -DSQLITE_ENABLE*) ;;
766     *) ac_temp_CPPFLAGS="$ac_temp_CPPFLAGS $option";;
767   esac
768 done
769 CPPFLAGS=$ac_temp_CPPFLAGS
772 # attempt to remove any OMITS and ENABLES from the $(BUILD_CFLAGS) parameter
773 ac_temp_BUILD_CFLAGS=""
774 for option in $BUILD_CFLAGS
776   case $option in
777     -DSQLITE_OMIT*) ;;
778     -DSQLITE_ENABLE*) ;;
779     *) ac_temp_BUILD_CFLAGS="$ac_temp_BUILD_CFLAGS $option";;
780   esac
781 done
782 BUILD_CFLAGS=$ac_temp_BUILD_CFLAGS
785 #########
786 # See whether we should use GCOV
787 AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov],
788       [Enable coverage testing using gcov]))
789 if test "${use_gcov}" = "yes" ; then
790   USE_GCOV=1
791 else
792   USE_GCOV=0
794 AC_SUBST(USE_GCOV)
797 #########
798 # Output the config header
799 AC_CONFIG_HEADERS(config.h)
801 #########
802 # Generate the output files.
804 AC_SUBST(BUILD_CFLAGS)
805 AC_OUTPUT([
806 Makefile
807 sqlcipher.pc