#
# 1) --debug is used by autosetup itself, so we have to rename it to
# --with-debug. We cannot use --enable-debug because that is, for
-# autosetup, and alias for --debug=1. Alternately, we can patch
+# autosetup, an alias for --debug=1. Alternately, we can patch
# autosetup to use --autosetup-debug for its own purposes instead.
#
# 2) In autosetup, all flags starting with (--enable, --disable) are
# forced to be booleans and receive special handling in how they're
# resolved. Because of that we have to rename:
#
-# 2.1) --enable-tempstore[=no] to --with-tempstore[=no].
+# 2.1) --enable-tempstore[=no] to --with-tempstore[=no], noting that
+# it has four legal values, not two.
#
########################################################################
# A gentle introduction to flags handling in autosetup
#
# Autosetup does no small amount of specialized handling for flags,
# especially booleans. Each bool-type --FLAG implicitly gets
-# --enable-FLAG and --disable-FLAG forms, and explicitly adding flags
-# with those prefixes will force them to be boolean flags. e.g. we
-# define a flag "readline", which will be interpreted in one of two
-# ways, depending on how it's invoked and how its default is defined:
+# --enable-FLAG and --disable-FLAG forms. e.g. we define a flag
+# "readline", which will be interpreted in one of two ways, depending
+# on how it's invoked and how its default is defined:
#
# --enable-readline ==> boolean true
# --disable-readline ==> boolean false
#
-# Trying to pass --readline or --readline=1 or --readline=0 will
-# result in an "unrecognized option" error, despite the the [options]
-# call listing the flag as "readline".
+# Passing --readline or --readline=1 is equivalent to passing
+# --enable-readline, and --readline=0 is equivalent to
+# --disable-readline.
#
# The behavior described above can lead lead to some confusion when
# writing help text. For example:
# options { json=1 {Disable JSON functions} }
#
# The reason the help text says "disable" is because a boolean option
-# defaulting to true is, in the --help text, rendered as:
+# which defaults to true is, in the --help text, rendered as:
#
# --disable-json Disable JSON functions
#
#
# Non-boolean flags, in contrast, use the names specifically given to
# them in the [options] invocation. e.g. "with-tcl" is the --with-tcl
-# flag. Autosetup may, however, choose to automatically alter the help
-# text, as demonstrated here:
-#
-# options {
-# readline=1 => {Disable readline support}
-# with-readline-lib: => {Readline library}
-# with-readline-inc: => {Readline include paths}
-# }
-#
-# $ ./configure --help | grep readline
-# --disable-readline disable readline support
-# --with-readline-lib specify readline library
-# --with-readline-inc specify readline include paths
-#
-# Note that it prefixed and lower-case the help message. Whether
-# that's a feature or a bug can be debated.
+# flag.
#
# Fetching values for flags:
#
#
# Non-boolean (i.e. string) flags:
# - [opt-val FLAG ?default?]
+# - [opt-str ...] - see the docs in ./autosetup/autosetup
#
########################################################################
set flags {
# When writing {help text blocks}, be aware that autosetup formats
- # them differently (left-aligned, under the --flag, if the block
- # starts with a newline.
+ # them differently (left-aligned, directly under the --flag) if the
+ # block starts with a newline. It does NOT expand vars and commands,
+ # but we use a [subst] call below which will replace (only) var
+ # refs.
# <build-modes>
shared=1 => {Disable build of shared libary}
# <tcl>
with-tcl:DIR =>
{Directory containing tclConfig.sh or a directory one level up from
- that, from which we can derive a directory containing tclConfig.sh.}
+ that, from which we can derive a directory containing tclConfig.sh.
+ A dir name of "prefix" is equivalent to the directory specified by
+ the --prefix flag.}
with-tclsh:PATH =>
{Full pathname of tclsh to use. It is used for (A) trying to find
tclConfig.sh and (B) all TCL-based code generation. Warning: if
if {".exe" eq [get-define TARGET_EXEEXT]} {
define SQLITE_OS_UNIX 0
define SQLITE_OS_WIN 1
- # todo? add -DSQLITE_OS_WIN=1 to CFLAGS or CFLAGS_sqlite3_os?
} else {
define SQLITE_OS_UNIX 1
define SQLITE_OS_WIN 0
- # todo? add -DSQLITE_OS_UNIX=1 to CFLAGS or CFLAGS_sqlite3_os
}
#########
# Programs needed
-cc-check-tools ld ar ; # must come before sqlite-check-wasi-sdk
+cc-check-tools ld ar ; # must come before [sqlite-check-wasi-sdk]
if {"" eq [proj-bin-define install]} {
proj-warn "Cannot find install binary, so 'make install' will not work."
+ define BIN_INSTALL false
}
########################################################################
proj-if-opt-truthy dev {
# --enable-dev needs to come early so that the downstream tests
- # which check for these flags will show the user their updated
- # state.
+ # which check for the following flags use their updated state.
proj-opt-set all 1
proj-opt-set debug 1
proj-opt-set amalgamation 0
define CFLAGS [get-env CFLAGS {-O0 -g}]
}
-define LINK_TOOLS_DYNAMICALLY [proj-opt-was-provided dynlink-tools]
-
########################################################################
# Handle --with-wasi-sdk=DIR
#
-# This must be run early on because it may change the toolchain and
-# disable a number of config options.
+# This must be run relatively early on because it may change the
+# toolchain and disable a number of config options.
proc sqlite-check-wasi-sdk {} {
set wasiSdkDir [opt-val with-wasi-sdk] ; # ??? [lindex [opt-val with-wasi-sdk] end]
define HAVE_WASI_SDK 0
msg-result "Using wasi-sdk clang. Disabling CLI shell modifying config flags:"
# Boolean (--enable-/--disable-) flags which must be switched off:
foreach opt {
+ dynlink-tools
editline
gcov
icu-collations
}; # sqlite-check-wasi-sdk
sqlite-check-wasi-sdk
+########################################################################
+# --dynlink-tools tells the build to dynamically link certain binaries
+# to libsqlite3.so instead of embedding a copy of the amalgamation.
+define LINK_TOOLS_DYNAMICALLY [proj-opt-was-provided dynlink-tools]
+
#
# Enable large file support (if special flags are necessary)
define HAVE_LFS 0
if {[proj-opt-was-provided soname]} {
set soname [join [opt-val soname] ""]
} else {
- set soname none; # enabling soname breaks linking for the --dynlink-tools feature
+ # Enabling soname breaks linking for the --dynlink-tools feature,
+ # and this project has no direct use for soname, so default to
+ # none. Package maintainers, on the other hand, like to have an
+ # soname.
+ set soname none
}
switch -exact -- $soname {
none - "" { return 0 }
# --soname was explicitly requested but not available, so fail fatally
proj-fatal "This environment does not support SONAME."
} else {
+ # --soname was not explicitly requested but not available, so just warn
msg-result "This environment does not support SONAME."
}
}}
# failure to find TCL is not fatal but a loud warning will be emitted.
#
proc sqlite-check-tcl {} {
+ rename sqlite-check-tcl ""
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
define TCLLIBDIR "" ; # Installation dir for TCL extension lib
if {![opt-bool tcl]} {
proj-indented-notice {
NOTE: TCL is disabled via --disable-tcl. This means that none
- of the TCL-based components, including tests and sqlite3_analyzer,
- will be built.
+ of the TCL-based components will be built, including tests
+ and sqlite3_analyzer.
}
return
}
# in main.mk (search it for T.tcl.env.sh) so that
# static/hand-written makefiles which import main.mk do not have
# to define that before importing main.mk. Even so, we export
- # TCLLIBDIR from here, which will cause the makefile to use this
- # one rather than to re-calculate it at make-time.
+ # TCLLIBDIR from here, which will cause the canonical makefile to
+ # use this one rather than to re-calculate it at make-time.
set tcllibdir [get-env TCLLIBDIR ""]
if {"" eq $tcllibdir} {
# Attempt to extract TCLLIBDIR from TCL's $auto_path
# 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.
+# which case prefer X.
#
# Returns the human-readable name of the TCL it selects. Fails fatally
# if it cannot detect a TCL appropriate for code generation.
set useJimForCodeGen 0 ; # Set to 1 when using jimsh for code generation.
# May affect later decisions.
proc sqlite-determine-codegen-tcl {} {
+ rename sqlite-determine-codegen-tcl ""
msg-result "Checking for TCL to use for code generation... "
define CFLAGS_JIMSH [proj-get-env CFLAGS_JIMSH {-O1}]
set cgtcl [opt-val with-tclsh jimsh]
+ if {"jimsh" ne $cgtcl} {
+ # When --with-tclsh=X is used, use that for all TCL purposes,
+ # including in-tree code generation, per developer request.
+ define BTCLSH "\$(TCLSH_CMD)"
+ return $cgtcl
+ }
set flagsToRestore {CC CFLAGS AS_CFLAGS CPPFLAGS AS_CPPFLAGS LDFLAGS LINKFLAGS LIBS CROSS}
define-push $flagsToRestore {
# We have to swap CC to CC_FOR_BUILD for purposes of the various
# block.
foreach flag $flagsToRestore {define $flag ""}
define CC [get-define CC_FOR_BUILD]
- if {"jimsh" ne $cgtcl} {
- # When --with-tclsh=X is used, use that for all TCL purposes,
- # including in-tree code generation, per developer request.
+ # These headers are technically optional for JimTCL but necessary if
+ # we want to use it for code generation:
+ set sysh [cc-check-includes dirent.h sys/time.h]
+ # jimsh0.c hard-codes #define's for HAVE_DIRENT_H and
+ # HAVE_SYS_TIME_H on the platforms it supports, so we do not
+ # need to add -D... flags for those. We check for them here only
+ # so that we can avoid the situation that we later, at
+ # make-time, try to compile jimsh but it then fails due to
+ # missing headers (i.e. fail earlier rather than later).
+ if {$sysh && [cc-check-functions realpath]} {
+ define-append CFLAGS_JIMSH -DHAVE_REALPATH
+ define BTCLSH "\$(JIMSH)"
+ set ::useJimForCodeGen 1
+ } elseif {$sysh && [cc-check-functions _fullpath]} {
+ # _fullpath() is a Windows API. It's not entirely clear
+ # whether we need to add {-DHAVE_SYS_TIME_H -DHAVE_DIRENT_H}
+ # to CFLAGS_JIMSH in this case. On MinGW32 we definitely do
+ # not want to because it already hard-codes them. On _MSC_VER
+ # builds it does not.
+ define-append CFLAGS_JIMSH -DHAVE__FULLPATH
+ define BTCLSH "\$(JIMSH)"
+ set ::useJimForCodeGen 1
+ } elseif {[file-isexec [get-define TCLSH_CMD]]} {
+ set cgtcl [get-define TCLSH_CMD]
define BTCLSH "\$(TCLSH_CMD)"
} else {
- # These headers are technically optional for JimTCL but necessary if
- # we want to use it for code generation:
- set sysh [cc-check-includes dirent.h sys/time.h]
- # jimsh0.c hard-codes #define's for HAVE_DIRENT_H and
- # HAVE_SYS_TIME_H on the platforms it supports, so we do not
- # need to add -D... flags for those. We check for them here only
- # so that we can avoid the situation that we later, at
- # make-time, try to compile jimsh but it then fails due to
- # missing headers (i.e. fail earlier rather than later).
- if {$sysh && [cc-check-functions realpath]} {
- define-append CFLAGS_JIMSH -DHAVE_REALPATH
- define BTCLSH "\$(JIMSH)"
- set ::useJimForCodeGen 1
- } elseif {$sysh && [cc-check-functions _fullpath]} {
- # _fullpath() is a Windows API. It's not entirely clear
- # whether we need to add {-DHAVE_SYS_TIME_H -DHAVE_DIRENT_H}
- # to CFLAGS_JIMSH in this case. On MinGW32 we definitely do
- # not want to because it already hard-codes them. On _MSC_VER
- # builds it does not.
- define-append CFLAGS_JIMSH -DHAVE__FULLPATH
- define BTCLSH "\$(JIMSH)"
- set ::useJimForCodeGen 1
- } elseif {[file-isexec [get-define TCLSH_CMD]]} {
- set cgtcl [get-define TCLSH_CMD]
- define BTCLSH "\$(TCLSH_CMD)"
- } else {
- # One last-ditch effort to find TCLSH_CMD: use info from
- # tclConfig.sh to try to find a tclsh
- if {"" eq [get-define TCLSH_CMD]} {
- set tpre [get-define TCL_EXEC_PREFIX]
- if {"" ne $tpre} {
- set tv [get-define TCL_VERSION]
- if {[file-isexec "${tpre}/bin/tclsh${tv}"]} {
- define TCLSH_CMD "${tpre}/bin/tclsh${tv}"
- } elseif {[file-isexec "${tpre}/bin/tclsh"]} {
- define TCLSH_CMD "${tpre}/bin/tclsh"
- }
+ # One last-ditch effort to find TCLSH_CMD: use info from
+ # tclConfig.sh to try to find a tclsh
+ if {"" eq [get-define TCLSH_CMD]} {
+ set tpre [get-define TCL_EXEC_PREFIX]
+ if {"" ne $tpre} {
+ set tv [get-define TCL_VERSION]
+ if {[file-isexec "${tpre}/bin/tclsh${tv}"]} {
+ define TCLSH_CMD "${tpre}/bin/tclsh${tv}"
+ } elseif {[file-isexec "${tpre}/bin/tclsh"]} {
+ define TCLSH_CMD "${tpre}/bin/tclsh"
}
}
- set cgtcl [get-define TCLSH_CMD]
- if {![file-isexec $cgtcl]} {
- proj-fatal "Cannot find a tclsh to use for code generation."
- }
- define BTCLSH "\$(TCLSH_CMD)"
}
+ set cgtcl [get-define TCLSH_CMD]
+ if {![file-isexec $cgtcl]} {
+ proj-fatal "Cannot find a tclsh to use for code generation."
+ }
+ define BTCLSH "\$(TCLSH_CMD)"
}
}; # CC swap-out
return $cgtcl
}
define LDFLAGS_PTHREAD [get-define lib_pthread_create]
undefine lib_pthread_create
+ # Recall that LDFLAGS_PTHREAD might be empty even if pthreads if
+ # found because it's in -lc on some platforms.
} {
msg-result no
sqlite-add-feature-flag -DSQLITE_THREADSAFE=0
set ts [opt-val with-tempstore no]
set tsn 1
msg-checking "Use an in-RAM database for temporary tables? "
- switch -- $ts {
+ switch -exact -- $ts {
never { set tsn 0 }
no { set tsn 1 }
yes { set tsn 2 }
# corresponding --FEATURE flag was explicitly given, fail fatally,
# else fail silently.
proc sqlite-check-line-editing {} {
+ rename sqlite-check-line-editing ""
msg-result "Checking for line-editing capability..."
define HAVE_READLINE 0
define HAVE_LINENOISE 0
# are 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
+# Design note: though we could automatically enable ICU if the
# icu-config binary or (pkg-config icu-io) are found, we specifically
# do not. ICU is always an opt-in feature.
-#
-# Maintenance reminder: check-in 09caa94c9e84 added pkg-config support
-# to this but the result fails to link on both Linux and OpenBSD
-# (other systems were untested) because the pkg-config results are
-# missing a required library.
proc sqlite-check-icu {} {
+ rename sqlite-check-icu ""
define LDFLAGS_ICU [join [opt-val with-icu-ldflags ""]]
define CFLAGS_ICU [join [opt-val with-icu-cflags ""]]
- # Flags sets seen in the wild for ICU:
- # - -licui18n -licuuc -licudata
- # - -licui18n -licuuc
- # - /usr/local/bin/icu-config --ldflags
- #
if {[proj-opt-was-provided with-icu-config]} {
set icuConfigBin [opt-val with-icu-config]
set tryIcuConfigBin 1; # set to 0 if we end up using pkg-config
########################################################################
# Check for the Emscripten SDK for building the web-based wasm
-# components.
+# components. The core lib and tools do not require this but ext/wasm
+# does.
apply {{} {
+ if {$::autosetup(srcdir) ne $::autosetup(builddir)} {
+ # The EMSDK pieces require writing to the original source tree
+ # even when doing an out-of-tree build. The ext/wasm pieces do not
+ # support an out-of-tree build so we catch that case and treat it
+ # as if EMSDK were not found.
+ msg-result "Out-of tree build: not checking for EMSDK."
+ define EMCC_WRAPPER ""
+ return
+ }
set emccsh $::srcdir/tool/emcc.sh
if {![get-define HAVE_WASI_SDK] && [proj-check-emsdk]} {
define EMCC_WRAPPER $emccsh