]> git.ipfire.org Git - thirdparty/sqlite.git/blame - configure.ac
Fix issues in [/info/1e227ad9f413227f|LIMIT/OFFSET support for virtual tables].
[thirdparty/sqlite.git] / configure.ac
CommitLineData
71eb93ea 1#
71eb93ea 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#
7b5717e1 48# TCL_*
71eb93ea 49#
7b5717e1 50# Lots of values are read in from the tclConfig.sh script,
4b2266ae 51# if that script is available. This values are used for
52# constructing and installing the TCL extension.
71eb93ea 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#
71eb93ea 67# TARGET_EXEEXT
68#
69# The filename extension for executables on the
70# target platform. "" for Unix and ".exe" for windows.
71#
71eb93ea 72# This configure.in file is easy to reuse on other projects. Just
f0962c9f 73# change the argument to AC_INIT. And disable any features that
71eb93ea 74# you don't need (for example BLT) by erasing or commenting out
75# the corresponding code.
76#
d706adba 77AC_INIT([sqlite],m4_esyscmd(cat VERSION | tr -d '\n'))
71eb93ea 78
faa68dbb 79dnl Make sure the local VERSION file matches this configure script
6f050aa2 80sqlite_version_sanity_check=`cat $srcdir/VERSION | tr -d '\n'`
faa68dbb 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
71eb93ea 88#########
89# Programs needed
90#
f0962c9f 91LT_INIT
71eb93ea 92AC_PROG_INSTALL
93
636a995d 94#########
95# Enable large file support (if special flags are necessary)
96#
97AC_SYS_LARGEFILE
98
b87057f2 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
86c5a930 106AC_CHECK_HEADERS([sys/types.h stdlib.h stdint.h inttypes.h malloc.h])
5b0a9ebe 107
108#########
109# Figure out whether or not we have these functions
110#
e32a256a 111AC_CHECK_FUNCS([fdatasync gmtime_r isnan localtime_r localtime_s malloc_usable_size strchrnul usleep utime pread pread64 pwrite pwrite64])
5b0a9ebe 112
f3868117 113#########
114# By default, we use the amalgamation (this may be changed below...)
115#
116USE_AMALGAMATION=1
117
ab1c47b0 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#
0b11bcb3 123AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.7 tclsh8.6 tclsh8.5 tclsh], none)
f3868117 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
ab1c47b0 131AC_SUBST(TCLSH_CMD)
132
6d120f39 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
ef36ccd1 137 if test -d $i ; then
138 TCLLIBDIR=$i
139 break
140 fi
6d120f39 141 done
142 TCLLIBDIR="${TCLLIBDIR}/sqlite3"
143fi
144
b87057f2 145
71eb93ea 146#########
147# Set up an appropriate program prefix
148#
149if test "$program_prefix" = "NONE"; then
150 program_prefix=""
151fi
152AC_SUBST(program_prefix)
153
4b2266ae 154VERSION=[`cat $srcdir/VERSION | sed 's/^\([0-9]*\.*[0-9]*\).*/\1/'`]
695f0970 155AC_MSG_NOTICE(Version set to $VERSION)
c7e9383a 156AC_SUBST(VERSION)
4b2266ae 157RELEASE=`cat $srcdir/VERSION`
695f0970 158AC_MSG_NOTICE(Release set to $RELEASE)
4b2266ae 159AC_SUBST(RELEASE)
c7e9383a 160
14696188 161##########
162# Handle --with-wasi-sdk=DIR
163#
164# This must be early because it changes the toolchain.
165#
166AC_ARG_WITH(wasi-sdk,
167AS_HELP_STRING([--with-wasi-sdk=DIR],
168 [directory containing the WASI SDK. Triggers cross-compile to WASM.]), with_wasisdk=${withval})
169AC_MSG_CHECKING([for WASI SDK directory])
170AC_CACHE_VAL(ac_cv_c_wasi_sdk,[
171 # First check to see if --with-tcl was specified.
172 if test x"${with_wasi_sdk}" != x ; then
173 if ! test -d "${with_wasi_sdk}" ; then
174 AC_MSG_ERROR([${with_wasi_sdk} directory doesn't exist])
175 fi
3bcb5ce4 176 AC_MSG_RESULT([${with_wasi_sdk}: using wasi-sdk clang, disabling: tcl, CLI shell, DLL])
14696188 177 use_wasi_sdk=yes
178 else
179 use_wasi_sdk=no
180 fi
181])
182if test "${use_wasi_sdk}" = "no" ; then
183 HAVE_WASI_SDK=""
a7c49859 184 AC_MSG_RESULT([no])
14696188 185else
186 HAVE_WASI_SDK=1
187# Changing --host and --target have no effect here except to possibly
188# cause confusion. autoconf has finished processing them by this
189# point.
190#
191# host_alias=wasm32-wasi
192# target=wasm32-wasi
193#
194# Merely changing CC and LD to the wasi-sdk's is enough to get
195# sqlite3.o building in WASM format.
196 CC="${with_wasi_sdk}/bin/clang"
197 LD="${with_wasi_sdk}/bin/wasm-ld"
60a1a0f7 198 RANLIB="${with_wasi_sdk}/bin/llvm-ranlib"
14696188 199 cross_compiling=yes
200 enable_threadsafe=no
201 use_tcl=no
202 enable_tcl=no
3bcb5ce4 203 # libtool is apparently hard-coded to use gcc for linking DLLs, so
204 # we disable the DLL build...
205 enable_shared=no
a7c49859 206 AC_MSG_RESULT([yes])
14696188 207fi
208AC_SUBST(HAVE_WASI_SDK)
209
210
71eb93ea 211#########
212# Locate a compiler for the build machine. This compiler should
213# generate command-line programs that run on the build machine.
214#
c8a15308 215if test x"$cross_compiling" = xno; then
216 BUILD_CC=$CC
217 BUILD_CFLAGS=$CFLAGS
71eb93ea 218else
c8a15308 219 if test "${BUILD_CC+set}" != set; then
220 AC_CHECK_PROGS(BUILD_CC, gcc cc cl)
221 fi
222 if test "${BUILD_CFLAGS+set}" != set; then
223 BUILD_CFLAGS="-g"
224 fi
71eb93ea 225fi
226AC_SUBST(BUILD_CC)
71eb93ea 227
228##########
0f290bf7 229# Do we want to support multithreaded use of sqlite
b0208cca 230#
0f290bf7 231AC_ARG_ENABLE(threadsafe,
f0962c9f 232AS_HELP_STRING([--disable-threadsafe],[Disable mutexing]))
0f290bf7 233AC_MSG_CHECKING([whether to support threadsafe operation])
234if test "$enable_threadsafe" = "no"; then
5a3032b3 235 SQLITE_THREADSAFE=0
b0208cca 236 AC_MSG_RESULT([no])
237else
5a3032b3 238 SQLITE_THREADSAFE=1
b0208cca 239 AC_MSG_RESULT([yes])
240fi
5a3032b3 241AC_SUBST(SQLITE_THREADSAFE)
b0208cca 242
5a3032b3 243if test "$SQLITE_THREADSAFE" = "1"; then
ba60fbb6 244 AC_SEARCH_LIBS(pthread_create, pthread)
13c808a9 245 AC_SEARCH_LIBS(pthread_mutexattr_init, pthread)
65623c78 246fi
65623c78 247
3b5543c4 248##########
249# Do we want to support release
250#
251AC_ARG_ENABLE(releasemode,
f0962c9f 252AS_HELP_STRING([--enable-releasemode],[Support libtool link to release mode]),,enable_releasemode=no)
3b5543c4 253AC_MSG_CHECKING([whether to support shared library linked as release mode or not])
254if test "$enable_releasemode" = "no"; then
255 ALLOWRELEASE=""
256 AC_MSG_RESULT([no])
257else
0b47d340 258 ALLOWRELEASE="-release `cat $srcdir/VERSION`"
3b5543c4 259 AC_MSG_RESULT([yes])
260fi
261AC_SUBST(ALLOWRELEASE)
262
b0208cca 263##########
264# Do we want temporary databases in memory
265#
0f290bf7 266AC_ARG_ENABLE(tempstore,
f0962c9f 267AS_HELP_STRING([--enable-tempstore],[Use an in-ram database for temporary tables (never,no,yes,always)]),,enable_tempstore=no)
b0208cca 268AC_MSG_CHECKING([whether to use an in-ram database for temporary tables])
0f290bf7 269case "$enable_tempstore" in
b0208cca 270 never )
2dc96f9e 271 TEMP_STORE=0
b0208cca 272 AC_MSG_RESULT([never])
273 ;;
274 no )
2dc96f9e 275 TEMP_STORE=1
b0208cca 276 AC_MSG_RESULT([no])
277 ;;
54414bb4 278 yes )
8b72747d 279 TEMP_STORE=2
280 AC_MSG_RESULT([yes])
281 ;;
282 always )
54414bb4 283 TEMP_STORE=3
284 AC_MSG_RESULT([always])
285 ;;
b0208cca 286 * )
54414bb4 287 TEMP_STORE=1
8b72747d 288 AC_MSG_RESULT([no])
b0208cca 289 ;;
290esac
2dc96f9e 291
2dc96f9e 292AC_SUBST(TEMP_STORE)
b0208cca 293
71eb93ea 294###########
295# Lots of things are different if we are compiling for Windows using
296# the CYGWIN environment. So check for that special case and handle
297# things accordingly.
298#
299AC_MSG_CHECKING([if executables have the .exe suffix])
300if test "$config_BUILD_EXEEXT" = ".exe"; then
301 CYGWIN=yes
302 AC_MSG_RESULT(yes)
303else
304 AC_MSG_RESULT(unknown)
305fi
306if test "$CYGWIN" != "yes"; then
f0962c9f 307 m4_warn([obsolete],
308[AC_CYGWIN is obsolete: use AC_CANONICAL_HOST and check if $host_os
309matches *cygwin*])dnl
310AC_CANONICAL_HOST
311case $host_os in
312 *cygwin* ) CYGWIN=yes;;
313 * ) CYGWIN=no;;
314esac
315
71eb93ea 316fi
317if test "$CYGWIN" = "yes"; then
318 BUILD_EXEEXT=.exe
319else
6194a5fb 320 BUILD_EXEEXT=$EXEEXT
71eb93ea 321fi
c8a15308 322if test x"$cross_compiling" = xno; then
71eb93ea 323 TARGET_EXEEXT=$BUILD_EXEEXT
324else
325 TARGET_EXEEXT=$config_TARGET_EXEEXT
326fi
327if test "$TARGET_EXEEXT" = ".exe"; then
fe27b089 328 SQLITE_OS_UNIX=0
329 SQLITE_OS_WIN=1
330 CFLAGS="$CFLAGS -DSQLITE_OS_WIN=1"
71eb93ea 331else
29bafeab 332 SQLITE_OS_UNIX=1
333 SQLITE_OS_WIN=0
29bafeab 334 CFLAGS="$CFLAGS -DSQLITE_OS_UNIX=1"
71eb93ea 335fi
71eb93ea 336
337AC_SUBST(BUILD_EXEEXT)
29bafeab 338AC_SUBST(SQLITE_OS_UNIX)
339AC_SUBST(SQLITE_OS_WIN)
71eb93ea 340AC_SUBST(TARGET_EXEEXT)
341
71eb93ea 342##########
7b5717e1 343# Figure out all the parameters needed to compile against Tcl.
344#
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.
349#
f0962c9f 350AC_ARG_ENABLE(tcl, AS_HELP_STRING([--disable-tcl],[do not build TCL extension]),
7b5717e1 351 [use_tcl=$enableval],[use_tcl=yes])
352if test "${use_tcl}" = "yes" ; then
f0962c9f 353 AC_ARG_WITH(tcl, AS_HELP_STRING([--with-tcl=DIR],[directory containing tcl configuration (tclConfig.sh)]), with_tclconfig=${withval})
7b5717e1 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
fe7e82e4 364
365 # Start autosearch by asking tclsh
e74f4651 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
fe7e82e4 376 fi
377
f960a64d 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
391
68314743 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
405
7b5717e1 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
71eb93ea 428
7b5717e1 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
443
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 ])
459
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 ***)
71eb93ea 465 else
7b5717e1 466 TCL_BIN_DIR=${ac_cv_c_tclconfig}
467 AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
468
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
ab1c47b0 486 if test -f $TCL_BIN_DIR/Makefile ; then
7b5717e1 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)
7b5717e1 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)
d881ce8f 516 AC_SUBST(TCL_SHLIB_SUFFIX)
71eb93ea 517 fi
518fi
7b5717e1 519if test "${use_tcl}" = "no" ; then
520 HAVE_TCL=""
71eb93ea 521else
7b5717e1 522 HAVE_TCL=1
71eb93ea 523fi
7b5717e1 524AC_SUBST(HAVE_TCL)
71eb93ea 525
526##########
527# Figure out what C libraries are required to compile programs
528# that use "readline()" library.
529#
4c10a8a0 530TARGET_READLINE_LIBS=""
531TARGET_READLINE_INC=""
532TARGET_HAVE_READLINE=0
e44b835e 533TARGET_HAVE_EDITLINE=0
534AC_ARG_ENABLE([editline],
f0962c9f 535 [AS_HELP_STRING([--enable-editline],[enable BSD editline support])],
e44b835e 536 [with_editline=$enableval],
537 [with_editline=auto])
4c10a8a0 538AC_ARG_ENABLE([readline],
f0962c9f 539 [AS_HELP_STRING([--disable-readline],[disable readline support])],
4c10a8a0 540 [with_readline=$enableval],
541 [with_readline=auto])
542
e44b835e 543if 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
550fi
4c10a8a0 551if test x"$with_readline" != xno; then
552 found="yes"
553
554 AC_ARG_WITH([readline-lib],
f0962c9f 555 [AS_HELP_STRING([--with-readline-lib],[specify readline library])],
4c10a8a0 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
568
569 AC_ARG_WITH([readline-inc],
f0962c9f 570 [AS_HELP_STRING([--with-readline-inc],[specify readline include paths])],
4c10a8a0 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
592
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
71eb93ea 600fi
8525e2d9 601AC_ARG_WITH([linenoise],
602 [AS_HELP_STRING([--with-linenoise=DIR],[source directory for linenoise library])],
603 [with_linenoise=$withval],
604 [with_linenoise="no"])
605if test "x$with_linenoise" != "xno"; then
606 TARGET_HAVE_READLINE=0
607 TARGET_HAVE_EDITLINE=0
608 TARGET_HAVE_LINENOISE=1
609 TARGET_READLINE_INC="-I${with_linenoise}"
610 TARGET_READLINE_LIBS="${with_linenoise}/linenoise.c"
611 echo "using linenoise source code at ${with_linenoise}"
612else
613 TARGET_HAVE_LINENOISE=0
614 echo "not using linenoise"
615fi
4c10a8a0 616
71eb93ea 617AC_SUBST(TARGET_READLINE_LIBS)
4c10a8a0 618AC_SUBST(TARGET_READLINE_INC)
619AC_SUBST(TARGET_HAVE_READLINE)
e44b835e 620AC_SUBST(TARGET_HAVE_EDITLINE)
8525e2d9 621AC_SUBST(TARGET_HAVE_LINENOISE)
622
71eb93ea 623
f1878b4a 624##########
625# Figure out what C libraries are required to compile programs
626# that use "fdatasync()" function.
627#
f1878b4a 628AC_SEARCH_LIBS(fdatasync, [rt])
f1878b4a 629
9d9f76c0 630#########
631# check for debug enabled
f0962c9f 632AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],[enable debugging & verbose explain]))
24ec37c3 633AC_MSG_CHECKING([build type])
8fa622d6 634if test "${enable_debug}" = "yes" ; then
cc11526e 635 TARGET_DEBUG="-DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0 -Wall"
24ec37c3 636 AC_MSG_RESULT([debug])
9d9f76c0 637else
638 TARGET_DEBUG="-DNDEBUG"
24ec37c3 639 AC_MSG_RESULT([release])
9d9f76c0 640fi
641AC_SUBST(TARGET_DEBUG)
642
94984910 643#########
644# See whether we should use the amalgamation to build
f0962c9f 645
646AC_ARG_ENABLE(amalgamation, AS_HELP_STRING([--disable-amalgamation],
8fa622d6 647 [Disable the amalgamation and instead build all files separately]))
b13d5c25 648if test "${enable_amalgamation}" = "no" ; then
94984910 649 USE_AMALGAMATION=0
650fi
651AC_SUBST(USE_AMALGAMATION)
652
56c9311c 653#########
654# Look for zlib. Only needed by extensions and by the sqlite3.exe shell
655AC_CHECK_HEADERS(zlib.h)
656AC_SEARCH_LIBS(deflate, z, [HAVE_ZLIB="-DSQLITE_HAVE_ZLIB=1"], [HAVE_ZLIB=""])
657AC_SUBST(HAVE_ZLIB)
658
a4edab0e 659#########
660# See whether we should allow loadable extensions
f0962c9f 661AC_ARG_ENABLE(load-extension, AS_HELP_STRING([--disable-load-extension],
8fa622d6 662 [Disable loading of external extensions]),,[enable_load_extension=yes])
663if test "${enable_load_extension}" = "yes" ; then
fbededef 664 OPT_FEATURE_FLAGS=""
dbe4b88a 665 AC_SEARCH_LIBS(dlopen, dl)
a4edab0e 666else
fbededef 667 OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1"
a4edab0e 668fi
a4edab0e 669
f6e904bd 670##########
671# Do we want to support math functions
672#
e2ce8c44 673AC_ARG_ENABLE(math,
f0962c9f 674AS_HELP_STRING([--disable-math],[Disable math functions]))
f6e904bd 675AC_MSG_CHECKING([whether to support math functions])
42c93b5e 676if test "$enable_math" = "no"; then
677 AC_MSG_RESULT([no])
678else
f6e904bd 679 AC_MSG_RESULT([yes])
680 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MATH_FUNCTIONS"
681 AC_SEARCH_LIBS(ceil, m)
682fi
683
9dbf96bd 684##########
685# Do we want to support JSON functions
686#
687AC_ARG_ENABLE(json,
f0962c9f 688AS_HELP_STRING([--disable-json],[Disable JSON functions]))
9dbf96bd 689AC_MSG_CHECKING([whether to support JSON functions])
690if test "$enable_json" = "no"; then
691 AC_MSG_RESULT([no])
692 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_OMIT_JSON"
693else
694 AC_MSG_RESULT([yes])
695fi
42c93b5e 696
697########
698# The --enable-all argument is short-hand to enable
699# multiple extensions.
f0962c9f 700AC_ARG_ENABLE(all, AS_HELP_STRING([--enable-all],
9dbf96bd 701 [Enable FTS4, FTS5, Geopoly, RTree, Sessions]))
42c93b5e 702
c530b9c6 703##########
704# Do we want to support memsys3 and/or memsys5
705#
c530b9c6 706AC_ARG_ENABLE(memsys5,
f0962c9f 707 AS_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]))
c530b9c6 708AC_MSG_CHECKING([whether to support MEMSYS5])
26197d1b 709if test "${enable_memsys5}" = "yes"; then
8c9ed054 710 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS5"
c530b9c6 711 AC_MSG_RESULT([yes])
712else
713 AC_MSG_RESULT([no])
714fi
5d513ba0 715AC_ARG_ENABLE(memsys3,
f0962c9f 716 AS_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]))
5d513ba0 717AC_MSG_CHECKING([whether to support MEMSYS3])
718if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then
8c9ed054 719 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS3"
5d513ba0 720 AC_MSG_RESULT([yes])
721else
722 AC_MSG_RESULT([no])
723fi
c530b9c6 724
ce1d9f54 725#########
726# See whether we should enable Full Text Search extensions
f0962c9f 727AC_ARG_ENABLE(fts3, AS_HELP_STRING([--enable-fts3],
8fa622d6 728 [Enable the FTS3 extension]))
24ec37c3 729AC_MSG_CHECKING([whether to support FTS3])
ce1d9f54 730if test "${enable_fts3}" = "yes" ; then
8c9ed054 731 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS3"
24ec37c3 732 AC_MSG_RESULT([yes])
733else
734 AC_MSG_RESULT([no])
ce1d9f54 735fi
f0962c9f 736AC_ARG_ENABLE(fts4, AS_HELP_STRING([--enable-fts4],
8fa622d6 737 [Enable the FTS4 extension]))
24ec37c3 738AC_MSG_CHECKING([whether to support FTS4])
29368eab 739if test "${enable_fts4}" = "yes" -o "${enable_all}" = "yes" ; then
24ec37c3 740 AC_MSG_RESULT([yes])
8c9ed054 741 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS4"
ce1d9f54 742 AC_SEARCH_LIBS([log],[m])
24ec37c3 743else
744 AC_MSG_RESULT([no])
ce1d9f54 745fi
f0962c9f 746AC_ARG_ENABLE(fts5, AS_HELP_STRING([--enable-fts5],
8fa622d6 747 [Enable the FTS5 extension]))
24ec37c3 748AC_MSG_CHECKING([whether to support FTS5])
29368eab 749if test "${enable_fts5}" = "yes" -o "${enable_all}" = "yes" ; then
24ec37c3 750 AC_MSG_RESULT([yes])
8c9ed054 751 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS5"
ce1d9f54 752 AC_SEARCH_LIBS([log],[m])
24ec37c3 753else
754 AC_MSG_RESULT([no])
ce1d9f54 755fi
756
83bebddb 757#########
758# See whether we should enable the LIMIT clause on UPDATE and DELETE
759# statements.
f0962c9f 760AC_ARG_ENABLE(update-limit, AS_HELP_STRING([--enable-update-limit],
8fa622d6 761 [Enable the UPDATE/DELETE LIMIT clause]))
24ec37c3 762AC_MSG_CHECKING([whether to support LIMIT on UPDATE and DELETE statements])
b13c3a33 763if test "${enable_update_limit}" = "yes" ; then
83bebddb 764 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT"
24ec37c3 765 AC_MSG_RESULT([yes])
766else
767 AC_MSG_RESULT([no])
83bebddb 768fi
769
748b8fda 770#########
771# See whether we should enable GEOPOLY
f0962c9f 772AC_ARG_ENABLE(geopoly, AS_HELP_STRING([--enable-geopoly],
748b8fda 773 [Enable the GEOPOLY extension]),
774 [enable_geopoly=yes],[enable_geopoly=no])
24ec37c3 775AC_MSG_CHECKING([whether to support GEOPOLY])
29368eab 776if test "${enable_geopoly}" = "yes" -o "${enable_all}" = "yes" ; then
748b8fda 777 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_GEOPOLY"
778 enable_rtree=yes
24ec37c3 779 AC_MSG_RESULT([yes])
780else
781 AC_MSG_RESULT([no])
748b8fda 782fi
783
ce1d9f54 784#########
785# See whether we should enable RTREE
f0962c9f 786AC_ARG_ENABLE(rtree, AS_HELP_STRING([--enable-rtree],
8fa622d6 787 [Enable the RTREE extension]))
24ec37c3 788AC_MSG_CHECKING([whether to support RTREE])
ce1d9f54 789if test "${enable_rtree}" = "yes" ; then
8c9ed054 790 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_RTREE"
24ec37c3 791 AC_MSG_RESULT([yes])
792else
793 AC_MSG_RESULT([no])
ce1d9f54 794fi
795
5e18d402 796#########
797# See whether we should enable the SESSION extension
f0962c9f 798AC_ARG_ENABLE(session, AS_HELP_STRING([--enable-session],
8fa622d6 799 [Enable the SESSION extension]))
24ec37c3 800AC_MSG_CHECKING([whether to support SESSION])
29368eab 801if test "${enable_session}" = "yes" -o "${enable_all}" = "yes" ; then
8c9ed054 802 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_SESSION"
803 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_PREUPDATE_HOOK"
24ec37c3 804 AC_MSG_RESULT([yes])
805else
806 AC_MSG_RESULT([no])
5e18d402 807fi
808
aac7b93e 809#########
8c9ed054 810# attempt to duplicate any OMITS and ENABLES into the ${OPT_FEATURE_FLAGS} parameter
fbededef 811for option in $CFLAGS $CPPFLAGS
812do
813 case $option in
33a14781 814 -DSQLITE_OMIT*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
b1cd7308 815 -DSQLITE_ENABLE*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
fbededef 816 esac
817done
818AC_SUBST(OPT_FEATURE_FLAGS)
819
820
b1cd7308 821# attempt to remove any OMITS and ENABLES from the $(CFLAGS) parameter
fbededef 822ac_temp_CFLAGS=""
823for option in $CFLAGS
824do
825 case $option in
826 -DSQLITE_OMIT*) ;;
b1cd7308 827 -DSQLITE_ENABLE*) ;;
33a14781 828 *) ac_temp_CFLAGS="$ac_temp_CFLAGS $option";;
fbededef 829 esac
830done
831CFLAGS=$ac_temp_CFLAGS
832
833
b1cd7308 834# attempt to remove any OMITS and ENABLES from the $(CPPFLAGS) parameter
fbededef 835ac_temp_CPPFLAGS=""
836for option in $CPPFLAGS
837do
838 case $option in
839 -DSQLITE_OMIT*) ;;
b1cd7308 840 -DSQLITE_ENABLE*) ;;
33a14781 841 *) ac_temp_CPPFLAGS="$ac_temp_CPPFLAGS $option";;
fbededef 842 esac
843done
844CPPFLAGS=$ac_temp_CPPFLAGS
845
846
b1cd7308 847# attempt to remove any OMITS and ENABLES from the $(BUILD_CFLAGS) parameter
fbededef 848ac_temp_BUILD_CFLAGS=""
849for option in $BUILD_CFLAGS
850do
851 case $option in
852 -DSQLITE_OMIT*) ;;
b1cd7308 853 -DSQLITE_ENABLE*) ;;
33a14781 854 *) ac_temp_BUILD_CFLAGS="$ac_temp_BUILD_CFLAGS $option";;
fbededef 855 esac
856done
857BUILD_CFLAGS=$ac_temp_BUILD_CFLAGS
858
859
860#########
861# See whether we should use GCOV
f0962c9f 862AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov],
8fa622d6 863 [Enable coverage testing using gcov]))
aac7b93e 864if test "${use_gcov}" = "yes" ; then
865 USE_GCOV=1
866else
867 USE_GCOV=0
868fi
869AC_SUBST(USE_GCOV)
870
4a0a98d3 871#########
872# Enable/disabled amalagamation line macros
873########
874AMALGAMATION_LINE_MACROS=--linemacros=0
875if test "${amalgamation_line_macros}" = "yes" ; then
876 AMALGAMATION_LINE_MACROS=--linemacros=1
877fi
878if test "${amalgamation_line_macros}" = "no" ; then
879 AMALGAMATION_LINE_MACROS=--linemacros=0
880fi
881AC_SUBST(AMALGAMATION_LINE_MACROS)
af6edf55 882
b87057f2 883#########
884# Output the config header
a4b2f419 885AC_CONFIG_HEADERS(sqlite_cfg.h)
b87057f2 886
71eb93ea 887#########
888# Generate the output files.
889#
8390bc38 890AC_SUBST(BUILD_CFLAGS)
f0962c9f 891AC_CONFIG_FILES([
c7e9383a 892Makefile
12b34444 893sqlite3.pc
c7e9383a 894])
f0962c9f 895AC_OUTPUT