use cc cc-db cc-shared cc-lib hwaci-common pkg-config
# Are we cross-compiling?
-set cross_compiling 0
-if {[get-define host] ne [get-define build]} {
- set cross_compiling 1
-} elseif {1
- && "nope" eq [get-env CC_FOR_BUILD "nope"]
- && [get-define CC] ne [get-define CC_FOR_BUILD]} {
+set cross_compiling [hwaci-is-cross-compiling]
+if {0
+ && !$cross_compiling
+ && "nope" eq [get-env CC_FOR_BUILD "nope"]
+ && [get-define CC] ne [get-define CC_FOR_BUILD]} {
# Arguable/debatable...
#
# When _not_ cross-compiling and CC_FOR_BUILD is _not_ explcitely
with-readline-inc:CFLAGS
=> {Readline CFLAGS, e.g. -I/path/to/includes}
with-readline-header:PATH
- => {Full path to readline.h, from which --with-readline-inc will be derived.}
+ => {Full path to readline.h, from which --with-readline-inc will be derived}
with-linenoise:DIR => {Source directory for linenoise.c and linenoise.h}
amalgamation=1 => {Disable the amalgamation and instead build all files separately}
load-extension=1 => {Disable loading of external extensions}
}
########################################################################
-# hwaci-check-line-editing jumps through proverbial hoops to try to
+# sqlite-check-line-editing jumps through proverbial hoops to try to
# find a working line-editing library, setting:
#
# - HAVE_READLINE to 0 or 1
#
# Returns a string describing which line-editing approach to use, or
# "none" if no option is available.
-proc hwaci-check-line-editing {} {
+proc sqlite-check-line-editing {} {
define HAVE_READLINE 0
define HAVE_LINENOISE 0
define HAVE_EDITLINE 0
set dirLn $check
if {![file isdir $dirLn]} {
hwaci-fatal "--with-linenoise value is not a directory"
- }
- if {![file exists $dirLn/linenoise.c] } {
+ } elseif {![file exists $dirLn/linenoise.c] } {
hwaci-fatal "Cannot find linenoise.c in $dirLn"
- }
- if {![file exists $dirLn/linenoise.h] } {
+ } elseif {![file exists $dirLn/linenoise.h] } {
hwaci-fatal "Cannot find linenoise.h in $dirLn"
}
user-notice "Using linenoise from $dirLn"
add-shell-opt -DHAVE_LINENOISE=1
return "linenoise"
} elseif {[opt-bool editline]} {
- # Use editline...
+ # TODO: reimplement --enable-editline
user-notice "WARNING: the --enable-editline flag is not yet supported"
return "none"
} elseif {![opt-bool readline]} {
- user-notice "Readline support explicitly disabled with --disable-readline."
+ user-notice "Readline support explicitly disabled with --disable-readline"
return "none"
}
- set check [opt-val with-readline-lib][opt-val with-readline-inc]
- if {"" ne $check} {
- # If any one of --with-readline-(lib|inc|header) are provided,
- # those trump any automated searching.
- set fL [join [opt-val with-readline-lib]]
- set v [opt-val with-readline-header]
- if {"" eq $v} {
- set fC [join [opt-val with-readline-inc]]
+
+ # Transform with-readline-header=X to with-readline-inc=-I...
+ set v [opt-val with-readline-header]
+ hwaci-opt-set with-readline-header ""
+ if {"" ne $v} {
+ if {"auto" eq $v} {
+ hwaci-opt-set with-readline-inc auto
} else {
- # Derive CFLAGS from header file name
set v [file dirname $v]
if {[string match */*line $v]} {
# Special case: if the path includes .../*line/readline.h", set
# work!
set v [file dirname $v]
}
- set fC "-I$v"
+ hwaci-opt-set with-readline-inc "-I$v"
}
- define LDFLAGS_READLINE $fL
- define CFLAGS_READLINE $fC
+ }
+
+ # Look for readline.h
+ set rlInc [opt-val with-readline-inc auto]
+ if {"auto" eq $rlInc} {
+ set rlInc ""
+ if {!$::cross_compiling} {
+ # ^^^ this check is derived from the legacy configure script
+ set rlInc [hwaci-search-for-header-dir readline.h \
+ -dirs {/usr /usr/local /usr/local/readline /usr/contrib /mingw} \
+ -subdirs {include/readline include}]
+ # ^^^ The -dirs and -subdirs lists are from the legacy configure script
+ if {"" ne $rlInc} {
+ if {[string match */*line $rlInc]} {
+ # See notes above for --with-readline-header
+ set rlInc [file dirname $rlInc]
+ }
+ set rlInc "-I${rlInc}"
+ }
+ }
+ }
+
+ # If readline.h was found/specified, look for libreadline...
+ set rlLib ""
+ if {"" ne $rlInc} {
+ set rlLib [opt-val with-readline-lib]
+ if {"" eq $rlLib || "auto" eq $rlLib} {
+ set rlLib ""
+ set libTerm ""
+ if {[hwaci-check-function-in-lib tgetent {readline ncurses curses termcap}]} {
+ # ^^^ that libs list comes from the legacy configure script ^^^
+ set libTerm [get-define lib_tgetent]
+ undefine lib_tgetent
+ }
+ if {"readline" eq $libTerm} {
+ set rlLib $libTerm
+ } elseif {[hwaci-check-function-in-lib readline readline $libTerm]} {
+ set rlLib [get-define lib_readline]
+ lappend rlLib $libTerm
+ undefine lib_readline
+ }
+ }
+ }
+
+ if {"" ne $rlLib} {
+ set rlLib [join $rlLib]
+ set rlInc [join $rlInc]
+ define LDFLAGS_READLINE $rlLib
+ define CFLAGS_READLINE $rlInc
define HAVE_READLINE 1
add-shell-opt -DHAVE_READLINE=1
- user-notice "Using client-provided readline flags: $fC $fL"
+ user-notice "Using readline flags: $rlInc $rlLib"
return "readline"
}
- # Try the project-agnostic readline detector:
- set v [hwaci-check-readline]
- add-shell-opt -DHAVE_READLINE=$v
- if {$v} { return "readline" }
- # TODO: reimplement:
- # --enable-editline
return "none"
-}; # hwaci-check-line-editing
-msg-checking "Line-editing support for the sqlite3 shell: "
-msg-result [hwaci-check-line-editing]
+}; # sqlite-check-line-editing
+msg-result "Line-editing support for the sqlite3 shell: [sqlite-check-line-editing]"
hwaci-if-opt-truthy load-extension {
if {[hwaci-check-function-in-lib dlopen dl]} {
user-error "ERROR: $msg"
}
+########################################################################
+# Returns 1 if cross-compiling, else 0.
+proc hwaci-is-cross-compiling {} {
+ return [expr {[get-define host] ne [get-define build]}]
+}
+
########################################################################
# hwaci-lshift_ shifts $count elements from the list named $listVar
# and returns them as a new list. On empty input, returns "".
return $found
}
+########################################################################
+# Searches for $header in a combination of dirs and subdirs, specified
+# by the -dirs {LIST} and -subdirs {LIST} flags (each of which have
+# sane defaults). Returns either the first matching dir or an empty
+# string. The return value does not contain the filename part.
+proc hwaci-search-for-header-dir {header args} {
+ set subdirs {include}
+ set dirs {/usr /usr/local /mingw}
+# Debatable:
+# if {![hwaci-is-cross-compiling]} {
+# lappend dirs [get-define prefix]
+# }
+ while {[llength $args]} {
+ switch -exact -- [lindex $args 0] {
+ -dirs { set args [lassign $args - dirs] }
+ -subdirs { set args [lassign $args - subdirs] }
+ default {
+ hwaci-fatal "Unhandled argument: $args"
+ }
+ }
+ }
+ foreach dir $dirs {
+ foreach sub $subdirs {
+ if {[file exists $dir/$sub/$header]} {
+ return "$dir/$sub"
+ }
+ }
+ }
+ return ""
+}
+
########################################################################
# If $v is true, [puts $msg] is called, else puts is not called.
#proc hwaci-maybe-verbose {v msg} {
}
########################################################################
-# Check for libreadline functionality. Linking in readline varies
+# Check for availability of libreadline. Linking in readline varies
# wildly by platform and this check does not cover all known options.
# This detection is known to fail under the following conditions:
#
# - (pkg-config readline) info is either unavailable for libreadline or
# simply misbehaves.
#
-# - Compile-and-link-with-default-path tests fail. This will fail for
-# platforms which store readline under, e.g., /usr/local.
+# - Either of readline.h or libreadline are in an exotic place.
#
# Defines the following vars:
#
# - LDFLAGS_READLINE: "" or linker flags
# - CFLAGS_READLINE: "" or c-flags
#
+# Quirks:
+#
+# - If readline.h is found in a directory name matching *line then the
+# resulting -I... flag points one directory _up_ from that, under
+# the assumption that client-side code will #include
+# <readline/readline.h>.
+#
# Returns the value of HAVE_READLINE.
proc hwaci-check-readline {} {
define HAVE_READLINE 0
# want termcap, it wants -lcurses, but we don't get that info from
# pkg-config either.
- set h "readline/readline.h"
- if {[cc-check-includes $h]} {
- if {[hwaci-check-function-in-lib readline readline]} {
- msg-result "Enabling libreadline."
- define HAVE_READLINE 1
- define LDFLAGS_READLINE [get-define lib_readline]
+ # Look for readline.h
+ set rlInc ""
+ if {![hwaci-is-cross-compiling]} {
+ # ^^^ this check is derived from SQLite's legacy configure script
+ set rlInc [hwaci-search-for-header-dir readline.h \
+ -subdirs {include/readline include}]
+ if {"" ne $rlInc} {
+ if {[string match */*line $rlInc]} {
+ # Special case: if the path includes .../*line/readline.h", set
+ # the -I to one dir up from that because our sources include
+ # <readline/readline.h> or <editline/readline.h>. Reminder: if
+ # auto.def is being run by jimsh0 then [file normalize] will not
+ # work!
+ set rlInc [file dirname $v]
+ }
+ set rlInc "-I${rlInc}"
+ }
+ }
+
+ # If readline.h was found/specified, look for libreadline...
+ set rlLib ""
+ if {"" ne $rlInc} {
+ set libTerm ""
+ if {[hwaci-check-function-in-lib tgetent {readline ncurses curses termcap}]} {
+ # ^^^ check extracted from an ancient autotools configure script.
+ set libTerm [get-define lib_tgetent]
+ undefine lib_tgetent
+ }
+ if {"readline" eq $libTerm} {
+ set rlLib $libTerm
+ } elseif {[hwaci-check-function-in-lib readline readline $libTerm]} {
+ set rlLib [get-define lib_readline]
+ lappend rlLib $libTerm
undefine lib_readline
- return 1
}
- # else TODO: look in various places and [define CFLAGS_READLINE
- # -I...]
- }
- # Numerous TODOs:
- # - Requires linking with [n]curses or similar on some platforms.
- # - Headers are in a weird place on some BSD systems.
- # - Add --with-readline=DIR
- # - Add --with-readline-lib=lib ==> pass lib file via LDFLAGS_READLINE
- # - Add --with-readline-inc=dir ==> pass -Idir via CFLAGS_READLINE
+ }
+
+ if {"" ne $rlLib} {
+ set rlLib [join $rlLib]
+ define LDFLAGS_READLINE $rlLib
+ define CFLAGS_READLINE $rlInc
+ define HAVE_READLINE 1
+ msg-result "Using readline with flags: $rlInc $rlLib"
+ return 1
+ }
+
msg-result "libreadline not found."
return 0
}
-C Rename\s--with-readline-ldflags/cflags\sto\s--with-readline-lib/inc\sbecause\sit\sturns\sout\sthat\sldflags/cflags\shave\s(when\spassed\san\sexplicit\svalue)\sthe\ssame\ssemantics\sthe\slegacy\slib/inc\sflags.\sStill\sto-fix\sis\sthat\sthe\sno-flag-given\sreadline\ssearch\sbehavior\sdiffers,\sand\sis\smuch\smore\slimited,\sfrom\sthe\slegacy\sconfigure\sbehavior.
-D 2024-10-27T02:27:07.440
+C Bring\sthe\sautomated\sreadline\sdetection\sup\sto\sparity\swith\sthe\slegacy\sconfigure\sscript.
+D 2024-10-27T04:27:47.182
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md b6e6c1baf38e4339bd3f1e0e5e5bfd0a9a93d133360691b2785c2d4b2f2dcec2
F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2
F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90
F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2
-F auto.def 7846fe16d52eb941504bf7335a876c5a3c6e35f9eef2330e3137cf65b8cac3c2
+F auto.def aba9d4d29eb7fd5a5bda791d338bf5a32e205d1164af8c9d579bb1b4083ad25d
F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903
F autoconf/Makefile.am adedc1324b6a87fdd1265ddd336d2fb7d4f36a0e77b86ea553ae7cc4ea239347
F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac
F autosetup/cc-shared.tcl 4f024e94a47f427ba61de1739f6381ef0080210f9fae89112d5c1de1e5460d78
F autosetup/cc.tcl 7e2fe943ae9d45cf39e9f5b05b6230df8e719415edea5af06c30eb68680bde14
F autosetup/default.auto 5cdf016de2140e50f1db190a02039dc42fb390af1dda4cc4853e3042a9ef0e82
-F autosetup/hwaci-common.tcl dd33af5ee7279956a58254accfb8f86e84d64b153afd69efb8c5dd8937845649
+F autosetup/hwaci-common.tcl a4276230b1c510b2a283fcaa59424a3ba77eafc441e7761286f55e3b2d155064
F autosetup/jimsh0.c 27ea5f221359ef6c58780fc6c185aadbf8d3bee9a021331a3e5de0eba0dc6de6
F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba
F autosetup/system.tcl 3a39d6e0b3bfba526fd39afe07c1d0d325e5a31925013a1ba7c671e1128e31bb
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P c8c70353bbdcee20487766f5f03f1638a1c35022bb5f1249141b86d561f1b613
-R aee97201b742768a8a881df4101db095
+P 8f6897b92c6a059f1c658ccce5bdc9ff3d29b41eec8298c6d46c7aeabace1d89
+R f0582379bec537e3414c67bad5681477
U stephan
-Z c7373ae669f742e7f6e85074f4e952ce
+Z cffd0ba4388e6bcce9ac7e976789ab0c
# Remove this line to create a well-formed Fossil manifest.
-8f6897b92c6a059f1c658ccce5bdc9ff3d29b41eec8298c6d46c7aeabace1d89
+2ddeb7a8f55735cc7f2cf95cbbb0b20c563ced87db1429816fcfb0ee89e751f0