xref: /sqlite-3.40.0/configure.ac (revision a4b2f419)
1#
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:
6#
7#    srcdir
8#
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.
12#
13#    bindir
14#
15#        The name of the directory where executables should be
16#        written by the "install" target of the makefile.
17#
18#    program_prefix
19#
20#        Add this prefix to the names of all executables that run
21#        on the target machine.  Default: ""
22#
23#    ENABLE_SHARED
24#
25#        True if shared libraries should be generated.
26#
27#    BUILD_CC
28#
29#        The name of a command that is used to convert C
30#        source files into executables that run on the build
31#        platform.
32#
33#    BUILD_CFLAGS
34#
35#        Switches that the build compiler needs in order to construct
36#        command-line programs.
37#
38#    BUILD_LIBS
39#
40#        Libraries that the build compiler needs in order to construct
41#        command-line programs.
42#
43#    BUILD_EXEEXT
44#
45#        The filename extension for executables on the build
46#        platform.  "" for Unix and ".exe" for Windows.
47#
48#    TCL_*
49#
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.
53#
54#    TARGET_READLINE_LIBS
55#
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".
60#
61#    TARGET_READLINE_INC
62#
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.
66#
67#    TARGET_EXEEXT
68#
69#        The filename extension for executables on the
70#        target platform.  "" for Unix and ".exe" for windows.
71#
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.
76#
77AC_INIT(sqlite, m4_esyscmd([cat VERSION | tr -d '\n']))
78
79dnl Make sure the local VERSION file matches this configure script
80sqlite_version_sanity_check=`cat $srcdir/VERSION | tr -d '\n'`
81if test "$PACKAGE_VERSION" != "$sqlite_version_sanity_check" ; then
82AC_MSG_ERROR([configure script is out of date:
83 configure \$PACKAGE_VERSION = $PACKAGE_VERSION
84 top level VERSION file     = $sqlite_version_sanity_check
85please regen with autoconf])
86fi
87
88#########
89# Programs needed
90#
91AC_PROG_LIBTOOL
92AC_PROG_INSTALL
93
94#########
95# Enable large file support (if special flags are necessary)
96#
97AC_SYS_LARGEFILE
98
99#########
100# Check for needed/wanted data types
101AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, intptr_t, uint8_t,
102                uint16_t, uint32_t, uint64_t, uintptr_t])
103
104#########
105# Check for needed/wanted headers
106AC_CHECK_HEADERS([sys/types.h stdlib.h stdint.h inttypes.h malloc.h])
107
108#########
109# Figure out whether or not we have these functions
110#
111AC_CHECK_FUNCS([fdatasync gmtime_r isnan localtime_r localtime_s malloc_usable_size strchrnul usleep utime pread pread64 pwrite pwrite64])
112
113#########
114# By default, we use the amalgamation (this may be changed below...)
115#
116USE_AMALGAMATION=1
117
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?
122#
123AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.7 tclsh8.6 tclsh8.5 tclsh], none)
124if 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"
130fi
131AC_SUBST(TCLSH_CMD)
132
133AC_ARG_VAR([TCLLIBDIR], [Where to install tcl plugin])
134if 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"
143fi
144
145
146#########
147# Set up an appropriate program prefix
148#
149if test "$program_prefix" = "NONE"; then
150  program_prefix=""
151fi
152AC_SUBST(program_prefix)
153
154VERSION=[`cat $srcdir/VERSION | sed 's/^\([0-9]*\.*[0-9]*\).*/\1/'`]
155AC_MSG_NOTICE(Version set to $VERSION)
156AC_SUBST(VERSION)
157RELEASE=`cat $srcdir/VERSION`
158AC_MSG_NOTICE(Release set to $RELEASE)
159AC_SUBST(RELEASE)
160
161#########
162# Locate a compiler for the build machine.  This compiler should
163# generate command-line programs that run on the build machine.
164#
165if test x"$cross_compiling" = xno; then
166	BUILD_CC=$CC
167	BUILD_CFLAGS=$CFLAGS
168else
169	if test "${BUILD_CC+set}" != set; then
170		AC_CHECK_PROGS(BUILD_CC, gcc cc cl)
171	fi
172	if test "${BUILD_CFLAGS+set}" != set; then
173		BUILD_CFLAGS="-g"
174	fi
175fi
176AC_SUBST(BUILD_CC)
177
178##########
179# Do we want to support multithreaded use of sqlite
180#
181AC_ARG_ENABLE(threadsafe,
182AC_HELP_STRING([--disable-threadsafe],[Disable mutexing]))
183AC_MSG_CHECKING([whether to support threadsafe operation])
184if test "$enable_threadsafe" = "no"; then
185  SQLITE_THREADSAFE=0
186  AC_MSG_RESULT([no])
187else
188  SQLITE_THREADSAFE=1
189  AC_MSG_RESULT([yes])
190fi
191AC_SUBST(SQLITE_THREADSAFE)
192
193if test "$SQLITE_THREADSAFE" = "1"; then
194  AC_SEARCH_LIBS(pthread_create, pthread)
195  AC_SEARCH_LIBS(pthread_mutexattr_init, pthread)
196fi
197
198##########
199# Do we want to support release
200#
201AC_ARG_ENABLE(releasemode,
202AC_HELP_STRING([--enable-releasemode],[Support libtool link to release mode]),,enable_releasemode=no)
203AC_MSG_CHECKING([whether to support shared library linked as release mode or not])
204if test "$enable_releasemode" = "no"; then
205  ALLOWRELEASE=""
206  AC_MSG_RESULT([no])
207else
208  ALLOWRELEASE="-release `cat $srcdir/VERSION`"
209  AC_MSG_RESULT([yes])
210fi
211AC_SUBST(ALLOWRELEASE)
212
213##########
214# Do we want temporary databases in memory
215#
216AC_ARG_ENABLE(tempstore,
217AC_HELP_STRING([--enable-tempstore],[Use an in-ram database for temporary tables (never,no,yes,always)]),,enable_tempstore=no)
218AC_MSG_CHECKING([whether to use an in-ram database for temporary tables])
219case "$enable_tempstore" in
220  never )
221    TEMP_STORE=0
222    AC_MSG_RESULT([never])
223  ;;
224  no )
225    TEMP_STORE=1
226    AC_MSG_RESULT([no])
227  ;;
228  yes )
229     TEMP_STORE=2
230    AC_MSG_RESULT([yes])
231  ;;
232  always )
233     TEMP_STORE=3
234    AC_MSG_RESULT([always])
235  ;;
236  * )
237    TEMP_STORE=1
238    AC_MSG_RESULT([no])
239  ;;
240esac
241
242AC_SUBST(TEMP_STORE)
243
244###########
245# Lots of things are different if we are compiling for Windows using
246# the CYGWIN environment.  So check for that special case and handle
247# things accordingly.
248#
249AC_MSG_CHECKING([if executables have the .exe suffix])
250if test "$config_BUILD_EXEEXT" = ".exe"; then
251  CYGWIN=yes
252  AC_MSG_RESULT(yes)
253else
254  AC_MSG_RESULT(unknown)
255fi
256if test "$CYGWIN" != "yes"; then
257  AC_CYGWIN
258fi
259if test "$CYGWIN" = "yes"; then
260  BUILD_EXEEXT=.exe
261else
262  BUILD_EXEEXT=$EXEEXT
263fi
264if test x"$cross_compiling" = xno; then
265  TARGET_EXEEXT=$BUILD_EXEEXT
266else
267  TARGET_EXEEXT=$config_TARGET_EXEEXT
268fi
269if test "$TARGET_EXEEXT" = ".exe"; then
270  SQLITE_OS_UNIX=0
271  SQLITE_OS_WIN=1
272  CFLAGS="$CFLAGS -DSQLITE_OS_WIN=1"
273else
274  SQLITE_OS_UNIX=1
275  SQLITE_OS_WIN=0
276  CFLAGS="$CFLAGS -DSQLITE_OS_UNIX=1"
277fi
278
279AC_SUBST(BUILD_EXEEXT)
280AC_SUBST(SQLITE_OS_UNIX)
281AC_SUBST(SQLITE_OS_WIN)
282AC_SUBST(TARGET_EXEEXT)
283
284##########
285# Figure out all the parameters needed to compile against Tcl.
286#
287# This code is derived from the SC_PATH_TCLCONFIG and SC_LOAD_TCLCONFIG
288# macros in the in the tcl.m4 file of the standard TCL distribution.
289# Those macros could not be used directly since we have to make some
290# minor changes to accomodate systems that do not have TCL installed.
291#
292AC_ARG_ENABLE(tcl, AC_HELP_STRING([--disable-tcl],[do not build TCL extension]),
293      [use_tcl=$enableval],[use_tcl=yes])
294if test "${use_tcl}" = "yes" ; then
295  AC_ARG_WITH(tcl, AC_HELP_STRING([--with-tcl=DIR],[directory containing tcl configuration (tclConfig.sh)]), with_tclconfig=${withval})
296  AC_MSG_CHECKING([for Tcl configuration])
297  AC_CACHE_VAL(ac_cv_c_tclconfig,[
298    # First check to see if --with-tcl was specified.
299    if test x"${with_tclconfig}" != x ; then
300      if test -f "${with_tclconfig}/tclConfig.sh" ; then
301        ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
302      else
303        AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
304      fi
305    fi
306
307    # Start autosearch by asking tclsh
308    if test x"${ac_cv_c_tclconfig}" = x ; then
309      if test x"$cross_compiling" = xno; then
310        for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}`
311        do
312          if test -f "$i/tclConfig.sh" ; then
313            ac_cv_c_tclconfig="$i"
314            break
315          fi
316        done
317      fi
318    fi
319
320    # On ubuntu 14.10, $auto_path on tclsh is not quite correct.
321    # So try again after applying corrections.
322    if test x"${ac_cv_c_tclconfig}" = x ; then
323      if test x"$cross_compiling" = xno; then
324        for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD} | sed 's,/tcltk/tcl,/tcl,g'`
325        do
326          if test -f "$i/tclConfig.sh" ; then
327            ac_cv_c_tclconfig="$i"
328            break
329          fi
330        done
331      fi
332    fi
333
334    # Recent versions of Xcode on Macs hid the tclConfig.sh file
335    # in a strange place.
336    if test x"${ac_cv_c_tclconfig}" = x ; then
337      if test x"$cross_compiling" = xno; then
338        for i in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk/usr/lib
339        do
340          if test -f "$i/tclConfig.sh" ; then
341            ac_cv_c_tclconfig="$i"
342            break
343          fi
344        done
345      fi
346    fi
347
348    # then check for a private Tcl installation
349    if test x"${ac_cv_c_tclconfig}" = x ; then
350      for i in \
351            ../tcl \
352            `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
353            `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
354            `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
355            ../../tcl \
356            `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
357            `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
358            `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
359            ../../../tcl \
360            `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
361            `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
362            `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null`
363      do
364        if test -f "$i/unix/tclConfig.sh" ; then
365          ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
366          break
367        fi
368      done
369    fi
370
371    # check in a few common install locations
372    if test x"${ac_cv_c_tclconfig}" = x ; then
373      for i in \
374            `ls -d ${libdir} 2>/dev/null` \
375            `ls -d /usr/local/lib 2>/dev/null` \
376            `ls -d /usr/contrib/lib 2>/dev/null` \
377            `ls -d /usr/lib 2>/dev/null`
378      do
379        if test -f "$i/tclConfig.sh" ; then
380           ac_cv_c_tclconfig=`(cd $i; pwd)`
381           break
382        fi
383      done
384    fi
385
386    # check in a few other private locations
387    if test x"${ac_cv_c_tclconfig}" = x ; then
388      for i in \
389         ${srcdir}/../tcl \
390         `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
391         `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
392         `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null`
393      do
394        if test -f "$i/unix/tclConfig.sh" ; then
395          ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
396          break
397        fi
398      done
399    fi
400  ])
401
402  if test x"${ac_cv_c_tclconfig}" = x ; then
403    use_tcl=no
404    AC_MSG_WARN(Can't find Tcl configuration definitions)
405    AC_MSG_WARN(*** Without Tcl the regression tests cannot be executed ***)
406    AC_MSG_WARN(*** Consider using --with-tcl=... to define location of Tcl ***)
407  else
408    TCL_BIN_DIR=${ac_cv_c_tclconfig}
409    AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
410
411    AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
412    if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
413      AC_MSG_RESULT([loading])
414      . $TCL_BIN_DIR/tclConfig.sh
415    else
416      AC_MSG_RESULT([file not found])
417    fi
418
419    #
420    # If the TCL_BIN_DIR is the build directory (not the install directory),
421    # then set the common variable name to the value of the build variables.
422    # For example, the variable TCL_LIB_SPEC will be set to the value
423    # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
424    # instead of TCL_BUILD_LIB_SPEC since it will work with both an
425    # installed and uninstalled version of Tcl.
426    #
427
428    if test -f $TCL_BIN_DIR/Makefile ; then
429      TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
430      TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
431      TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
432    fi
433
434    #
435    # eval is required to do the TCL_DBGX substitution
436    #
437
438    eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
439    eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
440    eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
441
442    eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
443    eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
444    eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
445
446    AC_SUBST(TCL_VERSION)
447    AC_SUBST(TCL_BIN_DIR)
448    AC_SUBST(TCL_SRC_DIR)
449    AC_SUBST(TCL_INCLUDE_SPEC)
450
451    AC_SUBST(TCL_LIB_FILE)
452    AC_SUBST(TCL_LIB_FLAG)
453    AC_SUBST(TCL_LIB_SPEC)
454
455    AC_SUBST(TCL_STUB_LIB_FILE)
456    AC_SUBST(TCL_STUB_LIB_FLAG)
457    AC_SUBST(TCL_STUB_LIB_SPEC)
458    AC_SUBST(TCL_SHLIB_SUFFIX)
459  fi
460fi
461if test "${use_tcl}" = "no" ; then
462  HAVE_TCL=""
463else
464  HAVE_TCL=1
465fi
466AC_SUBST(HAVE_TCL)
467
468##########
469# Figure out what C libraries are required to compile programs
470# that use "readline()" library.
471#
472TARGET_READLINE_LIBS=""
473TARGET_READLINE_INC=""
474TARGET_HAVE_READLINE=0
475TARGET_HAVE_EDITLINE=0
476AC_ARG_ENABLE([editline],
477	[AC_HELP_STRING([--enable-editline],[enable BSD editline support])],
478	[with_editline=$enableval],
479	[with_editline=auto])
480AC_ARG_ENABLE([readline],
481	[AC_HELP_STRING([--disable-readline],[disable readline support])],
482	[with_readline=$enableval],
483	[with_readline=auto])
484
485if test x"$with_editline" != xno; then
486        sLIBS=$LIBS
487        LIBS=""
488	TARGET_HAVE_EDITLINE=1
489	AC_SEARCH_LIBS(readline,edit,[with_readline=no],[TARGET_HAVE_EDITLINE=0])
490        TARGET_READLINE_LIBS=$LIBS
491        LIBS=$sLIBS
492fi
493if test x"$with_readline" != xno; then
494	found="yes"
495
496	AC_ARG_WITH([readline-lib],
497		[AC_HELP_STRING([--with-readline-lib],[specify readline library])],
498		[with_readline_lib=$withval],
499		[with_readline_lib="auto"])
500	if test "x$with_readline_lib" = xauto; then
501		save_LIBS="$LIBS"
502		LIBS=""
503		AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap], [term_LIBS="$LIBS"], [term_LIBS=""])
504		AC_CHECK_LIB([readline], [readline], [TARGET_READLINE_LIBS="-lreadline"], [found="no"])
505		TARGET_READLINE_LIBS="$TARGET_READLINE_LIBS $term_LIBS"
506		LIBS="$save_LIBS"
507	else
508		TARGET_READLINE_LIBS="$with_readline_lib"
509	fi
510
511	AC_ARG_WITH([readline-inc],
512		[AC_HELP_STRING([--with-readline-inc],[specify readline include paths])],
513		[with_readline_inc=$withval],
514		[with_readline_inc="auto"])
515	if test "x$with_readline_inc" = xauto; then
516		AC_CHECK_HEADER(readline.h, [found="yes"], [
517			found="no"
518			if test "$cross_compiling" != yes; then
519				for dir in /usr /usr/local /usr/local/readline /usr/contrib /mingw; do
520					for subdir in include include/readline; do
521						AC_CHECK_FILE($dir/$subdir/readline.h, found=yes)
522						if test "$found" = "yes"; then
523							TARGET_READLINE_INC="-I$dir/$subdir"
524							break
525						fi
526					done
527					test "$found" = "yes" && break
528				done
529			fi
530		])
531	else
532		TARGET_READLINE_INC="$with_readline_inc"
533	fi
534
535	if test x"$found" = xno; then
536		TARGET_READLINE_LIBS=""
537		TARGET_READLINE_INC=""
538		TARGET_HAVE_READLINE=0
539	else
540		TARGET_HAVE_READLINE=1
541	fi
542fi
543
544AC_SUBST(TARGET_READLINE_LIBS)
545AC_SUBST(TARGET_READLINE_INC)
546AC_SUBST(TARGET_HAVE_READLINE)
547AC_SUBST(TARGET_HAVE_EDITLINE)
548
549##########
550# Figure out what C libraries are required to compile programs
551# that use "fdatasync()" function.
552#
553AC_SEARCH_LIBS(fdatasync, [rt])
554
555#########
556# check for debug enabled
557AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain]))
558AC_MSG_CHECKING([build type])
559if test "${enable_debug}" = "yes" ; then
560  TARGET_DEBUG="-DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0"
561  AC_MSG_RESULT([debug])
562else
563  TARGET_DEBUG="-DNDEBUG"
564  AC_MSG_RESULT([release])
565fi
566AC_SUBST(TARGET_DEBUG)
567
568#########
569# See whether we should use the amalgamation to build
570AC_ARG_ENABLE(amalgamation, AC_HELP_STRING([--disable-amalgamation],
571      [Disable the amalgamation and instead build all files separately]))
572if test "${enable_amalgamation}" = "no" ; then
573  USE_AMALGAMATION=0
574fi
575AC_SUBST(USE_AMALGAMATION)
576
577#########
578# Look for zlib.  Only needed by extensions and by the sqlite3.exe shell
579AC_CHECK_HEADERS(zlib.h)
580AC_SEARCH_LIBS(deflate, z, [HAVE_ZLIB="-DSQLITE_HAVE_ZLIB=1"], [HAVE_ZLIB=""])
581AC_SUBST(HAVE_ZLIB)
582
583#########
584# See whether we should allow loadable extensions
585AC_ARG_ENABLE(load-extension, AC_HELP_STRING([--disable-load-extension],
586      [Disable loading of external extensions]),,[enable_load_extension=yes])
587if test "${enable_load_extension}" = "yes" ; then
588  OPT_FEATURE_FLAGS=""
589  AC_SEARCH_LIBS(dlopen, dl)
590else
591  OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1"
592fi
593
594##########
595# Do we want to support math functions
596#
597AC_ARG_ENABLE(math,
598AC_HELP_STRING([--disable-math],[Disable math functions]))
599AC_MSG_CHECKING([whether to support math functions])
600if test "$enable_math" = "no"; then
601  AC_MSG_RESULT([no])
602else
603  AC_MSG_RESULT([yes])
604  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MATH_FUNCTIONS"
605  AC_SEARCH_LIBS(ceil, m)
606fi
607
608##########
609# Do we want to support JSON functions
610#
611AC_ARG_ENABLE(json,
612AC_HELP_STRING([--disable-json],[Disable JSON functions]))
613AC_MSG_CHECKING([whether to support JSON functions])
614if test "$enable_json" = "no"; then
615  AC_MSG_RESULT([no])
616  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_OMIT_JSON"
617else
618  AC_MSG_RESULT([yes])
619fi
620
621########
622# The --enable-all argument is short-hand to enable
623# multiple extensions.
624AC_ARG_ENABLE(all, AC_HELP_STRING([--enable-all],
625      [Enable FTS4, FTS5, Geopoly, RTree, Sessions]))
626
627##########
628# Do we want to support memsys3 and/or memsys5
629#
630AC_ARG_ENABLE(memsys5,
631  AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]))
632AC_MSG_CHECKING([whether to support MEMSYS5])
633if test "${enable_memsys5}" = "yes"; then
634  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS5"
635  AC_MSG_RESULT([yes])
636else
637  AC_MSG_RESULT([no])
638fi
639AC_ARG_ENABLE(memsys3,
640  AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]))
641AC_MSG_CHECKING([whether to support MEMSYS3])
642if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then
643  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS3"
644  AC_MSG_RESULT([yes])
645else
646  AC_MSG_RESULT([no])
647fi
648
649#########
650# See whether we should enable Full Text Search extensions
651AC_ARG_ENABLE(fts3, AC_HELP_STRING([--enable-fts3],
652      [Enable the FTS3 extension]))
653AC_MSG_CHECKING([whether to support FTS3])
654if test "${enable_fts3}" = "yes" ; then
655  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS3"
656  AC_MSG_RESULT([yes])
657else
658  AC_MSG_RESULT([no])
659fi
660AC_ARG_ENABLE(fts4, AC_HELP_STRING([--enable-fts4],
661      [Enable the FTS4 extension]))
662AC_MSG_CHECKING([whether to support FTS4])
663if test "${enable_fts4}" = "yes" -o "${enable_all}" = "yes" ; then
664  AC_MSG_RESULT([yes])
665  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS4"
666  AC_SEARCH_LIBS([log],[m])
667else
668  AC_MSG_RESULT([no])
669fi
670AC_ARG_ENABLE(fts5, AC_HELP_STRING([--enable-fts5],
671      [Enable the FTS5 extension]))
672AC_MSG_CHECKING([whether to support FTS5])
673if test "${enable_fts5}" = "yes" -o "${enable_all}" = "yes" ; then
674  AC_MSG_RESULT([yes])
675  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS5"
676  AC_SEARCH_LIBS([log],[m])
677else
678  AC_MSG_RESULT([no])
679fi
680
681#########
682# See whether we should enable the LIMIT clause on UPDATE and DELETE
683# statements.
684AC_ARG_ENABLE(update-limit, AC_HELP_STRING([--enable-update-limit],
685      [Enable the UPDATE/DELETE LIMIT clause]))
686AC_MSG_CHECKING([whether to support LIMIT on UPDATE and DELETE statements])
687if test "${enable_update_limit}" = "yes" ; then
688  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT"
689  AC_MSG_RESULT([yes])
690else
691  AC_MSG_RESULT([no])
692fi
693
694#########
695# See whether we should enable GEOPOLY
696AC_ARG_ENABLE(geopoly, AC_HELP_STRING([--enable-geopoly],
697      [Enable the GEOPOLY extension]),
698      [enable_geopoly=yes],[enable_geopoly=no])
699AC_MSG_CHECKING([whether to support GEOPOLY])
700if test "${enable_geopoly}" = "yes" -o "${enable_all}" = "yes" ; then
701  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_GEOPOLY"
702  enable_rtree=yes
703  AC_MSG_RESULT([yes])
704else
705  AC_MSG_RESULT([no])
706fi
707
708#########
709# See whether we should enable RTREE
710AC_ARG_ENABLE(rtree, AC_HELP_STRING([--enable-rtree],
711      [Enable the RTREE extension]))
712AC_MSG_CHECKING([whether to support RTREE])
713if test "${enable_rtree}" = "yes" ; then
714  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_RTREE"
715  AC_MSG_RESULT([yes])
716else
717  AC_MSG_RESULT([no])
718fi
719
720#########
721# See whether we should enable the SESSION extension
722AC_ARG_ENABLE(session, AC_HELP_STRING([--enable-session],
723      [Enable the SESSION extension]))
724AC_MSG_CHECKING([whether to support SESSION])
725if test "${enable_session}" = "yes" -o "${enable_all}" = "yes" ; then
726  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_SESSION"
727  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_PREUPDATE_HOOK"
728  AC_MSG_RESULT([yes])
729else
730  AC_MSG_RESULT([no])
731fi
732
733#########
734# attempt to duplicate any OMITS and ENABLES into the ${OPT_FEATURE_FLAGS} parameter
735for option in $CFLAGS $CPPFLAGS
736do
737  case $option in
738    -DSQLITE_OMIT*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
739    -DSQLITE_ENABLE*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
740  esac
741done
742AC_SUBST(OPT_FEATURE_FLAGS)
743
744
745# attempt to remove any OMITS and ENABLES from the $(CFLAGS) parameter
746ac_temp_CFLAGS=""
747for option in $CFLAGS
748do
749  case $option in
750    -DSQLITE_OMIT*) ;;
751    -DSQLITE_ENABLE*) ;;
752    *) ac_temp_CFLAGS="$ac_temp_CFLAGS $option";;
753  esac
754done
755CFLAGS=$ac_temp_CFLAGS
756
757
758# attempt to remove any OMITS and ENABLES from the $(CPPFLAGS) parameter
759ac_temp_CPPFLAGS=""
760for option in $CPPFLAGS
761do
762  case $option in
763    -DSQLITE_OMIT*) ;;
764    -DSQLITE_ENABLE*) ;;
765    *) ac_temp_CPPFLAGS="$ac_temp_CPPFLAGS $option";;
766  esac
767done
768CPPFLAGS=$ac_temp_CPPFLAGS
769
770
771# attempt to remove any OMITS and ENABLES from the $(BUILD_CFLAGS) parameter
772ac_temp_BUILD_CFLAGS=""
773for option in $BUILD_CFLAGS
774do
775  case $option in
776    -DSQLITE_OMIT*) ;;
777    -DSQLITE_ENABLE*) ;;
778    *) ac_temp_BUILD_CFLAGS="$ac_temp_BUILD_CFLAGS $option";;
779  esac
780done
781BUILD_CFLAGS=$ac_temp_BUILD_CFLAGS
782
783
784#########
785# See whether we should use GCOV
786AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov],
787      [Enable coverage testing using gcov]))
788if test "${use_gcov}" = "yes" ; then
789  USE_GCOV=1
790else
791  USE_GCOV=0
792fi
793AC_SUBST(USE_GCOV)
794
795#########
796# Enable/disabled amalagamation line macros
797########
798AMALGAMATION_LINE_MACROS=--linemacros=0
799if test "${amalgamation_line_macros}" = "yes" ; then
800  AMALGAMATION_LINE_MACROS=--linemacros=1
801fi
802if test "${amalgamation_line_macros}" = "no" ; then
803  AMALGAMATION_LINE_MACROS=--linemacros=0
804fi
805AC_SUBST(AMALGAMATION_LINE_MACROS)
806
807#########
808# Output the config header
809AC_CONFIG_HEADERS(sqlite_cfg.h)
810
811#########
812# Generate the output files.
813#
814AC_SUBST(BUILD_CFLAGS)
815AC_OUTPUT([
816Makefile
817sqlite3.pc
818])
819