1#
2# This file describes a "configure" script that is used to build
3# makefiles for a particular platform.  Process this file using
4# Autoconf version 1.13 in order to generate that script.  All
5# lines of this file up to the AC_INIT macro are ignored.
6#
7# The build process allows for using a cross-compiler.  But the default
8# action is to target the same platform that we are running on.  The
9# configure script needs to discover the following properties of the
10# build and target systems:
11#
12#    srcdir
13#
14#        The is the name of the directory that contains the
15#        "configure" shell script.  All source files are
16#        located relative to this directory.
17#
18#    bindir
19#
20#        The name of the directory where executables should be
21#        written by the "install" target of the makefile.
22#
23#    program_prefix
24#
25#        Add this prefix to the names of all executables that run
26#        on the target machine.  Default: ""
27#
28#    ENABLE_SHARED
29#
30#        True if shared libraries should be generated.
31#
32#    BUILD_CC
33#
34#        The name of a command that is used to convert C
35#        source files into executables that run on the build
36#        platform.
37#
38#    BUILD_CFLAGS
39#
40#        Switches that the build compiler needs in order to construct
41#        command-line programs.
42#
43#    BUILD_LIBS
44#
45#        Libraries that the build compiler needs in order to construct
46#        command-line programs.
47#
48#    BUILD_EXEEXT
49#
50#        The filename extension for executables on the build
51#        platform.  "" for Unix and ".exe" for Windows.
52#
53#    TARGET_CC
54#
55#        The name of a command that runs on the build platform
56#        and converts C source files into *.o files for the
57#        target platform.  In other words, the cross-compiler.
58#
59#    TARGET_CFLAGS
60#
61#        Switches that the target compiler needs to turn C source files
62#        into *.o files.  Do not include TARGET_TCL_INC in this list.
63#        Makefiles might add additional switches such as "-I.".
64#
65#    TARGET_TCL_LIBS
66#
67#        This is the library directives passed to the target linker
68#        that cause the executable to link against Tcl.  This might
69#        be a switch like "-ltcl8.0" or pathnames of library file
70#        like "../../src/libtcl8.0.a".
71#
72#    TARGET_TCL_INC
73#
74#        This variables define the directory that contain header
75#        files for Tcl.  If the compiler is able to find <tcl.h>
76#        on its own, then this can be blank.
77#
78#    TARGET_READLINE_LIBS
79#
80#        This is the library directives passed to the target linker
81#        that cause the executable to link against the readline library.
82#        This might be a switch like "-lreadline" or pathnames of library
83#        file like "../../src/libreadline.a".
84#
85#    TARGET_READLINE_INC
86#
87#        This variables define the directory that contain header
88#        files for the readline library.  If the compiler is able
89#        to find <readline.h> on its own, then this can be blank.
90#
91#    TARGET_LINK
92#
93#        The name of the linker that combines *.o files generated
94#        by TARGET_CC into executables for the target platform.
95#
96#    TARGET_LIBS
97#
98#        Additional libraries or other switch that the target linker needs
99#        to build an executable on the target.  Do not include
100#        on this list any libraries in TARGET_TCL_LIBS and
101#        TARGET_READLINE_LIBS, etc.
102#
103#    TARGET_EXEEXT
104#
105#        The filename extension for executables on the
106#        target platform.  "" for Unix and ".exe" for windows.
107#
108# The generated configure script will make an attempt to guess
109# at all of the above parameters.  You can override any of
110# the guesses by setting the environment variable named
111# "config_AAAA" where "AAAA" is the name of the parameter
112# described above.  (Exception: srcdir cannot be set this way.)
113# If you have a file that sets one or more of these environment
114# variables, you can invoke configure as follows:
115#
116#           configure --with-hints=FILE
117#
118# where FILE is the name of the file that sets the environment
119# variables.  FILE should be an absolute pathname.
120#
121# If you have a Tcl/Tk/BLT source distribution available, then the
122# files in that distribution will be used instead of any other
123# Tcl/Tk/BLT files the script might discover if you tell the configure
124# script about the source tree.  Use commandline options:
125#
126#         --with-tcl=PATH  --with-tk=PATH  --with-blt=PATH
127#
128# Or set environment variables config_WITH_TCL, config_WITH_TK, or
129# config_WITH_BLT.
130#
131# This configure.in file is easy to reuse on other projects.  Just
132# change the argument to AC_INIT().  And disable any features that
133# you don't need (for example BLT) by erasing or commenting out
134# the corresponding code.
135#
136AC_INIT(src/sqlite.h.in)
137
138dnl Put the RCS revision string after AC_INIT so that it will also
139dnl show in in configure.
140# The following RCS revision string applies to configure.in
141# $Revision: 1.7 $
142
143#########
144# Programs needed
145#
146AC_PROG_LIBTOOL
147AC_PROG_INSTALL
148
149#########
150# Set up an appropriate program prefix
151#
152if test "$program_prefix" = "NONE"; then
153  program_prefix=""
154fi
155AC_SUBST(program_prefix)
156
157if test -f VERSION; then
158  VERSION=`cat VERSION`
159  echo "Version set to $VERSION"
160fi
161AC_SUBST(VERSION)
162
163#########
164# Check to see if the --with-hints=FILE option is used.  If there is none,
165# then check for a files named "$host.hints" and ../$hosts.hints where
166# $host is the hostname of the build system.  If still no hints are
167# found, try looking in $system.hints and ../$system.hints where
168# $system is the result of uname -s.
169#
170AC_ARG_WITH(hints,
171  [  --with-hints=FILE       Read configuration options from FILE],
172  hints=$withval)
173if test "$hints" = ""; then
174  host=`hostname | sed 's/\..*//'`
175  if test -r $host.hints; then
176    hints=$host.hints
177  else
178     if test -r ../$host.hints; then
179       hints=../$host.hints
180     fi
181  fi
182fi
183if test "$hints" = ""; then
184  sys=`uname -s`
185  if test -r $sys.hints; then
186    hints=$sys.hints
187  else
188     if test -r ../$sys.hints; then
189       hints=../$sys.hints
190     fi
191  fi
192fi
193if test "$hints" != ""; then
194  AC_MSG_RESULT(reading hints from $hints)
195  . $hints
196fi
197
198#########
199# Locate a compiler for the build machine.  This compiler should
200# generate command-line programs that run on the build machine.
201#
202default_build_cflags="-g"
203if test "$config_BUILD_CC" = ""; then
204  AC_PROG_CC
205  if test "$cross_compiling" = "yes"; then
206    AC_MSG_ERROR([unable to find a compiler for building build tools])
207  fi
208  BUILD_CC=$CC
209  default_build_cflags=$CFLAGS
210else
211  BUILD_CC=$config_BUILD_CC
212  AC_MSG_CHECKING([host compiler])
213  CC=$BUILD_CC
214  AC_MSG_RESULT($BUILD_CC)
215fi
216AC_MSG_CHECKING([switches for the host compiler])
217if test "$config_BUILD_CFLAGS" != ""; then
218  CFLAGS=$config_BUILD_CFLAGS
219  BUILD_CFLAGS=$config_BUILD_CFLAGS
220else
221  BUILD_CFLAGS=$default_build_cflags
222fi
223AC_MSG_RESULT($BUILD_CFLAGS)
224if test "$config_BUILD_LIBS" != ""; then
225  BUILD_LIBS=$config_BUILD_LIBS
226fi
227AC_SUBST(BUILD_CC)
228AC_SUBST(BUILD_CFLAGS)
229AC_SUBST(BUILD_LIBS)
230
231##########
232# Locate a compiler that converts C code into *.o files that run on
233# the target machine.
234#
235AC_MSG_CHECKING([target compiler])
236if test "$config_TARGET_CC" != ""; then
237  TARGET_CC=$config_TARGET_CC
238else
239  TARGET_CC=$BUILD_CC
240fi
241AC_MSG_RESULT($TARGET_CC)
242AC_MSG_CHECKING([switches on the target compiler])
243if test "$config_TARGET_CFLAGS" != ""; then
244  TARGET_CFLAGS=$config_TARGET_CFLAGS
245else
246  TARGET_CFLAGS=$BUILD_CFLAGS
247fi
248AC_MSG_RESULT($TARGET_CFLAGS)
249AC_MSG_CHECKING([target linker])
250if test "$config_TARGET_LINK" = ""; then
251  TARGET_LINK=$TARGET_CC
252else
253  TARGET_LINK=$config_TARGET_LINK
254fi
255AC_MSG_RESULT($TARGET_LINK)
256AC_MSG_CHECKING([switches on the target compiler])
257if test "$config_TARGET_TFLAGS" != ""; then
258  TARGET_TFLAGS=$config_TARGET_TFLAGS
259else
260  TARGET_TFLAGS=$BUILD_CFLAGS
261fi
262if test "$config_TARGET_RANLIB" != ""; then
263  TARGET_RANLIB=$config_TARGET_RANLIB
264else
265  AC_PROG_RANLIB
266  TARGET_RANLIB=$RANLIB
267fi
268if test "$config_TARGET_AR" != ""; then
269  TARGET_AR=$config_TARGET_AR
270else
271  TARGET_AR='ar cr'
272fi
273AC_MSG_RESULT($TARGET_TFLAGS)
274AC_SUBST(TARGET_CC)
275AC_SUBST(TARGET_CFLAGS)
276AC_SUBST(TARGET_LINK)
277AC_SUBST(TARGET_LFLAGS)
278AC_SUBST(TARGET_RANLIB)
279AC_SUBST(TARGET_AR)
280
281# Set the $cross variable if we are cross-compiling.  Make
282# it 0 if we are not.
283#
284AC_MSG_CHECKING([if host and target compilers are the same])
285if test "$BUILD_CC" = "$TARGET_CC"; then
286  cross=0
287  AC_MSG_RESULT(yes)
288else
289  cross=1
290  AC_MSG_RESULT(no)
291fi
292
293##########
294# Are we using UTF-8 or iso8859 encodings?
295#
296AC_ARG_ENABLE(utf8,
297[  --enable-utf8           Use UTF-8 encodings],,enable_utf8=no)
298AC_MSG_CHECKING([character encoding])
299if test "$enable_utf8" = "no"; then
300  ENCODING=ISO8859
301  AC_MSG_RESULT([iso8859])
302else
303  ENCODING=UTF8
304  AC_MSG_RESULT([UTF-8])
305fi
306AC_SUBST(ENCODING)
307
308##########
309# Do we want to support in-ram databases for ATTACH DATABASE and sqlite_open
310#
311AC_ARG_ENABLE(incore-db,
312[  --enable-incore-db           Support incore database],,enable_incore_db=yes)
313AC_MSG_CHECKING([whether to support incore databases for attach and open])
314if test "$enable_incore_db" = "no"; then
315  INMEMORYDB=0
316  AC_MSG_RESULT([no])
317else
318  INMEMORYDB=1
319  AC_MSG_RESULT([yes])
320fi
321AC_SUBST(ALLOWATTACHMEM)
322
323##########
324# Do we want to support release
325#
326AC_ARG_ENABLE(releasemode,
327[  --enable-releasemode           Support libtool link to release mode],,enable_releasemode=no)
328AC_MSG_CHECKING([whether to support shared library linked as release mode or not])
329if test "$enable_releasemode" = "no"; then
330  ALLOWRELEASE=""
331  AC_MSG_RESULT([no])
332else
333  ALLOWRELEASE="-release `cat VERSION`"
334  AC_MSG_RESULT([yes])
335fi
336AC_SUBST(ALLOWRELEASE)
337
338##########
339# Do we want temporary databases in memory
340#
341AC_ARG_ENABLE(tempdb-in-ram,
342[  --enable-tempdb-in-ram     Use an in-ram database for temporary tables],,enable_tempdb_in_ram=no)
343AC_MSG_CHECKING([whether to use an in-ram database for temporary tables])
344case "$enable_tempdb_in_ram" in
345  never )
346    TEMP_STORE=0
347    AC_MSG_RESULT([never])
348  ;;
349  no )
350    INMEMORYDB=1
351    TEMP_STORE=1
352    AC_MSG_RESULT([no])
353  ;;
354  always )
355    INMEMORYDB=1
356    TEMP_STORE=3
357    AC_MSG_RESULT([always])
358  ;;
359  * )
360    INMEMORYDB=1
361    TEMP_STORE=2
362    AC_MSG_RESULT([yes])
363  ;;
364esac
365
366AC_SUBST(INMEMORYDB)
367AC_SUBST(TEMP_STORE)
368
369###########
370# Lots of things are different if we are compiling for Windows using
371# the CYGWIN environment.  So check for that special case and handle
372# things accordingly.
373#
374AC_MSG_CHECKING([if executables have the .exe suffix])
375if test "$config_BUILD_EXEEXT" = ".exe"; then
376  CYGWIN=yes
377  AC_MSG_RESULT(yes)
378else
379  AC_MSG_RESULT(unknown)
380fi
381if test "$CYGWIN" != "yes"; then
382  AC_CYGWIN
383fi
384if test "$CYGWIN" = "yes"; then
385  BUILD_EXEEXT=.exe
386else
387  BUILD_EXEEXT=$EXEEXT
388fi
389if test "$cross" = "0"; then
390  TARGET_EXEEXT=$BUILD_EXEEXT
391else
392  TARGET_EXEEXT=$config_TARGET_EXEEXT
393fi
394if test "$TARGET_EXEEXT" = ".exe"; then
395  OS_UNIX=0
396  OS_WIN=1
397  tclsubdir=win
398else
399  OS_UNIX=1
400  OS_WIN=0
401  tclsubdir=unix
402fi
403TARGET_CFLAGS="$TARGET_CFLAGS -DOS_UNIX=$OS_UNIX -DOS_WIN=$OS_WIN"
404
405AC_SUBST(BUILD_EXEEXT)
406AC_SUBST(OS_UNIX)
407AC_SUBST(OS_WIN)
408AC_SUBST(TARGET_EXEEXT)
409
410##########
411# Extract generic linker options from the environment.
412#
413if test "$config_TARGET_LIBS" != ""; then
414  TARGET_LIBS=$config_TARGET_LIBS
415else
416  TARGET_LIBS=""
417fi
418AC_SUBST(TARGET_LIBS)
419
420##########
421# Figure out what C libraries are required to compile Tcl programs.
422#
423if test "$config_TARGET_TCL_LIBS" != ""; then
424  TARGET_TCL_LIBS="$config_TARGET_TCL_LIBS"
425else
426  if test "$with_tcl" != ""; then
427    extra=`echo $with_tcl/$tclsubdir/libtcl8*.a`
428  fi
429  CC=$TARGET_CC
430  AC_CHECK_FUNC(sin, LIBS="", LIBS="-lm")
431  AC_CHECK_LIB(dl, dlopen)
432  otherlibs=$LIBS
433  if test "$extra" != ""; then
434    LIBS=$extra
435  else
436    LIBS=""
437    AC_SEARCH_LIBS(Tcl_Init, dnl
438        tcl8.4 tcl8.3 tcl84 tcl83 tcl,,,$otherlibs)
439  fi
440  TARGET_TCL_LIBS="$LIBS $otherlibs"
441fi
442AC_SUBST(TARGET_TCL_LIBS)
443
444##########
445# Figure out where to get the TCL header files.
446#
447AC_MSG_CHECKING([TCL header files])
448found=no
449if test "$config_TARGET_TCL_INC" != ""; then
450  TARGET_TCL_INC=$config_TARGET_TCL_INC
451  found=yes
452else
453  if test "$with_tcl" != ""; then
454    TARGET_TCL_INC="-I$with_tcl/generic -I$with_tcl/$tclsubdir"
455    found=yes
456  else
457    TARGET_TCL_INC=""
458    found=no
459  fi
460fi
461if test "$found" = "yes"; then
462  AC_MSG_RESULT($TARGET_TCL_INC)
463else
464  AC_MSG_RESULT(not specified: still searching...)
465  AC_CHECK_HEADER(tcl.h, [found=yes])
466fi
467if test "$found" = "no"; then
468  for dir in /usr/local /usr/X11 /usr/X11R6 /usr/pkg /usr/contrib /usr; do
469    AC_CHECK_FILE($dir/include/tcl.h, found=yes)
470    if test "$found" = "yes"; then
471      TARGET_TCL_INC="-I$dir/include"
472      break
473    fi
474  done
475fi
476if test "$found" = "no"; then
477  TARGET_TCL_INC="-DNO_TCL=1"
478fi
479AC_SUBST(TARGET_TCL_INC)
480
481##########
482# Figure out what C libraries are required to compile programs
483# that use "readline()" library.
484#
485if test "$config_TARGET_READLINE_LIBS" != ""; then
486  TARGET_READLINE_LIBS="$config_TARGET_READLINE_LIBS"
487else
488  CC=$TARGET_CC
489  LIBS=""
490  AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap])
491  AC_CHECK_LIB([readline], [readline])
492  TARGET_READLINE_LIBS="$LIBS"
493fi
494AC_SUBST(TARGET_READLINE_LIBS)
495
496##########
497# Figure out where to get the READLINE header files.
498#
499AC_MSG_CHECKING([readline header files])
500found=no
501if test "$config_TARGET_READLINE_INC" != ""; then
502  TARGET_READLINE_INC=$config_TARGET_READLINE_INC
503  found=yes
504fi
505if test "$found" = "yes"; then
506  AC_MSG_RESULT($TARGET_READLINE_INC)
507else
508  AC_MSG_RESULT(not specified: still searching...)
509  AC_CHECK_HEADER(readline.h, [found=yes])
510fi
511if test "$found" = "no"; then
512  for dir in /usr /usr/local /usr/local/readline /usr/contrib /mingw; do
513    AC_CHECK_FILE($dir/include/readline.h, found=yes)
514    if test "$found" = "yes"; then
515      TARGET_READLINE_INC="-I$dir/include"
516      break
517    fi
518    AC_CHECK_FILE($dir/include/readline/readline.h, found=yes)
519    if test "$found" = "yes"; then
520      TARGET_READLINE_INC="-I$dir/include/readline"
521      break
522    fi
523  done
524fi
525if test "$found" = "yes"; then
526  if test "$TARGET_READLINE_LIBS" = ""; then
527    TARGET_HAVE_READLINE=0
528  else
529    TARGET_HAVE_READLINE=1
530  fi
531else
532  TARGET_HAVE_READLINE=0
533fi
534AC_SUBST(TARGET_READLINE_INC)
535AC_SUBST(TARGET_HAVE_READLINE)
536
537#########
538# Figure out whether or not we have a "usleep()" function.
539#
540AC_CHECK_FUNC(usleep, [TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_USLEEP=1"])
541
542#########
543# Generate the output files.
544#
545AC_OUTPUT([
546Makefile
547sqlite.pc
548])
549