blob: 5285581eec41b30f65264170e37127dc0b03e8fe [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
137 TCLLIBDIR=$i
138 break
139 done
140 TCLLIBDIR="${TCLLIBDIR}/sqlite3"
141fi
142
mlcreechb87057f2008-03-06 07:19:20 +0000143
144#########
drh71eb93e2001-09-28 01:34:43 +0000145# Set up an appropriate program prefix
146#
147if test "$program_prefix" = "NONE"; then
148 program_prefix=""
149fi
150AC_SUBST(program_prefix)
151
drh4b2266a2004-11-27 15:52:16 +0000152VERSION=[`cat $srcdir/VERSION | sed 's/^\([0-9]*\.*[0-9]*\).*/\1/'`]
vapier695f0972009-01-26 21:43:16 +0000153AC_MSG_NOTICE(Version set to $VERSION)
a.rottmannc7e93832003-03-24 09:39:32 +0000154AC_SUBST(VERSION)
drh4b2266a2004-11-27 15:52:16 +0000155RELEASE=`cat $srcdir/VERSION`
vapier695f0972009-01-26 21:43:16 +0000156AC_MSG_NOTICE(Release set to $RELEASE)
drh4b2266a2004-11-27 15:52:16 +0000157AC_SUBST(RELEASE)
a.rottmannc7e93832003-03-24 09:39:32 +0000158
drh71eb93e2001-09-28 01:34:43 +0000159#########
drh71eb93e2001-09-28 01:34:43 +0000160# Locate a compiler for the build machine. This compiler should
161# generate command-line programs that run on the build machine.
162#
vapierc8a15302007-02-17 14:31:55 +0000163if test x"$cross_compiling" = xno; then
164 BUILD_CC=$CC
165 BUILD_CFLAGS=$CFLAGS
drh71eb93e2001-09-28 01:34:43 +0000166else
vapierc8a15302007-02-17 14:31:55 +0000167 if test "${BUILD_CC+set}" != set; then
168 AC_CHECK_PROGS(BUILD_CC, gcc cc cl)
169 fi
170 if test "${BUILD_CFLAGS+set}" != set; then
171 BUILD_CFLAGS="-g"
172 fi
drh71eb93e2001-09-28 01:34:43 +0000173fi
174AC_SUBST(BUILD_CC)
drh71eb93e2001-09-28 01:34:43 +0000175
176##########
dougcurrie0f290bf2004-06-21 18:57:29 +0000177# Do we want to support multithreaded use of sqlite
drh71eb93e2001-09-28 01:34:43 +0000178#
dougcurrie0f290bf2004-06-21 18:57:29 +0000179AC_ARG_ENABLE(threadsafe,
drh8fa622d2018-06-11 19:47:14 +0000180AC_HELP_STRING([--disable-threadsafe],[Disable mutexing]))
dougcurrie0f290bf2004-06-21 18:57:29 +0000181AC_MSG_CHECKING([whether to support threadsafe operation])
182if test "$enable_threadsafe" = "no"; then
drh5a3032b2007-09-03 16:12:09 +0000183 SQLITE_THREADSAFE=0
paulb0208cc2003-04-13 18:26:49 +0000184 AC_MSG_RESULT([no])
185else
drh5a3032b2007-09-03 16:12:09 +0000186 SQLITE_THREADSAFE=1
paulb0208cc2003-04-13 18:26:49 +0000187 AC_MSG_RESULT([yes])
188fi
drh5a3032b2007-09-03 16:12:09 +0000189AC_SUBST(SQLITE_THREADSAFE)
paulb0208cc2003-04-13 18:26:49 +0000190
drh5a3032b2007-09-03 16:12:09 +0000191if test "$SQLITE_THREADSAFE" = "1"; then
drhba60fbb2016-01-28 02:47:32 +0000192 AC_SEARCH_LIBS(pthread_create, pthread)
drh13c808a2016-01-13 21:23:48 +0000193 AC_SEARCH_LIBS(pthread_mutexattr_init, pthread)
dougcurrie65623c72004-09-20 14:57:23 +0000194fi
dougcurrie65623c72004-09-20 14:57:23 +0000195
paulb0208cc2003-04-13 18:26:49 +0000196##########
xdong3b5543c2003-09-23 00:36:50 +0000197# Do we want to support release
198#
199AC_ARG_ENABLE(releasemode,
drh94e4f822006-02-15 02:00:25 +0000200AC_HELP_STRING([--enable-releasemode],[Support libtool link to release mode]),,enable_releasemode=no)
xdong3b5543c2003-09-23 00:36:50 +0000201AC_MSG_CHECKING([whether to support shared library linked as release mode or not])
202if test "$enable_releasemode" = "no"; then
203 ALLOWRELEASE=""
204 AC_MSG_RESULT([no])
205else
drh0b47d342007-11-27 14:50:06 +0000206 ALLOWRELEASE="-release `cat $srcdir/VERSION`"
xdong3b5543c2003-09-23 00:36:50 +0000207 AC_MSG_RESULT([yes])
208fi
209AC_SUBST(ALLOWRELEASE)
210
211##########
paulb0208cc2003-04-13 18:26:49 +0000212# Do we want temporary databases in memory
213#
dougcurrie0f290bf2004-06-21 18:57:29 +0000214AC_ARG_ENABLE(tempstore,
drh94e4f822006-02-15 02:00:25 +0000215AC_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 +0000216AC_MSG_CHECKING([whether to use an in-ram database for temporary tables])
dougcurrie0f290bf2004-06-21 18:57:29 +0000217case "$enable_tempstore" in
paulb0208cc2003-04-13 18:26:49 +0000218 never )
paul2dc96f92003-04-20 11:46:34 +0000219 TEMP_STORE=0
paulb0208cc2003-04-13 18:26:49 +0000220 AC_MSG_RESULT([never])
221 ;;
222 no )
paul2dc96f92003-04-20 11:46:34 +0000223 TEMP_STORE=1
paulb0208cc2003-04-13 18:26:49 +0000224 AC_MSG_RESULT([no])
225 ;;
drh54414bb2005-10-10 00:05:50 +0000226 yes )
drh8b727472009-01-19 18:18:40 +0000227 TEMP_STORE=2
228 AC_MSG_RESULT([yes])
229 ;;
230 always )
drh54414bb2005-10-10 00:05:50 +0000231 TEMP_STORE=3
232 AC_MSG_RESULT([always])
233 ;;
paulb0208cc2003-04-13 18:26:49 +0000234 * )
drh54414bb2005-10-10 00:05:50 +0000235 TEMP_STORE=1
drh8b727472009-01-19 18:18:40 +0000236 AC_MSG_RESULT([no])
paulb0208cc2003-04-13 18:26:49 +0000237 ;;
238esac
paul2dc96f92003-04-20 11:46:34 +0000239
paul2dc96f92003-04-20 11:46:34 +0000240AC_SUBST(TEMP_STORE)
paulb0208cc2003-04-13 18:26:49 +0000241
drh71eb93e2001-09-28 01:34:43 +0000242###########
243# Lots of things are different if we are compiling for Windows using
244# the CYGWIN environment. So check for that special case and handle
245# things accordingly.
246#
247AC_MSG_CHECKING([if executables have the .exe suffix])
248if test "$config_BUILD_EXEEXT" = ".exe"; then
249 CYGWIN=yes
250 AC_MSG_RESULT(yes)
251else
252 AC_MSG_RESULT(unknown)
253fi
254if test "$CYGWIN" != "yes"; then
255 AC_CYGWIN
256fi
257if test "$CYGWIN" = "yes"; then
258 BUILD_EXEEXT=.exe
259else
dougcurrie6194a5f2003-12-19 20:09:51 +0000260 BUILD_EXEEXT=$EXEEXT
drh71eb93e2001-09-28 01:34:43 +0000261fi
vapierc8a15302007-02-17 14:31:55 +0000262if test x"$cross_compiling" = xno; then
drh71eb93e2001-09-28 01:34:43 +0000263 TARGET_EXEEXT=$BUILD_EXEEXT
264else
265 TARGET_EXEEXT=$config_TARGET_EXEEXT
266fi
267if test "$TARGET_EXEEXT" = ".exe"; then
mistachkinfe27b082013-08-28 18:06:26 +0000268 SQLITE_OS_UNIX=0
269 SQLITE_OS_WIN=1
270 CFLAGS="$CFLAGS -DSQLITE_OS_WIN=1"
drh71eb93e2001-09-28 01:34:43 +0000271else
danielk197729bafea2008-06-26 10:41:19 +0000272 SQLITE_OS_UNIX=1
273 SQLITE_OS_WIN=0
danielk197729bafea2008-06-26 10:41:19 +0000274 CFLAGS="$CFLAGS -DSQLITE_OS_UNIX=1"
drh71eb93e2001-09-28 01:34:43 +0000275fi
drh71eb93e2001-09-28 01:34:43 +0000276
277AC_SUBST(BUILD_EXEEXT)
danielk197729bafea2008-06-26 10:41:19 +0000278AC_SUBST(SQLITE_OS_UNIX)
279AC_SUBST(SQLITE_OS_WIN)
drh71eb93e2001-09-28 01:34:43 +0000280AC_SUBST(TARGET_EXEEXT)
281
282##########
drh7b5717e2004-11-25 13:50:01 +0000283# Figure out all the parameters needed to compile against Tcl.
drh71eb93e2001-09-28 01:34:43 +0000284#
drh7b5717e2004-11-25 13:50:01 +0000285# This code is derived from the SC_PATH_TCLCONFIG and SC_LOAD_TCLCONFIG
286# macros in the in the tcl.m4 file of the standard TCL distribution.
287# Those macros could not be used directly since we have to make some
288# minor changes to accomodate systems that do not have TCL installed.
drh71eb93e2001-09-28 01:34:43 +0000289#
drh94e4f822006-02-15 02:00:25 +0000290AC_ARG_ENABLE(tcl, AC_HELP_STRING([--disable-tcl],[do not build TCL extension]),
drh7b5717e2004-11-25 13:50:01 +0000291 [use_tcl=$enableval],[use_tcl=yes])
292if test "${use_tcl}" = "yes" ; then
drh94e4f822006-02-15 02:00:25 +0000293 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 +0000294 AC_MSG_CHECKING([for Tcl configuration])
295 AC_CACHE_VAL(ac_cv_c_tclconfig,[
296 # First check to see if --with-tcl was specified.
297 if test x"${with_tclconfig}" != x ; then
298 if test -f "${with_tclconfig}/tclConfig.sh" ; then
299 ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
300 else
301 AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
302 fi
drh71eb93e2001-09-28 01:34:43 +0000303 fi
vapierfe7e82e2009-01-26 21:39:33 +0000304
305 # Start autosearch by asking tclsh
drhe74f4652012-08-15 16:06:54 +0000306 if test x"${ac_cv_c_tclconfig}" = x ; then
307 if test x"$cross_compiling" = xno; then
308 for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}`
309 do
310 if test -f "$i/tclConfig.sh" ; then
311 ac_cv_c_tclconfig="$i"
312 break
313 fi
314 done
315 fi
vapierfe7e82e2009-01-26 21:39:33 +0000316 fi
317
drhf960a642015-05-30 22:57:49 +0000318 # On ubuntu 14.10, $auto_path on tclsh is not quite correct.
319 # So try again after applying corrections.
320 if test x"${ac_cv_c_tclconfig}" = x ; then
321 if test x"$cross_compiling" = xno; then
322 for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD} | sed 's,/tcltk/tcl,/tcl,g'`
323 do
324 if test -f "$i/tclConfig.sh" ; then
325 ac_cv_c_tclconfig="$i"
326 break
327 fi
328 done
329 fi
330 fi
331
drh68314742016-05-23 00:10:58 +0000332 # Recent versions of Xcode on Macs hid the tclConfig.sh file
333 # in a strange place.
334 if test x"${ac_cv_c_tclconfig}" = x ; then
335 if test x"$cross_compiling" = xno; then
336 for i in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk/usr/lib
337 do
338 if test -f "$i/tclConfig.sh" ; then
339 ac_cv_c_tclconfig="$i"
340 break
341 fi
342 done
343 fi
344 fi
345
drh7b5717e2004-11-25 13:50:01 +0000346 # then check for a private Tcl installation
347 if test x"${ac_cv_c_tclconfig}" = x ; then
348 for i in \
349 ../tcl \
350 `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
351 `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
352 `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
353 ../../tcl \
354 `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
355 `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
356 `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
357 ../../../tcl \
358 `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
359 `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
360 `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null`
361 do
362 if test -f "$i/unix/tclConfig.sh" ; then
363 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
364 break
365 fi
366 done
367 fi
368
369 # check in a few common install locations
370 if test x"${ac_cv_c_tclconfig}" = x ; then
371 for i in \
372 `ls -d ${libdir} 2>/dev/null` \
373 `ls -d /usr/local/lib 2>/dev/null` \
374 `ls -d /usr/contrib/lib 2>/dev/null` \
375 `ls -d /usr/lib 2>/dev/null`
376 do
377 if test -f "$i/tclConfig.sh" ; then
378 ac_cv_c_tclconfig=`(cd $i; pwd)`
379 break
380 fi
381 done
382 fi
383
384 # check in a few other private locations
385 if test x"${ac_cv_c_tclconfig}" = x ; then
386 for i in \
387 ${srcdir}/../tcl \
388 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
389 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
390 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null`
391 do
392 if test -f "$i/unix/tclConfig.sh" ; then
393 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
394 break
395 fi
396 done
397 fi
398 ])
399
400 if test x"${ac_cv_c_tclconfig}" = x ; then
401 use_tcl=no
402 AC_MSG_WARN(Can't find Tcl configuration definitions)
403 AC_MSG_WARN(*** Without Tcl the regression tests cannot be executed ***)
404 AC_MSG_WARN(*** Consider using --with-tcl=... to define location of Tcl ***)
405 else
406 TCL_BIN_DIR=${ac_cv_c_tclconfig}
407 AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
408
409 AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
410 if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
411 AC_MSG_RESULT([loading])
412 . $TCL_BIN_DIR/tclConfig.sh
413 else
414 AC_MSG_RESULT([file not found])
415 fi
416
417 #
418 # If the TCL_BIN_DIR is the build directory (not the install directory),
419 # then set the common variable name to the value of the build variables.
420 # For example, the variable TCL_LIB_SPEC will be set to the value
421 # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
422 # instead of TCL_BUILD_LIB_SPEC since it will work with both an
423 # installed and uninstalled version of Tcl.
424 #
425
mlcreechab1c47b2008-03-09 02:51:10 +0000426 if test -f $TCL_BIN_DIR/Makefile ; then
drh7b5717e2004-11-25 13:50:01 +0000427 TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
428 TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
429 TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
430 fi
431
432 #
433 # eval is required to do the TCL_DBGX substitution
434 #
435
436 eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
437 eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
438 eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
439
440 eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
441 eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
442 eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
443
444 AC_SUBST(TCL_VERSION)
445 AC_SUBST(TCL_BIN_DIR)
446 AC_SUBST(TCL_SRC_DIR)
drh7b5717e2004-11-25 13:50:01 +0000447 AC_SUBST(TCL_INCLUDE_SPEC)
448
449 AC_SUBST(TCL_LIB_FILE)
450 AC_SUBST(TCL_LIB_FLAG)
451 AC_SUBST(TCL_LIB_SPEC)
452
453 AC_SUBST(TCL_STUB_LIB_FILE)
454 AC_SUBST(TCL_STUB_LIB_FLAG)
455 AC_SUBST(TCL_STUB_LIB_SPEC)
drhd881ce82015-03-31 17:01:52 +0000456 AC_SUBST(TCL_SHLIB_SUFFIX)
drh7b5717e2004-11-25 13:50:01 +0000457 fi
drh71eb93e2001-09-28 01:34:43 +0000458fi
drh7b5717e2004-11-25 13:50:01 +0000459if test "${use_tcl}" = "no" ; then
460 HAVE_TCL=""
461else
462 HAVE_TCL=1
drh71eb93e2001-09-28 01:34:43 +0000463fi
drh7b5717e2004-11-25 13:50:01 +0000464AC_SUBST(HAVE_TCL)
drh71eb93e2001-09-28 01:34:43 +0000465
466##########
467# Figure out what C libraries are required to compile programs
468# that use "readline()" library.
469#
vapier4c10a8a2007-02-17 14:28:26 +0000470TARGET_READLINE_LIBS=""
471TARGET_READLINE_INC=""
472TARGET_HAVE_READLINE=0
drhe44b8352015-10-30 14:25:57 +0000473TARGET_HAVE_EDITLINE=0
474AC_ARG_ENABLE([editline],
475 [AC_HELP_STRING([--enable-editline],[enable BSD editline support])],
476 [with_editline=$enableval],
477 [with_editline=auto])
vapier4c10a8a2007-02-17 14:28:26 +0000478AC_ARG_ENABLE([readline],
drhe44b8352015-10-30 14:25:57 +0000479 [AC_HELP_STRING([--disable-readline],[disable readline support])],
vapier4c10a8a2007-02-17 14:28:26 +0000480 [with_readline=$enableval],
481 [with_readline=auto])
482
drhe44b8352015-10-30 14:25:57 +0000483if test x"$with_editline" != xno; then
484 sLIBS=$LIBS
485 LIBS=""
486 TARGET_HAVE_EDITLINE=1
487 AC_SEARCH_LIBS(readline,edit,[with_readline=no],[TARGET_HAVE_EDITLINE=0])
488 TARGET_READLINE_LIBS=$LIBS
489 LIBS=$sLIBS
490fi
vapier4c10a8a2007-02-17 14:28:26 +0000491if test x"$with_readline" != xno; then
492 found="yes"
493
494 AC_ARG_WITH([readline-lib],
495 [AC_HELP_STRING([--with-readline-lib],[specify readline library])],
496 [with_readline_lib=$withval],
497 [with_readline_lib="auto"])
498 if test "x$with_readline_lib" = xauto; then
499 save_LIBS="$LIBS"
500 LIBS=""
501 AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap], [term_LIBS="$LIBS"], [term_LIBS=""])
502 AC_CHECK_LIB([readline], [readline], [TARGET_READLINE_LIBS="-lreadline"], [found="no"])
503 TARGET_READLINE_LIBS="$TARGET_READLINE_LIBS $term_LIBS"
504 LIBS="$save_LIBS"
505 else
506 TARGET_READLINE_LIBS="$with_readline_lib"
507 fi
508
509 AC_ARG_WITH([readline-inc],
510 [AC_HELP_STRING([--with-readline-inc],[specify readline include paths])],
511 [with_readline_inc=$withval],
512 [with_readline_inc="auto"])
513 if test "x$with_readline_inc" = xauto; then
514 AC_CHECK_HEADER(readline.h, [found="yes"], [
515 found="no"
516 if test "$cross_compiling" != yes; then
517 for dir in /usr /usr/local /usr/local/readline /usr/contrib /mingw; do
518 for subdir in include include/readline; do
519 AC_CHECK_FILE($dir/$subdir/readline.h, found=yes)
520 if test "$found" = "yes"; then
521 TARGET_READLINE_INC="-I$dir/$subdir"
522 break
523 fi
524 done
525 test "$found" = "yes" && break
526 done
527 fi
528 ])
529 else
530 TARGET_READLINE_INC="$with_readline_inc"
531 fi
532
533 if test x"$found" = xno; then
534 TARGET_READLINE_LIBS=""
535 TARGET_READLINE_INC=""
536 TARGET_HAVE_READLINE=0
537 else
538 TARGET_HAVE_READLINE=1
539 fi
drh71eb93e2001-09-28 01:34:43 +0000540fi
vapier4c10a8a2007-02-17 14:28:26 +0000541
drh71eb93e2001-09-28 01:34:43 +0000542AC_SUBST(TARGET_READLINE_LIBS)
vapier4c10a8a2007-02-17 14:28:26 +0000543AC_SUBST(TARGET_READLINE_INC)
544AC_SUBST(TARGET_HAVE_READLINE)
drhe44b8352015-10-30 14:25:57 +0000545AC_SUBST(TARGET_HAVE_EDITLINE)
drh71eb93e2001-09-28 01:34:43 +0000546
547##########
drhf1878b42006-01-23 18:06:52 +0000548# Figure out what C libraries are required to compile programs
549# that use "fdatasync()" function.
550#
drhf1878b42006-01-23 18:06:52 +0000551AC_SEARCH_LIBS(fdatasync, [rt])
drhf1878b42006-01-23 18:06:52 +0000552
drh71eb93e2001-09-28 01:34:43 +0000553#########
tpoindex9d9f76c2005-01-03 21:28:56 +0000554# check for debug enabled
drh8fa622d2018-06-11 19:47:14 +0000555AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain]))
556if test "${enable_debug}" = "yes" ; then
drh32d0eba2017-04-05 10:54:14 +0000557 TARGET_DEBUG="-DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0"
tpoindex9d9f76c2005-01-03 21:28:56 +0000558else
559 TARGET_DEBUG="-DNDEBUG"
560fi
561AC_SUBST(TARGET_DEBUG)
562
563#########
mlcreech94984912008-03-04 19:03:08 +0000564# See whether we should use the amalgamation to build
565AC_ARG_ENABLE(amalgamation, AC_HELP_STRING([--disable-amalgamation],
drh8fa622d2018-06-11 19:47:14 +0000566 [Disable the amalgamation and instead build all files separately]))
danb13d5c22020-07-07 19:24:34 +0000567if test "${enable_amalgamation}" = "no" ; then
mlcreech94984912008-03-04 19:03:08 +0000568 USE_AMALGAMATION=0
569fi
570AC_SUBST(USE_AMALGAMATION)
571
572#########
drh56c93112017-11-24 16:55:48 +0000573# Look for zlib. Only needed by extensions and by the sqlite3.exe shell
574AC_CHECK_HEADERS(zlib.h)
575AC_SEARCH_LIBS(deflate, z, [HAVE_ZLIB="-DSQLITE_HAVE_ZLIB=1"], [HAVE_ZLIB=""])
576AC_SUBST(HAVE_ZLIB)
577
578#########
mlcreecha4edab02008-03-06 04:14:17 +0000579# See whether we should allow loadable extensions
drh05c7e0b2015-01-10 14:27:17 +0000580AC_ARG_ENABLE(load-extension, AC_HELP_STRING([--disable-load-extension],
drh8fa622d2018-06-11 19:47:14 +0000581 [Disable loading of external extensions]),,[enable_load_extension=yes])
582if test "${enable_load_extension}" = "yes" ; then
shanefbedede2008-07-22 05:05:01 +0000583 OPT_FEATURE_FLAGS=""
drhdbe4b882011-06-20 18:00:17 +0000584 AC_SEARCH_LIBS(dlopen, dl)
mlcreecha4edab02008-03-06 04:14:17 +0000585else
shanefbedede2008-07-22 05:05:01 +0000586 OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1"
mlcreecha4edab02008-03-06 04:14:17 +0000587fi
mlcreecha4edab02008-03-06 04:14:17 +0000588
drhc530b9c2016-07-25 11:27:22 +0000589##########
drhf6e904b2020-12-07 17:15:32 +0000590# Do we want to support math functions
591#
592AC_ARG_ENABLE(threadsafe,
593AC_HELP_STRING([--disable-math],[Disable math functions]))
594AC_MSG_CHECKING([whether to support math functions])
595if test "$enable_math" = "no"; then
596 AC_MSG_RESULT([no])
597else
598 AC_MSG_RESULT([yes])
599 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MATH_FUNCTIONS"
600 AC_SEARCH_LIBS(ceil, m)
601fi
602
603##########
drhc530b9c2016-07-25 11:27:22 +0000604# Do we want to support memsys3 and/or memsys5
605#
drhc530b9c2016-07-25 11:27:22 +0000606AC_ARG_ENABLE(memsys5,
drh8fa622d2018-06-11 19:47:14 +0000607 AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]))
drhc530b9c2016-07-25 11:27:22 +0000608AC_MSG_CHECKING([whether to support MEMSYS5])
drh26197d12016-07-25 11:32:09 +0000609if test "${enable_memsys5}" = "yes"; then
drh8c9ed052017-05-29 17:43:06 +0000610 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS5"
drhc530b9c2016-07-25 11:27:22 +0000611 AC_MSG_RESULT([yes])
612else
613 AC_MSG_RESULT([no])
614fi
drh5d513ba2016-07-25 11:57:21 +0000615AC_ARG_ENABLE(memsys3,
drh8fa622d2018-06-11 19:47:14 +0000616 AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]))
drh5d513ba2016-07-25 11:57:21 +0000617AC_MSG_CHECKING([whether to support MEMSYS3])
618if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then
drh8c9ed052017-05-29 17:43:06 +0000619 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS3"
drh5d513ba2016-07-25 11:57:21 +0000620 AC_MSG_RESULT([yes])
621else
622 AC_MSG_RESULT([no])
623fi
drhc530b9c2016-07-25 11:27:22 +0000624
drh29368ea2019-12-28 13:17:11 +0000625########
626# The --enable-extensions argument is short-hand to enable
627# multiple extensions.
628AC_ARG_ENABLE(all, AC_HELP_STRING([--enable-all],
629 [Enable FTS4, FTS5, Geopoly, JSON, RTree, Sessions]))
630
mlcreechaac7b932008-04-01 02:45:22 +0000631#########
drhce1d9f52015-10-09 12:48:33 +0000632# See whether we should enable Full Text Search extensions
633AC_ARG_ENABLE(fts3, AC_HELP_STRING([--enable-fts3],
drh8fa622d2018-06-11 19:47:14 +0000634 [Enable the FTS3 extension]))
drhce1d9f52015-10-09 12:48:33 +0000635if test "${enable_fts3}" = "yes" ; then
drh8c9ed052017-05-29 17:43:06 +0000636 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS3"
drhce1d9f52015-10-09 12:48:33 +0000637fi
638AC_ARG_ENABLE(fts4, AC_HELP_STRING([--enable-fts4],
drh8fa622d2018-06-11 19:47:14 +0000639 [Enable the FTS4 extension]))
drh29368ea2019-12-28 13:17:11 +0000640if test "${enable_fts4}" = "yes" -o "${enable_all}" = "yes" ; then
drh8c9ed052017-05-29 17:43:06 +0000641 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS4"
drhce1d9f52015-10-09 12:48:33 +0000642 AC_SEARCH_LIBS([log],[m])
643fi
644AC_ARG_ENABLE(fts5, AC_HELP_STRING([--enable-fts5],
drh8fa622d2018-06-11 19:47:14 +0000645 [Enable the FTS5 extension]))
drh29368ea2019-12-28 13:17:11 +0000646if test "${enable_fts5}" = "yes" -o "${enable_all}" = "yes" ; then
drh8c9ed052017-05-29 17:43:06 +0000647 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS5"
drhce1d9f52015-10-09 12:48:33 +0000648 AC_SEARCH_LIBS([log],[m])
649fi
650
651#########
652# See whether we should enable JSON1
drh8fa622d2018-06-11 19:47:14 +0000653AC_ARG_ENABLE(json1, AC_HELP_STRING([--enable-json1],[Enable the JSON1 extension]))
drh29368ea2019-12-28 13:17:11 +0000654if test "${enable_json1}" = "yes" -o "${enable_all}" = "yes" ; then
drh8c9ed052017-05-29 17:43:06 +0000655 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_JSON1"
drhce1d9f52015-10-09 12:48:33 +0000656fi
657
658#########
drh83bebdd2017-08-28 17:00:12 +0000659# See whether we should enable the LIMIT clause on UPDATE and DELETE
660# statements.
661AC_ARG_ENABLE(update-limit, AC_HELP_STRING([--enable-update-limit],
drh8fa622d2018-06-11 19:47:14 +0000662 [Enable the UPDATE/DELETE LIMIT clause]))
drhb13c3a32020-06-15 14:38:57 +0000663if test "${enable_update_limit}" = "yes" ; then
drh83bebdd2017-08-28 17:00:12 +0000664 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT"
665fi
666
667#########
drh748b8fd2018-05-25 19:22:47 +0000668# See whether we should enable GEOPOLY
669AC_ARG_ENABLE(geopoly, AC_HELP_STRING([--enable-geopoly],
670 [Enable the GEOPOLY extension]),
671 [enable_geopoly=yes],[enable_geopoly=no])
drh29368ea2019-12-28 13:17:11 +0000672if test "${enable_geopoly}" = "yes" -o "${enable_all}" = "yes" ; then
drh748b8fd2018-05-25 19:22:47 +0000673 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_GEOPOLY"
674 enable_rtree=yes
675fi
676
677#########
drhce1d9f52015-10-09 12:48:33 +0000678# See whether we should enable RTREE
679AC_ARG_ENABLE(rtree, AC_HELP_STRING([--enable-rtree],
drh8fa622d2018-06-11 19:47:14 +0000680 [Enable the RTREE extension]))
drhce1d9f52015-10-09 12:48:33 +0000681if test "${enable_rtree}" = "yes" ; then
drh8c9ed052017-05-29 17:43:06 +0000682 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_RTREE"
drhce1d9f52015-10-09 12:48:33 +0000683fi
684
685#########
drh5e18d402016-05-03 13:14:18 +0000686# See whether we should enable the SESSION extension
687AC_ARG_ENABLE(session, AC_HELP_STRING([--enable-session],
drh8fa622d2018-06-11 19:47:14 +0000688 [Enable the SESSION extension]))
drh29368ea2019-12-28 13:17:11 +0000689if test "${enable_session}" = "yes" -o "${enable_all}" = "yes" ; then
drh8c9ed052017-05-29 17:43:06 +0000690 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_SESSION"
691 OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_PREUPDATE_HOOK"
drh5e18d402016-05-03 13:14:18 +0000692fi
693
694#########
drh8c9ed052017-05-29 17:43:06 +0000695# attempt to duplicate any OMITS and ENABLES into the ${OPT_FEATURE_FLAGS} parameter
shanefbedede2008-07-22 05:05:01 +0000696for option in $CFLAGS $CPPFLAGS
697do
698 case $option in
danielk197733a14782008-08-04 14:50:05 +0000699 -DSQLITE_OMIT*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
shaneb1cd7302008-10-22 18:27:31 +0000700 -DSQLITE_ENABLE*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
shanefbedede2008-07-22 05:05:01 +0000701 esac
702done
703AC_SUBST(OPT_FEATURE_FLAGS)
704
705
shaneb1cd7302008-10-22 18:27:31 +0000706# attempt to remove any OMITS and ENABLES from the $(CFLAGS) parameter
shanefbedede2008-07-22 05:05:01 +0000707ac_temp_CFLAGS=""
708for option in $CFLAGS
709do
710 case $option in
711 -DSQLITE_OMIT*) ;;
shaneb1cd7302008-10-22 18:27:31 +0000712 -DSQLITE_ENABLE*) ;;
danielk197733a14782008-08-04 14:50:05 +0000713 *) ac_temp_CFLAGS="$ac_temp_CFLAGS $option";;
shanefbedede2008-07-22 05:05:01 +0000714 esac
715done
716CFLAGS=$ac_temp_CFLAGS
717
718
shaneb1cd7302008-10-22 18:27:31 +0000719# attempt to remove any OMITS and ENABLES from the $(CPPFLAGS) parameter
shanefbedede2008-07-22 05:05:01 +0000720ac_temp_CPPFLAGS=""
721for option in $CPPFLAGS
722do
723 case $option in
724 -DSQLITE_OMIT*) ;;
shaneb1cd7302008-10-22 18:27:31 +0000725 -DSQLITE_ENABLE*) ;;
danielk197733a14782008-08-04 14:50:05 +0000726 *) ac_temp_CPPFLAGS="$ac_temp_CPPFLAGS $option";;
shanefbedede2008-07-22 05:05:01 +0000727 esac
728done
729CPPFLAGS=$ac_temp_CPPFLAGS
730
731
shaneb1cd7302008-10-22 18:27:31 +0000732# attempt to remove any OMITS and ENABLES from the $(BUILD_CFLAGS) parameter
shanefbedede2008-07-22 05:05:01 +0000733ac_temp_BUILD_CFLAGS=""
734for option in $BUILD_CFLAGS
735do
736 case $option in
737 -DSQLITE_OMIT*) ;;
shaneb1cd7302008-10-22 18:27:31 +0000738 -DSQLITE_ENABLE*) ;;
danielk197733a14782008-08-04 14:50:05 +0000739 *) ac_temp_BUILD_CFLAGS="$ac_temp_BUILD_CFLAGS $option";;
shanefbedede2008-07-22 05:05:01 +0000740 esac
741done
742BUILD_CFLAGS=$ac_temp_BUILD_CFLAGS
743
744
745#########
746# See whether we should use GCOV
mlcreechaac7b932008-04-01 02:45:22 +0000747AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov],
drh8fa622d2018-06-11 19:47:14 +0000748 [Enable coverage testing using gcov]))
mlcreechaac7b932008-04-01 02:45:22 +0000749if test "${use_gcov}" = "yes" ; then
750 USE_GCOV=1
751else
752 USE_GCOV=0
753fi
754AC_SUBST(USE_GCOV)
755
drhaf6edf52005-10-04 18:38:49 +0000756
drh71eb93e2001-09-28 01:34:43 +0000757#########
mlcreechb87057f2008-03-06 07:19:20 +0000758# Output the config header
mlcreech23797062008-03-20 02:25:35 +0000759AC_CONFIG_HEADERS(config.h)
mlcreechb87057f2008-03-06 07:19:20 +0000760
761#########
drh71eb93e2001-09-28 01:34:43 +0000762# Generate the output files.
763#
mlcreech8390bc32008-03-06 08:54:38 +0000764AC_SUBST(BUILD_CFLAGS)
a.rottmannc7e93832003-03-24 09:39:32 +0000765AC_OUTPUT([
766Makefile
dougcurrie12b34442004-07-19 03:24:59 +0000767sqlite3.pc
a.rottmannc7e93832003-03-24 09:39:32 +0000768])