blob: 6a1188842aba1eab63a36bc57f7e227d972a6dd0 [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
drhf1878b42006-01-23 18:06:52 +000093AC_PROG_AWK
drh71eb93e2001-09-28 01:34:43 +000094
95#########
mlcreech636a9952008-05-05 22:52:56 +000096# Enable large file support (if special flags are necessary)
97#
98AC_SYS_LARGEFILE
99
100#########
mlcreechb87057f2008-03-06 07:19:20 +0000101# Check for needed/wanted data types
102AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, intptr_t, uint8_t,
103 uint16_t, uint32_t, uint64_t, uintptr_t])
104
105#########
106# Check for needed/wanted headers
drh86c5a932012-02-08 12:13:28 +0000107AC_CHECK_HEADERS([sys/types.h stdlib.h stdint.h inttypes.h malloc.h])
mlcreech5b0a9eb2008-03-09 01:38:09 +0000108
109#########
110# Figure out whether or not we have these functions
111#
drh39311122015-01-15 17:38:35 +0000112AC_CHECK_FUNCS([fdatasync gmtime_r isnan localtime_r localtime_s malloc_usable_size strchrnul usleep utime])
mlcreech5b0a9eb2008-03-09 01:38:09 +0000113
mlcreechab1c47b2008-03-09 02:51:10 +0000114#########
mlcreechf3868112008-03-11 18:03:30 +0000115# By default, we use the amalgamation (this may be changed below...)
116#
117USE_AMALGAMATION=1
118
119#########
mlcreechab1c47b2008-03-09 02:51:10 +0000120# See whether we can run specific tclsh versions known to work well;
121# if not, then we fall back to plain tclsh.
122# TODO: try other versions before falling back?
123#
mistachkinfe27b082013-08-28 18:06:26 +0000124AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.6 tclsh8.5 tclsh], none)
mlcreechf3868112008-03-11 18:03:30 +0000125if test "$TCLSH_CMD" = "none"; then
126 # If we can't find a local tclsh, then building the amalgamation will fail.
127 # We act as though --disable-amalgamation has been used.
128 echo "Warning: can't find tclsh - defaulting to non-amalgamation build."
129 USE_AMALGAMATION=0
130 TCLSH_CMD="tclsh"
131fi
mlcreechab1c47b2008-03-09 02:51:10 +0000132AC_SUBST(TCLSH_CMD)
133
vapier6d120f32009-01-28 04:46:14 +0000134AC_ARG_VAR([TCLLIBDIR], [Where to install tcl plugin])
135if test "x${TCLLIBDIR+set}" != "xset" ; then
136 TCLLIBDIR='$(libdir)'
137 for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}` ; do
138 TCLLIBDIR=$i
139 break
140 done
141 TCLLIBDIR="${TCLLIBDIR}/sqlite3"
142fi
143
mlcreechb87057f2008-03-06 07:19:20 +0000144
145#########
drh71eb93e2001-09-28 01:34:43 +0000146# Set up an appropriate program prefix
147#
148if test "$program_prefix" = "NONE"; then
149 program_prefix=""
150fi
151AC_SUBST(program_prefix)
152
drh4b2266a2004-11-27 15:52:16 +0000153VERSION=[`cat $srcdir/VERSION | sed 's/^\([0-9]*\.*[0-9]*\).*/\1/'`]
vapier695f0972009-01-26 21:43:16 +0000154AC_MSG_NOTICE(Version set to $VERSION)
a.rottmannc7e93832003-03-24 09:39:32 +0000155AC_SUBST(VERSION)
drh4b2266a2004-11-27 15:52:16 +0000156RELEASE=`cat $srcdir/VERSION`
vapier695f0972009-01-26 21:43:16 +0000157AC_MSG_NOTICE(Release set to $RELEASE)
drh4b2266a2004-11-27 15:52:16 +0000158AC_SUBST(RELEASE)
vapier695f0972009-01-26 21:43:16 +0000159VERSION_NUMBER=[`cat $srcdir/VERSION \
drhb7977832005-02-16 03:45:51 +0000160 | sed 's/[^0-9]/ /g' \
drh26d0e2a2005-07-06 13:51:27 +0000161 | awk '{printf "%d%03d%03d",$1,$2,$3}'`]
vapier695f0972009-01-26 21:43:16 +0000162AC_MSG_NOTICE(Version number set to $VERSION_NUMBER)
drhb7977832005-02-16 03:45:51 +0000163AC_SUBST(VERSION_NUMBER)
a.rottmannc7e93832003-03-24 09:39:32 +0000164
drh71eb93e2001-09-28 01:34:43 +0000165#########
drh71eb93e2001-09-28 01:34:43 +0000166# Locate a compiler for the build machine. This compiler should
167# generate command-line programs that run on the build machine.
168#
vapierc8a15302007-02-17 14:31:55 +0000169if test x"$cross_compiling" = xno; then
170 BUILD_CC=$CC
171 BUILD_CFLAGS=$CFLAGS
drh71eb93e2001-09-28 01:34:43 +0000172else
vapierc8a15302007-02-17 14:31:55 +0000173 if test "${BUILD_CC+set}" != set; then
174 AC_CHECK_PROGS(BUILD_CC, gcc cc cl)
175 fi
176 if test "${BUILD_CFLAGS+set}" != set; then
177 BUILD_CFLAGS="-g"
178 fi
drh71eb93e2001-09-28 01:34:43 +0000179fi
180AC_SUBST(BUILD_CC)
drh71eb93e2001-09-28 01:34:43 +0000181
182##########
dougcurrie0f290bf2004-06-21 18:57:29 +0000183# Do we want to support multithreaded use of sqlite
drh71eb93e2001-09-28 01:34:43 +0000184#
dougcurrie0f290bf2004-06-21 18:57:29 +0000185AC_ARG_ENABLE(threadsafe,
drh05c7e0b2015-01-10 14:27:17 +0000186AC_HELP_STRING([--disable-threadsafe],[Disable mutexing]),,enable_threadsafe=yes)
dougcurrie0f290bf2004-06-21 18:57:29 +0000187AC_MSG_CHECKING([whether to support threadsafe operation])
188if test "$enable_threadsafe" = "no"; then
drh5a3032b2007-09-03 16:12:09 +0000189 SQLITE_THREADSAFE=0
paulb0208cc2003-04-13 18:26:49 +0000190 AC_MSG_RESULT([no])
191else
drh5a3032b2007-09-03 16:12:09 +0000192 SQLITE_THREADSAFE=1
paulb0208cc2003-04-13 18:26:49 +0000193 AC_MSG_RESULT([yes])
194fi
drh5a3032b2007-09-03 16:12:09 +0000195AC_SUBST(SQLITE_THREADSAFE)
paulb0208cc2003-04-13 18:26:49 +0000196
drh5a3032b2007-09-03 16:12:09 +0000197if test "$SQLITE_THREADSAFE" = "1"; then
mlcreechc658b0f2008-03-09 02:20:11 +0000198 AC_SEARCH_LIBS(pthread_create, pthread)
dougcurrie65623c72004-09-20 14:57:23 +0000199fi
dougcurrie65623c72004-09-20 14:57:23 +0000200
paulb0208cc2003-04-13 18:26:49 +0000201##########
xdong3b5543c2003-09-23 00:36:50 +0000202# Do we want to support release
203#
204AC_ARG_ENABLE(releasemode,
drh94e4f822006-02-15 02:00:25 +0000205AC_HELP_STRING([--enable-releasemode],[Support libtool link to release mode]),,enable_releasemode=no)
xdong3b5543c2003-09-23 00:36:50 +0000206AC_MSG_CHECKING([whether to support shared library linked as release mode or not])
207if test "$enable_releasemode" = "no"; then
208 ALLOWRELEASE=""
209 AC_MSG_RESULT([no])
210else
drh0b47d342007-11-27 14:50:06 +0000211 ALLOWRELEASE="-release `cat $srcdir/VERSION`"
xdong3b5543c2003-09-23 00:36:50 +0000212 AC_MSG_RESULT([yes])
213fi
214AC_SUBST(ALLOWRELEASE)
215
216##########
paulb0208cc2003-04-13 18:26:49 +0000217# Do we want temporary databases in memory
218#
dougcurrie0f290bf2004-06-21 18:57:29 +0000219AC_ARG_ENABLE(tempstore,
drh94e4f822006-02-15 02:00:25 +0000220AC_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 +0000221AC_MSG_CHECKING([whether to use an in-ram database for temporary tables])
dougcurrie0f290bf2004-06-21 18:57:29 +0000222case "$enable_tempstore" in
paulb0208cc2003-04-13 18:26:49 +0000223 never )
paul2dc96f92003-04-20 11:46:34 +0000224 TEMP_STORE=0
paulb0208cc2003-04-13 18:26:49 +0000225 AC_MSG_RESULT([never])
226 ;;
227 no )
paul2dc96f92003-04-20 11:46:34 +0000228 TEMP_STORE=1
paulb0208cc2003-04-13 18:26:49 +0000229 AC_MSG_RESULT([no])
230 ;;
drh54414bb2005-10-10 00:05:50 +0000231 yes )
drh8b727472009-01-19 18:18:40 +0000232 TEMP_STORE=2
233 AC_MSG_RESULT([yes])
234 ;;
235 always )
drh54414bb2005-10-10 00:05:50 +0000236 TEMP_STORE=3
237 AC_MSG_RESULT([always])
238 ;;
paulb0208cc2003-04-13 18:26:49 +0000239 * )
drh54414bb2005-10-10 00:05:50 +0000240 TEMP_STORE=1
drh8b727472009-01-19 18:18:40 +0000241 AC_MSG_RESULT([no])
paulb0208cc2003-04-13 18:26:49 +0000242 ;;
243esac
paul2dc96f92003-04-20 11:46:34 +0000244
paul2dc96f92003-04-20 11:46:34 +0000245AC_SUBST(TEMP_STORE)
paulb0208cc2003-04-13 18:26:49 +0000246
drh71eb93e2001-09-28 01:34:43 +0000247###########
248# Lots of things are different if we are compiling for Windows using
249# the CYGWIN environment. So check for that special case and handle
250# things accordingly.
251#
252AC_MSG_CHECKING([if executables have the .exe suffix])
253if test "$config_BUILD_EXEEXT" = ".exe"; then
254 CYGWIN=yes
255 AC_MSG_RESULT(yes)
256else
257 AC_MSG_RESULT(unknown)
258fi
259if test "$CYGWIN" != "yes"; then
260 AC_CYGWIN
261fi
262if test "$CYGWIN" = "yes"; then
263 BUILD_EXEEXT=.exe
264else
dougcurrie6194a5f2003-12-19 20:09:51 +0000265 BUILD_EXEEXT=$EXEEXT
drh71eb93e2001-09-28 01:34:43 +0000266fi
vapierc8a15302007-02-17 14:31:55 +0000267if test x"$cross_compiling" = xno; then
drh71eb93e2001-09-28 01:34:43 +0000268 TARGET_EXEEXT=$BUILD_EXEEXT
269else
270 TARGET_EXEEXT=$config_TARGET_EXEEXT
271fi
272if test "$TARGET_EXEEXT" = ".exe"; then
mistachkinfe27b082013-08-28 18:06:26 +0000273 SQLITE_OS_UNIX=0
274 SQLITE_OS_WIN=1
275 CFLAGS="$CFLAGS -DSQLITE_OS_WIN=1"
drh71eb93e2001-09-28 01:34:43 +0000276else
danielk197729bafea2008-06-26 10:41:19 +0000277 SQLITE_OS_UNIX=1
278 SQLITE_OS_WIN=0
danielk197729bafea2008-06-26 10:41:19 +0000279 CFLAGS="$CFLAGS -DSQLITE_OS_UNIX=1"
drh71eb93e2001-09-28 01:34:43 +0000280fi
drh71eb93e2001-09-28 01:34:43 +0000281
282AC_SUBST(BUILD_EXEEXT)
danielk197729bafea2008-06-26 10:41:19 +0000283AC_SUBST(SQLITE_OS_UNIX)
284AC_SUBST(SQLITE_OS_WIN)
drh71eb93e2001-09-28 01:34:43 +0000285AC_SUBST(TARGET_EXEEXT)
286
287##########
drh7b5717e2004-11-25 13:50:01 +0000288# Figure out all the parameters needed to compile against Tcl.
drh71eb93e2001-09-28 01:34:43 +0000289#
drh7b5717e2004-11-25 13:50:01 +0000290# This code is derived from the SC_PATH_TCLCONFIG and SC_LOAD_TCLCONFIG
291# macros in the in the tcl.m4 file of the standard TCL distribution.
292# Those macros could not be used directly since we have to make some
293# minor changes to accomodate systems that do not have TCL installed.
drh71eb93e2001-09-28 01:34:43 +0000294#
drh94e4f822006-02-15 02:00:25 +0000295AC_ARG_ENABLE(tcl, AC_HELP_STRING([--disable-tcl],[do not build TCL extension]),
drh7b5717e2004-11-25 13:50:01 +0000296 [use_tcl=$enableval],[use_tcl=yes])
297if test "${use_tcl}" = "yes" ; then
drh94e4f822006-02-15 02:00:25 +0000298 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 +0000299 AC_MSG_CHECKING([for Tcl configuration])
300 AC_CACHE_VAL(ac_cv_c_tclconfig,[
301 # First check to see if --with-tcl was specified.
302 if test x"${with_tclconfig}" != x ; then
303 if test -f "${with_tclconfig}/tclConfig.sh" ; then
304 ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
305 else
306 AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
307 fi
drh71eb93e2001-09-28 01:34:43 +0000308 fi
vapierfe7e82e2009-01-26 21:39:33 +0000309
310 # Start autosearch by asking tclsh
drhe74f4652012-08-15 16:06:54 +0000311 if test x"${ac_cv_c_tclconfig}" = x ; then
312 if test x"$cross_compiling" = xno; then
313 for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}`
314 do
315 if test -f "$i/tclConfig.sh" ; then
316 ac_cv_c_tclconfig="$i"
317 break
318 fi
319 done
320 fi
vapierfe7e82e2009-01-26 21:39:33 +0000321 fi
322
drh7b5717e2004-11-25 13:50:01 +0000323 # then check for a private Tcl installation
324 if test x"${ac_cv_c_tclconfig}" = x ; then
325 for i in \
326 ../tcl \
327 `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
328 `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
329 `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
330 ../../tcl \
331 `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
332 `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
333 `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
334 ../../../tcl \
335 `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
336 `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
337 `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null`
338 do
339 if test -f "$i/unix/tclConfig.sh" ; then
340 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
341 break
342 fi
343 done
344 fi
345
346 # check in a few common install locations
347 if test x"${ac_cv_c_tclconfig}" = x ; then
348 for i in \
349 `ls -d ${libdir} 2>/dev/null` \
350 `ls -d /usr/local/lib 2>/dev/null` \
351 `ls -d /usr/contrib/lib 2>/dev/null` \
352 `ls -d /usr/lib 2>/dev/null`
353 do
354 if test -f "$i/tclConfig.sh" ; then
355 ac_cv_c_tclconfig=`(cd $i; pwd)`
356 break
357 fi
358 done
359 fi
360
361 # check in a few other private locations
362 if test x"${ac_cv_c_tclconfig}" = x ; then
363 for i in \
364 ${srcdir}/../tcl \
365 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
366 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
367 `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null`
368 do
369 if test -f "$i/unix/tclConfig.sh" ; then
370 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
371 break
372 fi
373 done
374 fi
375 ])
376
377 if test x"${ac_cv_c_tclconfig}" = x ; then
378 use_tcl=no
379 AC_MSG_WARN(Can't find Tcl configuration definitions)
380 AC_MSG_WARN(*** Without Tcl the regression tests cannot be executed ***)
381 AC_MSG_WARN(*** Consider using --with-tcl=... to define location of Tcl ***)
382 else
383 TCL_BIN_DIR=${ac_cv_c_tclconfig}
384 AC_MSG_RESULT(found $TCL_BIN_DIR/tclConfig.sh)
385
386 AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
387 if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
388 AC_MSG_RESULT([loading])
389 . $TCL_BIN_DIR/tclConfig.sh
390 else
391 AC_MSG_RESULT([file not found])
392 fi
393
394 #
395 # If the TCL_BIN_DIR is the build directory (not the install directory),
396 # then set the common variable name to the value of the build variables.
397 # For example, the variable TCL_LIB_SPEC will be set to the value
398 # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
399 # instead of TCL_BUILD_LIB_SPEC since it will work with both an
400 # installed and uninstalled version of Tcl.
401 #
402
mlcreechab1c47b2008-03-09 02:51:10 +0000403 if test -f $TCL_BIN_DIR/Makefile ; then
drh7b5717e2004-11-25 13:50:01 +0000404 TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
405 TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
406 TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
407 fi
408
409 #
410 # eval is required to do the TCL_DBGX substitution
411 #
412
413 eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
414 eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
415 eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
416
417 eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
418 eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
419 eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
420
421 AC_SUBST(TCL_VERSION)
422 AC_SUBST(TCL_BIN_DIR)
423 AC_SUBST(TCL_SRC_DIR)
drh7b5717e2004-11-25 13:50:01 +0000424 AC_SUBST(TCL_INCLUDE_SPEC)
425
426 AC_SUBST(TCL_LIB_FILE)
427 AC_SUBST(TCL_LIB_FLAG)
428 AC_SUBST(TCL_LIB_SPEC)
429
430 AC_SUBST(TCL_STUB_LIB_FILE)
431 AC_SUBST(TCL_STUB_LIB_FLAG)
432 AC_SUBST(TCL_STUB_LIB_SPEC)
drhd881ce82015-03-31 17:01:52 +0000433 AC_SUBST(TCL_SHLIB_SUFFIX)
drh7b5717e2004-11-25 13:50:01 +0000434 fi
drh71eb93e2001-09-28 01:34:43 +0000435fi
drh7b5717e2004-11-25 13:50:01 +0000436if test "${use_tcl}" = "no" ; then
437 HAVE_TCL=""
438else
439 HAVE_TCL=1
drh71eb93e2001-09-28 01:34:43 +0000440fi
drh7b5717e2004-11-25 13:50:01 +0000441AC_SUBST(HAVE_TCL)
drh71eb93e2001-09-28 01:34:43 +0000442
443##########
444# Figure out what C libraries are required to compile programs
445# that use "readline()" library.
446#
vapier4c10a8a2007-02-17 14:28:26 +0000447TARGET_READLINE_LIBS=""
448TARGET_READLINE_INC=""
449TARGET_HAVE_READLINE=0
450AC_ARG_ENABLE([readline],
451 [AC_HELP_STRING([--disable-readline],[disable readline support [default=detect]])],
452 [with_readline=$enableval],
453 [with_readline=auto])
454
455if test x"$with_readline" != xno; then
456 found="yes"
457
458 AC_ARG_WITH([readline-lib],
459 [AC_HELP_STRING([--with-readline-lib],[specify readline library])],
460 [with_readline_lib=$withval],
461 [with_readline_lib="auto"])
462 if test "x$with_readline_lib" = xauto; then
463 save_LIBS="$LIBS"
464 LIBS=""
465 AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap], [term_LIBS="$LIBS"], [term_LIBS=""])
466 AC_CHECK_LIB([readline], [readline], [TARGET_READLINE_LIBS="-lreadline"], [found="no"])
467 TARGET_READLINE_LIBS="$TARGET_READLINE_LIBS $term_LIBS"
468 LIBS="$save_LIBS"
469 else
470 TARGET_READLINE_LIBS="$with_readline_lib"
471 fi
472
473 AC_ARG_WITH([readline-inc],
474 [AC_HELP_STRING([--with-readline-inc],[specify readline include paths])],
475 [with_readline_inc=$withval],
476 [with_readline_inc="auto"])
477 if test "x$with_readline_inc" = xauto; then
478 AC_CHECK_HEADER(readline.h, [found="yes"], [
479 found="no"
480 if test "$cross_compiling" != yes; then
481 for dir in /usr /usr/local /usr/local/readline /usr/contrib /mingw; do
482 for subdir in include include/readline; do
483 AC_CHECK_FILE($dir/$subdir/readline.h, found=yes)
484 if test "$found" = "yes"; then
485 TARGET_READLINE_INC="-I$dir/$subdir"
486 break
487 fi
488 done
489 test "$found" = "yes" && break
490 done
491 fi
492 ])
493 else
494 TARGET_READLINE_INC="$with_readline_inc"
495 fi
496
497 if test x"$found" = xno; then
498 TARGET_READLINE_LIBS=""
499 TARGET_READLINE_INC=""
500 TARGET_HAVE_READLINE=0
501 else
502 TARGET_HAVE_READLINE=1
503 fi
drh71eb93e2001-09-28 01:34:43 +0000504fi
vapier4c10a8a2007-02-17 14:28:26 +0000505
drh71eb93e2001-09-28 01:34:43 +0000506AC_SUBST(TARGET_READLINE_LIBS)
vapier4c10a8a2007-02-17 14:28:26 +0000507AC_SUBST(TARGET_READLINE_INC)
508AC_SUBST(TARGET_HAVE_READLINE)
drh71eb93e2001-09-28 01:34:43 +0000509
510##########
drhf1878b42006-01-23 18:06:52 +0000511# Figure out what C libraries are required to compile programs
512# that use "fdatasync()" function.
513#
drhf1878b42006-01-23 18:06:52 +0000514AC_SEARCH_LIBS(fdatasync, [rt])
drhf1878b42006-01-23 18:06:52 +0000515
drh71eb93e2001-09-28 01:34:43 +0000516#########
tpoindex9d9f76c2005-01-03 21:28:56 +0000517# check for debug enabled
drh94e4f822006-02-15 02:00:25 +0000518AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain]),
tpoindex9d9f76c2005-01-03 21:28:56 +0000519 [use_debug=$enableval],[use_debug=no])
520if test "${use_debug}" = "yes" ; then
drheae3a0d2006-03-03 20:37:52 +0000521 TARGET_DEBUG="-DSQLITE_DEBUG=1"
tpoindex9d9f76c2005-01-03 21:28:56 +0000522else
523 TARGET_DEBUG="-DNDEBUG"
524fi
525AC_SUBST(TARGET_DEBUG)
526
527#########
mlcreech94984912008-03-04 19:03:08 +0000528# See whether we should use the amalgamation to build
529AC_ARG_ENABLE(amalgamation, AC_HELP_STRING([--disable-amalgamation],
mlcreech969b2cd2008-03-14 04:11:03 +0000530 [Disable the amalgamation and instead build all files separately]),
mlcreech94984912008-03-04 19:03:08 +0000531 [use_amalgamation=$enableval],[use_amalgamation=yes])
mlcreechf3868112008-03-11 18:03:30 +0000532if test "${use_amalgamation}" != "yes" ; then
mlcreech94984912008-03-04 19:03:08 +0000533 USE_AMALGAMATION=0
534fi
535AC_SUBST(USE_AMALGAMATION)
536
537#########
mlcreecha4edab02008-03-06 04:14:17 +0000538# See whether we should allow loadable extensions
drh05c7e0b2015-01-10 14:27:17 +0000539AC_ARG_ENABLE(load-extension, AC_HELP_STRING([--disable-load-extension],
540 [Disable loading of external extensions]),
541 [use_loadextension=$enableval],[use_loadextension=yes])
mlcreecha4edab02008-03-06 04:14:17 +0000542if test "${use_loadextension}" = "yes" ; then
shanefbedede2008-07-22 05:05:01 +0000543 OPT_FEATURE_FLAGS=""
drhdbe4b882011-06-20 18:00:17 +0000544 AC_SEARCH_LIBS(dlopen, dl)
mlcreecha4edab02008-03-06 04:14:17 +0000545else
shanefbedede2008-07-22 05:05:01 +0000546 OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1"
mlcreecha4edab02008-03-06 04:14:17 +0000547fi
mlcreecha4edab02008-03-06 04:14:17 +0000548
mlcreechaac7b932008-04-01 02:45:22 +0000549#########
shaneb1cd7302008-10-22 18:27:31 +0000550# attempt to duplicate any OMITS and ENABLES into the $(OPT_FEATURE_FLAGS) parameter
shanefbedede2008-07-22 05:05:01 +0000551for option in $CFLAGS $CPPFLAGS
552do
553 case $option in
danielk197733a14782008-08-04 14:50:05 +0000554 -DSQLITE_OMIT*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
shaneb1cd7302008-10-22 18:27:31 +0000555 -DSQLITE_ENABLE*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
shanefbedede2008-07-22 05:05:01 +0000556 esac
557done
558AC_SUBST(OPT_FEATURE_FLAGS)
559
560
shaneb1cd7302008-10-22 18:27:31 +0000561# attempt to remove any OMITS and ENABLES from the $(CFLAGS) parameter
shanefbedede2008-07-22 05:05:01 +0000562ac_temp_CFLAGS=""
563for option in $CFLAGS
564do
565 case $option in
566 -DSQLITE_OMIT*) ;;
shaneb1cd7302008-10-22 18:27:31 +0000567 -DSQLITE_ENABLE*) ;;
danielk197733a14782008-08-04 14:50:05 +0000568 *) ac_temp_CFLAGS="$ac_temp_CFLAGS $option";;
shanefbedede2008-07-22 05:05:01 +0000569 esac
570done
571CFLAGS=$ac_temp_CFLAGS
572
573
shaneb1cd7302008-10-22 18:27:31 +0000574# attempt to remove any OMITS and ENABLES from the $(CPPFLAGS) parameter
shanefbedede2008-07-22 05:05:01 +0000575ac_temp_CPPFLAGS=""
576for option in $CPPFLAGS
577do
578 case $option in
579 -DSQLITE_OMIT*) ;;
shaneb1cd7302008-10-22 18:27:31 +0000580 -DSQLITE_ENABLE*) ;;
danielk197733a14782008-08-04 14:50:05 +0000581 *) ac_temp_CPPFLAGS="$ac_temp_CPPFLAGS $option";;
shanefbedede2008-07-22 05:05:01 +0000582 esac
583done
584CPPFLAGS=$ac_temp_CPPFLAGS
585
586
shaneb1cd7302008-10-22 18:27:31 +0000587# attempt to remove any OMITS and ENABLES from the $(BUILD_CFLAGS) parameter
shanefbedede2008-07-22 05:05:01 +0000588ac_temp_BUILD_CFLAGS=""
589for option in $BUILD_CFLAGS
590do
591 case $option in
592 -DSQLITE_OMIT*) ;;
shaneb1cd7302008-10-22 18:27:31 +0000593 -DSQLITE_ENABLE*) ;;
danielk197733a14782008-08-04 14:50:05 +0000594 *) ac_temp_BUILD_CFLAGS="$ac_temp_BUILD_CFLAGS $option";;
shanefbedede2008-07-22 05:05:01 +0000595 esac
596done
597BUILD_CFLAGS=$ac_temp_BUILD_CFLAGS
598
599
600#########
601# See whether we should use GCOV
mlcreechaac7b932008-04-01 02:45:22 +0000602AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov],
603 [Enable coverage testing using gcov]),
604 [use_gcov=$enableval],[use_gcov=no])
605if test "${use_gcov}" = "yes" ; then
606 USE_GCOV=1
607else
608 USE_GCOV=0
609fi
610AC_SUBST(USE_GCOV)
611
drhaf6edf52005-10-04 18:38:49 +0000612
drh71eb93e2001-09-28 01:34:43 +0000613#########
mlcreechb87057f2008-03-06 07:19:20 +0000614# Output the config header
mlcreech23797062008-03-20 02:25:35 +0000615AC_CONFIG_HEADERS(config.h)
mlcreechb87057f2008-03-06 07:19:20 +0000616
617#########
drh71eb93e2001-09-28 01:34:43 +0000618# Generate the output files.
619#
mlcreech8390bc32008-03-06 08:54:38 +0000620AC_SUBST(BUILD_CFLAGS)
a.rottmannc7e93832003-03-24 09:39:32 +0000621AC_OUTPUT([
622Makefile
dougcurrie12b34442004-07-19 03:24:59 +0000623sqlite3.pc
a.rottmannc7e93832003-03-24 09:39:32 +0000624])