1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435 |
- use cc cc-db cc-shared cc-lib proj pkg-config
- set DUMP_DEFINES_TXT ./config.defines.txt
- set DUMP_DEFINES_JSON ""
- set flags {
- shared=1 => {Disable build of shared libary}
- static=1 => {Disable build of static library (mostly)}
- amalgamation=1 => {Disable the amalgamation and instead build all files separately.}
- threadsafe=1 => {Disable mutexing}
- with-tempstore:=no => {Use an in-RAM database for temporary tables: never,no,yes,always}
- largefile=1 => {Disable large file support}
- load-extension=1 => {Disable loading of external extensions}
- math=1 => {Disable math functions}
- json=1 => {Disable JSON functions}
- memsys5 => {Enable MEMSYS5}
- memsys3 => {Enable MEMSYS3}
- fts3 => {Enable the FTS3 extension}
- fts4 => {Enable the FTS4 extension}
- fts5 => {Enable the FTS5 extension}
- update-limit => {Enable the UPDATE/DELETE LIMIT clause}
- geopoly => {Enable the GEOPOLY extension}
- rtree => {Enable the RTREE extension}
- session => {Enable the SESSION extension}
- all => {Enable FTS4, FTS5, Geopoly, RTree, Sessions}
- 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.
- 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
- its containing dir has multiple tclsh versions, it may select the
- wrong tclConfig.sh!}
- tcl=1 =>
- {Disable components which require TCL, including all tests.
- This tree requires TCL for code generation but can use the in-tree
- copy of autosetup/jimsh0.c for that. The SQLite TCL extension and the
- test code require a canonical tclsh.}
- readline=1 => {Disable readline support}
- with-readline-lib:
- with-readline-ldflags:=auto
- => {Readline LDFLAGS, e.g. -lreadline -lncurses}
- with-readline-inc:
- with-readline-cflags:=auto
- => {Readline CFLAGS, e.g. -I/path/to/includes}
- with-readline-header:PATH
- => {Full path to readline.h, from which --with-readline-cflags will be derived}
- with-linenoise:DIR => {Source directory for linenoise.c and linenoise.h}
- editline=0 => {Enable BSD editline support}
- with-icu-ldflags:LDFLAGS
- => {Enable SQLITE_ENABLE_ICU and add the given linker flags for the ICU libraries}
- with-icu-cflags:CFLAGS
- => {Apply extra CFLAGS/CPPFLAGS necessary for building with ICU. e.g. -I/usr/local/include}
- with-icu-config:=auto => {Enable SQLITE_ENABLE_ICU. Value must be one of: auto, pkg-config, /path/to/icu-config}
- icu-collations=0 => {Enable SQLITE_ENABLE_ICU_COLLATIONS. Requires --with-icu-ldflags=... or --with-icu-config}
- with-wasi-sdk:=/opt/wasi-sdk
- => {Top-most dir of the wasi-sdk for a WASI build}
- with-emsdk:=auto => {Top-most dir of the Emscripten SDK installation. Default = EMSDK env var.}
- with-debug=0
- debug=0 =>
- {Enable debug build flags. This option will impact performance by
- as much as 4x, as it includes large numbers of assert()s in
- performance-critical loops. Never use --debug for production
- builds.}
- scanstatus => {Enable the SQLITE_ENABLE_STMT_SCANSTATUS feature flag}
- dev => {Enable dev-mode build: automatically enables certain other flags}
- test-status => {Enable status of tests}
- gcov=0 => {Enable coverage testing using gcov}
- linemacros => {Enable #line macros in the amalgamation}
- dump-defines=0 => {Dump autosetup defines to $DUMP_DEFINES_TXT (for build debugging)}
- dynlink-tools => {Dynamically link libsqlite3 to certain tools which normally statically embed it.}
- soname:=legacy =>
- {SONAME for libsqlite3.so. "none", or not using this flag, sets no
- soname. "legacy" sets it to its historical value of
- libsqlite3.so.0. A value matching the glob "libsqlite3.*" sets
- it to that literal value. Any other value is assumed to be a
- suffix which gets applied to "libsqlite3.so.",
- e.g. --soname=9.10 equates to "libsqlite3.so.9.10".
- }
- }
- if {"" ne $DUMP_DEFINES_JSON} {
- lappend flags \
- defines-json-include-lowercase=0 \
- => {Include lower-case defines (primarily system paths) in $DUMP_DEFINES_JSON}
- }
- options [subst -nobackslashes -nocommands $flags]
- unset flags
- proj-xfer-options-aliases {
- with-readline-inc => with-readline-cflags
- with-readline-lib => with-readline-ldflags
- with-debug => debug
- }
- set srcdir $::autosetup(srcdir)
- set PACKAGE_VERSION [proj-file-content -trim $srcdir/VERSION]
- define PACKAGE_NAME "sqlite"
- define PACKAGE_URL {https://sqlite.org}
- define PACKAGE_VERSION $PACKAGE_VERSION
- define PACKAGE_STRING "[get-define PACKAGE_NAME] $PACKAGE_VERSION"
- define PACKAGE_BUGREPORT [get-define PACKAGE_URL]/forum
- msg-result "Source dir = $srcdir"
- msg-result "Build dir = $::autosetup(builddir)"
- msg-result "Configuring SQLite version $PACKAGE_VERSION"
- apply {{} {
- proc squote {arg} {
- if {[string match {*[ &;$*"]*} $arg]} { return '$arg' }
- return $arg
- }
- define-append SQLITE_AUTORECONFIG cd [squote $::autosetup(builddir)] && [squote $::srcdir/configure]
- #{*}$::autosetup(argv) breaks with --flag='val with spaces', so...
- foreach arg $::autosetup(argv) {
- define-append SQLITE_AUTORECONFIG [squote $arg]
- }
- rename squote ""
- }}
- # Are we cross-compiling?
- set isCrossCompiling [proj-is-cross-compiling]
- define OPT_FEATURE_FLAGS {} ; # -DSQLITE_OMIT/ENABLE flags.
- define OPT_SHELL {} ; # Feature-related CFLAGS for the sqlite3 CLI app
- ########################################################################
- # Adds $args, if not empty, to OPT_FEATURE_FLAGS. If the first arg is
- # -shell then it strips that arg and passes the remaining args the
- # sqlite-add-shell-opt in addition to adding them to
- # OPT_FEATURE_FLAGS.
- proc sqlite-add-feature-flag {args} {
- set shell ""
- if {"-shell" eq [lindex $args 0]} {
- set args [lassign $args shell]
- }
- if {"" ne $args} {
- if {"" ne $shell} {
- sqlite-add-shell-opt {*}$args
- }
- define-append OPT_FEATURE_FLAGS {*}$args
- }
- }
- # Appends $args, if not empty, to OPT_SHELL.
- proc sqlite-add-shell-opt {args} {
- if {"" ne $args} {
- define-append OPT_SHELL {*}$args
- }
- }
- # Pass msg-debug=1 to configure to enable obnoxiously loud output from
- # msg-debug.
- set msgDebugEnabled [proj-val-truthy [get-env msg-debug 0]]
- proc msg-debug {msg} {
- if {$::msgDebugEnabled} {
- puts stderr [proj-bold "** DEBUG: $msg"]
- }
- }
- proj-file-extensions
- if {".exe" eq [get-define TARGET_EXEEXT]} {
- define SQLITE_OS_UNIX 0
- define SQLITE_OS_WIN 1
- } else {
- define SQLITE_OS_UNIX 1
- define SQLITE_OS_WIN 0
- }
- cc-check-tools ld ar
- if {"" eq [proj-bin-define install]} {
- proj-warn "Cannot find install binary, so 'make install' will not work."
- define BIN_INSTALL false
- }
- define CFLAGS [proj-get-env CFLAGS {-g -O2}]
- define BUILD_CFLAGS [proj-get-env BUILD_CFLAGS {-g}]
- proj-if-opt-truthy dev {
- proj-opt-set all 1
- proj-opt-set debug 1
- proj-opt-set amalgamation 0
- define CFLAGS [get-env CFLAGS {-O0 -g}]
- }
- proc sqlite-check-wasi-sdk {} {
- set wasiSdkDir [opt-val with-wasi-sdk]
- define HAVE_WASI_SDK 0
- if {$wasiSdkDir eq ""} {
- return 0
- } elseif {$::isCrossCompiling} {
- proj-fatal "Cannot combine --with-wasi-sdk with cross-compilation"
- }
- msg-result "Checking WASI SDK directory \[$wasiSdkDir]... "
- proj-affirm-files-exist -v {*}[prefix "$wasiSdkDir/bin/" {clang wasm-ld ar}]
- define HAVE_WASI_SDK 1
- define WASI_SDK_DIR $wasiSdkDir
- msg-result "Using wasi-sdk clang. Disabling CLI shell modifying config flags:"
- foreach opt {
- dynlink-tools
- editline
- gcov
- icu-collations
- load-extension
- readline
- shared
- tcl
- threadsafe
- } {
- if {[opt-bool $opt]} {
- msg-result " --disable-$opt"
- proj-opt-set $opt 0
- }
- }
- foreach opt {
- with-emsdk
- with-icu-config
- with-icu-ldflags
- with-icu-cflags
- with-linenoise
- with-tcl
- } {
- if {[proj-opt-was-provided $opt]} {
- msg-result " removing --$opt"
- proj-opt-set $opt ""
- }
- }
- set ::isCrossCompiling 1
- define CC "${wasiSdkDir}/bin/clang"
- define LD "${wasiSdkDir}/bin/wasm-ld"
- define AR "${wasiSdkDir}/bin/ar"
- return 1
- }
- sqlite-check-wasi-sdk
- define LINK_TOOLS_DYNAMICALLY [proj-opt-was-provided dynlink-tools]
- define HAVE_LFS 0
- if {[opt-bool largefile]} {
- cc-check-lfs
- }
- cc-with {-includes stdint.h} \
- {cc-check-types int8_t int16_t int32_t int64_t intptr_t \
- uint8_t uint16_t uint32_t uint64_t uintptr_t}
- cc-check-functions gmtime_r isnan localtime_r localtime_s \
- malloc_usable_size strchrnul usleep utime pread pread64 pwrite pwrite64
- proj-check-function-in-lib fdatasync rt
- define LDFLAGS_FDATASYNC [get-define lib_fdatasync]
- undefine lib_fdatasync
- cc-check-includes \
- sys/types.h sys/stat.h dlfcn.h unistd.h \
- stdlib.h malloc.h memory.h \
- string.h strings.h \
- inttypes.h
- if {[cc-check-includes zlib.h] && [proj-check-function-in-lib deflate z]} {
- define HAVE_ZLIB 1
- define LDFLAGS_ZLIB -lz
- sqlite-add-shell-opt -DSQLITE_HAVE_ZLIB=1
- } else {
- define HAVE_ZLIB 0
- define LDFLAGS_ZLIB ""
- }
- proj-check-rpath
- apply {{} {
- define LDFLAGS_LIBSQLITE3_SONAME ""
- if {[proj-opt-was-provided soname]} {
- set soname [join [opt-val soname] ""]
- } else {
- set soname none
- }
- switch -exact -- $soname {
- none - "" { return 0 }
- auto { set soname libsqlite3.so.3 }
- legacy { set soname libsqlite3.so.0 }
- default {
- if {[string match libsqlite3.* $soname]} {
- } else {
- set soname "libsqlite3.so.${soname}"
- }
- }
- }
- msg-debug "soname=$soname"
- if {[proj-check-soname $soname]} {
- define LDFLAGS_LIBSQLITE3_SONAME [get-define LDFLAGS_SONAME_PREFIX]$soname
- msg-result "Setting SONAME using: [get-define LDFLAGS_LIBSQLITE3_SONAME]"
- } elseif {[proj-opt-was-provided soname]} {
- proj-fatal "This environment does not support SONAME."
- } else {
- msg-result "This environment does not support SONAME."
- }
- }}
- proj-define-for-opt shared ENABLE_SHARED "Build shared library?"
- if {![proj-define-for-opt static ENABLE_STATIC \
- "Build static library?"]} {
- proj-warn "Static lib build may be implicitly re-activated by other components, e.g. some test apps."
- }
- proj-define-for-opt amalgamation USE_AMALGAMATION "Use amalgamation for builds?"
- proj-define-for-opt gcov USE_GCOV "Use gcov?"
- proj-define-for-opt test-status TSTRNNR_OPTS \
- "test-runner flags:" {--status} {}
- proj-define-for-opt linemacros AMALGAMATION_LINE_MACROS \
- "Use #line macros in the amalgamation:"
- msg-checking "SQLITE_DEBUG build? "
- proj-if-opt-truthy debug {
- define SQLITE_DEBUG 1
- define TARGET_DEBUG {-g -DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0 -Wall}
- proj-opt-set memsys5
- msg-result yes
- } {
- define TARGET_DEBUG {-DNDEBUG}
- msg-result no
- }
- proc sqlite-check-tcl {} {
- rename sqlite-check-tcl ""
- define TCLSH_CMD false
- define HAVE_TCL 0
- define TCLLIBDIR ""
- define TCL_CONFIG_SH ""
- foreach k {TCL_INCLUDE_SPEC TCL_LIB_SPEC TCL_STUB_LIB_SPEC TCL_EXEC_PREFIX TCL_VERSION} {
- define $k ""
- }
- file delete -force ".tclenv.sh"
- if {![opt-bool tcl]} {
- proj-indented-notice {
- NOTE: TCL is disabled via --disable-tcl. This means that none
- of the TCL-based components will be built, including tests
- and sqlite3_analyzer.
- }
- return
- }
- global srcdir
- msg-result "Checking for a suitable tcl... "
- proj-assert [proj-opt-truthy tcl]
- set use_tcl 1
- set with_tclsh [opt-val with-tclsh]
- set with_tcl [opt-val with-tcl]
- if {"prefix" eq $with_tcl} {
- set with_tcl [get-define prefix]
- }
- msg-debug "sqlite-check-tcl: use_tcl ${use_tcl}"
- msg-debug "sqlite-check-tcl: with_tclsh=${with_tclsh}"
- msg-debug "sqlite-check-tcl: with_tcl=$with_tcl"
- if {"" eq $with_tclsh && "" eq $with_tcl} {
- set with_tclsh [proj-first-bin-of tclsh9.0 tclsh8.6 tclsh]
- msg-debug "sqlite-check-tcl: with_tclsh=${with_tclsh}"
- }
- set doConfigLookup 1
- if {"" ne $with_tclsh} {
- if {![file isfile $with_tclsh]} {
- proj-fatal "TCL shell $with_tclsh is not a file"
- } elseif {![file-isexec $with_tclsh]} {
- proj-fatal "TCL shell $with_tclsh is not executable"
- } else {
- define TCLSH_CMD $with_tclsh
- }
- if {$doConfigLookup &&
- [catch {exec $with_tclsh $srcdir/tool/find_tclconfig.tcl} result] == 0} {
- set with_tcl $result
- }
- if {"" ne $with_tcl && [file isdir $with_tcl]} {
- msg-result "$with_tclsh recommends the tclConfig.sh from $with_tcl"
- } else {
- proj-warn "$with_tclsh is unable to recommend a tclConfig.sh"
- set use_tcl 0
- }
- }
- set cfg ""
- set tclSubdirs {tcl9.0 tcl8.6 lib}
- while {$use_tcl} {
- if {"" ne $with_tcl} {
- if {$doConfigLookup} {
- if {[file readable "${with_tcl}/tclConfig.sh"]} {
- set cfg "${with_tcl}/tclConfig.sh"
- } else {
- foreach i $tclSubdirs {
- if {[file readable "${with_tcl}/$i/tclConfig.sh"]} {
- set cfg "${with_tcl}/$i/tclConfig.sh"
- break
- }
- }
- }
- }
- if {"" eq $cfg} {
- proj-fatal "No tclConfig.sh found under ${with_tcl}"
- }
- } else {
- set libdir [get-define libdir]
- if {[file readable "${libdir}/tclConfig.sh"]} {
- set cfg "${libdir}/tclConfig.sh"
- } else {
- foreach i $tclSubdirs {
- if {[file readable "${libdir}/$i/tclConfig.sh"]} {
- set cfg "${libdir}/$i/tclConfig.sh"
- break
- }
- }
- }
- if {![file readable $cfg]} {
- break
- }
- }
- msg-result "Using tclConfig.sh: $cfg"
- break
- }
- define TCL_CONFIG_SH $cfg
- eval [exec "${srcdir}/tool/tclConfigShToAutoDef.sh" "$cfg"]
- if {"" eq $with_tclsh && $cfg ne ""} {
- proj-assert {"" ne [get-define TCL_EXEC_PREFIX]}
- set with_tclsh [get-define TCL_EXEC_PREFIX]/bin/tclsh[get-define TCL_VERSION]
- if {![file-isexec $with_tclsh]} {
- set with_tclsh2 [get-define TCL_EXEC_PREFIX]/bin/tclsh
- if {![file-isexec $with_tclsh2]} {
- proj-warn "Cannot find a usable tclsh (tried: $with_tclsh $with_tclsh2)"
- } else {
- set with_tclsh $with_tclsh2
- }
- }
- }
- define TCLSH_CMD $with_tclsh
- if {$use_tcl} {
- set tcllibdir [get-env TCLLIBDIR ""]
- if {"" eq $tcllibdir} {
- if {"" ne $with_tclsh &&
- [catch {exec echo "puts stdout \$auto_path" | "$with_tclsh"} result] == 0} {
- foreach i $result {
- if {[file isdir $i]} {
- set tcllibdir $i/sqlite3
- break
- }
- }
- } else {
- proj-warn "Cannot determine TCLLIBDIR."
- }
- }
- define TCLLIBDIR $tcllibdir
- }
- if {[file-isexec $with_tclsh]} {
- msg-result "Using tclsh: $with_tclsh"
- if {$cfg ne ""} {
- define HAVE_TCL 1
- } else {
- proj-warn "Found tclsh but no tclConfig.sh."
- }
- }
- show-notices
- if {![get-define HAVE_TCL] &&
- ([proj-opt-was-provided tcl] || [proj-opt-was-provided with-tcl])} {
- proj-fatal "TCL support was requested but no tclConfig.sh could be found."
- }
- if {"" eq $cfg} {
- proj-assert {0 == [get-define HAVE_TCL]}
- proj-indented-notice {
- WARNING: Cannot find a usable tclConfig.sh file. Use
- --with-tcl=DIR to specify a directory where tclConfig.sh can be
- found. SQLite does not use TCL internally, but some optional
- components require TCL, including tests and sqlite3_analyzer.
- }
- }
- }
- sqlite-check-tcl
- set useJimForCodeGen 0
- 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} {
- define BTCLSH "\$(TCLSH_CMD)"
- return $cgtcl
- }
- set flagsToRestore {CC CFLAGS AS_CFLAGS CPPFLAGS AS_CPPFLAGS LDFLAGS LINKFLAGS LIBS CROSS}
- define-push $flagsToRestore {
- foreach flag $flagsToRestore {define $flag ""}
- define CC [get-define CC_FOR_BUILD]
- set sysh [cc-check-includes dirent.h sys/time.h]
- if {$sysh && [cc-check-functions realpath]} {
- define-append CFLAGS_JIMSH -DHAVE_REALPATH
- define BTCLSH "\$(JIMSH)"
- set ::useJimForCodeGen 1
- } elseif {$sysh && [cc-check-functions _fullpath]} {
- 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 {
- 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)"
- }
- }
- return $cgtcl
- }
- msg-result "TCL for code generation: [sqlite-determine-codegen-tcl]"
- msg-checking "Support threadsafe operation? "
- proj-if-opt-truthy threadsafe {
- msg-result yes
- sqlite-add-feature-flag -DSQLITE_THREADSAFE=1
- if {![proj-check-function-in-lib pthread_create pthread]
- || ![proj-check-function-in-lib pthread_mutexattr_init pthread]} {
- user-error "Missing required pthread bits"
- }
- define LDFLAGS_PTHREAD [get-define lib_pthread_create]
- undefine lib_pthread_create
- } {
- msg-result no
- sqlite-add-feature-flag -DSQLITE_THREADSAFE=0
- define LDFLAGS_PTHREAD ""
- }
- apply {{} {
- set ts [opt-val with-tempstore no]
- set tsn 1
- msg-checking "Use an in-RAM database for temporary tables? "
- switch -exact -- $ts {
- never { set tsn 0 }
- no { set tsn 1 }
- yes { set tsn 2 }
- always { set tsn 3 }
- default {
- user-error "Invalid --with-tempstore value '$ts'. Use one of: never, no, yes, always"
- }
- }
- msg-result $ts
- sqlite-add-feature-flag -DSQLITE_TEMP_STORE=$tsn
- }}
- 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
- define HAVE_EDITLINE 0
- define LDFLAGS_READLINE ""
- define CFLAGS_READLINE ""
- set failIfNotFound 0
- set libsForReadline {readline edit}
- set editLibName "readline"
- set editLibDef "HAVE_READLINE"
- set dirLn [opt-val with-linenoise]
- if {"" ne $dirLn} {
- if {![file isdir $dirLn]} {
- proj-fatal "--with-linenoise value is not a directory"
- }
- set lnH $dirLn/linenoise.h
- if {![file exists $lnH] } {
- proj-fatal "Cannot find linenoise.h in $dirLn"
- }
- set lnC ""
- set lnCOpts {linenoise-ship.c linenoise.c}
- foreach f $lnCOpts {
- if {[file exists $dirLn/$f]} {
- set lnC $dirLn/$f
- break;
- }
- }
- if {"" eq $lnC} {
- proj-fatal "Cannot find any of $lnCOpts in $dirLn"
- }
- set flavor ""
- set lnVal [proj-which-linenoise $lnH]
- switch -- $lnVal {
- 1 { set flavor "antirez" }
- 2 { set flavor "msteveb" }
- default {
- proj-fatal "Cannot determine the flavor of linenoise from $lnH"
- }
- }
- define CFLAGS_READLINE "-I$dirLn $lnC"
- define HAVE_LINENOISE $lnVal
- sqlite-add-shell-opt -DHAVE_LINENOISE=$lnVal
- if {$::useJimForCodeGen && 2 == $lnVal} {
- define-append CFLAGS_JIMSH -DUSE_LINENOISE [get-define CFLAGS_READLINE]
- user-notice "Adding linenoise support to jimsh."
- }
- return "linenoise ($flavor)"
- } elseif {[opt-bool editline]} {
- set failIfNotFound 1
- set libsForReadline {edit}
- set editLibName editline
- } elseif {![opt-bool readline]} {
- msg-result "Readline support explicitly disabled with --disable-readline"
- return "none"
- } elseif {[proj-opt-was-provided readline]} {
- set failIfNotFound 1
- }
- set v [opt-val with-readline-header]
- proj-opt-set with-readline-header ""
- if {"" ne $v} {
- if {"auto" eq $v} {
- proj-opt-set with-readline-cflags auto
- } else {
- set v [file dirname $v]
- if {[string match */readline $v]} {
- set v [file dirname $v]
- }
- proj-opt-set with-readline-cflags "-I$v"
- }
- }
- set rlInc [opt-val with-readline-cflags auto]
- if {"auto" eq $rlInc} {
- set rlInc ""
- if {$::isCrossCompiling} {
- 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 {"editline" eq $editLibName} {
- lappend subdirs include/readline
- }
- lappend subdirs include
- set rlInc [proj-search-for-header-dir readline.h \
- -dirs $dirs -subdirs $subdirs]
- if {"" ne $rlInc} {
- if {[string match */readline $rlInc]} {
- set rlInc [file dirname $rlInc]
- } elseif {[string match */editline $rlInc]} {
- set editLibDef HAVE_EDITLINE
- set rlInc [file dirname $rlInc]
- }
- set rlInc "-I${rlInc}"
- }
- }
- } elseif {"" ne $rlInc && ![string match *-I* $rlInc]} {
- proj-fatal "Argument to --with-readline-cflags is intended to be CFLAGS and contain -I..."
- }
- set rlLib ""
- if {"" ne $rlInc} {
- set rlLib [opt-val with-readline-ldflags]
- if {"" eq $rlLib || "auto" eq $rlLib} {
- set rlLib ""
- set libTerm ""
- if {[proj-check-function-in-lib tgetent "$editLibName ncurses curses termcap"]} {
- set libTerm [get-define lib_tgetent]
- undefine lib_tgetent
- }
- if {$editLibName eq $libTerm} {
- set rlLib $libTerm
- } elseif {[proj-check-function-in-lib readline $libsForReadline $libTerm]} {
- set rlLib [get-define lib_readline]
- lappend rlLib $libTerm
- undefine lib_readline
- }
- }
- }
- if {"" ne $rlLib} {
- if {"editline" eq $editLibName && "HAVE_READLINE" eq $editLibDef} {
- proj-indented-notice {
- NOTE: the local libedit but uses <readline/readline.h> so we
- will compile with -DHAVE_READLINE=1 but will link with
- libedit.
- }
- }
- set rlLib [join $rlLib]
- set rlInc [join $rlInc]
- define LDFLAGS_READLINE $rlLib
- define CFLAGS_READLINE $rlInc
- proj-assert {$editLibDef in {HAVE_READLINE HAVE_EDITLINE}}
- proj-assert {$editLibName in {readline editline}}
- sqlite-add-shell-opt -D${editLibDef}=1
- msg-result "Using $editLibName flags: $rlInc $rlLib"
- if {![cctest \
- -cflags "$rlInc -D${editLibDef}" -libs $rlLib -nooutput 1 -source {
- static char * rcg(const char *z, int i){(void)z; (void)i; return 0;}
- int main(void) {
- char ** x = rl_completion_matches("one", rcg);
- (void)x;
- return 0;
- }
- }]} {
- proj-warn "readline-style completion disabled due to rl_completion_matches() signature mismatch"
- sqlite-add-shell-opt -DSQLITE_OMIT_READLINE_COMPLETION
- }
- return $editLibName
- }
- if {$failIfNotFound} {
- proj-fatal "Explicit --$editLibName failed to find a matching library."
- }
- return "none"
- }
- msg-result "Line-editing support for the sqlite3 shell: [sqlite-check-line-editing]"
- proj-if-opt-truthy load-extension {
- if {[proj-check-function-in-lib dlopen dl]} {
- define LDFLAGS_DLOPEN [get-define lib_dlopen]
- undefine lib_dlopen
- } else {
- user-error "dlopen() not found. Use --disable-load-extension to bypass this check."
- }
- } {
- define LDFLAGS_DLOPEN ""
- sqlite-add-feature-flag {-DSQLITE_OMIT_LOAD_EXTENSION=1}
- msg-result "Disabling loadable extensions."
- }
- proj-if-opt-truthy math {
- if {![proj-check-function-in-lib ceil m]} {
- user-error "Cannot find libm functions. Use --disable-math to bypass this."
- }
- define LDFLAGS_MATH [get-define lib_ceil]
- undefine lib_ceil
- sqlite-add-feature-flag {-DSQLITE_ENABLE_MATH_FUNCTIONS}
- msg-result "Enabling math SQL functions [get-define LDFLAGS_MATH]"
- } {
- define LDFLAGS_MATH ""
- msg-result "Disabling math SQL functions"
- }
- 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 ""]]
- if {[proj-opt-was-provided with-icu-config]} {
- set icuConfigBin [opt-val with-icu-config]
- set tryIcuConfigBin 1
- if {"auto" eq $icuConfigBin || "pkg-config" eq $icuConfigBin} {
- if {[pkg-config-init 0] && [pkg-config icu-io]} {
- set tryIcuConfigBin 0
- define LDFLAGS_ICU [get-define PKG_ICU_IO_LDFLAGS]
- define-append LDFLAGS_ICU [get-define PKG_ICU_IO_LIBS]
- define CFLAGS_ICU [get-define PKG_ICU_IO_CFLAGS]
- } elseif {"pkg-config" eq $icuConfigBin} {
- proj-fatal "pkg-config cannot find package icu-io"
- } else {
- proj-assert {"auto" eq $icuConfigBin}
- }
- }
- if {$tryIcuConfigBin} {
- if {"auto" eq $icuConfigBin} {
- set icuConfigBin [proj-first-bin-of \
- /usr/local/bin/icu-config \
- /usr/bin/icu-config]
- if {"" eq $icuConfigBin} {
- proj-fatal "--with-icu-config=auto cannot find (pkg-config icu-io) or icu-config binary"
- }
- }
- if {[file-isexec $icuConfigBin]} {
- set x [exec $icuConfigBin --ldflags]
- if {"" eq $x} {
- proj-fatal "$icuConfigBin --ldflags returned no data"
- }
- define-append LDFLAGS_ICU $x
- set x [exec $icuConfigBin --cppflags]
- define-append CFLAGS_ICU $x
- } else {
- proj-fatal "--with-icu-config=$bin does not refer to an executable"
- }
- }
- }
- set ldflags [define LDFLAGS_ICU [string trim [get-define LDFLAGS_ICU]]]
- set cflags [define CFLAGS_ICU [string trim [get-define CFLAGS_ICU]]]
- if {"" ne $ldflags} {
- sqlite-add-feature-flag -shell -DSQLITE_ENABLE_ICU
- msg-result "Enabling ICU support with flags: $ldflags $cflags"
- if {[opt-bool icu-collations]} {
- msg-result "Enabling ICU collations."
- sqlite-add-feature-flag -shell -DSQLITE_ENABLE_ICU_COLLATIONS
- }
- } elseif {[opt-bool icu-collations]} {
- proj-warn "ignoring --enable-icu-collations because neither --with-icu-ldflags nor --with-icu-config provided any linker flags"
- } else {
- msg-result "ICU support is disabled."
- }
- }
- sqlite-check-icu
- apply {{} {
- if {$::autosetup(srcdir) ne $::autosetup(builddir)} {
- 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
- proj-make-from-dot-in $emccsh
- catch {exec chmod u+x $emccsh}
- } else {
- define EMCC_WRAPPER ""
- file delete -force $emccsh
- }
- }}
- proc affirm-have-math {featureName} {
- if {"" eq [get-define LDFLAGS_MATH ""]} {
- if {![msg-quiet proj-check-function-in-lib log m]} {
- user-error "Missing math APIs for $featureName"
- }
- define LDFLAGS_MATH [get-define lib_log ""]
- undefine lib_log
- }
- }
- msg-result "Feature flags..."
- foreach {boolFlag featureFlag ifSetEvalThis} {
- all {} {
- proj-opt-set fts4
- proj-opt-set fts5
- proj-opt-set geopoly
- proj-opt-set rtree
- proj-opt-set session
- }
- fts4 -DSQLITE_ENABLE_FTS4 {affirm-have-math fts4}
- fts5 -DSQLITE_ENABLE_FTS5 {affirm-have-math fts5}
- geopoly -DSQLITE_ENABLE_GEOPOLY {proj-opt-set rtree}
- rtree -DSQLITE_ENABLE_RTREE {}
- session {-DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK} {}
- update-limit -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT {}
- memsys5 -DSQLITE_ENABLE_MEMSYS5 {}
- memsys3 {} {
- if {[opt-bool memsys5]} {
- proj-warn "not enabling memsys3 because memsys5 is enabled."
- expr 0
- } else {
- sqlite-add-feature-flag -DSQLITE_ENABLE_MEMSYS3
- }
- }
- scanstatus -DSQLITE_ENABLE_STMT_SCANSTATUS {}
- } {
- proj-if-opt-truthy $boolFlag {
- sqlite-add-feature-flag $featureFlag
- if {0 != [eval $ifSetEvalThis] && "all" ne $boolFlag} {
- msg-result " + $boolFlag"
- }
- } {
- if {"all" ne $boolFlag} {
- msg-result " - $boolFlag"
- }
- }
- }
- foreach {boolFlag featureFlag} {
- json -DSQLITE_OMIT_JSON
- } {
- if {[proj-opt-truthy $boolFlag]} {
- msg-result " + $boolFlag"
- } else {
- sqlite-add-feature-flag $featureFlag
- msg-result " - $boolFlag"
- }
- }
- apply {{} {
- set oFF [get-define OPT_FEATURE_FLAGS]
- if {"" ne $oFF} {
- define OPT_FEATURE_FLAGS [lsort -unique $oFF]
- msg-result "Library feature flags: [get-define OPT_FEATURE_FLAGS]"
- }
- set oFF [get-define OPT_SHELL]
- if {"" ne $oFF} {
- define OPT_SHELL [lsort -unique $oFF]
- msg-result "Shell options: [get-define OPT_SHELL]"
- }
- unset oFF
- }}
- proj-remap-autoconf-dir-vars
- proj-make-from-dot-in -touch Makefile sqlite3.pc
- make-config-header sqlite_cfg.h \
- -bare {SIZEOF_* HAVE_DECL_*} \
- -none {HAVE_CFLAG_* LDFLAGS_* SH_* SQLITE_AUTORECONFIG
- TARGET_* USE_GCOV TCL_*} \
- -auto {HAVE_* PACKAGE_*} \
- -none *
- proj-touch sqlite_cfg.h
- proj-if-opt-truthy dump-defines {
- make-config-header $::DUMP_DEFINES_TXT \
- -bare {SQLITE_OS* SQLITE_DEBUG USE_*} \
- -str {BIN_* CC LD AR LDFLAG* OPT_*} \
- -auto {*}
- if {"" ne $DUMP_DEFINES_JSON} {
- msg-result "--dump-defines is creating $::DUMP_DEFINES_JSON"
- define OPT_FEATURE_FLAGS.list [get-define OPT_FEATURE_FLAGS]
- define OPT_SHELL.list [get-define OPT_SHELL]
- set dumpDefsOpt {
- -bare {SIZEOF_* HAVE_DECL_*}
- -none {HAVE_CFLAG_* LDFLAGS_* SH_* SQLITE_AUTORECONFIG TARGET_* USE_GCOV TCL_*}
- -array {*.list}
- -auto {OPT_* PACKAGE_* HAVE_*}
- }
- if {[opt-bool defines-json-include-lowercase]} {
- lappend dumpDefsOpt -none {lib_*}
- lappend dumpDefsOpt -auto {[a-z]*}
- }
- lappend dumpDefsOpt -none *
- proj-dump-defs-json $DUMP_DEFINES_JSON {*}$dumpDefsOpt
- undefine OPT_FEATURE_FLAGS.list
- undefine OPT_SHELL.list
- }
- }
- apply {{} {
- foreach f "Makefile sqlite3.pc $::srcdir/tool/emcc.sh" {
- if {![file exists $f]} continue
- set lnno 1
- foreach line [proj-file-content-list $f] {
- if {[regexp {(@[A-Za-z_]+@)} $line match]} {
- error "Unresolved reference to $match at line $lnno of $f"
- }
- incr lnno
- }
- }
- }}
|