add new amalgamation_line_macros option missing from configure.ac
[sqlcipher.git] / configure.ac
blob31ca1231026d40c7bb96f7a5804f942643324acb
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)
158 #########
159 # Locate a compiler for the build machine.  This compiler should
160 # generate command-line programs that run on the build machine.
162 if test x"$cross_compiling" = xno; then
163         BUILD_CC=$CC
164         BUILD_CFLAGS=$CFLAGS
165 else
166         if test "${BUILD_CC+set}" != set; then
167                 AC_CHECK_PROGS(BUILD_CC, gcc cc cl)
168         fi
169         if test "${BUILD_CFLAGS+set}" != set; then
170                 BUILD_CFLAGS="-g"
171         fi
173 AC_SUBST(BUILD_CC)
175 ##########
176 # Do we want to support multithreaded use of sqlite
178 AC_ARG_ENABLE(threadsafe, 
179 AC_HELP_STRING([--disable-threadsafe],[Disable mutexing]))
180 AC_MSG_CHECKING([whether to support threadsafe operation])
181 if test "$enable_threadsafe" = "no"; then
182   SQLITE_THREADSAFE=0
183   AC_MSG_RESULT([no])
184 else
185   SQLITE_THREADSAFE=1
186   AC_MSG_RESULT([yes])
188 AC_SUBST(SQLITE_THREADSAFE)
190 if test "$SQLITE_THREADSAFE" = "1"; then
191   AC_SEARCH_LIBS(pthread_create, pthread)
192   AC_SEARCH_LIBS(pthread_mutexattr_init, pthread)
195 ##########
196 # Which crypto library do we use
198 AC_ARG_WITH([crypto-lib],
199 AC_HELP_STRING([--with-crypto-lib],[Specify which crypto library to use]),
200 crypto_lib=$withval)
201 AC_MSG_CHECKING([for crypto library to use])
202 if test "$crypto_lib" = "none"; then
203   AC_MSG_RESULT([none])
204 else
205   if test "$crypto_lib" = "commoncrypto"; then
206     CFLAGS="$CFLAGS -DSQLCIPHER_CRYPTO_CC"
207     BUILD_CFLAGS="$BUILD_CFLAGS -DSQLCIPHER_CRYPTO_CC"
208           AC_MSG_RESULT([commoncrypto])
209   else
210     if test "$crypto_lib" = "libtomcrypt"; then
211       CFLAGS="$CFLAGS -DSQLCIPHER_CRYPTO_LIBTOMCRYPT"
212       BUILD_CFLAGS="$BUILD_CFLAGS -DSQLCIPHER_CRYPTO_LIBTOMCRYPT"
213       AC_MSG_RESULT([libtomcrypt])
214       AC_CHECK_LIB([tomcrypt], [register_cipher], ,
215                    AC_MSG_ERROR([Library crypto not found. Install libtomcrypt!"]))
216     else
217       if test "$crypto_lib" = "nss"; then
218         CFLAGS="$CFLAGS -DSQLCIPHER_CRYPTO_NSS"
219         BUILD_CFLAGS="$BUILD_CFLAGS -DSQLCIPHER_CRYPTO_NSS"
220         AC_MSG_RESULT([nss3])
221         AC_CHECK_LIB([nss3], [PK11_Decrypt], ,
222                      AC_MSG_ERROR([Library crypto not found. Install nss!"]))
223       else
224         CFLAGS="$CFLAGS -DSQLCIPHER_CRYPTO_OPENSSL"
225         BUILD_CFLAGS="$BUILD_CFLAGS -DSQLCIPHER_CRYPTO_OPENSSL"
226               AC_MSG_RESULT([openssl])
227         AC_CHECK_LIB([crypto], [HMAC_Init_ex], ,
228                      AC_MSG_ERROR([Library crypto not found. Install openssl!"]))
229       fi
230     fi
231   fi
234 ##########
235 # Do we want to allow a connection created in one thread to be used
236 # in another thread.  This does not work on many Linux systems (ex: RedHat 9)
237 # due to bugs in the threading implementations.  This is thus off by default.
239 AC_ARG_ENABLE(cross-thread-connections, 
240 AC_HELP_STRING([--enable-cross-thread-connections],[Allow connection sharing across threads]),,enable_xthreadconnect=no)
241 AC_MSG_CHECKING([whether to allow connections to be shared across threads])
242 if test "$enable_xthreadconnect" = "no"; then
243   XTHREADCONNECT=''
244   AC_MSG_RESULT([no])
245 else
246   XTHREADCONNECT='-DSQLITE_ALLOW_XTHREAD_CONNECT=1'
247   AC_MSG_RESULT([yes])
249 AC_SUBST(XTHREADCONNECT)
251 ##########
252 # Do we want to support release
254 AC_ARG_ENABLE(releasemode, 
255 AC_HELP_STRING([--enable-releasemode],[Support libtool link to release mode]),,enable_releasemode=no)
256 AC_MSG_CHECKING([whether to support shared library linked as release mode or not])
257 if test "$enable_releasemode" = "no"; then
258   ALLOWRELEASE=""
259   AC_MSG_RESULT([no])
260 else
261   ALLOWRELEASE="-release `cat $srcdir/VERSION`"
262   AC_MSG_RESULT([yes])
264 AC_SUBST(ALLOWRELEASE)
266 ##########
267 # Do we want temporary databases in memory
269 AC_ARG_ENABLE(tempstore, 
270 AC_HELP_STRING([--enable-tempstore],[Use an in-ram database for temporary tables (never,no,yes,always)]),,enable_tempstore=no)
271 AC_MSG_CHECKING([whether to use an in-ram database for temporary tables])
272 case "$enable_tempstore" in
273   never ) 
274     TEMP_STORE=0
275     AC_MSG_RESULT([never])
276   ;;
277   no ) 
278     TEMP_STORE=1
279     AC_MSG_RESULT([no])
280   ;;
281   yes ) 
282      TEMP_STORE=2
283     AC_MSG_RESULT([yes])
284   ;;
285   always ) 
286      TEMP_STORE=3
287     AC_MSG_RESULT([always])
288   ;;
289   * ) 
290     TEMP_STORE=1
291     AC_MSG_RESULT([no])
292   ;;
293 esac
295 AC_SUBST(TEMP_STORE)
297 ###########
298 # Lots of things are different if we are compiling for Windows using
299 # the CYGWIN environment.  So check for that special case and handle
300 # things accordingly.
302 AC_MSG_CHECKING([if executables have the .exe suffix])
303 if test "$config_BUILD_EXEEXT" = ".exe"; then
304   CYGWIN=yes
305   AC_MSG_RESULT(yes)
306 else
307   AC_MSG_RESULT(unknown)
309 if test "$CYGWIN" != "yes"; then
310   AC_CYGWIN
312 if test "$CYGWIN" = "yes"; then
313   BUILD_EXEEXT=.exe
314 else
315   BUILD_EXEEXT=$EXEEXT
317 if test x"$cross_compiling" = xno; then
318   TARGET_EXEEXT=$BUILD_EXEEXT
319 else
320   TARGET_EXEEXT=$config_TARGET_EXEEXT
322 if test "$TARGET_EXEEXT" = ".exe"; then
323   SQLITE_OS_UNIX=0
324   SQLITE_OS_WIN=1
325   CFLAGS="$CFLAGS -DSQLITE_OS_WIN=1"
326 else
327   SQLITE_OS_UNIX=1
328   SQLITE_OS_WIN=0
329   CFLAGS="$CFLAGS -DSQLITE_OS_UNIX=1"
332 AC_SUBST(BUILD_EXEEXT)
333 AC_SUBST(SQLITE_OS_UNIX)
334 AC_SUBST(SQLITE_OS_WIN)
335 AC_SUBST(TARGET_EXEEXT)
337 ##########
338 # Figure out all the parameters needed to compile against Tcl.
340 # This code is derived from the SC_PATH_TCLCONFIG and SC_LOAD_TCLCONFIG
341 # macros in the in the tcl.m4 file of the standard TCL distribution.
342 # Those macros could not be used directly since we have to make some
343 # minor changes to accomodate systems that do not have TCL installed.
345 AC_ARG_ENABLE(tcl, AC_HELP_STRING([--disable-tcl],[do not build TCL extension]),
346       [use_tcl=$enableval],[use_tcl=yes])
347 if test "${use_tcl}" = "yes" ; then
348   AC_ARG_WITH(tcl, AC_HELP_STRING([--with-tcl=DIR],[directory containing tcl configuration (tclConfig.sh)]), with_tclconfig=${withval})
349   AC_MSG_CHECKING([for Tcl configuration])
350   AC_CACHE_VAL(ac_cv_c_tclconfig,[
351     # First check to see if --with-tcl was specified.
352     if test x"${with_tclconfig}" != x ; then
353       if test -f "${with_tclconfig}/tclConfig.sh" ; then
354         ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
355       else
356         AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
357       fi
358     fi
360     # Start autosearch by asking tclsh
361     if test x"${ac_cv_c_tclconfig}" = x ; then
362       if test x"$cross_compiling" = xno; then
363         for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}`
364         do
365           if test -f "$i/tclConfig.sh" ; then
366             ac_cv_c_tclconfig="$i"
367             break
368           fi
369         done
370       fi
371     fi
373     # On ubuntu 14.10, $auto_path on tclsh is not quite correct.
374     # So try again after applying corrections.
375     if test x"${ac_cv_c_tclconfig}" = x ; then
376       if test x"$cross_compiling" = xno; then
377         for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD} | sed 's,/tcltk/tcl,/tcl,g'`
378         do
379           if test -f "$i/tclConfig.sh" ; then
380             ac_cv_c_tclconfig="$i"
381             break
382           fi
383         done
384       fi
385     fi
387     # Recent versions of Xcode on Macs hid the tclConfig.sh file
388     # in a strange place.
389     if test x"${ac_cv_c_tclconfig}" = x ; then
390       if test x"$cross_compiling" = xno; then
391         for i in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk/usr/lib
392         do
393           if test -f "$i/tclConfig.sh" ; then
394             ac_cv_c_tclconfig="$i"
395             break
396           fi
397         done
398       fi
399     fi
401     # then check for a private Tcl installation
402     if test x"${ac_cv_c_tclconfig}" = x ; then
403       for i in \
404             ../tcl \
405             `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
406             `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
407             `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
408             ../../tcl \
409             `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
410             `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
411             `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
412             ../../../tcl \
413             `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
414             `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
415             `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null`
416       do
417         if test -f "$i/unix/tclConfig.sh" ; then
418           ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
419           break
420         fi
421       done
422     fi
424     # check in a few common install locations
425     if test x"${ac_cv_c_tclconfig}" = x ; then
426       for i in \
427             `ls -d ${libdir} 2>/dev/null` \
428             `ls -d /usr/local/lib 2>/dev/null` \
429             `ls -d /usr/contrib/lib 2>/dev/null` \
430             `ls -d /usr/lib 2>/dev/null`
431       do
432         if test -f "$i/tclConfig.sh" ; then
433            ac_cv_c_tclconfig=`(cd $i; pwd)`
434            break
435         fi
436       done
437     fi
439     # check in a few other private locations
440     if test x"${ac_cv_c_tclconfig}" = x ; then
441       for i in \
442          ${srcdir}/../tcl \
443          `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
444          `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
445          `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null`
446       do
447         if test -f "$i/unix/tclConfig.sh" ; then
448           ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
449           break
450         fi
451       done
452     fi
453   ])
455   if test x"${ac_cv_c_tclconfig}" = x ; then
456     use_tcl=no
457     AC_MSG_WARN(Can't find Tcl configuration definitions)
458     AC_MSG_WARN(*** Without Tcl the regression tests cannot be executed ***)
459     AC_MSG_WARN(*** Consider using --with-tcl=... to define location of Tcl ***)
460   else
461     TCL_BIN_DIR=${ac_cv_c_tclconfig}
462     AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
464     AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
465     if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
466       AC_MSG_RESULT([loading])
467       . $TCL_BIN_DIR/tclConfig.sh
468     else
469       AC_MSG_RESULT([file not found])
470     fi
471     
472     #
473     # If the TCL_BIN_DIR is the build directory (not the install directory),
474     # then set the common variable name to the value of the build variables.
475     # For example, the variable TCL_LIB_SPEC will be set to the value
476     # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
477     # instead of TCL_BUILD_LIB_SPEC since it will work with both an
478     # installed and uninstalled version of Tcl.
479     #
480     
481     if test -f $TCL_BIN_DIR/Makefile ; then
482       TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
483       TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
484       TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
485     fi
486     
487     #
488     # eval is required to do the TCL_DBGX substitution
489     #
490     
491     eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
492     eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
493     eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
494     
495     eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
496     eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
497     eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
498     
499     AC_SUBST(TCL_VERSION)
500     AC_SUBST(TCL_BIN_DIR)
501     AC_SUBST(TCL_SRC_DIR)
502     AC_SUBST(TCL_INCLUDE_SPEC)
503     
504     AC_SUBST(TCL_LIB_FILE)
505     AC_SUBST(TCL_LIB_FLAG)
506     AC_SUBST(TCL_LIB_SPEC)
507     
508     AC_SUBST(TCL_STUB_LIB_FILE)
509     AC_SUBST(TCL_STUB_LIB_FLAG)
510     AC_SUBST(TCL_STUB_LIB_SPEC)
511     AC_SUBST(TCL_SHLIB_SUFFIX)
512   fi
514 if test "${use_tcl}" = "no" ; then
515   HAVE_TCL=""
516 else
517   HAVE_TCL=1
519 AC_SUBST(HAVE_TCL)
521 ##########
522 # Figure out what C libraries are required to compile programs
523 # that use "readline()" library.
525 TARGET_READLINE_LIBS=""
526 TARGET_READLINE_INC=""
527 TARGET_HAVE_READLINE=0
528 TARGET_HAVE_EDITLINE=0
529 AC_ARG_ENABLE([editline],
530         [AC_HELP_STRING([--enable-editline],[enable BSD editline support])],
531         [with_editline=$enableval],
532         [with_editline=auto])
533 AC_ARG_ENABLE([readline],
534         [AC_HELP_STRING([--disable-readline],[disable readline support])],
535         [with_readline=$enableval],
536         [with_readline=auto])
538 if test x"$with_editline" != xno; then
539         sLIBS=$LIBS
540         LIBS=""
541         TARGET_HAVE_EDITLINE=1
542         AC_SEARCH_LIBS(readline,edit,[with_readline=no],[TARGET_HAVE_EDITLINE=0])
543         TARGET_READLINE_LIBS=$LIBS
544         LIBS=$sLIBS
546 if test x"$with_readline" != xno; then
547         found="yes"
549         AC_ARG_WITH([readline-lib],
550                 [AC_HELP_STRING([--with-readline-lib],[specify readline library])],
551                 [with_readline_lib=$withval],
552                 [with_readline_lib="auto"])
553         if test "x$with_readline_lib" = xauto; then
554                 save_LIBS="$LIBS"
555                 LIBS=""
556                 AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap], [term_LIBS="$LIBS"], [term_LIBS=""])
557                 AC_CHECK_LIB([readline], [readline], [TARGET_READLINE_LIBS="-lreadline"], [found="no"])
558                 TARGET_READLINE_LIBS="$TARGET_READLINE_LIBS $term_LIBS"
559                 LIBS="$save_LIBS"
560         else
561                 TARGET_READLINE_LIBS="$with_readline_lib"
562         fi
564         AC_ARG_WITH([readline-inc],
565                 [AC_HELP_STRING([--with-readline-inc],[specify readline include paths])],
566                 [with_readline_inc=$withval],
567                 [with_readline_inc="auto"])
568         if test "x$with_readline_inc" = xauto; then
569                 AC_CHECK_HEADER(readline.h, [found="yes"], [
570                         found="no"
571                         if test "$cross_compiling" != yes; then
572                                 for dir in /usr /usr/local /usr/local/readline /usr/contrib /mingw; do
573                                         for subdir in include include/readline; do
574                                                 AC_CHECK_FILE($dir/$subdir/readline.h, found=yes)
575                                                 if test "$found" = "yes"; then
576                                                         TARGET_READLINE_INC="-I$dir/$subdir"
577                                                         break
578                                                 fi
579                                         done
580                                         test "$found" = "yes" && break
581                                 done
582                         fi
583                 ])
584         else
585                 TARGET_READLINE_INC="$with_readline_inc"
586         fi
588         if test x"$found" = xno; then
589                 TARGET_READLINE_LIBS=""
590                 TARGET_READLINE_INC=""
591                 TARGET_HAVE_READLINE=0
592         else
593                 TARGET_HAVE_READLINE=1
594         fi
597 AC_SUBST(TARGET_READLINE_LIBS)
598 AC_SUBST(TARGET_READLINE_INC)
599 AC_SUBST(TARGET_HAVE_READLINE)
600 AC_SUBST(TARGET_HAVE_EDITLINE)
602 ##########
603 # Figure out what C libraries are required to compile programs
604 # that use "fdatasync()" function.
606 AC_SEARCH_LIBS(fdatasync, [rt])
608 #########
609 # check for debug enabled
610 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain]))
611 if test "${enable_debug}" = "yes" ; then
612   TARGET_DEBUG="-DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0"
613 else
614   TARGET_DEBUG="-DNDEBUG"
616 AC_SUBST(TARGET_DEBUG)
618 #########
619 # See whether we should use the amalgamation to build
620 AC_ARG_ENABLE(amalgamation, AC_HELP_STRING([--disable-amalgamation],
621       [Disable the amalgamation and instead build all files separately]))
622 if test "${enable_amalgamation}" = "no" ; then
623   USE_AMALGAMATION=0
625 AC_SUBST(USE_AMALGAMATION)
627 #########
628 # By default, amalgamation sqlite3.c will have #line directives.
629 # This is a build option not shown by ./configure --help
630 # To control it, use configure option: amalgamation_line_macros=?
631 # where ? is no to suppress #line directives or yes to create them.
632 AMALGAMATION_LINE_MACROS=--linemacros=1
633 AC_ARG_VAR(amalgamation_line_macros,)
634 AC_SUBST(AMALGAMATION_LINE_MACROS)
635 if test "${amalgamation_line_macros+set}" = set; then :
636   enableval=$amalgamation_line_macros;
638 if test "${amalgamation_line_macros}" = "yes" ; then
639   AMALGAMATION_LINE_MACROS=--linemacros=1
641 if test "${amalgamation_line_macros}" = "no" ; then
642   AMALGAMATION_LINE_MACROS=--linemacros=0
645 #########
646 # Look for zlib.  Only needed by extensions and by the sqlite3.exe shell
647 AC_CHECK_HEADERS(zlib.h)
648 AC_SEARCH_LIBS(deflate, z, [HAVE_ZLIB="-DSQLITE_HAVE_ZLIB=1"], [HAVE_ZLIB=""])
649 AC_SUBST(HAVE_ZLIB)
651 #########
652 # See whether we should allow loadable extensions
653 AC_ARG_ENABLE(load-extension, AC_HELP_STRING([--disable-load-extension],
654       [Disable loading of external extensions]),,[enable_load_extension=yes])
655 if test "${enable_load_extension}" = "yes" ; then
656   OPT_FEATURE_FLAGS=""
657   AC_SEARCH_LIBS(dlopen, dl)
658 else
659   OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1"
662 ##########
663 # Do we want to support memsys3 and/or memsys5
665 AC_ARG_ENABLE(memsys5, 
666   AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]))
667 AC_MSG_CHECKING([whether to support MEMSYS5])
668 if test "${enable_memsys5}" = "yes"; then
669   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS5"
670   AC_MSG_RESULT([yes])
671 else
672   AC_MSG_RESULT([no])
674 AC_ARG_ENABLE(memsys3, 
675   AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]))
676 AC_MSG_CHECKING([whether to support MEMSYS3])
677 if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then
678   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS3"
679   AC_MSG_RESULT([yes])
680 else
681   AC_MSG_RESULT([no])
684 ########
685 # The --enable-extensions argument is short-hand to enable
686 # multiple extensions.
687 AC_ARG_ENABLE(all, AC_HELP_STRING([--enable-all],
688       [Enable FTS4, FTS5, Geopoly, JSON, RTree, Sessions]))
690 #########
691 # See whether we should enable Full Text Search extensions
692 AC_ARG_ENABLE(fts3, AC_HELP_STRING([--enable-fts3],
693       [Enable the FTS3 extension]))
694 if test "${enable_fts3}" = "yes" ; then
695   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS3"
697 AC_ARG_ENABLE(fts4, AC_HELP_STRING([--enable-fts4],
698       [Enable the FTS4 extension]))
699 if test "${enable_fts4}" = "yes" -o "${enable_all}" = "yes" ; then
700   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS4"
701   AC_SEARCH_LIBS([log],[m])
703 AC_ARG_ENABLE(fts5, AC_HELP_STRING([--enable-fts5],
704       [Enable the FTS5 extension]))
705 if test "${enable_fts5}" = "yes" -o "${enable_all}" = "yes" ; then
706   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS5"
707   AC_SEARCH_LIBS([log],[m])
710 #########
711 # See whether we should enable JSON1
712 AC_ARG_ENABLE(json1, AC_HELP_STRING([--enable-json1],[Enable the JSON1 extension]))
713 if test "${enable_json1}" = "yes" -o "${enable_all}" = "yes" ; then
714   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_JSON1"
717 #########
718 # See whether we should enable the LIMIT clause on UPDATE and DELETE
719 # statements.
720 AC_ARG_ENABLE(update-limit, AC_HELP_STRING([--enable-update-limit],
721       [Enable the UPDATE/DELETE LIMIT clause]))
722 if test "${enable_update_limit}" = "yes" ; then
723   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT"
726 #########
727 # See whether we should enable GEOPOLY
728 AC_ARG_ENABLE(geopoly, AC_HELP_STRING([--enable-geopoly],
729       [Enable the GEOPOLY extension]),
730       [enable_geopoly=yes],[enable_geopoly=no])
731 if test "${enable_geopoly}" = "yes" -o "${enable_all}" = "yes" ; then
732   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_GEOPOLY"
733   enable_rtree=yes
736 #########
737 # See whether we should enable RTREE
738 AC_ARG_ENABLE(rtree, AC_HELP_STRING([--enable-rtree],
739       [Enable the RTREE extension]))
740 if test "${enable_rtree}" = "yes" ; then
741   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_RTREE"
744 #########
745 # See whether we should enable the SESSION extension
746 AC_ARG_ENABLE(session, AC_HELP_STRING([--enable-session],
747       [Enable the SESSION extension]))
748 if test "${enable_session}" = "yes" -o "${enable_all}" = "yes" ; then
749   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_SESSION"
750   OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_PREUPDATE_HOOK"
753 #########
754 # attempt to duplicate any OMITS and ENABLES into the ${OPT_FEATURE_FLAGS} parameter
755 for option in $CFLAGS $CPPFLAGS
757   case $option in
758     -DSQLITE_OMIT*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
759     -DSQLITE_ENABLE*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
760   esac
761 done
762 AC_SUBST(OPT_FEATURE_FLAGS)
765 # attempt to remove any OMITS and ENABLES from the $(CFLAGS) parameter
766 ac_temp_CFLAGS=""
767 for option in $CFLAGS
769   case $option in
770     -DSQLITE_OMIT*) ;;
771     -DSQLITE_ENABLE*) ;;
772     *) ac_temp_CFLAGS="$ac_temp_CFLAGS $option";;
773   esac
774 done
775 CFLAGS=$ac_temp_CFLAGS
778 # attempt to remove any OMITS and ENABLES from the $(CPPFLAGS) parameter
779 ac_temp_CPPFLAGS=""
780 for option in $CPPFLAGS
782   case $option in
783     -DSQLITE_OMIT*) ;;
784     -DSQLITE_ENABLE*) ;;
785     *) ac_temp_CPPFLAGS="$ac_temp_CPPFLAGS $option";;
786   esac
787 done
788 CPPFLAGS=$ac_temp_CPPFLAGS
791 # attempt to remove any OMITS and ENABLES from the $(BUILD_CFLAGS) parameter
792 ac_temp_BUILD_CFLAGS=""
793 for option in $BUILD_CFLAGS
795   case $option in
796     -DSQLITE_OMIT*) ;;
797     -DSQLITE_ENABLE*) ;;
798     *) ac_temp_BUILD_CFLAGS="$ac_temp_BUILD_CFLAGS $option";;
799   esac
800 done
801 BUILD_CFLAGS=$ac_temp_BUILD_CFLAGS
804 #########
805 # See whether we should use GCOV
806 AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov],
807       [Enable coverage testing using gcov]))
808 if test "${use_gcov}" = "yes" ; then
809   USE_GCOV=1
810 else
811   USE_GCOV=0
813 AC_SUBST(USE_GCOV)
816 #########
817 # Output the config header
818 AC_CONFIG_HEADERS(config.h)
820 #########
821 # Generate the output files.
823 AC_SUBST(BUILD_CFLAGS)
824 AC_OUTPUT([
825 Makefile
826 sqlcipher.pc