set DUMP_DEFINES_TXT ./config.defines.txt
# $DUMP_DEFINES_JSON is the autosetup counterpart of the historical
# "DEFS" var which was generated by the autotools in the pre-processed
-# autotools builds (but not in the canonical tree). This is used by at
-# least one high-profile client to extract build config info for use
-# in compiling a scripting-language binding, so its name should not be
-# arbitrarily changed.
-#
-# 2024-10-26: generation of this file is disabled (via an empty file
-# name) until/unless someone voices a specific interest in it. The
-# original motivating use case is handled fine by sqlite_cfg.h.
+# autotools builds (but not in the canonical tree). Generation of this
+# file is disabled (via an empty file name) until/unless someone
+# voices a specific interest in it. The original motivating use case
+# is handled fine by sqlite_cfg.h.
set DUMP_DEFINES_JSON ""; #./config.defines.json
########################################################################
# Programs needed
if {"" eq [proj-bin-define install]} {
proj-warn "Cannot find install binary, so 'make install' will not work."
- # Reminder: we historically have ./install-sh in the source tree.
- # Can we not simply use that?
- #
- # define BIN_INSTALL "$top_srcdir/install-sh"
- #
- # Nope: it MOVES its source files over the target, which breaks the
- # installation in some cases, e.g. when libtclsqlite3.so is built in
- # response to 'make install' and libsqlite3.a is moved before
- # libtclsqlite3.so is linked. It's easy to hack to use cp instead
- # of mv (simply replace the instcmd=... bit) but that won't retain
- # the source timestamp and permissions unless we use cp's -p flag,
- # which may not be portable enough.
}
########################################################################
# We differentiate between two C compilers: the one used for binaries
-# which are to run on the build system (BUILD_CC, a.k.a. BCC) and the
-# one used for compiling binaries for the target system (CC,
-# a.k.a. TCC). Normally they're the same, but they will differ when
+# which are to run on the build system (in autosetup it's called
+# CC_FOR_BUILD and in Makefile.in it's $(B.cc)) and the one used for
+# compiling binaries for the target system (CC a.k.a. $(T.cc)).
+# Normally they're the same, but they will differ when
# cross-compiling.
-define BUILD_CC [get-define CC_FOR_BUILD]
define BUILD_CFLAGS [get-env BUILD_CFLAGS {-g}]
########################################################################
# be empty - this tree requires TCL to generated numerous
# components.
#
-define TCLSH_CMD {exit 1}
-define HAVE_TCL 0
+define TCLSH_CMD false ; # Significant is that it exits with non-0
+define HAVE_TCL 0 ; # Will be enabled via --tcl or a successful search
proc sqlite-check-tcl {} {
# TODO: document the steps this is taking.
if {![opt-bool tcl]} {
sqlite-check-tcl
########################################################################
-# Check which TCL to use as a code generator. Prefer jimsh simply
-# because we have it in-tree (it's part of autosetup), unless
-# --with-tclsh=X is used, in which case prefix X.
+# sqlite-determine-codegen-tcl checks which TCL to use as a code
+# generator. By default, prefer jimsh simply because we have it
+# in-tree (it's part of autosetup) unless --with-tclsh=X is used, in
+# which case prefix X.
#
# Returns the name of the TCL it selects. Fails fatally if it cannot
# detect a TCL appropriate for code generation.
+#
+# Defines:
+#
+# - BTCLSH = the TCL shell used for code generation. It may set this
+# to an unexpanded makefile var name.
+#
+# - CFLAGS_JIMSH = any flags needed for buildng a BTCLSH-compatible
+# jimsh.
proc sqlite-determine-codegen-tcl {} {
msg-result "Checking for TCL to use for code generation... "
define CFLAGS_JIMSH {}
} elseif {[file-isexec "${tpre}/bin/tclsh"]} {
define TCLSH_CMD "${tpre}/bin/tclsh"
}
- unset tv
}
- unset tpre
}
set cgtcl [get-define TCLSH_CMD]
if {![file exists $cgtcl]} {
return $cgtcl
}; # sqlite-determine-codegen-tcl
msg-result "TCL for code generation: [sqlite-determine-codegen-tcl]"
-
# /TCL
########################################################################
# - CFLAGS_READLINE = compilation flags for clients or empty string.
#
# Note that LDFLAGS_READLINE and CFLAGS_READLINE may refer to
-# linenoise or editline, not necessarily libreadline.
+# linenoise or editline, not necessarily libreadline. In some cases
+# it will set HAVE_READLINE=1 when it's really using editline, for
+# reasons described in this function's comments.
#
# Returns a string describing which line-editing approach to use, or
# "none" if no option is available.
define HAVE_EDITLINE 0
define LDFLAGS_READLINE ""
define CFLAGS_READLINE ""
- set failIfNotFound 0 ; # Set to 1 for explicit --FEATURE requests when FEATURE is not found
- set libsForReadline {readline edit} ; # -l names to check for readline()
+ set failIfNotFound 0 ; # Set to 1 for explicit --FEATURE requests
+ set libsForReadline {readline edit} ; # -l<LIB> names to check for readline().
+ # The libedit check changes this.
set editLibName "readline" ; # "readline" or "editline"
set editLibDef "HAVE_READLINE" ; # "HAVE_READLINE" or "HAVE_EDITLINE"
- set check [opt-val with-linenoise]
- if {"" ne $check} {
- # Use linenoise...
- set dirLn $check
+ set dirLn [opt-val with-linenoise]
+ if {"" ne $dirLn} {
+ # Use linenoise from a copy of its sources (not a library)...
if {![file isdir $dirLn]} {
proj-fatal "--with-linenoise value is not a directory"
} elseif {![file exists $dirLn/linenoise.c] } {
sqlite-add-shell-opt -DHAVE_LINENOISE=1
return "linenoise"
} elseif {[opt-bool editline]} {
- # libedit mimics of libreadline and on some systems does not
- # have its own header installed (instead, that of libreadline is used).
- # We treat --editline as, for purposes of this tree, readline except
- # that we'll link against libedit if it's available (and fail if
- # it's not). We will use either API's header file
+ # libedit mimics libreadline and on some systems does not have its
+ # own header installed (instead, that of libreadline is used).
#
# shell.c historically expects HAVE_EDITLINE to be set for
# libedit, but it then expects to see <editline/readline.h>, which
- # some system's don't actually have, despite having libedit. If we
- # end up finding <editline/readline.h> below, we will use
+ # some system's don't actually have, despite having libedit. If
+ # we end up finding <editline/readline.h> below, we will use
# -DHAVE_EDITLINE=1, else we will use -DHAVE_READLINE=1. In either
# case, we will link against libedit.
set failIfNotFound 1
msg-result "Readline support explicitly disabled with --disable-readline"
return "none"
} elseif {[proj-opt-was-provided readline]} {
- # If an explicit --enable-readline was used, fail if it's not found,
- # else treat the feature as optional.
+ # If an explicit --[enable-]readline was used, fail if it's not
+ # found, else treat the feature as optional.
set failIfNotFound 1
}
if {"auto" eq $rlInc} {
set rlInc ""
if {$::cross_compiling} {
- # ^^^ this check is derived from the legacy configure script
+ # ^^^ this check is derived from the legacy configure script.
proj-warn "Skipping check for readline.h because we're cross-compiling."
} else {
set dirs "[get-define prefix] /usr /usr/local /usr/local/readline /usr/contrib /mingw"
set subdirs "include/$editLibName"
- if {"readline" ne $editLibName} {
+ if {"editline" eq $editLibName} {
lappend subdirs include/readline
# ^^^ editline, on some systems, does not have its own header,
# and uses libreadline's header.
}
}
- # If readline.h was found/specified, look for libreadline...
+ # If readline.h was found/specified, look for lib(readline|edit)...
+ #
+ # This is not quite straightforward because both libreadline and
+ # libedit typically require some other library which (according to
+ # legacy autotools-generated tests) provides tgetent(3). On some
+ # systems that's built into libreadline/edit, on some (most?) its in
+ # lib[n]curses, and on some it's in libtermcap.
set rlLib ""
if {"" ne $rlInc} {
set rlLib [opt-val with-readline-ldflags]
}
}
+ # If we found a library, configure the build to use it...
if {"" ne $rlLib} {
if {"editline" eq $editLibName && "HAVE_READLINE" eq $editLibDef} {
proj-indented-notice {
- NOTE: this is libedit but using <readline/readline.h>,
- so will be compiled using -DHAVE_READLINE=1 but linked with
+ NOTE: the local libedit but uses <readline/readline.h> so we
+ will compile with -DHAVE_READLINE=1 but will link with
libedit.
}
}
define CFLAGS_READLINE $rlInc
proj-assert {expr {$editLibDef in {HAVE_READLINE HAVE_EDITLINE}}}
proj-assert {expr {$editLibName in {readline editline}}}
- define $editLibDef 1
sqlite-add-shell-opt -D${editLibDef}=1
msg-result "Using $editLibName flags: $rlInc $rlLib"
- # Now check whether rl_completion_matches() has a signature we can use.
- # cctest is producing unexpected test output when using:
- # -includes {stdio.h readline/readline.h}
- # so we have to use -source instead and write the whole test app inline
+ # Check whether rl_completion_matches() has a signature we can use
+ # and disable that sub-feature if it doesn't.
if {![cctest \
-cflags "$rlInc -D${editLibDef}" -libs $rlLib -nooutput 1 -source {
#include <stdio.h>
msg-result "Disabling math SQL functions"
}
-define cross_compiling ${cross_compiling}
-
-########################################################################
-# Emscripten SDK for building the web-based wasm components.
-#
-set emccsh $srcdir/tool/emcc.sh
-if {![get-define HAVE_WASI_SDK] && [proj-check-emsdk]} {
- define EMCC_WRAPPER $emccsh
- proj-make-from-dot-in $emccsh
- catch {exec chmod u+x $emccsh}
-} else {
- define EMCC_WRAPPER ""
- file delete -force $emccsh
-}
-unset emccsh
-
########################################################################
# ICU - International Components for Unicode
#
# --enable-icu-collations
#
# If both icu-ldflags and icu-config are provided, they are
-# cumulative. If neither are provided, icu-collations is not honored
+# cumulative. If neither are provided, icu-collations is not honored
# and a warning is emitted if it is provided.
#
# Design note: though we can automatically enable ICU if the
}; # sqlite-check-icu
sqlite-check-icu
+########################################################################
+# Emscripten SDK for building the web-based wasm components.
+#
+proc sqlite-check-emsdk {} {
+ set emccsh $::srcdir/tool/emcc.sh
+ if {![get-define HAVE_WASI_SDK] && [proj-check-emsdk]} {
+ define EMCC_WRAPPER $emccsh
+ proj-make-from-dot-in $emccsh
+ catch {exec chmod u+x $emccsh}
+ } else {
+ define EMCC_WRAPPER ""
+ file delete -force $emccsh
+ }
+}
+sqlite-check-emsdk
+
########################################################################
# Check for log(3) in libm and die with an error if it is not
-# found. $why should be the feature name which requires that function
-# (it's used only in error messages). defines LDFLAGS_MATH to the
-# required linker flags (which may be empty even if the math APIs are
-# found, depending on the OS).
-proc affirm-have-math {why} {
+# found. $featureName should be the feature name which requires that
+# function (it's used only in error messages). defines LDFLAGS_MATH to
+# the required linker flags (which may be empty even if the math APIs
+# are found, depending on the OS).
+proc affirm-have-math {featureName} {
if {![msg-quiet proj-check-function-in-lib log m]} {
- user-error "Missing math APIs for $why"
+ user-error "Missing math APIs for $featureName"
}
define LDFLAGS_MATH [get-define lib_log ""]
undefine lib_log