correct distclean to match sqlcipher.pc in current tree
[sqlcipher.git] / configure.ac
blobff703bb061d1ead91ca8046a682f5d2d805db3cb
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     if test -d $i ; then
138       TCLLIBDIR=$i
139       break
140     fi
141   done
142   TCLLIBDIR="${TCLLIBDIR}/sqlite3"
145 #########
146 # Set up an appropriate program prefix
148 if test "$program_prefix" = "NONE"; then
149   program_prefix=""
151 AC_SUBST(program_prefix)
153 VERSION=[`cat $srcdir/VERSION | sed 's/^\([0-9]*\.*[0-9]*\).*/\1/'`]
154 AC_MSG_NOTICE(Version set to $VERSION)
155 AC_SUBST(VERSION)
156 RELEASE=`cat $srcdir/VERSION`
157 AC_MSG_NOTICE(Release set to $RELEASE)
158 AC_SUBST(RELEASE)
160 #########
161 # Locate a compiler for the build machine.  This compiler should
162 # generate command-line programs that run on the build machine.
164 if test x"$cross_compiling" = xno; then
165         BUILD_CC=$CC
166         BUILD_CFLAGS=$CFLAGS
167 else
168         if test "${BUILD_CC+set}" != set; then
169                 AC_CHECK_PROGS(BUILD_CC, gcc cc cl)
170         fi
171         if test "${BUILD_CFLAGS+set}" != set; then
172                 BUILD_CFLAGS="-g"
173         fi
175 AC_SUBST(BUILD_CC)
177 ##########
178 # Do we want to support multithreaded use of sqlite
180 AC_ARG_ENABLE(threadsafe, 
181 AC_HELP_STRING([--disable-threadsafe],[Disable mutexing]))
182 AC_MSG_CHECKING([whether to support threadsafe operation])
183 if test "$enable_threadsafe" = "no"; then
184   SQLITE_THREADSAFE=0
185   AC_MSG_RESULT([no])
186 else
187   SQLITE_THREADSAFE=1
188   AC_MSG_RESULT([yes])
190 AC_SUBST(SQLITE_THREADSAFE)
192 if test "$SQLITE_THREADSAFE" = "1"; then
193   AC_SEARCH_LIBS(pthread_create, pthread)
194   AC_SEARCH_LIBS(pthread_mutexattr_init, pthread)
197 ##########
198 # Which crypto library do we use
200 AC_ARG_WITH([crypto-lib],
201 AC_HELP_STRING([--with-crypto-lib],[Specify which crypto library to use]),
202 crypto_lib=$withval)
203 AC_MSG_CHECKING([for crypto library to use])
204 if test "$crypto_lib" = "none"; then
205   AC_MSG_RESULT([none])
206 else
207   if test "$crypto_lib" = "commoncrypto"; then
208     CFLAGS="$CFLAGS -DSQLCIPHER_CRYPTO_CC"
209     BUILD_CFLAGS="$BUILD_CFLAGS -DSQLCIPHER_CRYPTO_CC"
210           AC_MSG_RESULT([commoncrypto])
211   else
212     if test "$crypto_lib" = "libtomcrypt"; then
213       CFLAGS="$CFLAGS -DSQLCIPHER_CRYPTO_LIBTOMCRYPT"
214       BUILD_CFLAGS="$BUILD_CFLAGS -DSQLCIPHER_CRYPTO_LIBTOMCRYPT"
215       AC_MSG_RESULT([libtomcrypt])
216       AC_CHECK_LIB([tomcrypt], [register_cipher], ,
217                    AC_MSG_ERROR([Library crypto not found. Install libtomcrypt!"]))
218     else
219       if test "$crypto_lib" = "nss"; then
220         CFLAGS="$CFLAGS -DSQLCIPHER_CRYPTO_NSS"
221         BUILD_CFLAGS="$BUILD_CFLAGS -DSQLCIPHER_CRYPTO_NSS"
222         AC_MSG_RESULT([nss3])
223         AC_CHECK_LIB([nss3], [PK11_Decrypt], ,
224                      AC_MSG_ERROR([Library crypto not found. Install nss!"]))
225       else
226         CFLAGS="$CFLAGS -DSQLCIPHER_CRYPTO_OPENSSL"
227         BUILD_CFLAGS="$BUILD_CFLAGS -DSQLCIPHER_CRYPTO_OPENSSL"
228               AC_MSG_RESULT([openssl])
229         AC_CHECK_LIB([crypto], [HMAC_Init_ex], ,
230                      AC_MSG_ERROR([Library crypto not found. Install openssl!"]))
231       fi
232     fi
233   fi
236 ##########
237 # Do we want to allow a connection created in one thread to be used
238 # in another thread.  This does not work on many Linux systems (ex: RedHat 9)
239 # due to bugs in the threading implementations.  This is thus off by default.
241 AC_ARG_ENABLE(cross-thread-connections, 
242 AC_HELP_STRING([--enable-cross-thread-connections],[Allow connection sharing across threads]),,enable_xthreadconnect=no)
243 AC_MSG_CHECKING([whether to allow connections to be shared across threads])
244 if test "$enable_xthreadconnect" = "no"; then
245   XTHREADCONNECT=''
246   AC_MSG_RESULT([no])
247 else
248   XTHREADCONNECT='-DSQLITE_ALLOW_XTHREAD_CONNECT=1'
249   AC_MSG_RESULT([yes])
251 AC_SUBST(XTHREADCONNECT)
253 ##########
254 # Do we want to support release
256 AC_ARG_ENABLE(releasemode, 
257 AC_HELP_STRING([--enable-releasemode],[Support libtool link to release mode]),,enable_releasemode=no)
258 AC_MSG_CHECKING([whether to support shared library linked as release mode or not])
259 if test "$enable_releasemode" = "no"; then
260   ALLOWRELEASE=""
261   AC_MSG_RESULT([no])
262 else
263   ALLOWRELEASE="-release `cat $srcdir/VERSION`"
264   AC_MSG_RESULT([yes])
266 AC_SUBST(ALLOWRELEASE)
268 ##########
269 # Do we want temporary databases in memory
271 AC_ARG_ENABLE(tempstore, 
272 AC_HELP_STRING([--enable-tempstore],[Use an in-ram database for temporary tables (never,no,yes,always)]),,enable_tempstore=no)
273 AC_MSG_CHECKING([whether to use an in-ram database for temporary tables])
274 case "$enable_tempstore" in
275   never ) 
276     TEMP_STORE=0
277     AC_MSG_RESULT([never])
278   ;;
279   no ) 
280     TEMP_STORE=1
281     AC_MSG_RESULT([no])
282   ;;
283   yes ) 
284      TEMP_STORE=2
285     AC_MSG_RESULT([yes])
286   ;;
287   always ) 
288      TEMP_STORE=3
289     AC_MSG_RESULT([always])
290   ;;
291   * ) 
292     TEMP_STORE=1
293     AC_MSG_RESULT([no])
294   ;;
295 esac
297 AC_SUBST(TEMP_STORE)
299 ###########
300 # Lots of things are different if we are compiling for Windows using
301 # the CYGWIN environment.  So check for that special case and handle
302 # things accordingly.
304 AC_MSG_CHECKING([if executables have the .exe suffix])
305 if test "$config_BUILD_EXEEXT" = ".exe"; then
306   CYGWIN=yes
307   AC_MSG_RESULT(yes)
308 else
309   AC_MSG_RESULT(unknown)
311 if test "$CYGWIN" != "yes"; then
312   AC_CYGWIN
314 if test "$CYGWIN" = "yes"; then
315   BUILD_EXEEXT=.exe
316 else
317   BUILD_EXEEXT=$EXEEXT
319 if test x"$cross_compiling" = xno; then
320   TARGET_EXEEXT=$BUILD_EXEEXT
321 else
322   TARGET_EXEEXT=$config_TARGET_EXEEXT
324 if test "$TARGET_EXEEXT" = ".exe"; then
325   SQLITE_OS_UNIX=0
326   SQLITE_OS_WIN=1
327   CFLAGS="$CFLAGS -DSQLITE_OS_WIN=1"
328 else
329   SQLITE_OS_UNIX=1
330   SQLITE_OS_WIN=0
331   CFLAGS="$CFLAGS -DSQLITE_OS_UNIX=1"
334 AC_SUBST(BUILD_EXEEXT)
335 AC_SUBST(SQLITE_OS_UNIX)
336 AC_SUBST(SQLITE_OS_WIN)
337 AC_SUBST(TARGET_EXEEXT)
339 ##########
340 # Figure out all the parameters needed to compile against Tcl.
342 # This code is derived from the SC_PATH_TCLCONFIG and SC_LOAD_TCLCONFIG
343 # macros in the in the tcl.m4 file of the standard TCL distribution.
344 # Those macros could not be used directly since we have to make some
345 # minor changes to accomodate systems that do not have TCL installed.
347 AC_ARG_ENABLE(tcl, AC_HELP_STRING([--disable-tcl],[do not build TCL extension]),
348       [use_tcl=$enableval],[use_tcl=yes])
349 if test "${use_tcl}" = "yes" ; then
350   AC_ARG_WITH(tcl, AC_HELP_STRING([--with-tcl=DIR],[directory containing tcl configuration (tclConfig.sh)]), with_tclconfig=${withval})
351   AC_MSG_CHECKING([for Tcl configuration])
352   AC_CACHE_VAL(ac_cv_c_tclconfig,[
353     # First check to see if --with-tcl was specified.
354     if test x"${with_tclconfig}" != x ; then
355       if test -f "${with_tclconfig}/tclConfig.sh" ; then
356         ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
357       else
358         AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
359       fi
360     fi
362     # Start autosearch by asking tclsh
363     if test x"${ac_cv_c_tclconfig}" = x ; then
364       if test x"$cross_compiling" = xno; then
365         for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}`
366         do
367           if test -f "$i/tclConfig.sh" ; then
368             ac_cv_c_tclconfig="$i"
369             break
370           fi
371         done
372       fi
373     fi
375     # On ubuntu 14.10, $auto_path on tclsh is not quite correct.
376     # So try again after applying corrections.
377     if test x"${ac_cv_c_tclconfig}" = x ; then
378       if test x"$cross_compiling" = xno; then
379         for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD} | sed 's,/tcltk/tcl,/tcl,g'`
380         do
381           if test -f "$i/tclConfig.sh" ; then
382             ac_cv_c_tclconfig="$i"
383             break
384           fi
385         done
386       fi
387     fi
389     # Recent versions of Xcode on Macs hid the tclConfig.sh file
390     # in a strange place.
391     if test x"${ac_cv_c_tclconfig}" = x ; then
392       if test x"$cross_compiling" = xno; then
393         for i in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk/usr/lib
394         do
395           if test -f "$i/tclConfig.sh" ; then
396             ac_cv_c_tclconfig="$i"
397             break
398           fi
399         done
400       fi
401     fi
403     # then check for a private Tcl installation
404     if test x"${ac_cv_c_tclconfig}" = x ; then
405       for i in \
406             ../tcl \
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` \
410             ../../tcl \
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` \
414             ../../../tcl \
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`
418       do
419         if test -f "$i/unix/tclConfig.sh" ; then
420           ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
421           break
422         fi
423       done
424     fi
426     # check in a few common install locations
427     if test x"${ac_cv_c_tclconfig}" = x ; then
428       for i in \
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`
433       do
434         if test -f "$i/tclConfig.sh" ; then
435            ac_cv_c_tclconfig=`(cd $i; pwd)`
436            break
437         fi
438       done
439     fi
441     # check in a few other private locations
442     if test x"${ac_cv_c_tclconfig}" = x ; then
443       for i in \
444          ${srcdir}/../tcl \
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`
448       do
449         if test -f "$i/unix/tclConfig.sh" ; then
450           ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
451           break
452         fi
453       done
454     fi
455   ])
457   if test x"${ac_cv_c_tclconfig}" = x ; then
458     use_tcl=no
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 ***)
462   else
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
470     else
471       AC_MSG_RESULT([file not found])
472     fi
473     
474     #
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.
481     #
482     
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}
487     fi
488     
489     #
490     # eval is required to do the TCL_DBGX substitution
491     #
492     
493     eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
494     eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
495     eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
496     
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}\""
500     
501     AC_SUBST(TCL_VERSION)
502     AC_SUBST(TCL_BIN_DIR)
503     AC_SUBST(TCL_SRC_DIR)
504     AC_SUBST(TCL_INCLUDE_SPEC)
505     
506     AC_SUBST(TCL_LIB_FILE)
507     AC_SUBST(TCL_LIB_FLAG)
508     AC_SUBST(TCL_LIB_SPEC)
509     
510     AC_SUBST(TCL_STUB_LIB_FILE)
511     AC_SUBST(TCL_STUB_LIB_FLAG)
512     AC_SUBST(TCL_STUB_LIB_SPEC)
513     AC_SUBST(TCL_SHLIB_SUFFIX)
514   fi
516 if test "${use_tcl}" = "no" ; then
517   HAVE_TCL=""
518 else
519   HAVE_TCL=1
521 AC_SUBST(HAVE_TCL)
523 ##########
524 # Figure out what C libraries are required to compile programs
525 # that use "readline()" library.
527 TARGET_READLINE_LIBS=""
528 TARGET_READLINE_INC=""
529 TARGET_HAVE_READLINE=0
530 TARGET_HAVE_EDITLINE=0
531 AC_ARG_ENABLE([editline],
532         [AC_HELP_STRING([--enable-editline],[enable BSD editline support])],
533         [with_editline=$enableval],
534         [with_editline=auto])
535 AC_ARG_ENABLE([readline],
536         [AC_HELP_STRING([--disable-readline],[disable readline support])],
537         [with_readline=$enableval],
538         [with_readline=auto])
540 if test x"$with_editline" != xno; then
541         sLIBS=$LIBS
542         LIBS=""
543         TARGET_HAVE_EDITLINE=1
544         AC_SEARCH_LIBS(readline,edit,[with_readline=no],[TARGET_HAVE_EDITLINE=0])
545         TARGET_READLINE_LIBS=$LIBS
546         LIBS=$sLIBS
548 if test x"$with_readline" != xno; then
549         found="yes"
551         AC_ARG_WITH([readline-lib],
552                 [AC_HELP_STRING([--with-readline-lib],[specify readline library])],
553                 [with_readline_lib=$withval],
554                 [with_readline_lib="auto"])
555         if test "x$with_readline_lib" = xauto; then
556                 save_LIBS="$LIBS"
557                 LIBS=""
558                 AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap], [term_LIBS="$LIBS"], [term_LIBS=""])
559                 AC_CHECK_LIB([readline], [readline], [TARGET_READLINE_LIBS="-lreadline"], [found="no"])
560                 TARGET_READLINE_LIBS="$TARGET_READLINE_LIBS $term_LIBS"
561                 LIBS="$save_LIBS"
562         else
563                 TARGET_READLINE_LIBS="$with_readline_lib"
564         fi
566         AC_ARG_WITH([readline-inc],
567                 [AC_HELP_STRING([--with-readline-inc],[specify readline include paths])],
568                 [with_readline_inc=$withval],
569                 [with_readline_inc="auto"])
570         if test "x$with_readline_inc" = xauto; then
571                 AC_CHECK_HEADER(readline.h, [found="yes"], [
572                         found="no"
573                         if test "$cross_compiling" != yes; then
574                                 for dir in /usr /usr/local /usr/local/readline /usr/contrib /mingw; do
575                                         for subdir in include include/readline; do
576                                                 AC_CHECK_FILE($dir/$subdir/readline.h, found=yes)
577                                                 if test "$found" = "yes"; then
578                                                         TARGET_READLINE_INC="-I$dir/$subdir"
579                                                         break
580                                                 fi
581                                         done
582                                         test "$found" = "yes" && break
583                                 done
584                         fi
585                 ])
586         else
587                 TARGET_READLINE_INC="$with_readline_inc"
588         fi
590         if test x"$found" = xno; then
591                 TARGET_READLINE_LIBS=""
592                 TARGET_READLINE_INC=""
593                 TARGET_HAVE_READLINE=0
594         else
595                 TARGET_HAVE_READLINE=1
596         fi
599 AC_SUBST(TARGET_READLINE_LIBS)
600 AC_SUBST(TARGET_READLINE_INC)
601 AC_SUBST(TARGET_HAVE_READLINE)
602 AC_SUBST(TARGET_HAVE_EDITLINE)
604 ##########
605 # Figure out what C libraries are required to compile programs
606 # that use "fdatasync()" function.
608 AC_SEARCH_LIBS(fdatasync, [rt])
610 #########
611 # check for debug enabled
612 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain]))
613 AC_MSG_CHECKING([build type])
614 if test "${enable_debug}" = "yes" ; then
615   TARGET_DEBUG="-DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0"
616   AC_MSG_RESULT([debug])
617 else
618   TARGET_DEBUG="-DNDEBUG"
619   AC_MSG_RESULT([release])
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 # By default, amalgamation sqlite3.c will have #line directives.
634 # This is a build option not shown by ./configure --help
635 # To control it, use configure option: amalgamation_line_macros=?
636 # where ? is no to suppress #line directives or yes to create them.
637 AMALGAMATION_LINE_MACROS=--linemacros=1
638 AC_ARG_VAR(amalgamation_line_macros,)
639 AC_SUBST(AMALGAMATION_LINE_MACROS)
640 if test "${amalgamation_line_macros+set}" = set; then :
641   enableval=$amalgamation_line_macros;
643 if test "${amalgamation_line_macros}" = "yes" ; then
644   AMALGAMATION_LINE_MACROS=--linemacros=1
646 if test "${amalgamation_line_macros}" = "no" ; then
647   AMALGAMATION_LINE_MACROS=--linemacros=0
650 #########
651 # Look for zlib.  Only needed by extensions and by the sqlite3.exe shell
652 AC_CHECK_HEADERS(zlib.h)
653 AC_SEARCH_LIBS(deflate, z, [HAVE_ZLIB="-DSQLITE_HAVE_ZLIB=1"], [HAVE_ZLIB=""])
654 AC_SUBST(HAVE_ZLIB)
656 #########
657 # See whether we should allow loadable extensions
658 AC_ARG_ENABLE(load-extension, AC_HELP_STRING([--disable-load-extension],
659       [Disable loading of external extensions]),,[enable_load_extension=yes])
660 if test "${enable_load_extension}" = "yes" ; then
661   OPT_FEATURE_FLAGS=""
662   AC_SEARCH_LIBS(dlopen, dl)
663 else
664   OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1"
667 ##########
668 # Do we want to support math functions
670 AC_ARG_ENABLE(math, 
671 AC_HELP_STRING([--disable-math],[Disable math functions]))
672 AC_MSG_CHECKING([whether to support math functions])
673 if test "$enable_math" = "no"; then
674   AC_MSG_RESULT([no])
675 else
676   AC_MSG_RESULT([yes])
677   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MATH_FUNCTIONS"
678   AC_SEARCH_LIBS(ceil, m)
681 ##########
682 # Do we want to support JSON functions
684 AC_ARG_ENABLE(json, 
685 AC_HELP_STRING([--disable-json],[Disable JSON functions]))
686 AC_MSG_CHECKING([whether to support JSON functions])
687 if test "$enable_json" = "no"; then
688   AC_MSG_RESULT([no])
689   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_OMIT_JSON"
690 else
691   AC_MSG_RESULT([yes])
694 ########
695 # The --enable-all argument is short-hand to enable
696 # multiple extensions.
697 AC_ARG_ENABLE(all, AC_HELP_STRING([--enable-all],
698       [Enable FTS4, FTS5, Geopoly, RTree, Sessions]))
700 ##########
701 # Do we want to support memsys3 and/or memsys5
703 AC_ARG_ENABLE(memsys5, 
704   AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]))
705 AC_MSG_CHECKING([whether to support MEMSYS5])
706 if test "${enable_memsys5}" = "yes"; then
707   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS5"
708   AC_MSG_RESULT([yes])
709 else
710   AC_MSG_RESULT([no])
712 AC_ARG_ENABLE(memsys3, 
713   AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]))
714 AC_MSG_CHECKING([whether to support MEMSYS3])
715 if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then
716   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS3"
717   AC_MSG_RESULT([yes])
718 else
719   AC_MSG_RESULT([no])
722 #########
723 # See whether we should enable Full Text Search extensions
724 AC_ARG_ENABLE(fts3, AC_HELP_STRING([--enable-fts3],
725       [Enable the FTS3 extension]))
726 AC_MSG_CHECKING([whether to support FTS3])
727 if test "${enable_fts3}" = "yes" ; then
728   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS3"
729   AC_MSG_RESULT([yes])
730 else
731   AC_MSG_RESULT([no])
733 AC_ARG_ENABLE(fts4, AC_HELP_STRING([--enable-fts4],
734       [Enable the FTS4 extension]))
735 AC_MSG_CHECKING([whether to support FTS4])
736 if test "${enable_fts4}" = "yes" -o "${enable_all}" = "yes" ; then
737   AC_MSG_RESULT([yes])
738   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS4"
739   AC_SEARCH_LIBS([log],[m])
740 else
741   AC_MSG_RESULT([no])
743 AC_ARG_ENABLE(fts5, AC_HELP_STRING([--enable-fts5],
744       [Enable the FTS5 extension]))
745 AC_MSG_CHECKING([whether to support FTS5])
746 if test "${enable_fts5}" = "yes" -o "${enable_all}" = "yes" ; then
747   AC_MSG_RESULT([yes])
748   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS5"
749   AC_SEARCH_LIBS([log],[m])
750 else
751   AC_MSG_RESULT([no])
754 #########
755 # See whether we should enable the LIMIT clause on UPDATE and DELETE
756 # statements.
757 AC_ARG_ENABLE(update-limit, AC_HELP_STRING([--enable-update-limit],
758       [Enable the UPDATE/DELETE LIMIT clause]))
759 AC_MSG_CHECKING([whether to support LIMIT on UPDATE and DELETE statements])
760 if test "${enable_update_limit}" = "yes" ; then
761   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT"
762   AC_MSG_RESULT([yes])
763 else
764   AC_MSG_RESULT([no])
767 #########
768 # See whether we should enable GEOPOLY
769 AC_ARG_ENABLE(geopoly, AC_HELP_STRING([--enable-geopoly],
770       [Enable the GEOPOLY extension]),
771       [enable_geopoly=yes],[enable_geopoly=no])
772 AC_MSG_CHECKING([whether to support GEOPOLY])
773 if test "${enable_geopoly}" = "yes" -o "${enable_all}" = "yes" ; then
774   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_GEOPOLY"
775   enable_rtree=yes
776   AC_MSG_RESULT([yes])
777 else
778   AC_MSG_RESULT([no])
781 #########
782 # See whether we should enable RTREE
783 AC_ARG_ENABLE(rtree, AC_HELP_STRING([--enable-rtree],
784       [Enable the RTREE extension]))
785 AC_MSG_CHECKING([whether to support RTREE])
786 if test "${enable_rtree}" = "yes" ; then
787   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_RTREE"
788   AC_MSG_RESULT([yes])
789 else
790   AC_MSG_RESULT([no])
793 #########
794 # See whether we should enable the SESSION extension
795 AC_ARG_ENABLE(session, AC_HELP_STRING([--enable-session],
796       [Enable the SESSION extension]))
797 AC_MSG_CHECKING([whether to support SESSION])
798 if test "${enable_session}" = "yes" -o "${enable_all}" = "yes" ; then
799   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_SESSION"
800   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_PREUPDATE_HOOK"
801   AC_MSG_RESULT([yes])
802 else
803   AC_MSG_RESULT([no])
806 #########
807 # attempt to duplicate any OMITS and ENABLES into the ${OPT_FEATURE_FLAGS} parameter
808 for option in $CFLAGS $CPPFLAGS
810   case $option in
811     -DSQLITE_OMIT*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
812     -DSQLITE_ENABLE*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
813   esac
814 done
815 AC_SUBST(OPT_FEATURE_FLAGS)
818 # attempt to remove any OMITS and ENABLES from the $(CFLAGS) parameter
819 ac_temp_CFLAGS=""
820 for option in $CFLAGS
822   case $option in
823     -DSQLITE_OMIT*) ;;
824     -DSQLITE_ENABLE*) ;;
825     *) ac_temp_CFLAGS="$ac_temp_CFLAGS $option";;
826   esac
827 done
828 CFLAGS=$ac_temp_CFLAGS
831 # attempt to remove any OMITS and ENABLES from the $(CPPFLAGS) parameter
832 ac_temp_CPPFLAGS=""
833 for option in $CPPFLAGS
835   case $option in
836     -DSQLITE_OMIT*) ;;
837     -DSQLITE_ENABLE*) ;;
838     *) ac_temp_CPPFLAGS="$ac_temp_CPPFLAGS $option";;
839   esac
840 done
841 CPPFLAGS=$ac_temp_CPPFLAGS
844 # attempt to remove any OMITS and ENABLES from the $(BUILD_CFLAGS) parameter
845 ac_temp_BUILD_CFLAGS=""
846 for option in $BUILD_CFLAGS
848   case $option in
849     -DSQLITE_OMIT*) ;;
850     -DSQLITE_ENABLE*) ;;
851     *) ac_temp_BUILD_CFLAGS="$ac_temp_BUILD_CFLAGS $option";;
852   esac
853 done
854 BUILD_CFLAGS=$ac_temp_BUILD_CFLAGS
857 #########
858 # See whether we should use GCOV
859 AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov],
860       [Enable coverage testing using gcov]))
861 if test "${use_gcov}" = "yes" ; then
862   USE_GCOV=1
863 else
864   USE_GCOV=0
866 AC_SUBST(USE_GCOV)
868 #########
869 # Enable/disabled amalagamation line macros
870 ########
871 AMALGAMATION_LINE_MACROS=--linemacros=0
872 if test "${amalgamation_line_macros}" = "yes" ; then
873   AMALGAMATION_LINE_MACROS=--linemacros=1
875 if test "${amalgamation_line_macros}" = "no" ; then
876   AMALGAMATION_LINE_MACROS=--linemacros=0
878 AC_SUBST(AMALGAMATION_LINE_MACROS)
880 #########
881 # Output the config header
882 AC_CONFIG_HEADERS(config.h)
884 #########
885 # Generate the output files.
887 AC_SUBST(BUILD_CFLAGS)
888 AC_OUTPUT([
889 Makefile
890 sqlcipher.pc