blob: 8a58d3dd33bbfa4b1c9e6b816035beee5625b2a4 [file] [log] [blame]
drh71eb93e2001-09-28 01:34:43 +00001#
drh71eb93e2001-09-28 01:34:43 +00002# 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#
drh7b5717e2004-11-25 13:50:01 +000048# TCL_*
drh71eb93e2001-09-28 01:34:43 +000049#
drh7b5717e2004-11-25 13:50:01 +000050# Lots of values are read in from the tclConfig.sh script,
drh4b2266a2004-11-27 15:52:16 +000051# if that script is available. This values are used for
52# constructing and installing the TCL extension.
drh71eb93e2001-09-28 01:34:43 +000053#
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#
drh71eb93e2001-09-28 01:34:43 +000067# TARGET_EXEEXT
68#
69# The filename extension for executables on the
70# target platform. "" for Unix and ".exe" for windows.
71#
drh71eb93e2001-09-28 01:34:43 +000072# 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#
mlcreechb87057f2008-03-06 07:19:20 +000077AC_INIT(sqlite, m4_esyscmd([cat VERSION | tr -d '\n']))
drh71eb93e2001-09-28 01:34:43 +000078
vapierfaa68db2009-04-01 07:38:31 +000079dnl Make sure the local VERSION file matches this configure script
danielk19776f050aa2009-04-25 08:39:14 +000080sqlite_version_sanity_check=`cat $srcdir/VERSION | tr -d '\n'`
vapierfaa68db2009-04-01 07:38:31 +000081if 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
drh71eb93e2001-09-28 01:34:43 +000088#########
89# Programs needed
90#
91AC_PROG_LIBTOOL
92AC_PROG_INSTALL
93
94#########
mlcreech636a9952008-05-05 22:52:56 +000095# Enable large file support (if special flags are necessary)
96#
97AC_SYS_LARGEFILE
98
99#########
mlcreechb87057f2008-03-06 07:19:20 +0000100# 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
drh86c5a932012-02-08 12:13:28 +0000106AC_CHECK_HEADERS([sys/types.h stdlib.h stdint.h inttypes.h malloc.h])
mlcreech5b0a9eb2008-03-09 01:38:09 +0000107
108#########
109# Figure out whether or not we have these functions
110#
drhe32a2562016-03-04 02:38:00 +0000111AC_CHECK_FUNCS([fdatasync gmtime_r isnan localtime_r localtime_s malloc_usable_size strchrnul usleep utime pread pread64 pwrite pwrite64])
mlcreech5b0a9eb2008-03-09 01:38:09 +0000112
mlcreechab1c47b2008-03-09 02:51:10 +0000113#########
mlcreechf3868112008-03-11 18:03:30 +0000114# By default, we use the amalgamation (this may be changed below...)
115#
116USE_AMALGAMATION=1
117
118#########
mlcreechab1c47b2008-03-09 02:51:10 +0000119# 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#
drh0b11bcb2017-09-22 00:24:44 +0000123AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.7 tclsh8.6 tclsh8.5 tclsh], none)
mlcreechf3868112008-03-11 18:03:30 +0000124if 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
mlcreechab1c47b2008-03-09 02:51:10 +0000131AC_SUBST(TCLSH_CMD)
132
vapier6d120f32009-01-28 04:46:14 +0000133AC_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
danef36ccd2021-01-12 14:19:12 +0000137 if test -d $i ; then
138 TCLLIBDIR=$i
139 break
140 fi
vapier6d120f32009-01-28 04:46:14 +0000141 done
142 TCLLIBDIR="${TCLLIBDIR}/sqlite3"
143fi
144
mlcreechb87057f2008-03-06 07:19:20 +0000145
146#########
drh71eb93e2001-09-28 01:34:43 +0000147# Set up an appropriate program prefix
148#
149if test "$program_prefix" = "NONE"; then
150 program_prefix=""
151fi
152AC_SUBST(program_prefix)
153
drh4b2266a2004-11-27 15:52:16 +0000154VERSION=[`cat $srcdir/VERSION | sed 's/^\([0-9]*\.*[0-9]*\).*/\1/'`]
vapier695f0972009-01-26 21:43:16 +0000155AC_MSG_NOTICE(Version set to $VERSION)
a.rottmannc7e93832003-03-24 09:39:32 +0000156AC_SUBST(VERSION)
drh4b2266a2004-11-27 15:52:16 +0000157RELEASE=`cat $srcdir/VERSION`
vapier695f0972009-01-26 21:43:16 +0000158AC_MSG_NOTICE(Release set to $RELEASE)
drh4b2266a2004-11-27 15:52:16 +0000159AC_SUBST(RELEASE)
a.rottmannc7e93832003-03-24 09:39:32 +0000160
drh71eb93e2001-09-28 01:34:43 +0000161#########
drh71eb93e2001-09-28 01:34:43 +0000162# Locate a compiler for the build machine. This compiler should
163# generate command-line programs that run on the build machine.
164#
vapierc8a15302007-02-17 14:31:55 +0000165if test x"$cross_compiling" = xno; then
166 BUILD_CC=$CC
167 BUILD_CFLAGS=$CFLAGS
drh71eb93e2001-09-28 01:34:43 +0000168else
vapierc8a15302007-02-17 14:31:55 +0000169 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
drh71eb93e2001-09-28 01:34:43 +0000175fi
176AC_SUBST(BUILD_CC)
drh71eb93e2001-09-28 01:34:43 +0000177
178##########
dougcurrie0f290bf2004-06-21 18:57:29 +0000179# Do we want to support multithreaded use of sqlite
drh71eb93e2001-09-28 01:34:43 +0000180#
dougcurrie0f290bf2004-06-21 18:57:29 +0000181AC_ARG_ENABLE(threadsafe,
drh8fa622d2018-06-11 19:47:14 +0000182AC_HELP_STRING([--disable-threadsafe],[Disable mutexing]))
dougcurrie0f290bf2004-06-21 18:57:29 +0000183AC_MSG_CHECKING([whether to support threadsafe operation])
184if test "$enable_threadsafe" = "no"; then
drh5a3032b2007-09-03 16:12:09 +0000185 SQLITE_THREADSAFE=0
paulb0208cc2003-04-13 18:26:49 +0000186 AC_MSG_RESULT([no])
187else
drh5a3032b2007-09-03 16:12:09 +0000188 SQLITE_THREADSAFE=1
paulb0208cc2003-04-13 18:26:49 +0000189 AC_MSG_RESULT([yes])
190fi
drh5a3032b2007-09-03 16:12:09 +0000191AC_SUBST(SQLITE_THREADSAFE)
paulb0208cc2003-04-13 18:26:49 +0000192
drh5a3032b2007-09-03 16:12:09 +0000193if test "$SQLITE_THREADSAFE" = "1"; then
drhba60fbb2016-01-28 02:47:32 +0000194 AC_SEARCH_LIBS(pthread_create, pthread)
drh13c808a2016-01-13 21:23:48 +0000195 AC_SEARCH_LIBS(pthread_mutexattr_init, pthread)
dougcurrie65623c72004-09-20 14:57:23 +0000196fi
dougcurrie65623c72004-09-20 14:57:23 +0000197
paulb0208cc2003-04-13 18:26:49 +0000198##########
xdong3b5543c2003-09-23 00:36:50 +0000199# Do we want to support release
200#
201AC_ARG_ENABLE(releasemode,
drh94e4f822006-02-15 02:00:25 +0000202AC_HELP_STRING([--enable-releasemode],[Support libtool link to release mode]),,enable_releasemode=no)
xdong3b5543c2003-09-23 00:36:50 +0000203AC_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
drh0b47d342007-11-27 14:50:06 +0000208 ALLOWRELEASE="-release `cat $srcdir/VERSION`"
xdong3b5543c2003-09-23 00:36:50 +0000209 AC_MSG_RESULT([yes])
210fi
211AC_SUBST(ALLOWRELEASE)
212
213##########
paulb0208cc2003-04-13 18:26:49 +0000214# Do we want temporary databases in memory
215#
dougcurrie0f290bf2004-06-21 18:57:29 +0000216AC_ARG_ENABLE(tempstore,
drh94e4f822006-02-15 02:00:25 +0000217AC_HELP_STRING([--enable-tempstore],[Use an in-ram database for temporary tables (never,no,yes,always)]),,enable_tempstore=no)
paulb0208cc2003-04-13 18:26:49 +0000218AC_MSG_CHECKING([whether to use an in-ram database for temporary tables])
dougcurrie0f290bf2004-06-21 18:57:29 +0000219case "$enable_tempstore" in
paulb0208cc2003-04-13 18:26:49 +0000220 never )
paul2dc96f92003-04-20 11:46:34 +0000221 TEMP_STORE=0
paulb0208cc2003-04-13 18:26:49 +0000222 AC_MSG_RESULT([never])
223 ;;
224 no )
paul2dc96f92003-04-20 11:46:34 +0000225 TEMP_STORE=1
paulb0208cc2003-04-13 18:26:49 +0000226 AC_MSG_RESULT([no])
227 ;;
drh54414bb2005-10-10 00:05:50 +0000228 yes )
drh8b727472009-01-19 18:18:40 +0000229 TEMP_STORE=2
230 AC_MSG_RESULT([yes])
231 ;;
232 always )
drh54414bb2005-10-10 00:05:50 +0000233 TEMP_STORE=3
234 AC_MSG_RESULT([always])
235 ;;
paulb0208cc2003-04-13 18:26:49 +0000236 * )
drh54414bb2005-10-10 00:05:50 +0000237 TEMP_STORE=1
drh8b727472009-01-19 18:18:40 +0000238 AC_MSG_RESULT([no])
paulb0208cc2003-04-13 18:26:49 +0000239 ;;
240esac
paul2dc96f92003-04-20 11:46:34 +0000241
paul2dc96f92003-04-20 11:46:34 +0000242AC_SUBST(TEMP_STORE)
paulb0208cc2003-04-13 18:26:49 +0000243
drh71eb93e2001-09-28 01:34:43 +0000244###########
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
dougcurrie6194a5f2003-12-19 20:09:51 +0000262 BUILD_EXEEXT=$EXEEXT
drh71eb93e2001-09-28 01:34:43 +0000263fi
vapierc8a15302007-02-17 14:31:55 +0000264if test x"$cross_compiling" = xno; then
drh71eb93e2001-09-28 01:34:43 +0000265 TARGET_EXEEXT=$BUILD_EXEEXT
266else
267 TARGET_EXEEXT=$config_TARGET_EXEEXT
268fi
269if test "$TARGET_EXEEXT" = ".exe"; then
mistachkinfe27b082013-08-28 18:06:26 +0000270 SQLITE_OS_UNIX=0
271 SQLITE_OS_WIN=1
272 CFLAGS="$CFLAGS -DSQLITE_OS_WIN=1"
drh71eb93e2001-09-28 01:34:43 +0000273else
danielk197729bafea2008-06-26 10:41:19 +0000274 SQLITE_OS_UNIX=1
275 SQLITE_OS_WIN=0
danielk197729bafea2008-06-26 10:41:19 +0000276 CFLAGS="$CFLAGS -DSQLITE_OS_UNIX=1"
drh71eb93e2001-09-28 01:34:43 +0000277fi
drh71eb93e2001-09-28 01:34:43 +0000278
279AC_SUBST(BUILD_EXEEXT)
danielk197729bafea2008-06-26 10:41:19 +0000280AC_SUBST(SQLITE_OS_UNIX)
281AC_SUBST(SQLITE_OS_WIN)
drh71eb93e2001-09-28 01:34:43 +0000282AC_SUBST(TARGET_EXEEXT)
283
284##########
drh7b5717e2004-11-25 13:50:01 +0000285# Figure out all the parameters needed to compile against Tcl.
drh71eb93e2001-09-28 01:34:43 +0000286#
drh7b5717e2004-11-25 13:50:01 +0000287# 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.
drh71eb93e2001-09-28 01:34:43 +0000291#
drh94e4f822006-02-15 02:00:25 +0000292AC_ARG_ENABLE(tcl, AC_HELP_STRING([--disable-tcl],[do not build TCL extension]),
drh7b5717e2004-11-25 13:50:01 +0000293 [use_tcl=$enableval],[use_tcl=yes])
294if test "${use_tcl}" = "yes" ; then
drh94e4f822006-02-15 02:00:25 +0000295 AC_ARG_WITH(tcl, AC_HELP_STRING([--with-tcl=DIR],[directory containing tcl configuration (tclConfig.sh)]), with_tclconfig=${withval})
drh7b5717e2004-11-25 13:50:01 +0000296 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
drh71eb93e2001-09-28 01:34:43 +0000305 fi
vapierfe7e82e2009-01-26 21:39:33 +0000306
307 # Start autosearch by asking tclsh
drhe74f4652012-08-15 16:06:54 +0000308 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
vapierfe7e82e2009-01-26 21:39:33 +0000318 fi
319
drhf960a642015-05-30 22:57:49 +0000320 # 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
drh68314742016-05-23 00:10:58 +0000334 # 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
drh7b5717e2004-11-25 13:50:01 +0000348 # 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
mlcreechab1c47b2008-03-09 02:51:10 +0000428 if test -f $TCL_BIN_DIR/Makefile ; then
drh7b5717e2004-11-25 13:50:01 +0000429 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)
drh7b5717e2004-11-25 13:50:01 +0000449 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)
drhd881ce82015-03-31 17:01:52 +0000458 AC_SUBST(TCL_SHLIB_SUFFIX)
drh7b5717e2004-11-25 13:50:01 +0000459 fi
drh71eb93e2001-09-28 01:34:43 +0000460fi
drh7b5717e2004-11-25 13:50:01 +0000461if test "${use_tcl}" = "no" ; then
462 HAVE_TCL=""
463else
464 HAVE_TCL=1
drh71eb93e2001-09-28 01:34:43 +0000465fi
drh7b5717e2004-11-25 13:50:01 +0000466AC_SUBST(HAVE_TCL)
drh71eb93e2001-09-28 01:34:43 +0000467
468##########
469# Figure out what C libraries are required to compile programs
470# that use "readline()" library.
471#
vapier4c10a8a2007-02-17 14:28:26 +0000472TARGET_READLINE_LIBS=""
473TARGET_READLINE_INC=""
474TARGET_HAVE_READLINE=0
drhe44b8352015-10-30 14:25:57 +0000475TARGET_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])
vapier4c10a8a2007-02-17 14:28:26 +0000480AC_ARG_ENABLE([readline],
drhe44b8352015-10-30 14:25:57 +0000481 [AC_HELP_STRING([--disable-readline],[disable readline support])],
vapier4c10a8a2007-02-17 14:28:26 +0000482 [with_readline=$enableval],
483 [with_readline=auto])
484
drhe44b8352015-10-30 14:25:57 +0000485if 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
vapier4c10a8a2007-02-17 14:28:26 +0000493if 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
drh71eb93e2001-09-28 01:34:43 +0000542fi
vapier4c10a8a2007-02-17 14:28:26 +0000543
drh71eb93e2001-09-28 01:34:43 +0000544AC_SUBST(TARGET_READLINE_LIBS)
vapier4c10a8a2007-02-17 14:28:26 +0000545AC_SUBST(TARGET_READLINE_INC)
546AC_SUBST(TARGET_HAVE_READLINE)
drhe44b8352015-10-30 14:25:57 +0000547AC_SUBST(TARGET_HAVE_EDITLINE)
drh71eb93e2001-09-28 01:34:43 +0000548
549##########
drhf1878b42006-01-23 18:06:52 +0000550# Figure out what C libraries are required to compile programs
551# that use "fdatasync()" function.
552#
drhf1878b42006-01-23 18:06:52 +0000553AC_SEARCH_LIBS(fdatasync, [rt])
drhf1878b42006-01-23 18:06:52 +0000554
drh71eb93e2001-09-28 01:34:43 +0000555#########
tpoindex9d9f76c2005-01-03 21:28:56 +0000556# check for debug enabled
drh8fa622d2018-06-11 19:47:14 +0000557AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain]))
558if test "${enable_debug}" = "yes" ; then
drh32d0eba2017-04-05 10:54:14 +0000559 TARGET_DEBUG="-DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0"
tpoindex9d9f76c2005-01-03 21:28:56 +0000560else
561 TARGET_DEBUG="-DNDEBUG"
562fi
563AC_SUBST(TARGET_DEBUG)
564
565#########
mlcreech94984912008-03-04 19:03:08 +0000566# See whether we should use the amalgamation to build
567AC_ARG_ENABLE(amalgamation, AC_HELP_STRING([--disable-amalgamation],
drh8fa622d2018-06-11 19:47:14 +0000568 [Disable the amalgamation and instead build all files separately]))
danb13d5c22020-07-07 19:24:34 +0000569if test "${enable_amalgamation}" = "no" ; then
mlcreech94984912008-03-04 19:03:08 +0000570 USE_AMALGAMATION=0
571fi
572AC_SUBST(USE_AMALGAMATION)
573
574#########
drh56c93112017-11-24 16:55:48 +0000575# Look for zlib. Only needed by extensions and by the sqlite3.exe shell
576AC_CHECK_HEADERS(zlib.h)
577AC_SEARCH_LIBS(deflate, z, [HAVE_ZLIB="-DSQLITE_HAVE_ZLIB=1"], [HAVE_ZLIB=""])
578AC_SUBST(HAVE_ZLIB)
579
580#########
mlcreecha4edab02008-03-06 04:14:17 +0000581# See whether we should allow loadable extensions
drh05c7e0b2015-01-10 14:27:17 +0000582AC_ARG_ENABLE(load-extension, AC_HELP_STRING([--disable-load-extension],
drh8fa622d2018-06-11 19:47:14 +0000583 [Disable loading of external extensions]),,[enable_load_extension=yes])
584if test "${enable_load_extension}" = "yes" ; then
shanefbedede2008-07-22 05:05:01 +0000585 OPT_FEATURE_FLAGS=""
drhdbe4b882011-06-20 18:00:17 +0000586 AC_SEARCH_LIBS(dlopen, dl)
mlcreecha4edab02008-03-06 04:14:17 +0000587else
shanefbedede2008-07-22 05:05:01 +0000588 OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1"
mlcreecha4edab02008-03-06 04:14:17 +0000589fi
mlcreecha4edab02008-03-06 04:14:17 +0000590
drhc530b9c2016-07-25 11:27:22 +0000591##########
drhf6e904b2020-12-07 17:15:32 +0000592# Do we want to support math functions
593#
drhe2ce8c42020-12-07 21:19:17 +0000594AC_ARG_ENABLE(math,
drhf6e904b2020-12-07 17:15:32 +0000595AC_HELP_STRING([--disable-math],[Disable math functions]))
596AC_MSG_CHECKING([whether to support math functions])
597if test "$enable_math" = "no"; then
598 AC_MSG_RESULT([no])
599else
600 AC_MSG_RESULT([yes])
601 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MATH_FUNCTIONS"
602 AC_SEARCH_LIBS(ceil, m)
603fi
604
605##########
drhc530b9c2016-07-25 11:27:22 +0000606# Do we want to support memsys3 and/or memsys5
607#
drhc530b9c2016-07-25 11:27:22 +0000608AC_ARG_ENABLE(memsys5,
drh8fa622d2018-06-11 19:47:14 +0000609 AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]))
drhc530b9c2016-07-25 11:27:22 +0000610AC_MSG_CHECKING([whether to support MEMSYS5])
drh26197d12016-07-25 11:32:09 +0000611if test "${enable_memsys5}" = "yes"; then
drh8c9ed052017-05-29 17:43:06 +0000612 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS5"
drhc530b9c2016-07-25 11:27:22 +0000613 AC_MSG_RESULT([yes])
614else
615 AC_MSG_RESULT([no])
616fi
drh5d513ba2016-07-25 11:57:21 +0000617AC_ARG_ENABLE(memsys3,
drh8fa622d2018-06-11 19:47:14 +0000618 AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]))
drh5d513ba2016-07-25 11:57:21 +0000619AC_MSG_CHECKING([whether to support MEMSYS3])
620if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then
drh8c9ed052017-05-29 17:43:06 +0000621 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS3"
drh5d513ba2016-07-25 11:57:21 +0000622 AC_MSG_RESULT([yes])
623else
624 AC_MSG_RESULT([no])
625fi
drhc530b9c2016-07-25 11:27:22 +0000626
drh29368ea2019-12-28 13:17:11 +0000627########
628# The --enable-extensions argument is short-hand to enable
629# multiple extensions.
630AC_ARG_ENABLE(all, AC_HELP_STRING([--enable-all],
631 [Enable FTS4, FTS5, Geopoly, JSON, RTree, Sessions]))
632
mlcreechaac7b932008-04-01 02:45:22 +0000633#########
drhce1d9f52015-10-09 12:48:33 +0000634# See whether we should enable Full Text Search extensions
635AC_ARG_ENABLE(fts3, AC_HELP_STRING([--enable-fts3],
drh8fa622d2018-06-11 19:47:14 +0000636 [Enable the FTS3 extension]))
drhce1d9f52015-10-09 12:48:33 +0000637if test "${enable_fts3}" = "yes" ; then
drh8c9ed052017-05-29 17:43:06 +0000638 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS3"
drhce1d9f52015-10-09 12:48:33 +0000639fi
640AC_ARG_ENABLE(fts4, AC_HELP_STRING([--enable-fts4],
drh8fa622d2018-06-11 19:47:14 +0000641 [Enable the FTS4 extension]))
drh29368ea2019-12-28 13:17:11 +0000642if test "${enable_fts4}" = "yes" -o "${enable_all}" = "yes" ; then
drh8c9ed052017-05-29 17:43:06 +0000643 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS4"
drhce1d9f52015-10-09 12:48:33 +0000644 AC_SEARCH_LIBS([log],[m])
645fi
646AC_ARG_ENABLE(fts5, AC_HELP_STRING([--enable-fts5],
drh8fa622d2018-06-11 19:47:14 +0000647 [Enable the FTS5 extension]))
drh29368ea2019-12-28 13:17:11 +0000648if test "${enable_fts5}" = "yes" -o "${enable_all}" = "yes" ; then
drh8c9ed052017-05-29 17:43:06 +0000649 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS5"
drhce1d9f52015-10-09 12:48:33 +0000650 AC_SEARCH_LIBS([log],[m])
651fi
652
653#########
654# See whether we should enable JSON1
drh8fa622d2018-06-11 19:47:14 +0000655AC_ARG_ENABLE(json1, AC_HELP_STRING([--enable-json1],[Enable the JSON1 extension]))
drh29368ea2019-12-28 13:17:11 +0000656if test "${enable_json1}" = "yes" -o "${enable_all}" = "yes" ; then
drh8c9ed052017-05-29 17:43:06 +0000657 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_JSON1"
drhce1d9f52015-10-09 12:48:33 +0000658fi
659
660#########
drh83bebdd2017-08-28 17:00:12 +0000661# See whether we should enable the LIMIT clause on UPDATE and DELETE
662# statements.
663AC_ARG_ENABLE(update-limit, AC_HELP_STRING([--enable-update-limit],
drh8fa622d2018-06-11 19:47:14 +0000664 [Enable the UPDATE/DELETE LIMIT clause]))
drhb13c3a32020-06-15 14:38:57 +0000665if test "${enable_update_limit}" = "yes" ; then
drh83bebdd2017-08-28 17:00:12 +0000666 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT"
667fi
668
669#########
drh748b8fd2018-05-25 19:22:47 +0000670# See whether we should enable GEOPOLY
671AC_ARG_ENABLE(geopoly, AC_HELP_STRING([--enable-geopoly],
672 [Enable the GEOPOLY extension]),
673 [enable_geopoly=yes],[enable_geopoly=no])
drh29368ea2019-12-28 13:17:11 +0000674if test "${enable_geopoly}" = "yes" -o "${enable_all}" = "yes" ; then
drh748b8fd2018-05-25 19:22:47 +0000675 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_GEOPOLY"
676 enable_rtree=yes
677fi
678
679#########
drhce1d9f52015-10-09 12:48:33 +0000680# See whether we should enable RTREE
681AC_ARG_ENABLE(rtree, AC_HELP_STRING([--enable-rtree],
drh8fa622d2018-06-11 19:47:14 +0000682 [Enable the RTREE extension]))
drhce1d9f52015-10-09 12:48:33 +0000683if test "${enable_rtree}" = "yes" ; then
drh8c9ed052017-05-29 17:43:06 +0000684 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_RTREE"
drhce1d9f52015-10-09 12:48:33 +0000685fi
686
687#########
drh5e18d402016-05-03 13:14:18 +0000688# See whether we should enable the SESSION extension
689AC_ARG_ENABLE(session, AC_HELP_STRING([--enable-session],
drh8fa622d2018-06-11 19:47:14 +0000690 [Enable the SESSION extension]))
drh29368ea2019-12-28 13:17:11 +0000691if test "${enable_session}" = "yes" -o "${enable_all}" = "yes" ; then
drh8c9ed052017-05-29 17:43:06 +0000692 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_SESSION"
693 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_PREUPDATE_HOOK"
drh5e18d402016-05-03 13:14:18 +0000694fi
695
696#########
drh8c9ed052017-05-29 17:43:06 +0000697# attempt to duplicate any OMITS and ENABLES into the ${OPT_FEATURE_FLAGS} parameter
shanefbedede2008-07-22 05:05:01 +0000698for option in $CFLAGS $CPPFLAGS
699do
700 case $option in
danielk197733a14782008-08-04 14:50:05 +0000701 -DSQLITE_OMIT*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
shaneb1cd7302008-10-22 18:27:31 +0000702 -DSQLITE_ENABLE*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
shanefbedede2008-07-22 05:05:01 +0000703 esac
704done
705AC_SUBST(OPT_FEATURE_FLAGS)
706
707
shaneb1cd7302008-10-22 18:27:31 +0000708# attempt to remove any OMITS and ENABLES from the $(CFLAGS) parameter
shanefbedede2008-07-22 05:05:01 +0000709ac_temp_CFLAGS=""
710for option in $CFLAGS
711do
712 case $option in
713 -DSQLITE_OMIT*) ;;
shaneb1cd7302008-10-22 18:27:31 +0000714 -DSQLITE_ENABLE*) ;;
danielk197733a14782008-08-04 14:50:05 +0000715 *) ac_temp_CFLAGS="$ac_temp_CFLAGS $option";;
shanefbedede2008-07-22 05:05:01 +0000716 esac
717done
718CFLAGS=$ac_temp_CFLAGS
719
720
shaneb1cd7302008-10-22 18:27:31 +0000721# attempt to remove any OMITS and ENABLES from the $(CPPFLAGS) parameter
shanefbedede2008-07-22 05:05:01 +0000722ac_temp_CPPFLAGS=""
723for option in $CPPFLAGS
724do
725 case $option in
726 -DSQLITE_OMIT*) ;;
shaneb1cd7302008-10-22 18:27:31 +0000727 -DSQLITE_ENABLE*) ;;
danielk197733a14782008-08-04 14:50:05 +0000728 *) ac_temp_CPPFLAGS="$ac_temp_CPPFLAGS $option";;
shanefbedede2008-07-22 05:05:01 +0000729 esac
730done
731CPPFLAGS=$ac_temp_CPPFLAGS
732
733
shaneb1cd7302008-10-22 18:27:31 +0000734# attempt to remove any OMITS and ENABLES from the $(BUILD_CFLAGS) parameter
shanefbedede2008-07-22 05:05:01 +0000735ac_temp_BUILD_CFLAGS=""
736for option in $BUILD_CFLAGS
737do
738 case $option in
739 -DSQLITE_OMIT*) ;;
shaneb1cd7302008-10-22 18:27:31 +0000740 -DSQLITE_ENABLE*) ;;
danielk197733a14782008-08-04 14:50:05 +0000741 *) ac_temp_BUILD_CFLAGS="$ac_temp_BUILD_CFLAGS $option";;
shanefbedede2008-07-22 05:05:01 +0000742 esac
743done
744BUILD_CFLAGS=$ac_temp_BUILD_CFLAGS
745
746
747#########
748# See whether we should use GCOV
mlcreechaac7b932008-04-01 02:45:22 +0000749AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov],
drh8fa622d2018-06-11 19:47:14 +0000750 [Enable coverage testing using gcov]))
mlcreechaac7b932008-04-01 02:45:22 +0000751if test "${use_gcov}" = "yes" ; then
752 USE_GCOV=1
753else
754 USE_GCOV=0
755fi
756AC_SUBST(USE_GCOV)
757
drhaf6edf52005-10-04 18:38:49 +0000758
drh71eb93e2001-09-28 01:34:43 +0000759#########
mlcreechb87057f2008-03-06 07:19:20 +0000760# Output the config header
mlcreech23797062008-03-20 02:25:35 +0000761AC_CONFIG_HEADERS(config.h)
mlcreechb87057f2008-03-06 07:19:20 +0000762
763#########
drh71eb93e2001-09-28 01:34:43 +0000764# Generate the output files.
765#
mlcreech8390bc32008-03-06 08:54:38 +0000766AC_SUBST(BUILD_CFLAGS)
a.rottmannc7e93832003-03-24 09:39:32 +0000767AC_OUTPUT([
768Makefile
dougcurrie12b34442004-07-19 03:24:59 +0000769sqlite3.pc
a.rottmannc7e93832003-03-24 09:39:32 +0000770])