sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
sqlite / autosetup / sqlite-config.tcl
| 1 | # This file holds functions for autosetup which are specific to the |
| 2 | # sqlite build tree. They are in this file, instead of auto.def, so |
| 3 | # that they can be reused in the autoconf sub-tree. This file requires |
| 4 | # functions from the project-agnostic proj.tcl. |
| 5 | |
| 6 | if {[string first " " $autosetup(srcdir)] != -1} { |
| 7 | user-error "The pathname of the source tree\ |
| 8 | may not contain space characters" |
| 9 | } |
| 10 | if {[string first " " $autosetup(builddir)] != -1} { |
| 11 | user-error "The pathname of the build directory\ |
| 12 | may not contain space characters" |
| 13 | } |
| 14 | |
| 15 | use proj |
| 16 | # |
| 17 | # We want the package version info to be emitted early on, but doing |
| 18 | # so requires a bit of juggling. We have to [use system] for |
| 19 | # --prefix=... to work and to emit the Host/Build system info, but we |
| 20 | # don't want those to interfere with --help output. |
| 21 | define PACKAGE_VERSION [proj-file-content -trim $::autosetup(srcdir)/VERSION] |
| 22 | if {"--help" ni $::argv} { |
| 23 | msg-result "Configuring SQLite version [get-define PACKAGE_VERSION]" |
| 24 | } |
| 25 | use system ; # Will output "Host System" and "Build System" lines |
| 26 | if {"--help" ni $::argv} { |
| 27 | proj-tweak-default-env-dirs |
| 28 | msg-result "Source dir = $::autosetup(srcdir)" |
| 29 | msg-result "Build dir = $::autosetup(builddir)" |
| 30 | use cc cc-db cc-shared cc-lib pkg-config |
| 31 | } |
| 32 | |
| 33 | # |
| 34 | # Object for communicating certain config-time state across various |
| 35 | # auto.def-related pieces. |
| 36 | array set sqliteConfig [subst [proj-strip-hash-comments { |
| 37 | # |
| 38 | # Gets set by [sqlite-configure] (the main configure script driver). |
| 39 | build-mode unknown |
| 40 | # |
| 41 | # Gets set to 1 when using jimsh for code generation. May affect |
| 42 | # later decisions. |
| 43 | use-jim-for-codegen 0 |
| 44 | # |
| 45 | # Set to 1 when cross-compiling This value may be changed by certain |
| 46 | # build options, so it's important that config code which checks for |
| 47 | # cross-compilation uses this var instead of |
| 48 | # [proj-is-cross-compiling]. |
| 49 | is-cross-compiling [proj-is-cross-compiling] |
| 50 | # |
| 51 | # Pass msg-debug=1 to configure to enable obnoxiously loud output |
| 52 | # from [msg-debug]. |
| 53 | msg-debug-enabled 0 |
| 54 | # |
| 55 | # Output file for --dump-defines. Intended only for build debugging |
| 56 | # and not part of the public build interface. |
| 57 | dump-defines-txt ./config.defines.txt |
| 58 | # |
| 59 | # If not empty then --dump-defines will dump not only |
| 60 | # (dump-defines-txt) but also a JSON file named after this option's |
| 61 | # value. |
| 62 | dump-defines-json "" |
| 63 | |
| 64 | # |
| 65 | # The list of feature --flags which the --all flag implies. This |
| 66 | # requires special handling in a few places. |
| 67 | # |
| 68 | all-flag-enables {fts4 fts5 rtree geopoly session dbpage dbstat carray} |
| 69 | |
| 70 | # |
| 71 | # Default value for the --all flag. Can hypothetically be modified |
| 72 | # by non-canonical builds (it was added for a Tcl extension build |
| 73 | # mode which was eventually removed). |
| 74 | # |
| 75 | all-flag-default 0 |
| 76 | }]] |
| 77 | |
| 78 | ######################################################################## |
| 79 | # Processes all configure --flags for this build, run build-specific |
| 80 | # config checks, then finalize the configure process. $buildMode must |
| 81 | # be one of (canonical, autoconf), and others may be added in the |
| 82 | # future. After bootstrapping, $configScript is eval'd in the caller's |
| 83 | # scope, then post-configuration finalization is run. $configScript is |
| 84 | # intended to hold configure code which is specific to the given |
| 85 | # $buildMode, with the caveat that _some_ build-specific code is |
| 86 | # encapsulated in the configuration finalization step. |
| 87 | # |
| 88 | # The intent is that all (or almost all) build-mode-specific |
| 89 | # configuration goes inside the $configScript argument to this |
| 90 | # function, and that an auto.def file contains only two commands: |
| 91 | # |
| 92 | # use sqlite-config |
| 93 | # sqlite-configure BUILD_NAME { build-specific configure script } |
| 94 | # |
| 95 | # There are snippets of build-mode-specific decision-making in |
| 96 | # [sqlite-configure-finalize], which gets run after $configScript. |
| 97 | proc sqlite-configure {buildMode configScript} { |
| 98 | proj-assert {$::sqliteConfig(build-mode) eq "unknown"} \ |
| 99 | "sqlite-configure must not be called more than once" |
| 100 | set allBuildModes {canonical autoconf} |
| 101 | if {$buildMode ni $allBuildModes} { |
| 102 | user-error "Invalid build mode: $buildMode. Expecting one of: $allBuildModes" |
| 103 | } |
| 104 | if {$::sqliteConfig(all-flag-default)} { |
| 105 | set allFlagHelp "Disable these extensions: $::sqliteConfig(all-flag-enables)" |
| 106 | } else { |
| 107 | set allFlagHelp "Enable these extensions: $::sqliteConfig(all-flag-enables)" |
| 108 | } |
| 109 | |
| 110 | set ::sqliteConfig(build-mode) $buildMode |
| 111 | ######################################################################## |
| 112 | # A gentle introduction to flags handling in autosetup |
| 113 | # |
| 114 | # Reference: https://msteveb.github.io/autosetup/developer/ |
| 115 | # |
| 116 | # All configure flags must be described in one or more calls to |
| 117 | # autosetup's [options] and [options-add] functions. The general |
| 118 | # syntax of the single argument to those functions is a list contain |
| 119 | # a mapping of flags to help text: |
| 120 | # |
| 121 | # FLAG => {Help text} |
| 122 | # |
| 123 | # Where FLAG can have any of the following formats: |
| 124 | # |
| 125 | # boolopt => "a boolean option which defaults to disabled" |
| 126 | # boolopt2=1 => "a boolean option which defaults to enabled" |
| 127 | # stringopt: => "an option which takes an argument, e.g. --stringopt=value" |
| 128 | # stringopt:DESCR => As for stringopt: with a description for the value |
| 129 | # stringopt2:=value => "an option where the argument is optional and defaults to 'value'" |
| 130 | # optalias booltopt3 => "a boolean with a hidden alias. --optalias is not shown in --help" |
| 131 | # |
| 132 | # Autosetup does no small amount of specialized handling for flags, |
| 133 | # especially booleans. Each bool-type --FLAG implicitly gets |
| 134 | # --enable-FLAG and --disable-FLAG forms. That can lead lead to some |
| 135 | # confusion when writing help text. For example: |
| 136 | # |
| 137 | # options { json=1 {Disable JSON functions} } |
| 138 | # |
| 139 | # The reason the help text says "disable" is because a boolean option |
| 140 | # which defaults to true is, in the --help text, rendered as: |
| 141 | # |
| 142 | # --disable-json Disable JSON functions |
| 143 | # |
| 144 | # Whereas a bool flag which defaults to false will instead render as: |
| 145 | # |
| 146 | # --enable-FLAG |
| 147 | # |
| 148 | # Non-boolean flags, in contrast, use the names specifically given to |
| 149 | # them in the [options] invocation. e.g. "with-tcl" is the --with-tcl |
| 150 | # flag. |
| 151 | # |
| 152 | # Fetching values for flags: |
| 153 | # |
| 154 | # booleans: use one of: |
| 155 | # - [opt-bool FLAG] is autosetup's built-in command for this, but we |
| 156 | # have some convenience variants: |
| 157 | # - [proj-opt-truthy FLAG] |
| 158 | # - [proj-opt-if-truthy FLAG {THEN} {ELSE}] |
| 159 | # |
| 160 | # Non-boolean (i.e. string) flags: |
| 161 | # - [opt-val FLAG ?default?] |
| 162 | # - [opt-str ...] - see the docs in ./autosetup/autosetup |
| 163 | # |
| 164 | # [proj-opt-was-provided] can be used to determine whether a flag was |
| 165 | # explicitly provided, which is often useful for distinguishing from |
| 166 | # the case of a default value. |
| 167 | ######################################################################## |
| 168 | set allFlags { |
| 169 | # Structure: a list of M {Z} pairs, where M is a descriptive |
| 170 | # option group name and Z is a list of X Y pairs. X is a list of |
| 171 | # $buildMode name(s) to which the Y flags apply, or {*} to apply |
| 172 | # to all builds. Y is a {block} in the form expected by |
| 173 | # autosetup's [options] and [options-add] command. Each block |
| 174 | # which is applicable to $buildMode is passed on to |
| 175 | # [options-add]. The order of each Y and sub-Y is retained, which |
| 176 | # is significant for rendering of --help. |
| 177 | # |
| 178 | # Maintenance note: [options] does not support comments in |
| 179 | # options, but we filter this object through |
| 180 | # [proj-strip-hash-comments] to remove them before passing them on |
| 181 | # to [options]. |
| 182 | |
| 183 | # When writing {help text blocks}, be aware that: |
| 184 | # |
| 185 | # A) autosetup formats them differently if the {block} starts with |
| 186 | # a newline: it starts left-aligned, directly under the --flag, and |
| 187 | # the rest of the block is pasted verbatim rather than |
| 188 | # pretty-printed. |
| 189 | # |
| 190 | # B) Vars and commands are NOT expanded, but we use a [subst] call |
| 191 | # below which will replace (only) $var refs. |
| 192 | |
| 193 | # Options for how to build the library |
| 194 | build-modes { |
| 195 | {canonical autoconf} { |
| 196 | shared=1 => {Disable build of shared library} |
| 197 | static=1 => {Disable build of static library} |
| 198 | } |
| 199 | {canonical} { |
| 200 | amalgamation=1 => {Disable the amalgamation and instead build all files separately} |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | # Library-level features and defaults |
| 205 | lib-features { |
| 206 | {*} { |
| 207 | threadsafe=1 => {Disable mutexing} |
| 208 | with-tempstore:=no => {Use an in-RAM database for temporary tables: never,no,yes,always} |
| 209 | load-extension=1 => {Disable loading of external extensions} |
| 210 | # ^^^ one of the downstream custom builds overrides the load-extension default to 0, which |
| 211 | # confuses the --help text generator. https://github.com/msteveb/autosetup/issues/77 |
| 212 | math=1 => {Disable math functions} |
| 213 | json=1 => {Disable JSON functions} |
| 214 | memsys5 => {Enable MEMSYS5} |
| 215 | memsys3 => {Enable MEMSYS3} |
| 216 | fts3 => {Enable the FTS3 extension} |
| 217 | fts4 => {Enable the FTS4 extension} |
| 218 | fts5 => {Enable the FTS5 extension} |
| 219 | update-limit => {Enable the UPDATE/DELETE LIMIT clause} |
| 220 | geopoly => {Enable the GEOPOLY extension} |
| 221 | rtree => {Enable the RTREE extension} |
| 222 | session => {Enable the SESSION extension} |
| 223 | dbpage => {Enable the sqlite3_dbpage extension} |
| 224 | dbstat => {Enable the sqlite3_dbstat extension} |
| 225 | carray=1 => {Disable the CARRAY extension} |
| 226 | column-metadata => {Enable the column metadata APIs} |
| 227 | all=$::sqliteConfig(all-flag-default) => {$allFlagHelp} |
| 228 | largefile=1 |
| 229 | => {This legacy flag has no effect on the library but may influence |
| 230 | the generated sqlite_cfg.h by adding #define HAVE_LFS} |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | # Options for Tcl support |
| 235 | tcl { |
| 236 | {canonical} { |
| 237 | tcl=1 |
| 238 | => {Disable components which require Tcl, including all tests. |
| 239 | This tree requires Tcl for code generation but can use the in-tree |
| 240 | copy of autosetup/jimsh0.c for that. The SQLite Tcl extension and the |
| 241 | test code require a canonical tclsh.} |
| 242 | with-tcl:DIR |
| 243 | => {Directory containing tclConfig.sh or a directory one level up from |
| 244 | that, from which we can derive a directory containing tclConfig.sh. |
| 245 | A dir name of "prefix" is equivalent to the directory specified by |
| 246 | the --prefix flag. |
| 247 | |
| 248 | This determines the Tcl that SQLite will link against. It |
| 249 | does not affect the Tcl that is executed as part of the |
| 250 | build.} |
| 251 | with-tclsh:PATH |
| 252 | => {Full pathname of tclsh to use. It is used for all Tcl-based |
| 253 | code generation. |
| 254 | |
| 255 | Additionally, when doing a native (build = host) build, it |
| 256 | may also be used as a legacy fallback to find tclConfig.sh |
| 257 | if --with-tcl does not say where that is. Relying on that |
| 258 | is not recommended. Warning: if its containing dir has |
| 259 | multiple tclsh versions, it may select the wrong |
| 260 | tclConfig.sh! The safe thing is to only pass --with-tclsh |
| 261 | if one also passes --with-tcl.} |
| 262 | static-tclsqlite3=0 |
| 263 | => {Statically-link tclsqlite3. This only works if Tcl support is |
| 264 | enabled and all requisite libraries are available in |
| 265 | static form. Note that glibc is unable to fully statically |
| 266 | link certain libraries required by tclsqlite3, so this won't |
| 267 | work on most Linux environments.} |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | # Options for line-editing modes for the CLI shell |
| 272 | line-editing { |
| 273 | {canonical autoconf} { |
| 274 | readline=1 |
| 275 | => {Disable readline support} |
| 276 | # --with-readline-lib is a backwards-compatible alias for |
| 277 | # --with-readline-ldflags |
| 278 | with-readline-lib: |
| 279 | with-readline-ldflags:=auto |
| 280 | => {Readline LDFLAGS, e.g. -lreadline -lncurses} |
| 281 | # --with-readline-inc is a backwards-compatible alias for |
| 282 | # --with-readline-cflags. |
| 283 | with-readline-inc: |
| 284 | with-readline-cflags:=auto |
| 285 | => {Readline CFLAGS, e.g. -I/path/to/includes} |
| 286 | with-readline-header:PATH |
| 287 | => {Full path to readline.h, from which --with-readline-cflags will be derived} |
| 288 | with-linenoise:DIR |
| 289 | => {Source directory for linenoise.c and linenoise.h} |
| 290 | editline=0 |
| 291 | => {Enable BSD editline support} |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | # Options for ICU: International Components for Unicode |
| 296 | icu { |
| 297 | {*} { |
| 298 | with-icu-ldflags:LDFLAGS |
| 299 | => {Enable SQLITE_ENABLE_ICU and add the given linker flags for the |
| 300 | ICU libraries. e.g. on Ubuntu systems, try '-licui18n -licuuc -licudata'.} |
| 301 | with-icu-cflags:CFLAGS |
| 302 | => {Apply extra CFLAGS/CPPFLAGS necessary for building with ICU. |
| 303 | e.g. -I/usr/local/include} |
| 304 | with-icu-config:=auto |
| 305 | => {Enable SQLITE_ENABLE_ICU. Value must be one of: auto, pkg-config, |
| 306 | /path/to/icu-config} |
| 307 | icu-collations=0 |
| 308 | => {Enable SQLITE_ENABLE_ICU_COLLATIONS. Requires --with-icu-ldflags=... |
| 309 | or --with-icu-config} |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | # Options for exotic/alternative build modes |
| 314 | alternative-builds { |
| 315 | {canonical autoconf} { |
| 316 | with-wasi-sdk:=/opt/wasi-sdk |
| 317 | => {Top-most dir of the wasi-sdk for a WASI build} |
| 318 | } |
| 319 | |
| 320 | {*} { |
| 321 | # Note that --static-cli-shell has a completely different |
| 322 | # meaning from --static-shell in the autoconf build! |
| 323 | # --[disable-]static-shell is a legacy flag which we can't |
| 324 | # remove without breaking downstream builds. |
| 325 | static-cli-shell=0 |
| 326 | => {Statically-link the sqlite3 CLI shell. |
| 327 | This only works if the requisite libraries are all available in |
| 328 | static form.} |
| 329 | } |
| 330 | |
| 331 | {canonical} { |
| 332 | static-shells=0 |
| 333 | => {Shorthand for --static-cli-shell --static-tclsqlite3} |
| 334 | |
| 335 | with-emsdk:=auto |
| 336 | => {Top-most dir of the Emscripten SDK installation. |
| 337 | Needed only by ext/wasm. Default=EMSDK env var.} |
| 338 | |
| 339 | amalgamation-extra-src:FILES |
| 340 | => {Space-separated list of source files to append as-is to the resulting |
| 341 | sqlite3.c amalgamation file. May be provided multiple times.} |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | # Options primarily for downstream packagers/package maintainers |
| 346 | packaging { |
| 347 | {autoconf} { |
| 348 | # --disable-static-shell: https://sqlite.org/forum/forumpost/cc219ee704 |
| 349 | # Note that this has a different meaning from --static-cli-shell in the |
| 350 | # canonical build! |
| 351 | static-shell=1 |
| 352 | => {Link the sqlite3 shell app against the DLL instead of embedding sqlite3.c} |
| 353 | } |
| 354 | {canonical autoconf} { |
| 355 | rpath=1 => {Disable use of the rpath linker flag} |
| 356 | # soname: https://sqlite.org/src/forumpost/5a3b44f510df8ded |
| 357 | soname:=legacy |
| 358 | => {SONAME for libsqlite3.so. "none", or not using this flag, sets no |
| 359 | soname. "legacy" sets it to its historical value of |
| 360 | libsqlite3.so.0. A value matching the glob "libsqlite3.*" sets |
| 361 | it to that literal value. Any other value is assumed to be a |
| 362 | suffix which gets applied to "libsqlite3.so.", |
| 363 | e.g. --soname=9.10 equates to "libsqlite3.so.9.10".} |
| 364 | # dll-basename: https://sqlite.org/forum/forumpost/828fdfe904 |
| 365 | dll-basename:=auto |
| 366 | => {Specifies the base name of the resulting DLL file. |
| 367 | If not provided, "libsqlite3" is usually assumed but on some platforms |
| 368 | a platform-dependent default is used. On some platforms this flag |
| 369 | gets automatically enabled if it is not provided. Use "default" to |
| 370 | explicitly disable platform-dependent activation on such systems.} |
| 371 | # out-implib: https://sqlite.org/forum/forumpost/0c7fc097b2 |
| 372 | out-implib:=auto |
| 373 | => {Enable use of --out-implib linker flag to generate an |
| 374 | "import library" for the DLL. The output's base name is |
| 375 | specified by this flag's value, with "auto" meaning to figure |
| 376 | out a name automatically. On some platforms this flag gets |
| 377 | automatically enabled if it is not provided. Use "none" to |
| 378 | explicitly disable this feature on such platforms.} |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | # Options mostly for sqlite's own development |
| 383 | developer { |
| 384 | {*} { |
| 385 | # Note that using the --debug/--enable-debug flag here |
| 386 | # requires patching autosetup/autosetup to rename its builtin |
| 387 | # --debug to --autosetup-debug. See details in |
| 388 | # autosetup/README.md#patching. |
| 389 | with-debug=0 |
| 390 | debug=0 |
| 391 | => {Enable debug build flags. This option will impact performance by |
| 392 | as much as 4x, as it includes large numbers of assert()s in |
| 393 | performance-critical loops. Never use --debug for production |
| 394 | builds.} |
| 395 | scanstatus |
| 396 | => {Enable the SQLITE_ENABLE_STMT_SCANSTATUS feature flag} |
| 397 | } |
| 398 | {canonical} { |
| 399 | dev |
| 400 | => {Enable dev-mode build: automatically enables certain other flags} |
| 401 | test-status |
| 402 | => {Enable status of tests} |
| 403 | gcov=0 |
| 404 | => {Enable coverage testing using gcov} |
| 405 | linemacros |
| 406 | => {Enable #line macros in the amalgamation} |
| 407 | dynlink-tools |
| 408 | => {Dynamically link libsqlite3 to certain tools which normally statically embed it} |
| 409 | asan-fsanitize:=auto |
| 410 | => {Comma- or space-separated list of -fsanitize flags for use with the |
| 411 | fuzzcheck-asan tool. Only those which the compiler claims to support |
| 412 | will actually be used. May be provided multiple times.} |
| 413 | } |
| 414 | {*} { |
| 415 | dump-defines=0 |
| 416 | => {Dump autosetup defines to $::sqliteConfig(dump-defines-txt) |
| 417 | (for build debugging)} |
| 418 | } |
| 419 | } |
| 420 | }; # $allFlags |
| 421 | |
| 422 | set allFlags [proj-strip-hash-comments $allFlags] |
| 423 | # ^^^ lappend of [sqlite-custom-flags] introduces weirdness if |
| 424 | # we delay [proj-strip-hash-comments] until after that. |
| 425 | |
| 426 | ######################################################################## |
| 427 | # sqlite-custom.tcl is intended only for vendor-branch-specific |
| 428 | # customization. See autosetup/README.md#branch-customization for |
| 429 | # details. |
| 430 | if {[file exists $::autosetup(libdir)/sqlite-custom.tcl]} { |
| 431 | uplevel 1 {source $::autosetup(libdir)/sqlite-custom.tcl} |
| 432 | } |
| 433 | |
| 434 | if {[llength [info proc sqlite-custom-flags]] > 0} { |
| 435 | # sqlite-custom-flags is assumed to be imported via |
| 436 | # autosetup/sqlite-custom.tcl. |
| 437 | set scf [sqlite-custom-flags] |
| 438 | if {"" ne $scf} { |
| 439 | lappend allFlags sqlite-custom-flags $scf |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | #lappend allFlags just-testing {{*} {soname:=duplicateEntry => {x}}} |
| 444 | |
| 445 | # Filter allFlags to create the set of [options] legal for this build |
| 446 | foreach {group XY} [subst -nobackslashes -nocommands $allFlags] { |
| 447 | foreach {X Y} $XY { |
| 448 | if { $buildMode in $X || "*" in $X } { |
| 449 | options-add $Y |
| 450 | } |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | if {[catch {options {}} msg xopts]} { |
| 455 | # Workaround for <https://github.com/msteveb/autosetup/issues/73> |
| 456 | # where [options] behaves oddly on _some_ Tcl builds when it's |
| 457 | # called from deeper than the global scope. |
| 458 | dict incr xopts -level |
| 459 | return {*}$xopts $msg |
| 460 | } |
| 461 | sqlite-configure-phase1 $buildMode |
| 462 | uplevel 1 $configScript |
| 463 | sqlite-configure-finalize |
| 464 | }; # sqlite-configure |
| 465 | |
| 466 | ######################################################################## |
| 467 | # Runs "phase 1" of the configure process: after initial --flags |
| 468 | # handling but before sqlite-configure's $configScript argument is |
| 469 | # run. $buildMode must be the mode which was passed to |
| 470 | # [sqlite-configure]. |
| 471 | proc sqlite-configure-phase1 {buildMode} { |
| 472 | define PACKAGE_NAME sqlite |
| 473 | define PACKAGE_URL {https://sqlite.org} |
| 474 | define PACKAGE_BUGREPORT [get-define PACKAGE_URL]/bugs |
| 475 | define PACKAGE_STRING "[get-define PACKAGE_NAME] [get-define PACKAGE_VERSION]" |
| 476 | proj-xfer-options-aliases { |
| 477 | # Carry values from hidden --flag aliases over to their canonical |
| 478 | # flag forms. This list must include only options which are common |
| 479 | # to all build modes supported by [sqlite-configure]. |
| 480 | with-readline-inc => with-readline-cflags |
| 481 | with-readline-lib => with-readline-ldflags |
| 482 | with-debug => debug |
| 483 | } |
| 484 | set ::sqliteConfig(msg-debug-enabled) [proj-val-truthy [get-env msg-debug 0]] |
| 485 | proc-debug "msg-debug is enabled" |
| 486 | proj-setup-autoreconfig SQLITE_AUTORECONFIG |
| 487 | proj-file-extensions |
| 488 | if {".exe" eq [get-define TARGET_EXEEXT]} { |
| 489 | define SQLITE_OS_UNIX 0 |
| 490 | define SQLITE_OS_WIN 1 |
| 491 | } else { |
| 492 | define SQLITE_OS_UNIX 1 |
| 493 | define SQLITE_OS_WIN 0 |
| 494 | } |
| 495 | sqlite-setup-default-cflags |
| 496 | define HAVE_LFS 0 |
| 497 | if {[opt-bool largefile]} { |
| 498 | # |
| 499 | # Insofar as we can determine HAVE_LFS has no effect on the |
| 500 | # library. Perhaps it did back in the early 2000's. The |
| 501 | # --enable/disable-largefile flag is retained because it's |
| 502 | # harmless, but it doesn't do anything useful. It does have |
| 503 | # visible side-effects, though: the generated sqlite_cfg.h may (or |
| 504 | # may not) define HAVE_LFS. |
| 505 | cc-check-lfs |
| 506 | } |
| 507 | set srcdir $::autosetup(srcdir) |
| 508 | proj-dot-ins-append $srcdir/Makefile.in |
| 509 | if {[file exists $srcdir/sqlite3.pc.in]} { |
| 510 | proj-dot-ins-append $srcdir/sqlite3.pc.in |
| 511 | } |
| 512 | sqlite-handle-hpux; # must be relatively early so that other config tests can work |
| 513 | }; # sqlite-configure-phase1 |
| 514 | |
| 515 | ######################################################################## |
| 516 | # Performs late-stage config steps common to all supported |
| 517 | # $::sqliteConfig(build-mode) values. |
| 518 | proc sqlite-configure-finalize {} { |
| 519 | sqlite-handle-rpath |
| 520 | sqlite-handle-soname |
| 521 | sqlite-handle-threadsafe |
| 522 | sqlite-handle-tempstore |
| 523 | sqlite-handle-load-extension |
| 524 | sqlite-handle-math |
| 525 | sqlite-handle-icu |
| 526 | if {[proj-opt-exists readline]} { |
| 527 | sqlite-handle-line-editing |
| 528 | } |
| 529 | if {[proj-opt-exists shared]} { |
| 530 | proj-define-for-opt shared ENABLE_LIB_SHARED "Build shared library?" |
| 531 | } |
| 532 | if {[proj-opt-exists static]} { |
| 533 | if {![proj-define-for-opt static ENABLE_LIB_STATIC "Build static library?"]} { |
| 534 | # This notice really only applies to the canonical build... |
| 535 | proj-indented-notice { |
| 536 | NOTICE: static lib build may be implicitly re-activated by |
| 537 | other components, e.g. some test apps. |
| 538 | } |
| 539 | } |
| 540 | } |
| 541 | sqlite-handle-env-quirks |
| 542 | sqlite-handle-common-feature-flags |
| 543 | sqlite-finalize-feature-flags |
| 544 | sqlite-process-dot-in-files; # do not [define] anything after this |
| 545 | sqlite-dump-defines |
| 546 | } |
| 547 | |
| 548 | ######################################################################## |
| 549 | # Internal config-time debugging output routine. It generates no |
| 550 | # output unless msg-debug=1 is passed to the configure script. |
| 551 | proc msg-debug {msg} { |
| 552 | if {$::sqliteConfig(msg-debug-enabled)} { |
| 553 | puts stderr [proj-bold "** DEBUG: $msg"] |
| 554 | } |
| 555 | } |
| 556 | ######################################################################## |
| 557 | # A [msg-debug] proxy which prepends the name of the current proc to |
| 558 | # the debug message. It is not legal to call this from the global |
| 559 | # scope. |
| 560 | proc proc-debug {msg} { |
| 561 | msg-debug "\[[proj-scope 1]\]: $msg" |
| 562 | } |
| 563 | |
| 564 | define OPT_FEATURE_FLAGS {} ; # -DSQLITE_OMIT/ENABLE flags. |
| 565 | # |
| 566 | # OPT_SHELL = feature-related CFLAGS for the sqlite3 CLI app. The |
| 567 | # list's initial values are defaults which are always applied and not |
| 568 | # affected by --feature-flags. The list is appended to by various |
| 569 | # --feature-flags. |
| 570 | define OPT_SHELL { |
| 571 | -DSQLITE_DQS=0 |
| 572 | -DSQLITE_ENABLE_FTS4 |
| 573 | -DSQLITE_ENABLE_RTREE |
| 574 | -DSQLITE_ENABLE_EXPLAIN_COMMENTS |
| 575 | -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION |
| 576 | -DSQLITE_ENABLE_STMTVTAB |
| 577 | -DSQLITE_ENABLE_DBPAGE_VTAB |
| 578 | -DSQLITE_ENABLE_DBSTAT_VTAB |
| 579 | -DSQLITE_ENABLE_BYTECODE_VTAB |
| 580 | -DSQLITE_ENABLE_OFFSET_SQL_FUNC |
| 581 | -DSQLITE_ENABLE_PERCENTILE |
| 582 | -DSQLITE_STRICT_SUBTYPE=1 |
| 583 | } |
| 584 | ######################################################################## |
| 585 | # Adds $args, if not empty, to OPT_FEATURE_FLAGS. If the first arg is |
| 586 | # -shell then it strips that arg and passes the remaining args the |
| 587 | # sqlite-add-shell-opt in addition to adding them to |
| 588 | # OPT_FEATURE_FLAGS. This is intended only for holding |
| 589 | # -DSQLITE_ENABLE/OMIT/... flags, but that is not enforced here. |
| 590 | proc sqlite-add-feature-flag {args} { |
| 591 | set shell "" |
| 592 | if {"-shell" eq [lindex $args 0]} { |
| 593 | set args [lassign $args shell] |
| 594 | } |
| 595 | if {"" ne $args} { |
| 596 | if {"" ne $shell} { |
| 597 | sqlite-add-shell-opt {*}$args |
| 598 | } |
| 599 | define-append OPT_FEATURE_FLAGS {*}$args |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | ######################################################################## |
| 604 | # Appends $args, if not empty, to OPT_SHELL. |
| 605 | proc sqlite-add-shell-opt {args} { |
| 606 | if {"" ne $args} { |
| 607 | define-append OPT_SHELL {*}$args |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | ######################################################################## |
| 612 | # Check for log(3) in libm and die with an error if it is not |
| 613 | # found. $featureName should be the feature name which requires that |
| 614 | # function (it's used only in error messages). defines LDFLAGS_MATH to |
| 615 | # the required linker flags (which may be empty even if the math APIs |
| 616 | # are found, depending on the OS). |
| 617 | proc sqlite-affirm-have-math {featureName} { |
| 618 | if {"" eq [get-define LDFLAGS_MATH ""]} { |
| 619 | if {![msg-quiet proj-check-function-in-lib log m]} { |
| 620 | user-error "Missing math APIs for $featureName" |
| 621 | } |
| 622 | set lfl [get-define lib_log ""] |
| 623 | undefine lib_log |
| 624 | if {"" ne $lfl} { |
| 625 | user-notice "Forcing requirement of $lfl for $featureName" |
| 626 | } |
| 627 | define LDFLAGS_MATH $lfl |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | ######################################################################## |
| 632 | # Run checks for required binaries, like ld and ar. In the canonical |
| 633 | # build this must come before [sqlite-handle-wasi-sdk]. |
| 634 | proc sqlite-check-common-bins {} { |
| 635 | cc-check-tools ld ar ; # must come before [sqlite-handle-wasi-sdk] |
| 636 | if {"" eq [proj-bin-define install]} { |
| 637 | proj-warn "Cannot find install binary, so 'make install' will not work." |
| 638 | define BIN_INSTALL false |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | ######################################################################## |
| 643 | # Run checks for system-level includes and libs which are common to |
| 644 | # both the canonical build and the "autoconf" bundle. |
| 645 | # |
| 646 | # For the canonical build this must come after |
| 647 | # [sqlite-handle-wasi-sdk], as that function may change the |
| 648 | # environment in ways which affect this. |
| 649 | proc sqlite-check-common-system-deps {} { |
| 650 | # Check for needed/wanted data types |
| 651 | cc-with {-includes stdint.h} \ |
| 652 | {cc-check-types int8_t int16_t int32_t int64_t intptr_t \ |
| 653 | uint8_t uint16_t uint32_t uint64_t uintptr_t} |
| 654 | |
| 655 | # Check for needed/wanted functions |
| 656 | cc-check-functions gmtime_r isnan localtime_r localtime_s \ |
| 657 | usleep utime pread pread64 pwrite pwrite64 |
| 658 | |
| 659 | apply {{} { |
| 660 | set ldrt "" |
| 661 | # Collapse funcs from librt into LDFLAGS_RT. |
| 662 | # Some systems (ex: SunOS) require -lrt in order to use nanosleep |
| 663 | foreach func {fdatasync nanosleep} { |
| 664 | if {[proj-check-function-in-lib $func rt]} { |
| 665 | set ldrt [get-define lib_${func} ""] |
| 666 | undefine lib_${func} |
| 667 | if {"" ne $ldrt} { |
| 668 | break |
| 669 | } |
| 670 | } |
| 671 | } |
| 672 | define LDFLAGS_RT $ldrt |
| 673 | }} |
| 674 | |
| 675 | # Check for needed/wanted headers |
| 676 | cc-check-includes \ |
| 677 | sys/types.h sys/stat.h dlfcn.h unistd.h \ |
| 678 | stdlib.h malloc.h memory.h \ |
| 679 | string.h strings.h \ |
| 680 | inttypes.h |
| 681 | |
| 682 | if {[cc-check-includes zlib.h] && [proj-check-function-in-lib deflate z]} { |
| 683 | # TODO? port over the more sophisticated zlib search from the fossil auto.def |
| 684 | define HAVE_ZLIB 1 |
| 685 | define LDFLAGS_ZLIB -lz |
| 686 | sqlite-add-shell-opt -DSQLITE_HAVE_ZLIB=1 |
| 687 | sqlite-add-feature-flag -DSQLITE_HAVE_ZLIB=1 |
| 688 | } else { |
| 689 | define HAVE_ZLIB 0 |
| 690 | define LDFLAGS_ZLIB "" |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | ######################################################################## |
| 695 | # Move -DSQLITE_OMIT... and -DSQLITE_ENABLE... flags from CFLAGS and |
| 696 | # CPPFLAGS to OPT_FEATURE_FLAGS and remove them from BUILD_CFLAGS. |
| 697 | proc sqlite-munge-cflags {} { |
| 698 | # Move CFLAGS and CPPFLAGS entries matching -DSQLITE_OMIT* and |
| 699 | # -DSQLITE_ENABLE* to OPT_FEATURE_FLAGS. This behavior is derived |
| 700 | # from the legacy build and was missing the 3.48.0 release (the |
| 701 | # initial Autosetup port). |
| 702 | # https://sqlite.org/forum/forumpost/9801e54665afd728 |
| 703 | # |
| 704 | # Handling of CPPFLAGS, as well as removing ENABLE/OMIT from |
| 705 | # CFLAGS/CPPFLAGS, was missing in the 3.49.0 release as well. |
| 706 | # |
| 707 | # If any configure flags for features are in conflict with |
| 708 | # CFLAGS/CPPFLAGS-specified feature flags, all bets are off. There |
| 709 | # are no guarantees about which one will take precedence. |
| 710 | foreach flagDef {CFLAGS CPPFLAGS} { |
| 711 | set tmp "" |
| 712 | foreach cf [get-define $flagDef ""] { |
| 713 | switch -glob -- $cf { |
| 714 | -DSQLITE_OMIT* - |
| 715 | -DSQLITE_ENABLE* { |
| 716 | sqlite-add-feature-flag $cf |
| 717 | } |
| 718 | default { |
| 719 | lappend tmp $cf |
| 720 | } |
| 721 | } |
| 722 | } |
| 723 | define $flagDef $tmp |
| 724 | } |
| 725 | |
| 726 | # Strip all SQLITE_ENABLE/OMIT flags from BUILD_CFLAGS, |
| 727 | # for compatibility with the legacy build. |
| 728 | set tmp "" |
| 729 | foreach cf [get-define BUILD_CFLAGS ""] { |
| 730 | switch -glob -- $cf { |
| 731 | -DSQLITE_OMIT* - |
| 732 | -DSQLITE_ENABLE* {} |
| 733 | default { |
| 734 | lappend tmp $cf |
| 735 | } |
| 736 | } |
| 737 | } |
| 738 | define BUILD_CFLAGS $tmp |
| 739 | } |
| 740 | |
| 741 | ######################################################################### |
| 742 | # Set up the default CFLAGS and BUILD_CFLAGS values. |
| 743 | proc sqlite-setup-default-cflags {} { |
| 744 | ######################################################################## |
| 745 | # We differentiate between two C compilers: the one used for binaries |
| 746 | # which are to run on the build system (in autosetup it's called |
| 747 | # CC_FOR_BUILD and in Makefile.in it's $(B.cc)) and the one used for |
| 748 | # compiling binaries for the target system (CC a.k.a. $(T.cc)). |
| 749 | # Normally they're the same, but they will differ when |
| 750 | # cross-compiling. |
| 751 | set defaultCFlags {-O2} |
| 752 | if {!$::sqliteConfig(is-cross-compiling)} { |
| 753 | # When cross-compiling we default to not using the -g flag, based |
| 754 | # on a /chat discussion prompted by |
| 755 | # https://sqlite.org/forum/forumpost/9a67df63eda9925c |
| 756 | lappend defaultCFlags -g |
| 757 | } |
| 758 | define CFLAGS [proj-get-env CFLAGS $defaultCFlags] |
| 759 | # BUILD_CFLAGS is the CFLAGS for CC_FOR_BUILD. |
| 760 | define BUILD_CFLAGS [proj-get-env BUILD_CFLAGS {-g}] |
| 761 | sqlite-munge-cflags |
| 762 | } |
| 763 | |
| 764 | ######################################################################## |
| 765 | # Handle various SQLITE_ENABLE/OMIT_... feature flags. |
| 766 | proc sqlite-handle-common-feature-flags {} { |
| 767 | msg-result "Feature flags..." |
| 768 | if {![opt-bool all]} { |
| 769 | # Special handling for --disable-all |
| 770 | foreach flag $::sqliteConfig(all-flag-enables) { |
| 771 | if {![proj-opt-was-provided $flag]} { |
| 772 | proj-opt-set $flag 0 |
| 773 | } |
| 774 | } |
| 775 | } |
| 776 | foreach {boolFlag featureFlag ifSetEvalThis} [proj-strip-hash-comments { |
| 777 | all {} { |
| 778 | # The 'all' option must be first in this list. This impl makes |
| 779 | # an effort to only apply flags which the user did not already |
| 780 | # apply, so that combinations like (--all --disable-geopoly) |
| 781 | # will indeed disable geopoly. There are corner cases where |
| 782 | # flags which depend on each other will behave in non-intuitive |
| 783 | # ways: |
| 784 | # |
| 785 | # --all --disable-rtree |
| 786 | # |
| 787 | # Will NOT disable geopoly, though geopoly depends on rtree. |
| 788 | # The --geopoly flag, though, will automatically re-enable |
| 789 | # --rtree, so --disable-rtree won't actually disable anything in |
| 790 | # that case. |
| 791 | foreach k $::sqliteConfig(all-flag-enables) { |
| 792 | if {![proj-opt-was-provided $k]} { |
| 793 | proj-opt-set $k 1 |
| 794 | } |
| 795 | } |
| 796 | } |
| 797 | fts3 -DSQLITE_ENABLE_FTS3 {sqlite-affirm-have-math fts3} |
| 798 | fts4 -DSQLITE_ENABLE_FTS4 {sqlite-affirm-have-math fts4} |
| 799 | fts5 -DSQLITE_ENABLE_FTS5 {sqlite-affirm-have-math fts5} |
| 800 | geopoly -DSQLITE_ENABLE_GEOPOLY {proj-opt-set rtree} |
| 801 | rtree -DSQLITE_ENABLE_RTREE {} |
| 802 | session {-DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK} {} |
| 803 | update-limit -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT {} |
| 804 | memsys5 -DSQLITE_ENABLE_MEMSYS5 {} |
| 805 | memsys3 {} { |
| 806 | if {[opt-bool memsys5]} { |
| 807 | proj-warn "not enabling memsys3 because memsys5 is enabled." |
| 808 | expr 0 |
| 809 | } else { |
| 810 | sqlite-add-feature-flag -DSQLITE_ENABLE_MEMSYS3 |
| 811 | } |
| 812 | } |
| 813 | bytecode-vtab -DSQLITE_ENABLE_BYTECODE_VTAB {} |
| 814 | scanstatus {-DSQLITE_ENABLE_STMT_SCANSTATUS -DSQLITE_ENABLE_BYTECODE_VTAB} {} |
| 815 | column-metadata -DSQLITE_ENABLE_COLUMN_METADATA {} |
| 816 | dbpage -DSQLITE_ENABLE_DBPAGE_VTAB {} |
| 817 | dbstat -DSQLITE_ENABLE_DBSTAT_VTAB {} |
| 818 | carray -DSQLITE_ENABLE_CARRAY {} |
| 819 | }] { |
| 820 | if {$boolFlag ni $::autosetup(options)} { |
| 821 | # Skip flags which are in the canonical build but not |
| 822 | # the autoconf bundle. |
| 823 | continue |
| 824 | } |
| 825 | proj-if-opt-truthy $boolFlag { |
| 826 | sqlite-add-feature-flag $featureFlag |
| 827 | if {0 != [eval $ifSetEvalThis] && "all" ne $boolFlag} { |
| 828 | msg-result " + $boolFlag" |
| 829 | } |
| 830 | } { |
| 831 | if {"all" ne $boolFlag} { |
| 832 | msg-result " - $boolFlag" |
| 833 | } |
| 834 | } |
| 835 | } |
| 836 | ######################################################################## |
| 837 | # Invert the above loop's logic for some SQLITE_OMIT_... cases. If |
| 838 | # config option $boolFlag is false, [sqlite-add-feature-flag |
| 839 | # $featureFlag], where $featureFlag is intended to be |
| 840 | # -DSQLITE_OMIT_... |
| 841 | foreach {boolFlag featureFlag} { |
| 842 | json -DSQLITE_OMIT_JSON |
| 843 | } { |
| 844 | if {[proj-opt-truthy $boolFlag]} { |
| 845 | msg-result " + $boolFlag" |
| 846 | } else { |
| 847 | sqlite-add-feature-flag $featureFlag |
| 848 | msg-result " - $boolFlag" |
| 849 | } |
| 850 | } |
| 851 | } |
| 852 | |
| 853 | ######################################################################### |
| 854 | # Remove duplicates from the final feature flag sets and show them to |
| 855 | # the user. |
| 856 | proc sqlite-finalize-feature-flags {} { |
| 857 | set oFF [get-define OPT_FEATURE_FLAGS] |
| 858 | if {"" ne $oFF} { |
| 859 | define OPT_FEATURE_FLAGS [lsort -unique $oFF] |
| 860 | msg-result "Library feature flags: [get-define OPT_FEATURE_FLAGS]" |
| 861 | } |
| 862 | set oFF [get-define OPT_SHELL] |
| 863 | if {"" ne $oFF} { |
| 864 | define OPT_SHELL [lsort -unique $oFF] |
| 865 | msg-result "Shell options: [get-define OPT_SHELL]" |
| 866 | } |
| 867 | if {"" ne [set extraSrc [get-define AMALGAMATION_EXTRA_SRC ""]]} { |
| 868 | proj-assert {"canonical" eq $::sqliteConfig(build-mode)} |
| 869 | msg-result "Appending source files to amalgamation: $extraSrc" |
| 870 | } |
| 871 | if {[lsearch [get-define TARGET_DEBUG ""] -DSQLITE_DEBUG=1] > -1} { |
| 872 | msg-result "Note: this is a debug build, so performance will suffer." |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | ######################################################################## |
| 877 | # Checks for the --debug flag and [define]s TARGET_DEBUG based on |
| 878 | # that. TARGET_DEBUG is unused in the autoconf build but that is |
| 879 | # arguably a bug. |
| 880 | proc sqlite-handle-debug {} { |
| 881 | msg-checking "SQLITE_DEBUG build? " |
| 882 | proj-if-opt-truthy debug { |
| 883 | define TARGET_DEBUG {-g -DSQLITE_DEBUG=1 -O0 -Wall} |
| 884 | sqlite-add-feature-flag -DSQLITE_ENABLE_SELECTTRACE \ |
| 885 | -DSQLITE_ENABLE_WHERETRACE \ |
| 886 | -DSQLITE_ENABLE_BYTECODE_VTAB |
| 887 | proj-opt-set memsys5 |
| 888 | msg-result yes |
| 889 | } { |
| 890 | define TARGET_DEBUG {-DNDEBUG} |
| 891 | msg-result no |
| 892 | } |
| 893 | } |
| 894 | |
| 895 | ######################################################################## |
| 896 | # "soname" for libsqlite3.so. See discussion at: |
| 897 | # https://sqlite.org/src/forumpost/5a3b44f510df8ded |
| 898 | proc sqlite-handle-soname {} { |
| 899 | define LDFLAGS_LIBSQLITE3_SONAME "" |
| 900 | if {[proj-opt-was-provided soname]} { |
| 901 | set soname [join [opt-val soname] ""] |
| 902 | } else { |
| 903 | # Enabling soname breaks linking for the --dynlink-tools feature, |
| 904 | # and this project has no direct use for soname, so default to |
| 905 | # none. Package maintainers, on the other hand, like to have an |
| 906 | # soname. |
| 907 | set soname none |
| 908 | } |
| 909 | switch -exact -- $soname { |
| 910 | none - "" { return 0 } |
| 911 | legacy { set soname libsqlite3.so.0 } |
| 912 | default { |
| 913 | if {[string match libsqlite3.* $soname]} { |
| 914 | # use it as-is |
| 915 | } else { |
| 916 | # Assume it's a suffix |
| 917 | set soname "libsqlite3.so.${soname}" |
| 918 | } |
| 919 | } |
| 920 | } |
| 921 | proc-debug "soname=$soname" |
| 922 | if {[proj-check-soname $soname]} { |
| 923 | define LDFLAGS_LIBSQLITE3_SONAME [get-define LDFLAGS_SONAME_PREFIX]$soname |
| 924 | msg-result "Setting SONAME using: [get-define LDFLAGS_LIBSQLITE3_SONAME]" |
| 925 | } elseif {[proj-opt-was-provided soname]} { |
| 926 | # --soname was explicitly requested but not available, so fail fatally |
| 927 | proj-fatal "This environment does not support SONAME." |
| 928 | } else { |
| 929 | # --soname was not explicitly requested but not available, so just warn |
| 930 | msg-result "This environment does not support SONAME." |
| 931 | } |
| 932 | } |
| 933 | |
| 934 | ######################################################################## |
| 935 | # If --enable-threadsafe is set, this adds -DSQLITE_THREADSAFE=1 to |
| 936 | # OPT_FEATURE_FLAGS and sets LDFLAGS_PTHREAD to the linker flags |
| 937 | # needed for linking pthread (possibly an empty string). If |
| 938 | # --enable-threadsafe is not set, adds -DSQLITE_THREADSAFE=0 to |
| 939 | # OPT_FEATURE_FLAGS and sets LDFLAGS_PTHREAD to an empty string. |
| 940 | proc sqlite-handle-threadsafe {} { |
| 941 | msg-checking "Support threadsafe operation? " |
| 942 | define LDFLAGS_PTHREAD "" |
| 943 | set enable 0 |
| 944 | proj-if-opt-truthy threadsafe { |
| 945 | msg-result "Checking for libs..." |
| 946 | if {[proj-check-function-in-lib pthread_create pthread] |
| 947 | && [proj-check-function-in-lib pthread_mutexattr_init pthread]} { |
| 948 | set enable 1 |
| 949 | define LDFLAGS_PTHREAD [get-define lib_pthread_create] |
| 950 | undefine lib_pthread_create |
| 951 | undefine lib_pthread_mutexattr_init |
| 952 | } elseif {[proj-opt-was-provided threadsafe]} { |
| 953 | user-error "Missing required pthread libraries. Use --disable-threadsafe to disable this check." |
| 954 | } else { |
| 955 | msg-result "pthread support not detected" |
| 956 | } |
| 957 | # Recall that LDFLAGS_PTHREAD might be empty even if pthreads if |
| 958 | # found because it's in -lc on some platforms. |
| 959 | } { |
| 960 | msg-result "Disabled using --disable-threadsafe" |
| 961 | } |
| 962 | sqlite-add-feature-flag -DSQLITE_THREADSAFE=${enable} |
| 963 | return $enable |
| 964 | } |
| 965 | |
| 966 | ######################################################################## |
| 967 | # Handles the --with-tempstore flag. |
| 968 | # |
| 969 | # The test fixture likes to set SQLITE_TEMP_STORE on its own, so do |
| 970 | # not set that feature flag unless it was explicitly provided to the |
| 971 | # configure script. |
| 972 | proc sqlite-handle-tempstore {} { |
| 973 | if {[proj-opt-was-provided with-tempstore]} { |
| 974 | set ts [opt-val with-tempstore no] |
| 975 | set tsn 1 |
| 976 | msg-checking "Use an in-RAM database for temporary tables? " |
| 977 | switch -exact -- $ts { |
| 978 | never { set tsn 0 } |
| 979 | no { set tsn 1 } |
| 980 | yes { set tsn 2 } |
| 981 | always { set tsn 3 } |
| 982 | default { |
| 983 | user-error "Invalid --with-tempstore value '$ts'. Use one of: never, no, yes, always" |
| 984 | } |
| 985 | } |
| 986 | msg-result $ts |
| 987 | sqlite-add-feature-flag -DSQLITE_TEMP_STORE=$tsn |
| 988 | } |
| 989 | } |
| 990 | |
| 991 | ######################################################################## |
| 992 | # Check for the Emscripten SDK for building the web-based wasm |
| 993 | # components. The core lib and tools do not require this but ext/wasm |
| 994 | # does. Most of the work is done via [proj-check-emsdk], then this |
| 995 | # function adds the following defines: |
| 996 | # |
| 997 | # - EMCC_WRAPPER = "" or top-srcdir/tool/emcc.sh |
| 998 | # - BIN_WASM_OPT = "" or path to wasm-opt |
| 999 | # - BIN_WASM_STRIP = "" or path to wasm-strip |
| 1000 | # |
| 1001 | # Noting that: |
| 1002 | # |
| 1003 | # 1) Not finding the SDK is not fatal at this level, nor is failure to |
| 1004 | # find one of the related binaries. |
| 1005 | # |
| 1006 | # 2) wasm-strip is part of the wabt package: |
| 1007 | # |
| 1008 | # https://github.com/WebAssembly/wabt |
| 1009 | # |
| 1010 | # and this project requires it for production-mode builds but not dev |
| 1011 | # builds. |
| 1012 | # |
| 1013 | proc sqlite-handle-emsdk {} { |
| 1014 | define EMCC_WRAPPER "" |
| 1015 | define BIN_WASM_STRIP "" |
| 1016 | define BIN_WASM_OPT "" |
| 1017 | set srcdir $::autosetup(srcdir) |
| 1018 | if {$srcdir ne $::autosetup(builddir)} { |
| 1019 | # The EMSDK pieces require writing to the original source tree |
| 1020 | # even when doing an out-of-tree build. The ext/wasm pieces do not |
| 1021 | # support an out-of-tree build so we treat that case as if EMSDK |
| 1022 | # were not found. |
| 1023 | msg-result "Out-of tree build: not checking for EMSDK." |
| 1024 | return |
| 1025 | } |
| 1026 | set emccSh $srcdir/tool/emcc.sh |
| 1027 | set extWasmConfig $srcdir/ext/wasm/config.make |
| 1028 | if {![get-define HAVE_WASI_SDK] && [proj-check-emsdk]} { |
| 1029 | define EMCC_WRAPPER $emccSh |
| 1030 | set emsdkHome [get-define EMSDK_HOME ""] |
| 1031 | proj-assert {"" ne $emsdkHome} |
| 1032 | #define EMCC_WRAPPER ""; # just for testing |
| 1033 | proj-bin-define wasm-strip |
| 1034 | proj-bin-define bash; # ext/wasm/GNUmakefile requires bash |
| 1035 | if {[file-isexec $emsdkHome/upstream/bin/wasm-opt]} { |
| 1036 | define BIN_WASM_OPT $emsdkHome/upstream/bin/wasm-opt |
| 1037 | } else { |
| 1038 | # Maybe there's a copy in the path? |
| 1039 | proj-bin-define wasm-opt BIN_WASM_OPT |
| 1040 | } |
| 1041 | proj-dot-ins-append $emccSh.in $emccSh { |
| 1042 | catch {exec chmod u+x $dotInsOut} |
| 1043 | } |
| 1044 | proj-dot-ins-append $extWasmConfig.in $extWasmConfig |
| 1045 | } else { |
| 1046 | define EMCC_WRAPPER "" |
| 1047 | file delete -force -- $emccSh $extWasmConfig |
| 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | ######################################################################## |
| 1052 | # Internal helper for [sqlite-check-line-editing]. Returns a list of |
| 1053 | # potential locations under which readline.h might be found. |
| 1054 | # |
| 1055 | # On some environments this function may perform extra work to help |
| 1056 | # sqlite-check-line-editing figure out how to find libreadline and |
| 1057 | # friends. It will communicate those results via means other than the |
| 1058 | # result value, e.g. by modifying configure --flags. |
| 1059 | proc sqlite-get-readline-dir-list {} { |
| 1060 | # Historical note: the dirs list, except for the inclusion of |
| 1061 | # $prefix and some platform-specific dirs, originates from the |
| 1062 | # legacy configure script. |
| 1063 | set dirs [list [get-define prefix]] |
| 1064 | switch -glob -- [get-define host] { |
| 1065 | *-linux-android { |
| 1066 | # Possibly termux |
| 1067 | lappend dirs /data/data/com.termux/files/usr |
| 1068 | } |
| 1069 | *-mingw32 { |
| 1070 | lappend dirs /mingw32 /mingw |
| 1071 | } |
| 1072 | *-mingw64 { |
| 1073 | lappend dirs /mingw64 /mingw |
| 1074 | } |
| 1075 | *-haiku { |
| 1076 | lappend dirs /boot/system/develop/headers |
| 1077 | if {![opt-bool editline] && [opt-val with-readline-ldflags] in {auto ""}} { |
| 1078 | # If the user did not supply their own --with-readline-ldflags |
| 1079 | # value, hijack that flag to inject options which are known to |
| 1080 | # work on Haiku OS installations. |
| 1081 | if {"" ne [glob -nocomplain /boot/system/lib/libreadline*]} { |
| 1082 | proj-opt-set with-readline-ldflags {-L/boot/system/lib -lreadline} |
| 1083 | } |
| 1084 | } |
| 1085 | } |
| 1086 | } |
| 1087 | lappend dirs /usr /usr/local /usr/local/readline /usr/contrib |
| 1088 | set rv {} |
| 1089 | foreach d $dirs { |
| 1090 | if {[file isdir $d]} {lappend rv $d} |
| 1091 | } |
| 1092 | #proc-debug "dirs=$rv" |
| 1093 | return $rv |
| 1094 | } |
| 1095 | |
| 1096 | ######################################################################## |
| 1097 | # sqlite-check-line-editing jumps through proverbial hoops to try to |
| 1098 | # find a working line-editing library, setting: |
| 1099 | # |
| 1100 | # - HAVE_READLINE to 0 or 1 |
| 1101 | # - HAVE_LINENOISE to 0, 1, or 2 |
| 1102 | # - HAVE_EDITLINE to 0 or 1 |
| 1103 | # |
| 1104 | # Those will be set as follows: |
| 1105 | # |
| 1106 | # HAVE_LINENOISE=0, HAVE_EDITLINE=0, HAVE_READLINE=0: no line editing |
| 1107 | # |
| 1108 | # HAVE_LINENOISE>0: 1=antirez flavor, 2=msteveb flavor |
| 1109 | # |
| 1110 | # HAVE_EDITLINE=0, HAVE_READLINE=1: use GNU readline |
| 1111 | # |
| 1112 | # HAVE_EDITLINE=1, HAVE_READLINE=1: use BSD editline header |
| 1113 | # <readline/readline.h>. |
| 1114 | # |
| 1115 | # HAVE_EDITLINE=1, HAVE_READLINE=0: use BSD editline header |
| 1116 | # <editline/readline.h>. |
| 1117 | # |
| 1118 | # Other defines it sets: |
| 1119 | # |
| 1120 | # - LDFLAGS_READLINE = linker flags or empty string |
| 1121 | # |
| 1122 | # - CFLAGS_READLINE = compilation flags for clients or empty string. |
| 1123 | # |
| 1124 | # Both LDFLAGS_READLINE and CFLAGS_READLINE may refer to linenoise or |
| 1125 | # editline, not necessarily libreadline. In some cases it will set |
| 1126 | # HAVE_READLINE=1 when it's really using editline, for reasons |
| 1127 | # described in this function's comments. |
| 1128 | # |
| 1129 | # Returns a string describing which line-editing approach to use, or |
| 1130 | # "none" if no option is available. |
| 1131 | # |
| 1132 | # Order of checks: |
| 1133 | # |
| 1134 | # 1) --with-linenoise trumps all others and skips all of the |
| 1135 | # complexities involved with the remaining options. |
| 1136 | # |
| 1137 | # 2) --editline trumps --readline |
| 1138 | # |
| 1139 | # 3) --disable-readline trumps --readline |
| 1140 | # |
| 1141 | # 4) Default to automatic search for optional readline |
| 1142 | # |
| 1143 | # 5) Try to find readline or editline. If it's not found AND the |
| 1144 | # corresponding --FEATURE flag was explicitly given then fail |
| 1145 | # fatally, else fail non-fatally. |
| 1146 | proc sqlite-check-line-editing {} { |
| 1147 | msg-result "Checking for line-editing capability..." |
| 1148 | define HAVE_READLINE 0 |
| 1149 | define HAVE_LINENOISE 0 |
| 1150 | define HAVE_EDITLINE 0 |
| 1151 | define LDFLAGS_READLINE "" |
| 1152 | define CFLAGS_READLINE "" |
| 1153 | set failIfNotFound 0 ; # Gets set to 1 for explicit --FEATURE requests |
| 1154 | # so that we know whether to fail fatally or not |
| 1155 | # if the library is not found. |
| 1156 | set libsForReadline {readline edit} ; # -l<LIB> names to check for readline(). |
| 1157 | # The libedit check changes this. |
| 1158 | set editLibName "readline" ; # "readline" or "editline" |
| 1159 | set editLibDef "HAVE_READLINE" ; # "HAVE_READLINE" or "HAVE_EDITLINE" |
| 1160 | set dirLn [opt-val with-linenoise] |
| 1161 | |
| 1162 | # If none of --with-linenoise, --enable-readline, or --enable-editline |
| 1163 | # are provided, but there exists a directory "linenoise" at $HOME or |
| 1164 | # a sibling of the build or source directory, then try to use that linenoise |
| 1165 | # directory. |
| 1166 | # |
| 1167 | if {"" eq $dirLn |
| 1168 | && ![proj-opt-was-provided readline] |
| 1169 | && ![proj-opt-was-provided editline] |
| 1170 | } { |
| 1171 | set dirlist ../linenoise |
| 1172 | catch {lappend dirlist [file-normalize $::autosetup(srcdir)/../linenoise]} |
| 1173 | catch {lappend dirlist $::env(HOME)/linenoise} |
| 1174 | foreach d $dirlist { |
| 1175 | if {[file exists $d/linenoise.c] && [file exists $d/linenoise.h]} { |
| 1176 | set dirLn $d |
| 1177 | break |
| 1178 | } |
| 1179 | } |
| 1180 | } |
| 1181 | |
| 1182 | if {"" ne $dirLn} { |
| 1183 | # Use linenoise from a copy of its sources (not a library)... |
| 1184 | if {![file isdir $dirLn]} { |
| 1185 | proj-fatal "--with-linenoise value is not a directory" |
| 1186 | } |
| 1187 | set lnH $dirLn/linenoise.h |
| 1188 | if {![file exists $lnH] } { |
| 1189 | proj-fatal "Cannot find linenoise.h in $dirLn" |
| 1190 | } |
| 1191 | set lnC "" |
| 1192 | set lnCOpts {linenoise-ship.c linenoise.c} |
| 1193 | foreach f $lnCOpts { |
| 1194 | if {[file exists $dirLn/$f]} { |
| 1195 | set lnC $dirLn/$f |
| 1196 | break |
| 1197 | } |
| 1198 | } |
| 1199 | if {"" eq $lnC} { |
| 1200 | proj-fatal "Cannot find any of $lnCOpts in $dirLn" |
| 1201 | } |
| 1202 | set flavor "" |
| 1203 | set lnVal [proj-which-linenoise $lnH] |
| 1204 | switch -- $lnVal { |
| 1205 | 1 { set flavor "antirez" } |
| 1206 | 2 { set flavor "msteveb" } |
| 1207 | default { |
| 1208 | proj-fatal "Cannot determine the flavor of linenoise from $lnH" |
| 1209 | } |
| 1210 | } |
| 1211 | define CFLAGS_READLINE "-I$dirLn $lnC" |
| 1212 | define HAVE_LINENOISE $lnVal |
| 1213 | sqlite-add-shell-opt -DHAVE_LINENOISE=$lnVal |
| 1214 | if {$::sqliteConfig(use-jim-for-codegen) && 2 == $lnVal} { |
| 1215 | define-append CFLAGS_JIMSH -DUSE_LINENOISE [get-define CFLAGS_READLINE] |
| 1216 | user-notice "Adding linenoise support to jimsh." |
| 1217 | } else { |
| 1218 | msg-result "Using linenoise at [file-normalize $dirLn]" |
| 1219 | } |
| 1220 | return "linenoise ($flavor)" |
| 1221 | } elseif {[opt-bool editline]} { |
| 1222 | # libedit mimics libreadline and on some systems does not have its |
| 1223 | # own header installed (instead, that of libreadline is used). |
| 1224 | # |
| 1225 | # shell.c historically expects HAVE_EDITLINE to be set for |
| 1226 | # libedit, but it then expects to see <editline/readline.h>, which |
| 1227 | # some system's don't actually have despite having libedit. If we |
| 1228 | # end up finding <editline/readline.h> below, we will use |
| 1229 | # -DHAVE_EDITLINE=1, else we will use -DHAVE_READLINE=1. In either |
| 1230 | # case, we will link against libedit. |
| 1231 | set failIfNotFound 1 |
| 1232 | set libsForReadline {edit} |
| 1233 | set editLibName editline |
| 1234 | set editLibDef HAVE_EDITLINE |
| 1235 | } elseif {![opt-bool readline]} { |
| 1236 | msg-result "Readline support explicitly disabled with --disable-readline" |
| 1237 | return "none" |
| 1238 | } elseif {[proj-opt-was-provided readline]} { |
| 1239 | # If an explicit --[enable-]readline was used, fail if it's not |
| 1240 | # found, else treat the feature as optional. |
| 1241 | set failIfNotFound 1 |
| 1242 | } |
| 1243 | |
| 1244 | # Transform with-readline-header=X to with-readline-cflags=-I... |
| 1245 | set v [opt-val with-readline-header] |
| 1246 | proj-opt-set with-readline-header "" |
| 1247 | if {"" ne $v} { |
| 1248 | if {"auto" eq $v} { |
| 1249 | proj-opt-set with-readline-cflags auto |
| 1250 | } else { |
| 1251 | set v [file dirname $v] |
| 1252 | if {[string match */readline $v]} { |
| 1253 | # Special case: if the path includes .../readline/readline.h, |
| 1254 | # set the -I to one dir up from that because our sources |
| 1255 | # #include <readline/readline.h> or <editline/readline.h>. |
| 1256 | set v [file dirname $v] |
| 1257 | } |
| 1258 | proj-opt-set with-readline-cflags "-I$v" |
| 1259 | } |
| 1260 | } |
| 1261 | |
| 1262 | # Look for readline.h |
| 1263 | set rlInc [opt-val with-readline-cflags auto] |
| 1264 | if {"auto" eq $rlInc} { |
| 1265 | set rlInc "" |
| 1266 | if {$::sqliteConfig(is-cross-compiling)} { |
| 1267 | # ^^^ this check is derived from the legacy configure script. |
| 1268 | proj-warn "Skipping check for readline.h because we're cross-compiling." |
| 1269 | } else { |
| 1270 | set dirs [sqlite-get-readline-dir-list] |
| 1271 | set subdirs [list \ |
| 1272 | include/$editLibName \ |
| 1273 | readline] |
| 1274 | if {"editline" eq $editLibName} { |
| 1275 | lappend subdirs include/readline |
| 1276 | # ^^^ editline, on some systems, does not have its own header, |
| 1277 | # and uses libreadline's header. |
| 1278 | } |
| 1279 | lappend subdirs include |
| 1280 | set rlInc [proj-search-for-header-dir readline.h \ |
| 1281 | -dirs $dirs -subdirs $subdirs] |
| 1282 | #proc-debug "rlInc=$rlInc" |
| 1283 | if {"" ne $rlInc} { |
| 1284 | if {[string match */readline $rlInc]} { |
| 1285 | set rlInc [file dirname $rlInc]; # CLI shell: #include <readline/readline.h> |
| 1286 | } elseif {[string match */editline $rlInc]} { |
| 1287 | set editLibDef HAVE_EDITLINE |
| 1288 | set rlInc [file dirname $rlInc]; # CLI shell: #include <editline/readline.h> |
| 1289 | } |
| 1290 | set rlInc "-I${rlInc}" |
| 1291 | } |
| 1292 | } |
| 1293 | } elseif {"" ne $rlInc && ![string match *-I* $rlInc]} { |
| 1294 | proj-fatal "Argument to --with-readline-cflags is intended to be CFLAGS and contain -I..." |
| 1295 | } |
| 1296 | |
| 1297 | # If readline.h was found/specified, look for lib(readline|edit)... |
| 1298 | # |
| 1299 | # This is not quite straightforward because both libreadline and |
| 1300 | # libedit typically require some other library which (according to |
| 1301 | # legacy autotools-generated tests) provides tgetent(3). On some |
| 1302 | # systems that's built into libreadline/edit, on some (most?) its in |
| 1303 | # lib[n]curses, and on some it's in libtermcap. |
| 1304 | set rlLib "" |
| 1305 | if {"" ne $rlInc} { |
| 1306 | set rlLib [opt-val with-readline-ldflags] |
| 1307 | #proc-debug "rlLib=$rlLib" |
| 1308 | if {$rlLib in {auto ""}} { |
| 1309 | set rlLib "" ; # make sure it's not "auto", as we may append to it below |
| 1310 | set libTerm ""; # lib with tgetent(3) |
| 1311 | if {[proj-check-function-in-lib tgetent [list $editLibName ncurses curses termcap]]} { |
| 1312 | # ^^^ that libs list comes from the legacy configure script ^^^ |
| 1313 | set libTerm [get-define lib_tgetent] |
| 1314 | undefine lib_tgetent |
| 1315 | } |
| 1316 | if {$editLibName eq $libTerm} { |
| 1317 | # tgetent(3) was found in the editing library |
| 1318 | set rlLib $libTerm |
| 1319 | } elseif {[proj-check-function-in-lib readline $libsForReadline $libTerm]} { |
| 1320 | # tgetent(3) was found in an external lib |
| 1321 | set rlLib [get-define lib_readline] |
| 1322 | lappend rlLib $libTerm |
| 1323 | undefine lib_readline |
| 1324 | } |
| 1325 | } |
| 1326 | } |
| 1327 | |
| 1328 | # If we found a library, configure the build to use it... |
| 1329 | if {"" ne $rlLib} { |
| 1330 | if {"editline" eq $editLibName} { |
| 1331 | # sqlite-add-shell-opt -DEL_WIDECHAR=1; |
| 1332 | if {"HAVE_READLINE" eq $editLibDef} { |
| 1333 | sqlite-add-shell-opt -DHAVE_EDITLINE=1 |
| 1334 | # Alert the user that, despite outward appearances, we won't be |
| 1335 | # linking to the GPL'd libreadline. Presumably that distinction is |
| 1336 | # significant for those using --editline. |
| 1337 | proj-indented-notice { |
| 1338 | NOTE: the local libedit uses <readline/readline.h> so we |
| 1339 | will compile with -DHAVE_READLINE=1 but will link with |
| 1340 | libedit. |
| 1341 | } |
| 1342 | } |
| 1343 | } |
| 1344 | set rlLib [join $rlLib] |
| 1345 | set rlInc [join $rlInc] |
| 1346 | define LDFLAGS_READLINE $rlLib |
| 1347 | define CFLAGS_READLINE $rlInc |
| 1348 | proj-assert {$editLibDef in {HAVE_READLINE HAVE_EDITLINE}} |
| 1349 | proj-assert {$editLibName in {readline editline}} |
| 1350 | sqlite-add-shell-opt -D${editLibDef}=1 |
| 1351 | msg-result "Using $editLibName flags: $rlInc $rlLib" |
| 1352 | # Check whether rl_completion_matches() has a signature we can use |
| 1353 | # and disable that sub-feature if it doesn't. |
| 1354 | if {![cctest -cflags "$rlInc -D${editLibDef}" -libs $rlLib -nooutput 1 \ |
| 1355 | -source { |
| 1356 | #include <stdio.h> |
| 1357 | #ifdef HAVE_EDITLINE |
| 1358 | #include <editline/readline.h> |
| 1359 | #else |
| 1360 | #include <readline/readline.h> |
| 1361 | #endif |
| 1362 | static char * rcg(const char *z, int i){(void)z; (void)i; return 0;} |
| 1363 | int main(void) { |
| 1364 | char ** x = rl_completion_matches("one", rcg); |
| 1365 | (void)x; |
| 1366 | return 0; |
| 1367 | } |
| 1368 | }]} { |
| 1369 | proj-warn "readline-style completion disabled due to rl_completion_matches() signature mismatch" |
| 1370 | sqlite-add-shell-opt -DSQLITE_OMIT_READLINE_COMPLETION |
| 1371 | } |
| 1372 | return $editLibName |
| 1373 | } |
| 1374 | |
| 1375 | if {$failIfNotFound} { |
| 1376 | proj-fatal "Explicit --$editLibName failed to find a matching library." |
| 1377 | } |
| 1378 | return "none" |
| 1379 | }; # sqlite-check-line-editing |
| 1380 | |
| 1381 | ######################################################################## |
| 1382 | # Runs sqlite-check-line-editing and adds a message around it. In the |
| 1383 | # canonical build this must not be called before |
| 1384 | # sqlite-determine-codegen-tcl for reasons now lost to history (and |
| 1385 | # might not still be applicable). |
| 1386 | proc sqlite-handle-line-editing {} { |
| 1387 | msg-result "Line-editing support for the sqlite3 shell: [sqlite-check-line-editing]" |
| 1388 | } |
| 1389 | |
| 1390 | |
| 1391 | ######################################################################## |
| 1392 | # ICU - International Components for Unicode |
| 1393 | # |
| 1394 | # Handles these flags: |
| 1395 | # |
| 1396 | # --with-icu-ldflags=LDFLAGS |
| 1397 | # --with-icu-cflags=CFLAGS |
| 1398 | # --with-icu-config[=auto | pkg-config | /path/to/icu-config] |
| 1399 | # --enable-icu-collations |
| 1400 | # |
| 1401 | # --with-icu-config values: |
| 1402 | # |
| 1403 | # - auto: use the first one of (pkg-config, icu-config) found on the |
| 1404 | # system. |
| 1405 | # - pkg-config: use only pkg-config to determine flags |
| 1406 | # - /path/to/icu-config: use that to determine flags |
| 1407 | # |
| 1408 | # If --with-icu-config is used and neither pkg-config nor icu-config |
| 1409 | # are found, fail fatally. |
| 1410 | # |
| 1411 | # If both --with-icu-ldflags and --with-icu-config are provided, they |
| 1412 | # are cumulative. If neither are provided, icu-collations is not |
| 1413 | # honored and a warning is emitted if it is provided. |
| 1414 | # |
| 1415 | # Design note: though we could automatically enable ICU if the |
| 1416 | # icu-config binary or (pkg-config icu-io) are found, we specifically |
| 1417 | # do not. ICU is always an opt-in feature. |
| 1418 | proc sqlite-handle-icu {} { |
| 1419 | define LDFLAGS_ICU [join [opt-val with-icu-ldflags ""]] |
| 1420 | define CFLAGS_ICU [join [opt-val with-icu-cflags ""]] |
| 1421 | if {[proj-opt-was-provided with-icu-config]} { |
| 1422 | msg-result "Checking for ICU support..." |
| 1423 | set icuConfigBin [opt-val with-icu-config] |
| 1424 | set tryIcuConfigBin 1; # set to 0 if we end up using pkg-config |
| 1425 | if {$icuConfigBin in {auto pkg-config}} { |
| 1426 | if {[pkg-config-init 0] && [pkg-config icu-io]} { |
| 1427 | # Maintenance reminder: historical docs say to use both of |
| 1428 | # (icu-io, icu-uc). icu-uc lacks a required lib and icu-io has |
| 1429 | # all of them on tested OSes. |
| 1430 | set tryIcuConfigBin 0 |
| 1431 | define LDFLAGS_ICU [get-define PKG_ICU_IO_LDFLAGS] |
| 1432 | define-append LDFLAGS_ICU [get-define PKG_ICU_IO_LIBS] |
| 1433 | define CFLAGS_ICU [get-define PKG_ICU_IO_CFLAGS] |
| 1434 | } elseif {"pkg-config" eq $icuConfigBin} { |
| 1435 | proj-fatal "pkg-config cannot find package icu-io" |
| 1436 | } else { |
| 1437 | proj-assert {"auto" eq $icuConfigBin} |
| 1438 | } |
| 1439 | } |
| 1440 | if {$tryIcuConfigBin} { |
| 1441 | if {"auto" eq $icuConfigBin} { |
| 1442 | set icuConfigBin [proj-first-bin-of \ |
| 1443 | /usr/local/bin/icu-config \ |
| 1444 | /usr/bin/icu-config] |
| 1445 | if {"" eq $icuConfigBin} { |
| 1446 | proj-indented-notice -error { |
| 1447 | --with-icu-config=auto cannot find (pkg-config icu-io) or icu-config binary. |
| 1448 | On Ubuntu-like systems try: |
| 1449 | --with-icu-ldflags='-licui18n -licuuc -licudata' |
| 1450 | } |
| 1451 | } |
| 1452 | } |
| 1453 | if {[file-isexec $icuConfigBin]} { |
| 1454 | set x [exec $icuConfigBin --ldflags] |
| 1455 | if {"" eq $x} { |
| 1456 | proj-indented-notice -error \ |
| 1457 | [subst { |
| 1458 | $icuConfigBin --ldflags returned no data. |
| 1459 | On Ubuntu-like systems try: |
| 1460 | --with-icu-ldflags='-licui18n -licuuc -licudata' |
| 1461 | }] |
| 1462 | } |
| 1463 | define-append LDFLAGS_ICU $x |
| 1464 | set x [exec $icuConfigBin --cppflags] |
| 1465 | define-append CFLAGS_ICU $x |
| 1466 | } else { |
| 1467 | proj-fatal "--with-icu-config=$icuConfigBin does not refer to an executable" |
| 1468 | } |
| 1469 | } |
| 1470 | } |
| 1471 | set ldflags [define LDFLAGS_ICU [string trim [get-define LDFLAGS_ICU]]] |
| 1472 | set cflags [define CFLAGS_ICU [string trim [get-define CFLAGS_ICU]]] |
| 1473 | if {"" ne $ldflags} { |
| 1474 | sqlite-add-feature-flag -shell -DSQLITE_ENABLE_ICU |
| 1475 | msg-result "Enabling ICU support with flags: $ldflags $cflags" |
| 1476 | if {[opt-bool icu-collations]} { |
| 1477 | msg-result "Enabling ICU collations." |
| 1478 | sqlite-add-feature-flag -shell -DSQLITE_ENABLE_ICU_COLLATIONS |
| 1479 | # Recall that shell.c builds with sqlite3.c except in the case |
| 1480 | # of --disable-static-shell, a combination we do not |
| 1481 | # specifically attempt to account for. |
| 1482 | } |
| 1483 | } elseif {[opt-bool icu-collations]} { |
| 1484 | proj-warn "ignoring --enable-icu-collations because neither --with-icu-ldflags nor --with-icu-config provided any linker flags" |
| 1485 | } else { |
| 1486 | msg-result "ICU support is disabled." |
| 1487 | } |
| 1488 | }; # sqlite-handle-icu |
| 1489 | |
| 1490 | |
| 1491 | ######################################################################## |
| 1492 | # Handles the --enable-load-extension flag. Returns 1 if the support |
| 1493 | # is enabled, else 0. If support for that feature is not found, a |
| 1494 | # fatal error is triggered if --enable-load-extension is explicitly |
| 1495 | # provided, else a loud warning is instead emitted. If |
| 1496 | # --disable-load-extension is used, no check is performed. |
| 1497 | # |
| 1498 | # Makes the following environment changes: |
| 1499 | # |
| 1500 | # - defines LDFLAGS_DLOPEN to any linker flags needed for this |
| 1501 | # feature. It may legally be empty on (A) some systems where |
| 1502 | # dlopen() is in libc and (B) certain Unix-esque Windows |
| 1503 | # environments which identify as Windows for SQLite's purposes so |
| 1504 | # use LoadLibrary(). |
| 1505 | # |
| 1506 | # - If the feature is not available, adds |
| 1507 | # -DSQLITE_OMIT_LOAD_EXTENSION=1 to the feature flags list. |
| 1508 | proc sqlite-handle-load-extension {} { |
| 1509 | define LDFLAGS_DLOPEN "" |
| 1510 | set found 0 |
| 1511 | set suffix "" |
| 1512 | proj-if-opt-truthy load-extension { |
| 1513 | switch -glob -- [get-define host] { |
| 1514 | *-*-mingw* - *windows* { |
| 1515 | incr found |
| 1516 | set suffix "Using LoadLibrary()" |
| 1517 | } |
| 1518 | default { |
| 1519 | set found [proj-check-function-in-lib dlopen dl] |
| 1520 | if {$found} { |
| 1521 | set suffix [define LDFLAGS_DLOPEN [get-define lib_dlopen]] |
| 1522 | undefine lib_dlopen |
| 1523 | } else { |
| 1524 | if {[proj-opt-was-provided load-extension]} { |
| 1525 | # Explicit --enable-load-extension: fail if not found |
| 1526 | proj-indented-notice -error { |
| 1527 | --enable-load-extension was provided but dlopen() |
| 1528 | not found. Use --disable-load-extension to bypass this |
| 1529 | check. |
| 1530 | } |
| 1531 | } else { |
| 1532 | # It was implicitly enabled: warn if not found |
| 1533 | proj-indented-notice { |
| 1534 | WARNING: dlopen() not found, so loadable module support will |
| 1535 | be disabled. Use --disable-load-extension to bypass this |
| 1536 | check. |
| 1537 | } |
| 1538 | } |
| 1539 | } |
| 1540 | } |
| 1541 | } |
| 1542 | } |
| 1543 | if {$found} { |
| 1544 | msg-result "Loadable extension support enabled. $suffix" |
| 1545 | } else { |
| 1546 | msg-result "Disabling loadable extension support. Use --enable-load-extension to enable them." |
| 1547 | sqlite-add-feature-flag -DSQLITE_OMIT_LOAD_EXTENSION=1 |
| 1548 | } |
| 1549 | return $found |
| 1550 | } |
| 1551 | |
| 1552 | ######################################################################## |
| 1553 | # Handles the --enable-math flag. |
| 1554 | proc sqlite-handle-math {} { |
| 1555 | proj-if-opt-truthy math { |
| 1556 | if {![proj-check-function-in-lib ceil m]} { |
| 1557 | user-error "Cannot find libm functions. Use --disable-math to bypass this." |
| 1558 | } |
| 1559 | define LDFLAGS_MATH [get-define lib_ceil] |
| 1560 | undefine lib_ceil |
| 1561 | sqlite-add-feature-flag -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_PERCENTILE |
| 1562 | msg-result "Enabling math SQL functions" |
| 1563 | } { |
| 1564 | define LDFLAGS_MATH "" |
| 1565 | msg-result "Disabling math SQL functions" |
| 1566 | } |
| 1567 | } |
| 1568 | |
| 1569 | ######################################################################## |
| 1570 | # If this OS looks like a Mac, checks for the Mac-specific |
| 1571 | # -current_version and -compatibility_version linker flags. Defines |
| 1572 | # LDFLAGS_MAC_CVERSION to an empty string and returns 0 if they're not |
| 1573 | # supported, else defines that to the linker flags and returns 1. |
| 1574 | # |
| 1575 | # We don't check this on non-Macs because this whole thing is a |
| 1576 | # libtool compatibility kludge to account for a version stamp which |
| 1577 | # libtool applied only on Mac platforms. |
| 1578 | # |
| 1579 | # Based on https://sqlite.org/forum/forumpost/9dfd5b8fd525a5d7. |
| 1580 | proc sqlite-handle-mac-cversion {} { |
| 1581 | define LDFLAGS_MAC_CVERSION "" |
| 1582 | set rc 0 |
| 1583 | if {[proj-looks-like-mac]} { |
| 1584 | cc-with {-link 1} { |
| 1585 | # These version numbers are historical libtool-defined values, not |
| 1586 | # library-defined ones |
| 1587 | if {[cc-check-flags "-Wl,-current_version,9.6.0"] |
| 1588 | && [cc-check-flags "-Wl,-compatibility_version,9.0.0"]} { |
| 1589 | define LDFLAGS_MAC_CVERSION "-Wl,-compatibility_version,9.0.0 -Wl,-current_version,9.6.0" |
| 1590 | set rc 1 |
| 1591 | } elseif {[cc-check-flags "-compatibility_version 9.0.0"] |
| 1592 | && [cc-check-flags "-current_version 9.6.0"]} { |
| 1593 | define LDFLAGS_MAC_CVERSION "-compatibility_version 9.0.0 -current_version 9.6.0" |
| 1594 | set rc 1 |
| 1595 | } |
| 1596 | } |
| 1597 | } |
| 1598 | return $rc |
| 1599 | } |
| 1600 | |
| 1601 | ######################################################################## |
| 1602 | # If this is a Mac platform, check for support for |
| 1603 | # -Wl,-install_name,... and, if it's available, define |
| 1604 | # LDFLAGS_MAC_INSTALL_NAME to a variant of that string which is |
| 1605 | # intended to expand at make-time, else set LDFLAGS_MAC_INSTALL_NAME |
| 1606 | # to an empty string. |
| 1607 | # |
| 1608 | # https://sqlite.org/forum/forumpost/5651662b8875ec0a |
| 1609 | proc sqlite-handle-mac-install-name {} { |
| 1610 | define LDFLAGS_MAC_INSTALL_NAME ""; # {-Wl,-install_name,"$(install-dir.lib)/$(libsqlite3.DLL)"} |
| 1611 | set rc 0 |
| 1612 | if {[proj-looks-like-mac]} { |
| 1613 | cc-with {-link 1} { |
| 1614 | if {[cc-check-flags "-Wl,-install_name,/usr/local/lib/libsqlite3.dylib"]} { |
| 1615 | define LDFLAGS_MAC_INSTALL_NAME {-Wl,-install_name,"$(install-dir.lib)/$(libsqlite3.DLL)"} |
| 1616 | set rc 1 |
| 1617 | } |
| 1618 | } |
| 1619 | } |
| 1620 | return $rc |
| 1621 | } |
| 1622 | |
| 1623 | # |
| 1624 | # Checks specific to HP-UX. |
| 1625 | # |
| 1626 | proc sqlite-handle-hpux {} { |
| 1627 | switch -glob -- [get-define host] { |
| 1628 | *hpux* { |
| 1629 | if {[cc-check-flags "-Ae"]} { |
| 1630 | define-append CFLAGS -Ae |
| 1631 | } |
| 1632 | } |
| 1633 | } |
| 1634 | } |
| 1635 | |
| 1636 | ######################################################################## |
| 1637 | # Handles the --dll-basename configure flag. [define]'s |
| 1638 | # SQLITE_DLL_BASENAME to the DLL's preferred base name (minus |
| 1639 | # extension). If --dll-basename is not provided (or programmatically |
| 1640 | # set - see [sqlite-handle-env-quirks]) then this is always |
| 1641 | # "libsqlite3", otherwise it may use a different value based on the |
| 1642 | # value of [get-define host]. |
| 1643 | proc sqlite-handle-dll-basename {} { |
| 1644 | if {[proj-opt-was-provided dll-basename]} { |
| 1645 | set dn [join [opt-val dll-basename] ""] |
| 1646 | if {$dn in {none default}} { set dn libsqlite3 } |
| 1647 | } else { |
| 1648 | set dn libsqlite3 |
| 1649 | } |
| 1650 | if {$dn in {auto ""}} { |
| 1651 | switch -glob -- [get-define host] { |
| 1652 | *-*-cygwin { set dn cygsqlite3-0 } |
| 1653 | *-*-ming* { set dn libsqlite3-0 } |
| 1654 | *-*-msys { set dn msys-sqlite3-0 } |
| 1655 | default { set dn libsqlite3 } |
| 1656 | } |
| 1657 | } |
| 1658 | define SQLITE_DLL_BASENAME $dn |
| 1659 | } |
| 1660 | |
| 1661 | ######################################################################## |
| 1662 | # Handles the --out-implib flag. |
| 1663 | # |
| 1664 | # [define]s LDFLAGS_OUT_IMPLIB to either an empty string or to a |
| 1665 | # -Wl,... flag for the platform-specific --out-implib flag, which is |
| 1666 | # used for building an "import library .dll.a" file on some platforms |
| 1667 | # (e.g. msys2, mingw). Returns 1 if supported, else 0. |
| 1668 | # |
| 1669 | # The name of the import library is [define]d in SQLITE_OUT_IMPLIB, |
| 1670 | # as an empty string if it's not supported. |
| 1671 | # |
| 1672 | # If the configure flag --out-implib is not used (or programmatically |
| 1673 | # set) then this simply sets the above-listed defines to empty strings |
| 1674 | # (but see [sqlite-handle-env-quirks]). If that flag is used but the |
| 1675 | # capability is not available, a fatal error is triggered. |
| 1676 | # |
| 1677 | # This feature is specifically opt-in because it's supported on far |
| 1678 | # more platforms than actually need it and enabling it causes creation |
| 1679 | # of libsqlite3.so.a files which are unnecessary in most environments. |
| 1680 | # |
| 1681 | # Added in response to: https://sqlite.org/forum/forumpost/0c7fc097b2 |
| 1682 | # |
| 1683 | # Platform notes: |
| 1684 | # |
| 1685 | # - cygwin sqlite packages historically install no .dll.a file. |
| 1686 | # |
| 1687 | # - msys2 and mingw sqlite packages historically install |
| 1688 | # /usr/lib/libsqlite3.dll.a despite the DLL being in |
| 1689 | # /usr/bin. |
| 1690 | proc sqlite-handle-out-implib {} { |
| 1691 | define LDFLAGS_OUT_IMPLIB "" |
| 1692 | define SQLITE_OUT_IMPLIB "" |
| 1693 | set rc 0 |
| 1694 | if {[proj-opt-was-provided out-implib]} { |
| 1695 | set olBaseName [join [opt-val out-implib] ""] |
| 1696 | if {$olBaseName in {auto ""}} { |
| 1697 | set olBaseName "libsqlite3" ;# [get-define SQLITE_DLL_BASENAME] |
| 1698 | # Based on discussions with mingw/msys users, the import lib |
| 1699 | # should always be called libsqlite3.dll.a even on platforms |
| 1700 | # which rename libsqlite3.dll to something else. |
| 1701 | } |
| 1702 | if {$olBaseName ne "none"} { |
| 1703 | cc-with {-link 1} { |
| 1704 | set dll "${olBaseName}[get-define TARGET_DLLEXT]" |
| 1705 | set flags [proj-cc-check-Wl-flag --out-implib ${dll}.a] |
| 1706 | if {"" ne $flags} { |
| 1707 | define LDFLAGS_OUT_IMPLIB $flags |
| 1708 | define SQLITE_OUT_IMPLIB ${dll}.a |
| 1709 | set rc 1 |
| 1710 | } |
| 1711 | } |
| 1712 | if {!$rc} { |
| 1713 | user-error "--out-implib is not supported on this platform" |
| 1714 | } |
| 1715 | } |
| 1716 | } |
| 1717 | return $rc |
| 1718 | } |
| 1719 | |
| 1720 | ######################################################################## |
| 1721 | # If the given platform identifier (defaulting to [get-define host]) |
| 1722 | # appears to be one of the Unix-on-Windows environments, returns a |
| 1723 | # brief symbolic name for that environment, else returns an empty |
| 1724 | # string. |
| 1725 | # |
| 1726 | # It does not distinguish between msys and msys2, returning msys for |
| 1727 | # both. The build does not, as of this writing, specifically support |
| 1728 | # msys v1. Similarly, this function returns "mingw" for both "mingw32" |
| 1729 | # and "mingw64". |
| 1730 | proc sqlite-env-is-unix-on-windows {{envTuple ""}} { |
| 1731 | if {"" eq $envTuple} { |
| 1732 | set envTuple [get-define host] |
| 1733 | } |
| 1734 | set name "" |
| 1735 | switch -glob -- $envTuple { |
| 1736 | *-*-cygwin { set name cygwin } |
| 1737 | *-*-ming* { set name mingw } |
| 1738 | *-*-msys { set name msys } |
| 1739 | } |
| 1740 | return $name |
| 1741 | } |
| 1742 | |
| 1743 | ######################################################################## |
| 1744 | # Performs various tweaks to the build which are only relevant on |
| 1745 | # certain platforms, e.g. Mac and "Unix on Windows" platforms (msys2, |
| 1746 | # cygwin, ...). |
| 1747 | # |
| 1748 | # 1) DLL installation: |
| 1749 | # |
| 1750 | # [define]s SQLITE_DLL_INSTALL_RULES to a symbolic name suffix for a |
| 1751 | # set of "make install" rules to use for installation of the DLL |
| 1752 | # deliverable. The makefile is tasked with providing rules named |
| 1753 | # install-dll-NAME which runs the installation for that set, as well |
| 1754 | # as providing a rule named install-dll which resolves to |
| 1755 | # install-dll-NAME (perhaps indirectly, depending on whether the DLL |
| 1756 | # is (de)activated). |
| 1757 | # |
| 1758 | # The default value is "unix-generic". |
| 1759 | # |
| 1760 | # 2) --out-implib: |
| 1761 | # |
| 1762 | # On platforms where an "import library" is conventionally used but |
| 1763 | # --out-implib was not explicitly used, automatically add that flag. |
| 1764 | # This conventionally applies only to the "Unix on Windows" |
| 1765 | # environments like msys and cygwin. |
| 1766 | # |
| 1767 | # 3) --dll-basename: |
| 1768 | # |
| 1769 | # On the same platforms addressed by --out-implib, if --dll-basename |
| 1770 | # is not explicitly specified, --dll-basename=auto is implied. |
| 1771 | proc sqlite-handle-env-quirks {} { |
| 1772 | set instName unix-generic; # name of installation rules set |
| 1773 | set autoDll 0; # true if --out-implib/--dll-basename should be implied |
| 1774 | set host [get-define host] |
| 1775 | switch -glob -- $host { |
| 1776 | *-*-darwin* { |
| 1777 | set instName darwin |
| 1778 | # We don't look for *apple* because: |
| 1779 | # https://sqlite.org/forum/forumpost/7b218c3c9f207646 |
| 1780 | # There's at least one Linux out there which matches *apple*. |
| 1781 | } |
| 1782 | default { |
| 1783 | set x [sqlite-env-is-unix-on-windows $host] |
| 1784 | if {"" ne $x} { |
| 1785 | set instName $x |
| 1786 | set autoDll 1 |
| 1787 | } |
| 1788 | } |
| 1789 | } |
| 1790 | define SQLITE_DLL_INSTALL_RULES $instName |
| 1791 | if {$autoDll} { |
| 1792 | if {![proj-opt-was-provided out-implib]} { |
| 1793 | # Imply --out-implib=auto |
| 1794 | proj-indented-notice [subst -nocommands -nobackslashes { |
| 1795 | NOTICE: auto-enabling --out-implib for environment [$host]. |
| 1796 | Use --out-implib=none to disable this special case |
| 1797 | or --out-implib=auto to squelch this notice. |
| 1798 | }] |
| 1799 | proj-opt-set out-implib auto |
| 1800 | } |
| 1801 | if {![proj-opt-was-provided dll-basename]} { |
| 1802 | # Imply --dll-basename=auto |
| 1803 | proj-indented-notice [subst -nocommands -nobackslashes { |
| 1804 | NOTICE: auto-enabling --dll-basename for environment [$host]. |
| 1805 | Use --dll-basename=default to disable this special case |
| 1806 | or --dll-basename=auto to squelch this notice. |
| 1807 | }] |
| 1808 | proj-opt-set dll-basename auto |
| 1809 | } |
| 1810 | } |
| 1811 | sqlite-handle-dll-basename |
| 1812 | sqlite-handle-out-implib |
| 1813 | sqlite-handle-mac-cversion |
| 1814 | sqlite-handle-mac-install-name |
| 1815 | if {[llength [info proc sqlite-custom-handle-flags]] > 0} { |
| 1816 | # sqlite-custom-handle-flags is assumed to be imported via a |
| 1817 | # client-specific import: autosetup/sqlite-custom.tcl. |
| 1818 | sqlite-custom-handle-flags |
| 1819 | } |
| 1820 | } |
| 1821 | |
| 1822 | ######################################################################## |
| 1823 | # Perform some late-stage work and generate the configure-process |
| 1824 | # output file(s). |
| 1825 | proc sqlite-process-dot-in-files {} { |
| 1826 | ######################################################################## |
| 1827 | # "Re-export" the autoconf-conventional --XYZdir flags into something |
| 1828 | # which is more easily overridable from a make invocation. See the docs |
| 1829 | # for [proj-remap-autoconf-dir-vars] for the explanation of why. |
| 1830 | # |
| 1831 | # We do this late in the config process, immediately before we export |
| 1832 | # the Makefile and other generated files, so that configure tests |
| 1833 | # which make make use of the autotools-conventional flags |
| 1834 | # (e.g. [proj-check-rpath]) may do so before we "mangle" them here. |
| 1835 | proj-remap-autoconf-dir-vars |
| 1836 | |
| 1837 | proj-dot-ins-process -validate |
| 1838 | make-config-header sqlite_cfg.h \ |
| 1839 | -bare {SIZEOF_* HAVE_DECL_*} \ |
| 1840 | -none {HAVE_CFLAG_* LDFLAGS_* SH_* SQLITE_AUTORECONFIG |
| 1841 | TARGET_* USE_GCOV TCL_*} \ |
| 1842 | -auto {HAVE_* PACKAGE_*} \ |
| 1843 | -none * |
| 1844 | proj-touch sqlite_cfg.h ; # help avoid frequent unnecessary @SQLITE_AUTORECONFIG@ |
| 1845 | } |
| 1846 | |
| 1847 | ######################################################################## |
| 1848 | # Handle --with-wasi-sdk[=DIR] |
| 1849 | # |
| 1850 | # This must be run relatively early on because it may change the |
| 1851 | # toolchain and disable a number of config options. However, in the |
| 1852 | # canonical build this must come after [sqlite-check-common-bins]. |
| 1853 | proc sqlite-handle-wasi-sdk {} { |
| 1854 | set wasiSdkDir [opt-val with-wasi-sdk] ; # ??? [lindex [opt-val with-wasi-sdk] end] |
| 1855 | define HAVE_WASI_SDK 0 |
| 1856 | if {$wasiSdkDir eq ""} { |
| 1857 | return 0 |
| 1858 | } elseif {$::sqliteConfig(is-cross-compiling)} { |
| 1859 | proj-fatal "Cannot combine --with-wasi-sdk with cross-compilation" |
| 1860 | } |
| 1861 | msg-result "Checking WASI SDK directory \[$wasiSdkDir]... " |
| 1862 | proj-affirm-files-exist -v {*}[prefix "$wasiSdkDir/bin/" {clang wasm-ld ar}] |
| 1863 | define HAVE_WASI_SDK 1 |
| 1864 | define WASI_SDK_DIR $wasiSdkDir |
| 1865 | # Disable numerous options which we know either can't work or are |
| 1866 | # not useful in this build... |
| 1867 | msg-result "Using wasi-sdk clang. Disabling CLI shell and modifying config flags:" |
| 1868 | # Boolean (--enable-/--disable-) flags which must be switched off: |
| 1869 | foreach opt { |
| 1870 | dynlink-tools |
| 1871 | editline |
| 1872 | gcov |
| 1873 | icu-collations |
| 1874 | load-extension |
| 1875 | readline |
| 1876 | shared |
| 1877 | tcl |
| 1878 | threadsafe |
| 1879 | } { |
| 1880 | if {[proj-opt-exists $opt] && [opt-bool $opt]} { |
| 1881 | # -^^^^ not all builds define all of these flags |
| 1882 | msg-result " --disable-$opt" |
| 1883 | proj-opt-set $opt 0 |
| 1884 | } |
| 1885 | } |
| 1886 | # Non-boolean flags which need to be cleared: |
| 1887 | foreach opt { |
| 1888 | with-emsdk |
| 1889 | with-icu-config |
| 1890 | with-icu-ldflags |
| 1891 | with-icu-cflags |
| 1892 | with-linenoise |
| 1893 | with-tcl |
| 1894 | } { |
| 1895 | if {[proj-opt-was-provided $opt]} { |
| 1896 | msg-result " removing --$opt" |
| 1897 | proj-opt-set $opt "" |
| 1898 | } |
| 1899 | } |
| 1900 | # Remember that we now have a discrepancy between |
| 1901 | # $::sqliteConfig(is-cross-compiling) and [proj-is-cross-compiling]. |
| 1902 | set ::sqliteConfig(is-cross-compiling) 1 |
| 1903 | |
| 1904 | # |
| 1905 | # Changing --host and --target have no effect here except to |
| 1906 | # possibly cause confusion. Autosetup has finished processing them |
| 1907 | # by this point. |
| 1908 | # |
| 1909 | # host_alias=wasm32-wasi |
| 1910 | # target=wasm32-wasi |
| 1911 | # |
| 1912 | # Merely changing CC, LD, and AR to the wasi-sdk's is enough to get |
| 1913 | # sqlite3.o building in WASM format. |
| 1914 | # |
| 1915 | define CC "${wasiSdkDir}/bin/clang" |
| 1916 | define LD "${wasiSdkDir}/bin/wasm-ld" |
| 1917 | define AR "${wasiSdkDir}/bin/ar" |
| 1918 | #define STRIP "${wasiSdkDir}/bin/strip" |
| 1919 | return 1 |
| 1920 | }; # sqlite-handle-wasi-sdk |
| 1921 | |
| 1922 | ######################################################################## |
| 1923 | # Tcl... |
| 1924 | # |
| 1925 | # sqlite-check-tcl performs most of the --with-tcl and --with-tclsh |
| 1926 | # handling. Some related bits and pieces are performed before and |
| 1927 | # after that function is called. |
| 1928 | # |
| 1929 | # Important [define]'d vars. They can be split into library and tool vars. |
| 1930 | # |
| 1931 | # Tcl library vars: |
| 1932 | # |
| 1933 | # - HAVE_TCL indicates whether we have the Tcl that the SQLite Tcl |
| 1934 | # extension will be linked with, and so whether that extension is |
| 1935 | # built. This is 1 for environments where tclConfig.sh can be found. |
| 1936 | # That file describes a library to link against, so whether any tclsh |
| 1937 | # can be run is a separate matter, and none is needed for this. |
| 1938 | # |
| 1939 | # - TCL_CONFIG_SH is the path to tclConfig.sh or "". |
| 1940 | # |
| 1941 | # - TCLLIBDIR is the dir to which libtclsqlite3 gets installed. |
| 1942 | # |
| 1943 | # Tcl tool vars: |
| 1944 | # |
| 1945 | # - TCLSH_CMD is the path to the canonical tclsh or "". It never |
| 1946 | # refers to jimtcl. |
| 1947 | # |
| 1948 | # - BTCLSH = the path to the tcl interpreter used for in-tree code |
| 1949 | # generation. It may be jimtcl or the canonical tclsh but may not be |
| 1950 | # empty, as Tcl code is run as part of the build to generate numerous |
| 1951 | # components. |
| 1952 | # |
| 1953 | # The two configure CLI flags are separated by which set of variables |
| 1954 | # they affect. --with-tcl affects only Tcl library vars, and |
| 1955 | # --with-tclsh almost only affects Tcl tool vars. There is just one |
| 1956 | # exception: when compiling natively, a tclsh is asked where its own |
| 1957 | # tclConfig.sh is if --with-tcl is not passed. |
| 1958 | # |
| 1959 | # This distinction is good in any event to separate concerns, but it is |
| 1960 | # especially important for cross compilation. In that case, the Tcl that |
| 1961 | # SQLite links against will be one that runs on the host platform, while |
| 1962 | # the Tcl that SQLite's build scripts use at build time will run on the |
| 1963 | # build platform. Mixing up the two flags and the two kinds of vars is |
| 1964 | # likely to break cross compilation; that is why the one exception to |
| 1965 | # the separation is strictly confined to the native compilation case. |
| 1966 | # See: https://sqlite.org/forum/forumpost/fe9e99eb27c8c2ba |
| 1967 | # |
| 1968 | # If --tcl or --with-tcl are provided but no Tcl is found, this |
| 1969 | # function fails fatally. If they are not explicitly provided then |
| 1970 | # failure to find Tcl is not fatal but a loud warning will be emitted. |
| 1971 | # |
| 1972 | proc sqlite-check-tcl {} { |
| 1973 | define TCLSH_CMD false ; # Significant is that it exits with non-0 |
| 1974 | define HAVE_TCL 0 ; # Will be enabled via --tcl or a successful search |
| 1975 | define TCLLIBDIR "" ; # Installation dir for Tcl extension lib |
| 1976 | define TCL_CONFIG_SH ""; # full path to tclConfig.sh |
| 1977 | |
| 1978 | # Clear out all vars which would harvest from tclConfig.sh so that |
| 1979 | # the late-config validation of @VARS@ works even if --disable-tcl |
| 1980 | # is used. |
| 1981 | proj-tclConfig-sh-to-autosetup "" |
| 1982 | |
| 1983 | file delete -force ".tclenv.sh"; # ensure no stale state from previous configures. |
| 1984 | if {![opt-bool tcl]} { |
| 1985 | proj-indented-notice { |
| 1986 | NOTE: Tcl is disabled via --disable-tcl. This means that none |
| 1987 | of the Tcl-based components will be built, including tests |
| 1988 | and sqlite3_analyzer. |
| 1989 | } |
| 1990 | return |
| 1991 | } |
| 1992 | # TODO: document the steps this is taking. |
| 1993 | set srcdir $::autosetup(srcdir) |
| 1994 | msg-result "Checking for a suitable tcl... " |
| 1995 | proj-assert [proj-opt-truthy tcl] |
| 1996 | set use_tcl 1 |
| 1997 | set with_tclsh [opt-val with-tclsh] |
| 1998 | set with_tcl [opt-val with-tcl] |
| 1999 | if {"prefix" eq $with_tcl} { |
| 2000 | set with_tcl [get-define prefix] |
| 2001 | } |
| 2002 | proc-debug "use_tcl ${use_tcl}" |
| 2003 | proc-debug "with_tclsh=${with_tclsh}" |
| 2004 | proc-debug "with_tcl=$with_tcl" |
| 2005 | if {"" eq $with_tclsh && "" eq $with_tcl} { |
| 2006 | # If neither --with-tclsh nor --with-tcl are provided, try to find |
| 2007 | # a workable tclsh. |
| 2008 | set with_tclsh [proj-first-bin-of tclsh9.1 tclsh9.0 tclsh8.6 tclsh] |
| 2009 | proc-debug "with_tclsh=${with_tclsh}" |
| 2010 | } |
| 2011 | |
| 2012 | set doConfigLookup 1 ; # set to 0 to test the tclConfig.sh-not-found cases |
| 2013 | if {"" ne $with_tclsh} { |
| 2014 | # --with-tclsh was provided or found above. Validate it and, if |
| 2015 | # nothing better is to be had, ask it where its tclConfig.sh is. |
| 2016 | # The two name different things: the shell runs here, whereas |
| 2017 | # tclConfig.sh describes the library the extension is linked |
| 2018 | # against. The shell is a guide to that only when neither |
| 2019 | # --with-tcl=DIR says where it is nor cross compiling puts it on |
| 2020 | # another platform entirely. |
| 2021 | if {![file-isexec $with_tclsh]} { |
| 2022 | proj-fatal "Tcl shell $with_tclsh is not executable" |
| 2023 | } else { |
| 2024 | define TCLSH_CMD $with_tclsh |
| 2025 | #msg-result "Using tclsh: $with_tclsh" |
| 2026 | } |
| 2027 | |
| 2028 | if {"" ne $with_tcl} { |
| 2029 | # --with-tcl was given explicitly; do not second-guess it with tclsh. |
| 2030 | } elseif {$::sqliteConfig(is-cross-compiling)} { |
| 2031 | # This tclsh runs on the build platform, so the tclConfig.sh it would |
| 2032 | # recommend describes Tcl for here, not for the host platform. |
| 2033 | proj-warn "Cannot ask $with_tclsh to recommend a tclConfig.sh because we are cross compiling." |
| 2034 | # Leave with_tcl empty and do not set use_tcl either way so the $libdir |
| 2035 | # search below can still attempt to find one. |
| 2036 | } else { |
| 2037 | if {$doConfigLookup && |
| 2038 | [catch {exec $with_tclsh $::autosetup(libdir)/find_tclconfig.tcl} result] == 0} { |
| 2039 | set with_tcl $result |
| 2040 | } |
| 2041 | if {"" ne $with_tcl && [file isdir $with_tcl]} { |
| 2042 | msg-result "$with_tclsh recommends the tclConfig.sh from $with_tcl" |
| 2043 | } else { |
| 2044 | proj-warn "$with_tclsh is unable to recommend a tclConfig.sh" |
| 2045 | set use_tcl 0 |
| 2046 | } |
| 2047 | } |
| 2048 | } |
| 2049 | set cfg "" |
| 2050 | set tclSubdirs {tcl9.1 tcl9.0 tcl8.6 lib} |
| 2051 | while {$use_tcl} { |
| 2052 | if {"" ne $with_tcl} { |
| 2053 | # Ensure that we can find tclConfig.sh under ${with_tcl}/... |
| 2054 | if {$doConfigLookup} { |
| 2055 | if {[file readable "${with_tcl}/tclConfig.sh"]} { |
| 2056 | set cfg "${with_tcl}/tclConfig.sh" |
| 2057 | } else { |
| 2058 | foreach i $tclSubdirs { |
| 2059 | if {[file readable "${with_tcl}/$i/tclConfig.sh"]} { |
| 2060 | set cfg "${with_tcl}/$i/tclConfig.sh" |
| 2061 | break |
| 2062 | } |
| 2063 | } |
| 2064 | } |
| 2065 | } |
| 2066 | if {"" eq $cfg} { |
| 2067 | proj-fatal "No tclConfig.sh found under ${with_tcl}" |
| 2068 | } |
| 2069 | } else { |
| 2070 | # If we have not yet found a tclConfig.sh file, look in $libdir |
| 2071 | # which is set automatically by autosetup or via the --prefix |
| 2072 | # command-line option. See |
| 2073 | # https://sqlite.org/forum/forumpost/e04e693439a22457 |
| 2074 | set libdir [get-define libdir] |
| 2075 | if {[file readable "${libdir}/tclConfig.sh"]} { |
| 2076 | set cfg "${libdir}/tclConfig.sh" |
| 2077 | } else { |
| 2078 | foreach i $tclSubdirs { |
| 2079 | if {[file readable "${libdir}/$i/tclConfig.sh"]} { |
| 2080 | set cfg "${libdir}/$i/tclConfig.sh" |
| 2081 | break |
| 2082 | } |
| 2083 | } |
| 2084 | } |
| 2085 | if {![file readable $cfg]} { |
| 2086 | break |
| 2087 | } |
| 2088 | } |
| 2089 | msg-result "Using tclConfig.sh: $cfg" |
| 2090 | break |
| 2091 | } |
| 2092 | define TCL_CONFIG_SH $cfg |
| 2093 | # Export a subset of tclConfig.sh to the current Tcl-space. If $cfg |
| 2094 | # is an empty string, this emits empty-string entries for the |
| 2095 | # various options we're interested in. |
| 2096 | proj-tclConfig-sh-to-autosetup $cfg |
| 2097 | |
| 2098 | if {"" eq $with_tclsh && $cfg ne ""} { |
| 2099 | # We have tclConfig.sh but no tclsh. Attempt to locate a tclsh |
| 2100 | # based on info from tclConfig.sh. |
| 2101 | set tclExecPrefix [get-define TCL_EXEC_PREFIX] |
| 2102 | proj-assert {"" ne $tclExecPrefix} |
| 2103 | set tryThese [list \ |
| 2104 | $tclExecPrefix/bin/tclsh[get-define TCL_VERSION] \ |
| 2105 | $tclExecPrefix/bin/tclsh ] |
| 2106 | foreach trySh $tryThese { |
| 2107 | if {[file-isexec $trySh]} { |
| 2108 | set with_tclsh $trySh |
| 2109 | break |
| 2110 | } |
| 2111 | } |
| 2112 | if {![file-isexec $with_tclsh]} { |
| 2113 | proj-warn "Cannot find a usable tclsh (tried: $tryThese)" |
| 2114 | } |
| 2115 | } |
| 2116 | define TCLSH_CMD $with_tclsh |
| 2117 | if {$use_tcl} { |
| 2118 | # Set up the TCLLIBDIR |
| 2119 | # |
| 2120 | # 2024-10-28: calculation of TCLLIBDIR is now done via the shell |
| 2121 | # in main.mk (search it for T.tcl.env.sh) so that |
| 2122 | # static/hand-written makefiles which import main.mk do not have |
| 2123 | # to define that before importing main.mk. Even so, we export |
| 2124 | # TCLLIBDIR from here, which will cause the canonical makefile to |
| 2125 | # use this one rather than to re-calculate it at make-time. |
| 2126 | set tcllibdir [get-env TCLLIBDIR ""] |
| 2127 | set sq3Ver [get-define PACKAGE_VERSION] |
| 2128 | if {"" eq $tcllibdir} { |
| 2129 | # Attempt to extract TCLLIBDIR from Tcl's $auto_path |
| 2130 | if {"" ne $with_tclsh && |
| 2131 | [catch {exec echo "puts stdout \$auto_path" | "$with_tclsh"} result] == 0} { |
| 2132 | foreach i $result { |
| 2133 | if {![string match "//zipfs:*" $i] && [file isdir $i]} { |
| 2134 | # Tcl9 may report //zipfs paths as dirs. Filter those out. |
| 2135 | set tcllibdir $i/sqlite${sq3Ver} |
| 2136 | break |
| 2137 | } |
| 2138 | # proj-warn "filtering out auto_path $i" |
| 2139 | } |
| 2140 | } else { |
| 2141 | proj-warn "Cannot determine TCLLIBDIR." |
| 2142 | # The makefile will fail fatally in this case if a target is |
| 2143 | # invoked which requires TCLLIBDIR. |
| 2144 | } |
| 2145 | } |
| 2146 | #if {"" ne $tcllibdir} { msg-result "TCLLIBDIR = ${tcllibdir}"; } |
| 2147 | define TCLLIBDIR $tcllibdir |
| 2148 | }; # find TCLLIBDIR |
| 2149 | |
| 2150 | if {[file-isexec $with_tclsh]} { |
| 2151 | msg-result "Using tclsh: $with_tclsh" |
| 2152 | } |
| 2153 | # tclConfig.sh describes what the extension is built against. |
| 2154 | # Whether a tclsh can be run here is a separate question, affecting |
| 2155 | # code generation and the test suite. |
| 2156 | if {$cfg ne ""} { |
| 2157 | define HAVE_TCL 1 |
| 2158 | } elseif {[file-isexec $with_tclsh]} { |
| 2159 | proj-warn "Found tclsh (${with_tclsh}) but no tclConfig.sh." |
| 2160 | } |
| 2161 | show-notices |
| 2162 | # If Tcl is not found: if it was explicitly requested then fail |
| 2163 | # fatally, else just emit a warning. If we can find the APIs needed |
| 2164 | # to generate a working JimTcl then that will suffice for build-time |
| 2165 | # Tcl purposes (see: proc sqlite-determine-codegen-tcl). |
| 2166 | if {![get-define HAVE_TCL] && |
| 2167 | ([proj-opt-was-provided tcl] || [proj-opt-was-provided with-tcl])} { |
| 2168 | proj-fatal "Tcl support was requested but no tclConfig.sh could be found." |
| 2169 | } |
| 2170 | if {"" eq $cfg} { |
| 2171 | proj-assert {0 == [get-define HAVE_TCL]} |
| 2172 | proj-indented-notice { |
| 2173 | WARNING: Cannot find a usable tclConfig.sh file. Use |
| 2174 | --with-tcl=DIR to specify a directory where tclConfig.sh can be |
| 2175 | found. SQLite does not use Tcl internally, but some optional |
| 2176 | components require Tcl, including tests and sqlite3_analyzer. |
| 2177 | } |
| 2178 | } |
| 2179 | }; # sqlite-check-tcl |
| 2180 | |
| 2181 | ######################################################################## |
| 2182 | # sqlite-determine-codegen-tcl checks which Tcl to use as a code |
| 2183 | # generator. By default, prefer jimsh simply because we have it |
| 2184 | # in-tree (it's part of autosetup) unless --with-tclsh=X is used, in |
| 2185 | # which case prefer X. |
| 2186 | # |
| 2187 | # Returns the human-readable name of the Tcl it selects. Fails fatally |
| 2188 | # if it cannot detect a Tcl appropriate for code generation. |
| 2189 | # |
| 2190 | # Defines: |
| 2191 | # |
| 2192 | # - BTCLSH = the Tcl shell used for code generation. It may set this |
| 2193 | # to an unexpanded makefile var name. |
| 2194 | # |
| 2195 | # - CFLAGS_JIMSH = any flags needed for buildng a BTCLSH-compatible |
| 2196 | # jimsh. The defaults may be passed on to configure as |
| 2197 | # CFLAGS_JIMSH=... |
| 2198 | proc sqlite-determine-codegen-tcl {} { |
| 2199 | msg-result "Checking for Tcl to use for code generation... " |
| 2200 | define CFLAGS_JIMSH [proj-get-env CFLAGS_JIMSH {-O1}] |
| 2201 | set cgtcl [opt-val with-tclsh jimsh] |
| 2202 | if {"jimsh" ne $cgtcl} { |
| 2203 | # When --with-tclsh=X is used, generate code with X rather than with |
| 2204 | # the in-tree jimsh, per developer request. |
| 2205 | # |
| 2206 | # Name it directly rather than through the $(TCLSH_CMD) makefile |
| 2207 | # var, which gets set to "false" when the extension is not built, |
| 2208 | # but we need code generation regardless of whether the extension |
| 2209 | # is built. |
| 2210 | define BTCLSH $cgtcl |
| 2211 | return $cgtcl |
| 2212 | } |
| 2213 | set flagsToRestore {CC CFLAGS AS_CFLAGS CPPFLAGS AS_CPPFLAGS LDFLAGS LINKFLAGS LIBS CROSS} |
| 2214 | define-push $flagsToRestore { |
| 2215 | # We have to swap CC to CC_FOR_BUILD for purposes of the various |
| 2216 | # [cc-...] tests below. Recall that --with-wasi-sdk may have |
| 2217 | # swapped out CC with one which is not appropriate for this block. |
| 2218 | # Per consulation with autosetup's creator, doing this properly |
| 2219 | # requires us to [define-push] the whole $flagsToRestore list |
| 2220 | # (plus a few others which are not relevant in this tree). |
| 2221 | # |
| 2222 | # These will get set to their previous values at the end of this |
| 2223 | # block. |
| 2224 | foreach flag $flagsToRestore {define $flag ""} |
| 2225 | define CC [get-define CC_FOR_BUILD] |
| 2226 | # These headers are technically optional for JimTcl but necessary if |
| 2227 | # we want to use it for code generation: |
| 2228 | set sysh [cc-check-includes dirent.h sys/time.h] |
| 2229 | # jimsh0.c hard-codes #define's for HAVE_DIRENT_H and |
| 2230 | # HAVE_SYS_TIME_H on the platforms it supports, so we do not |
| 2231 | # need to add -D... flags for those. We check for them here only |
| 2232 | # so that we can avoid the situation that we later, at |
| 2233 | # make-time, try to compile jimsh but it then fails due to |
| 2234 | # missing headers (i.e. fail earlier rather than later). |
| 2235 | # |
| 2236 | # One of HAVE_REALPATH or HAVE__FULLPATH are required here for |
| 2237 | # jimsh's [file normalize] to work. |
| 2238 | if {$sysh && [cc-check-functions realpath]} { |
| 2239 | define-append CFLAGS_JIMSH -DHAVE_REALPATH |
| 2240 | define BTCLSH "\$(JIMSH)" |
| 2241 | set ::sqliteConfig(use-jim-for-codegen) 1 |
| 2242 | } elseif {$sysh && [cc-check-functions _fullpath]} { |
| 2243 | # _fullpath() is a Windows API. It's not entirely clear |
| 2244 | # whether we need to add {-DHAVE_SYS_TIME_H -DHAVE_DIRENT_H} |
| 2245 | # to CFLAGS_JIMSH in this case. On MinGW32 we definitely do |
| 2246 | # not want to because it already hard-codes them. On _MSC_VER |
| 2247 | # builds it does not. |
| 2248 | define-append CFLAGS_JIMSH -DHAVE__FULLPATH |
| 2249 | define BTCLSH "\$(JIMSH)" |
| 2250 | set ::sqliteConfig(use-jim-for-codegen) 1 |
| 2251 | } elseif {[file-isexec [get-define TCLSH_CMD]]} { |
| 2252 | set cgtcl [get-define TCLSH_CMD] |
| 2253 | define BTCLSH "\$(TCLSH_CMD)" |
| 2254 | } else { |
| 2255 | # One last-ditch effort to find TCLSH_CMD: use info from |
| 2256 | # tclConfig.sh to try to find a tclsh |
| 2257 | if {"" eq [get-define TCLSH_CMD]} { |
| 2258 | set tpre [get-define TCL_EXEC_PREFIX] |
| 2259 | if {"" ne $tpre} { |
| 2260 | set tv [get-define TCL_VERSION] |
| 2261 | if {[file-isexec "${tpre}/bin/tclsh${tv}"]} { |
| 2262 | define TCLSH_CMD "${tpre}/bin/tclsh${tv}" |
| 2263 | } elseif {[file-isexec "${tpre}/bin/tclsh"]} { |
| 2264 | define TCLSH_CMD "${tpre}/bin/tclsh" |
| 2265 | } |
| 2266 | } |
| 2267 | } |
| 2268 | set cgtcl [get-define TCLSH_CMD] |
| 2269 | if {![file-isexec $cgtcl]} { |
| 2270 | proj-fatal "Cannot find a tclsh to use for code generation." |
| 2271 | } |
| 2272 | define BTCLSH "\$(TCLSH_CMD)" |
| 2273 | } |
| 2274 | }; # /define-push $flagsToRestore |
| 2275 | return $cgtcl |
| 2276 | }; # sqlite-determine-codegen-tcl |
| 2277 | |
| 2278 | ######################################################################## |
| 2279 | # Runs sqlite-check-tcl and, if this is the canonical build, |
| 2280 | # sqlite-determine-codegen-tcl. |
| 2281 | proc sqlite-handle-tcl {} { |
| 2282 | sqlite-check-tcl |
| 2283 | if {"canonical" ne $::sqliteConfig(build-mode)} return |
| 2284 | msg-result "Tcl for code generation: [sqlite-determine-codegen-tcl]" |
| 2285 | |
| 2286 | # Determine the base name of the Tcl extension's DLL |
| 2287 | # |
| 2288 | if {[get-define HAVE_TCL]} { |
| 2289 | if {[string match *-cygwin [get-define host]]} { |
| 2290 | set libname cyg |
| 2291 | } else { |
| 2292 | set libname lib |
| 2293 | } |
| 2294 | if {[get-define TCL_MAJOR_VERSION] > 8} { |
| 2295 | append libname tcl9 |
| 2296 | } |
| 2297 | append libname sqlite |
| 2298 | } else { |
| 2299 | set libname "" |
| 2300 | } |
| 2301 | define TCL_EXT_DLL_BASENAME $libname |
| 2302 | # The extension is added in the makefile |
| 2303 | } |
| 2304 | |
| 2305 | ######################################################################## |
| 2306 | # Handle the --enable/disable-rpath flag. |
| 2307 | proc sqlite-handle-rpath {} { |
| 2308 | # autosetup/cc-shared.tcl sets the rpath flag definition in |
| 2309 | # [get-define SH_LINKRPATH], but it does so on a per-platform basis |
| 2310 | # rather than as a compiler check. Though we should do a proper |
| 2311 | # compiler check (as proj-check-rpath does), we may want to consider |
| 2312 | # adopting its approach of clearing the rpath flags for environments |
| 2313 | # for which sqlite-env-is-unix-on-windows returns a non-empty |
| 2314 | # string. |
| 2315 | |
| 2316 | # https://sqlite.org/forum/forumpost/13cac3b56516f849 |
| 2317 | if {[proj-opt-truthy rpath]} { |
| 2318 | proj-check-rpath |
| 2319 | } else { |
| 2320 | msg-result "Disabling use of rpath." |
| 2321 | define LDFLAGS_RPATH "" |
| 2322 | } |
| 2323 | } |
| 2324 | |
| 2325 | ######################################################################## |
| 2326 | # If the --dump-defines configure flag is provided then emit a list of |
| 2327 | # all [define] values to config.defines.txt, else do nothing. |
| 2328 | proc sqlite-dump-defines {} { |
| 2329 | proj-if-opt-truthy dump-defines { |
| 2330 | make-config-header $::sqliteConfig(dump-defines-txt) \ |
| 2331 | -bare {SQLITE_OS* SQLITE_DEBUG USE_*} \ |
| 2332 | -str {BIN_* CC LD AR LDFLAG* OPT_*} \ |
| 2333 | -auto {*} |
| 2334 | # achtung: ^^^^ whichever SQLITE_OS_foo flag which is set to 0 will |
| 2335 | # get _undefined_ here unless it's part of the -bare set. |
| 2336 | if {"" ne $::sqliteConfig(dump-defines-json)} { |
| 2337 | msg-result "--dump-defines is creating $::sqliteConfig(dump-defines-json)" |
| 2338 | ######################################################################## |
| 2339 | # Dump config-defines.json... |
| 2340 | # Demonstrate (mis?)handling of spaces in JSON-export array values: |
| 2341 | # define-append OPT_FOO.list {"-DFOO=bar baz" -DBAR="baz barre"} |
| 2342 | define OPT_FEATURE_FLAGS.list [get-define OPT_FEATURE_FLAGS] |
| 2343 | define OPT_SHELL.list [get-define OPT_SHELL] |
| 2344 | set dumpDefsOpt { |
| 2345 | -bare {SIZEOF_* HAVE_DECL_*} |
| 2346 | -none {HAVE_CFLAG_* LDFLAGS_* SH_* SQLITE_AUTORECONFIG TARGET_* USE_GCOV TCL_*} |
| 2347 | -array {*.list} |
| 2348 | -auto {OPT_* PACKAGE_* HAVE_*} |
| 2349 | } |
| 2350 | # if {$::sqliteConfig(dump-defines-json-include-lowercase)} { |
| 2351 | # lappend dumpDefsOpt -none {lib_*} ; # remnants from proj-check-function-in-lib and friends |
| 2352 | # lappend dumpDefsOpt -auto {[a-z]*} |
| 2353 | # } |
| 2354 | lappend dumpDefsOpt -none * |
| 2355 | proj-dump-defs-json $::sqliteConfig(dump-defines-json) {*}$dumpDefsOpt |
| 2356 | undefine OPT_FEATURE_FLAGS.list |
| 2357 | undefine OPT_SHELL.list |
| 2358 | } |
| 2359 | } |
| 2360 | } |