|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
array set sqlite__Config [proj-strip-hash-comments { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
all-flag-enables {fts3 fts4 fts5 rtree geopoly} |
|
|
|
|
|
|
|
|
is-canonical -1 |
|
|
}] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
apply {{dir} { |
|
|
|
|
|
set version "" |
|
|
if {[file exists $dir/../VERSION]} { |
|
|
|
|
|
set version [proj-file-content -trim $dir/../VERSION] |
|
|
set ::sqlite__Config(is-canonical) 1 |
|
|
set distname sqlite-tcl |
|
|
} elseif {[file exists $dir/generic/tclsqlite3.c]} { |
|
|
|
|
|
|
|
|
set ::sqlite__Config(is-canonical) 0 |
|
|
set fd [open $dir/generic/tclsqlite3.c rb] |
|
|
while {[gets $fd line] >=0} { |
|
|
if {[regexp {^#define[ ]+SQLITE_VERSION[ ]+"(3.+)"} \ |
|
|
$line - version]} { |
|
|
set distname sqlite-teaish |
|
|
break |
|
|
} |
|
|
} |
|
|
close $fd |
|
|
} |
|
|
|
|
|
if {"" eq $version} { |
|
|
proj-fatal "Cannot determine the SQLite version number" |
|
|
} |
|
|
|
|
|
proj-assert {$::sqlite__Config(is-canonical) > -1} |
|
|
proj-assert {[string match 3.*.* $version]} \ |
|
|
"Unexpected SQLite version: $version" |
|
|
|
|
|
set pragmas {} |
|
|
if {$::sqlite__Config(is-canonical)} { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lappend pragmas no-dist |
|
|
} else { |
|
|
lappend pragmas full-dist |
|
|
} |
|
|
|
|
|
teaish-pkginfo-set -vars { |
|
|
-name sqlite |
|
|
-name.pkg sqlite3 |
|
|
-version $version |
|
|
-name.dist $distname |
|
|
-libDir sqlite$version |
|
|
-pragmas $pragmas |
|
|
-src generic/tclsqlite3.c |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}} [teaish-get -dir] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc teaish-options {} { |
|
|
|
|
|
|
|
|
return [subst -nocommands -nobackslashes { |
|
|
with-system-sqlite=0 |
|
|
=> {Use the system-level SQLite instead of the copy in this tree. |
|
|
Also requires use of --override-sqlite-version so that the build |
|
|
knows what version number to associate with the system-level SQLite.} |
|
|
override-sqlite-version:VERSION |
|
|
=> {For use with --with-system-sqlite to set the version number.} |
|
|
threadsafe=1 => {Disable mutexing} |
|
|
with-tempstore:=no => {Use an in-RAM database for temporary tables: never,no,yes,always} |
|
|
load-extension=0 => {Enable loading of external extensions} |
|
|
math=1 => {Disable math functions} |
|
|
json=1 => {Disable JSON functions} |
|
|
fts3 => {Enable the FTS3 extension} |
|
|
fts4 => {Enable the FTS4 extension} |
|
|
fts5 => {Enable the FTS5 extension} |
|
|
update-limit => {Enable the UPDATE/DELETE LIMIT clause} |
|
|
geopoly => {Enable the GEOPOLY extension} |
|
|
rtree => {Enable the RTREE extension} |
|
|
session => {Enable the SESSION extension} |
|
|
all=1 => {Disable $::sqlite__Config(all-flag-enables)} |
|
|
with-icu-ldflags:LDFLAGS |
|
|
=> {Enable SQLITE_ENABLE_ICU and add the given linker flags for the |
|
|
ICU libraries. e.g. on Ubuntu systems, try '-licui18n -licuuc -licudata'.} |
|
|
with-icu-cflags:CFLAGS |
|
|
=> {Apply extra CFLAGS/CPPFLAGS necessary for building with ICU. |
|
|
e.g. -I/usr/local/include} |
|
|
with-icu-config:=auto |
|
|
=> {Enable SQLITE_ENABLE_ICU. Value must be one of: auto, pkg-config, |
|
|
/path/to/icu-config} |
|
|
icu-collations=0 |
|
|
=> {Enable SQLITE_ENABLE_ICU_COLLATIONS. Requires --with-icu-ldflags=... |
|
|
or --with-icu-config} |
|
|
}] |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc teaish-configure {} { |
|
|
use teaish/feature |
|
|
|
|
|
if {[proj-opt-was-provided override-sqlite-version]} { |
|
|
teaish-pkginfo-set -version [opt-val override-sqlite-version] |
|
|
proj-warn "overriding sqlite version number:" [teaish-pkginfo-get -version] |
|
|
} elseif {[proj-opt-was-provided with-system-sqlite] |
|
|
&& [opt-val with-system-sqlite] ne "0"} { |
|
|
proj-fatal "when using --with-system-sqlite also use" \ |
|
|
"--override-sqlite-version to specify a library version number." |
|
|
} |
|
|
|
|
|
define CFLAGS [proj-get-env CFLAGS {-O2}] |
|
|
sqlite-munge-cflags |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sqlite-add-feature-flag { |
|
|
-DSQLITE_3_SUFFIX_ONLY=1 |
|
|
-DSQLITE_ENABLE_DESERIALIZE=1 |
|
|
-DSQLITE_ENABLE_DBPAGE_VTAB=1 |
|
|
-DSQLITE_ENABLE_BYTECODE_VTAB=1 |
|
|
-DSQLITE_ENABLE_DBSTAT_VTAB=1 |
|
|
} |
|
|
|
|
|
if {[opt-bool with-system-sqlite]} { |
|
|
msg-result "Using system-level sqlite3." |
|
|
teaish-cflags-add -DUSE_SYSTEM_SQLITE |
|
|
teaish-ldflags-add -lsqlite3 |
|
|
} elseif {$::sqlite__Config(is-canonical)} { |
|
|
teaish-cflags-add -I[teaish-get -dir]/.. |
|
|
} |
|
|
|
|
|
teaish-check-librt |
|
|
teaish-check-libz |
|
|
sqlite-handle-threadsafe |
|
|
sqlite-handle-tempstore |
|
|
sqlite-handle-load-extension |
|
|
sqlite-handle-math |
|
|
sqlite-handle-icu |
|
|
|
|
|
sqlite-handle-common-feature-flags |
|
|
} |
|
|
|
|
|
define OPT_FEATURE_FLAGS {} |
|
|
|
|
|
|
|
|
|
|
|
proc sqlite-add-feature-flag {args} { |
|
|
if {"" ne $args} { |
|
|
define-append OPT_FEATURE_FLAGS {*}$args |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc sqlite-affirm-have-math {featureName} { |
|
|
if {"" eq [get-define LDFLAGS_MATH ""]} { |
|
|
if {![msg-quiet proj-check-function-in-lib log m]} { |
|
|
user-error "Missing math APIs for $featureName" |
|
|
} |
|
|
set lfl [get-define lib_log ""] |
|
|
undefine lib_log |
|
|
if {"" ne $lfl} { |
|
|
user-notice "Forcing requirement of $lfl for $featureName" |
|
|
} |
|
|
define LDFLAGS_MATH $lfl |
|
|
teaish-ldflags-prepend $lfl |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
proc sqlite-handle-common-feature-flags {} { |
|
|
msg-result "Feature flags..." |
|
|
if {![opt-bool all]} { |
|
|
|
|
|
foreach flag $::sqlite__Config(all-flag-enables) { |
|
|
if {![proj-opt-was-provided $flag]} { |
|
|
proj-opt-set $flag 0 |
|
|
} |
|
|
} |
|
|
} |
|
|
foreach {boolFlag featureFlag ifSetEvalThis} [proj-strip-hash-comments { |
|
|
all {} { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach k $::sqlite__Config(all-flag-enables) { |
|
|
if {![proj-opt-was-provided $k]} { |
|
|
proj-opt-set $k 1 |
|
|
} |
|
|
} |
|
|
} |
|
|
fts3 -DSQLITE_ENABLE_FTS3 {sqlite-affirm-have-math fts3} |
|
|
fts4 -DSQLITE_ENABLE_FTS4 {sqlite-affirm-have-math fts4} |
|
|
fts5 -DSQLITE_ENABLE_FTS5 {sqlite-affirm-have-math fts5} |
|
|
geopoly -DSQLITE_ENABLE_GEOPOLY {proj-opt-set rtree} |
|
|
rtree -DSQLITE_ENABLE_RTREE {} |
|
|
session {-DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK} {} |
|
|
update-limit -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT {} |
|
|
scanstatus -DSQLITE_ENABLE_STMT_SCANSTATUS {} |
|
|
}] { |
|
|
if {$boolFlag ni $::autosetup(options)} { |
|
|
|
|
|
|
|
|
continue |
|
|
} |
|
|
proj-if-opt-truthy $boolFlag { |
|
|
sqlite-add-feature-flag $featureFlag |
|
|
if {0 != [eval $ifSetEvalThis] && "all" ne $boolFlag} { |
|
|
msg-result " + $boolFlag" |
|
|
} |
|
|
} { |
|
|
if {"all" ne $boolFlag} { |
|
|
msg-result " - $boolFlag" |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach {boolFlag featureFlag} { |
|
|
json -DSQLITE_OMIT_JSON |
|
|
} { |
|
|
if {[proj-opt-truthy $boolFlag]} { |
|
|
msg-result " + $boolFlag" |
|
|
} else { |
|
|
sqlite-add-feature-flag $featureFlag |
|
|
msg-result " - $boolFlag" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set oFF [get-define OPT_FEATURE_FLAGS] |
|
|
if {"" ne $oFF} { |
|
|
define OPT_FEATURE_FLAGS [lsort -unique $oFF] |
|
|
msg-result "Library feature flags: [get-define OPT_FEATURE_FLAGS]" |
|
|
} |
|
|
if {[lsearch [get-define TARGET_DEBUG ""] -DSQLITE_DEBUG=1] > -1} { |
|
|
msg-result "Note: this is a debug build, so performance will suffer." |
|
|
} |
|
|
teaish-cflags-add -define OPT_FEATURE_FLAGS |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc sqlite-handle-threadsafe {} { |
|
|
msg-checking "Support threadsafe operation? " |
|
|
define LDFLAGS_PTHREAD "" |
|
|
set enable 0 |
|
|
if {[proj-opt-was-provided threadsafe]} { |
|
|
proj-if-opt-truthy threadsafe { |
|
|
if {[proj-check-function-in-lib pthread_create pthread] |
|
|
&& [proj-check-function-in-lib pthread_mutexattr_init pthread]} { |
|
|
incr enable |
|
|
set ldf [get-define lib_pthread_create] |
|
|
define LDFLAGS_PTHREAD $ldf |
|
|
teaish-ldflags-prepend $ldf |
|
|
undefine lib_pthread_create |
|
|
undefine lib_pthread_mutexattr_init |
|
|
} else { |
|
|
user-error "Missing required pthread libraries. Use --disable-threadsafe to disable this check." |
|
|
} |
|
|
|
|
|
|
|
|
} { |
|
|
msg-result "Disabled using --disable-threadsafe" |
|
|
} |
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
catch { |
|
|
scan [exec echo {puts [tcl::pkgconfig get threaded]} | [get-define TCLSH_CMD]] \ |
|
|
%d enable |
|
|
} |
|
|
if {$enable} { |
|
|
set flagName "--threadsafe" |
|
|
set lblAbled "enabled" |
|
|
msg-result yes |
|
|
} else { |
|
|
set flagName "--disable-threadsafe" |
|
|
set lblAbled "disabled" |
|
|
msg-result no |
|
|
} |
|
|
msg-result "Defaulting to ${flagName} because Tcl has threading ${lblAbled}." |
|
|
|
|
|
|
|
|
} |
|
|
sqlite-add-feature-flag -DSQLITE_THREADSAFE=${enable} |
|
|
return $enable |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc sqlite-handle-load-extension {} { |
|
|
define LDFLAGS_DLOPEN "" |
|
|
set found 0 |
|
|
proj-if-opt-truthy load-extension { |
|
|
set found [proj-check-function-in-lib dlopen dl] |
|
|
if {$found} { |
|
|
set ldf [get-define lib_dlopen] |
|
|
define LDFLAGS_DLOPEN $ldf |
|
|
teaish-ldflags-prepend $ldf |
|
|
undefine lib_dlopen |
|
|
} else { |
|
|
if {[proj-opt-was-provided load-extension]} { |
|
|
|
|
|
proj-indented-notice -error { |
|
|
--enable-load-extension was provided but dlopen() |
|
|
not found. Use --disable-load-extension to bypass this |
|
|
check. |
|
|
} |
|
|
} else { |
|
|
|
|
|
proj-indented-notice { |
|
|
WARNING: dlopen() not found, so loadable module support will |
|
|
be disabled. Use --disable-load-extension to bypass this |
|
|
check. |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if {$found} { |
|
|
msg-result "Loadable extension support enabled." |
|
|
} else { |
|
|
msg-result "Disabling loadable extension support. Use --enable-load-extension to enable them." |
|
|
sqlite-add-feature-flag -DSQLITE_OMIT_LOAD_EXTENSION=1 |
|
|
} |
|
|
return $found |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc sqlite-handle-icu {} { |
|
|
define LDFLAGS_LIBICU [join [opt-val with-icu-ldflags ""]] |
|
|
define CFLAGS_LIBICU [join [opt-val with-icu-cflags ""]] |
|
|
if {[proj-opt-was-provided with-icu-config]} { |
|
|
msg-result "Checking for ICU support..." |
|
|
set icuConfigBin [opt-val with-icu-config] |
|
|
set tryIcuConfigBin 1 |
|
|
if {$icuConfigBin in {auto pkg-config}} { |
|
|
uplevel 3 { use pkg-config } |
|
|
if {[pkg-config-init 0] && [pkg-config icu-io]} { |
|
|
|
|
|
|
|
|
|
|
|
set tryIcuConfigBin 0 |
|
|
define LDFLAGS_LIBICU [get-define PKG_ICU_IO_LDFLAGS] |
|
|
define-append LDFLAGS_LIBICU [get-define PKG_ICU_IO_LIBS] |
|
|
define CFLAGS_LIBICU [get-define PKG_ICU_IO_CFLAGS] |
|
|
} elseif {"pkg-config" eq $icuConfigBin} { |
|
|
proj-fatal "pkg-config cannot find package icu-io" |
|
|
} else { |
|
|
proj-assert {"auto" eq $icuConfigBin} |
|
|
} |
|
|
} |
|
|
if {$tryIcuConfigBin} { |
|
|
if {"auto" eq $icuConfigBin} { |
|
|
set icuConfigBin [proj-first-bin-of \ |
|
|
/usr/local/bin/icu-config \ |
|
|
/usr/bin/icu-config] |
|
|
if {"" eq $icuConfigBin} { |
|
|
proj-indented-notice -error { |
|
|
--with-icu-config=auto cannot find (pkg-config icu-io) or icu-config binary. |
|
|
On Ubuntu-like systems try: |
|
|
--with-icu-ldflags='-licui18n -licuuc -licudata' |
|
|
} |
|
|
} |
|
|
} |
|
|
if {[file-isexec $icuConfigBin]} { |
|
|
set x [exec $icuConfigBin --ldflags] |
|
|
if {"" eq $x} { |
|
|
proj-indented-notice -error \ |
|
|
[subst { |
|
|
$icuConfigBin --ldflags returned no data. |
|
|
On Ubuntu-like systems try: |
|
|
--with-icu-ldflags='-licui18n -licuuc -licudata' |
|
|
}] |
|
|
} |
|
|
define-append LDFLAGS_LIBICU $x |
|
|
set x [exec $icuConfigBin --cppflags] |
|
|
define-append CFLAGS_LIBICU $x |
|
|
} else { |
|
|
proj-fatal "--with-icu-config=$icuConfigBin does not refer to an executable" |
|
|
} |
|
|
} |
|
|
} |
|
|
set ldflags [define LDFLAGS_LIBICU [string trim [get-define LDFLAGS_LIBICU]]] |
|
|
set cflags [define CFLAGS_LIBICU [string trim [get-define CFLAGS_LIBICU]]] |
|
|
if {"" ne $ldflags} { |
|
|
sqlite-add-feature-flag -DSQLITE_ENABLE_ICU |
|
|
msg-result "Enabling ICU support with flags: $ldflags $cflags" |
|
|
if {[opt-bool icu-collations]} { |
|
|
msg-result "Enabling ICU collations." |
|
|
sqlite-add-feature-flag -DSQLITE_ENABLE_ICU_COLLATIONS |
|
|
} |
|
|
teaish-ldflags-prepend $ldflags |
|
|
teaish-cflags-add $cflags |
|
|
} elseif {[opt-bool icu-collations]} { |
|
|
proj-warn "ignoring --enable-icu-collations because neither --with-icu-ldflags nor --with-icu-config provided any linker flags" |
|
|
} else { |
|
|
msg-result "ICU support is disabled." |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc sqlite-handle-tempstore {} { |
|
|
if {[proj-opt-was-provided with-tempstore]} { |
|
|
set ts [opt-val with-tempstore no] |
|
|
set tsn 1 |
|
|
msg-checking "Use an in-RAM database for temporary tables? " |
|
|
switch -exact -- $ts { |
|
|
never { set tsn 0 } |
|
|
no { set tsn 1 } |
|
|
yes { set tsn 2 } |
|
|
always { set tsn 3 } |
|
|
default { |
|
|
user-error "Invalid --with-tempstore value '$ts'. Use one of: never, no, yes, always" |
|
|
} |
|
|
} |
|
|
msg-result $ts |
|
|
sqlite-add-feature-flag -DSQLITE_TEMP_STORE=$tsn |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
proc sqlite-handle-math {} { |
|
|
proj-if-opt-truthy math { |
|
|
if {![proj-check-function-in-lib ceil m]} { |
|
|
user-error "Cannot find libm functions. Use --disable-math to bypass this." |
|
|
} |
|
|
set lfl [get-define lib_ceil] |
|
|
undefine lib_ceil |
|
|
define LDFLAGS_MATH $lfl |
|
|
teaish-ldflags-prepend $lfl |
|
|
sqlite-add-feature-flag -DSQLITE_ENABLE_MATH_FUNCTIONS |
|
|
msg-result "Enabling math SQL functions" |
|
|
} { |
|
|
define LDFLAGS_MATH "" |
|
|
msg-result "Disabling math SQL functions" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc sqlite-munge-cflags {} { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach flagDef {CFLAGS CPPFLAGS} { |
|
|
set tmp "" |
|
|
foreach cf [get-define $flagDef ""] { |
|
|
switch -glob -- $cf { |
|
|
-DSQLITE_OMIT* - |
|
|
-DSQLITE_ENABLE* { |
|
|
sqlite-add-feature-flag $cf |
|
|
} |
|
|
default { |
|
|
lappend tmp $cf |
|
|
} |
|
|
} |
|
|
} |
|
|
define $flagDef $tmp |
|
|
} |
|
|
} |
|
|
|