|
f476744…
|
drh
|
1 |
# System autoconfiguration. Try: ./configure --help |
|
f476744…
|
drh
|
2 |
|
|
65c7196…
|
wyoung
|
3 |
# This must be above "options" below because it implicitly brings in the |
|
65c7196…
|
wyoung
|
4 |
# default Autosetup options, things like --prefix. |
|
65c7196…
|
wyoung
|
5 |
use cc cc-lib |
|
65c7196…
|
wyoung
|
6 |
|
|
f476744…
|
drh
|
7 |
options { |
|
a0061bb…
|
mistachkin
|
8 |
with-openssl:path|auto|tree|none |
|
a0061bb…
|
mistachkin
|
9 |
=> {Look for OpenSSL in the given path, automatically, in the source tree, or none} |
|
8435adc…
|
mistachkin
|
10 |
with-zlib:path|auto|tree |
|
a0061bb…
|
mistachkin
|
11 |
=> {Look for zlib in the given path, automatically, or in the source tree} |
|
dfa758b…
|
stephan
|
12 |
with-sqlite:path|auto|tree |
|
31d431e…
|
stephan
|
13 |
=> {Look for sqlite in the given path, automatically, or in the source tree.} |
|
825d78b…
|
mistachkin
|
14 |
with-exec-rel-paths=0 |
|
825d78b…
|
mistachkin
|
15 |
=> {Enable relative paths for external diff/gdiff} |
|
231d693…
|
drh
|
16 |
with-sanitizer: => {Build with C compiler's -fsanitize=LIST; e.g. address,enum,null,undefined} |
|
c91bafc…
|
mistachkin
|
17 |
with-th1-docs=0 => {Enable TH1 for embedded documentation pages} |
|
1c528d3…
|
mistachkin
|
18 |
with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages} |
|
23c8937…
|
drh
|
19 |
with-tcl:path => {Enable Tcl integration, with Tcl in the specified path} |
|
955886f…
|
mistachkin
|
20 |
with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism} |
|
955886f…
|
mistachkin
|
21 |
with-tcl-private-stubs=0 |
|
955886f…
|
mistachkin
|
22 |
=> {Enable Tcl integration via private stubs mechanism} |
|
d5ca538…
|
mistachkin
|
23 |
with-mman=0 => {Enable use of POSIX memory APIs from "sys/mman.h"} |
|
ed871fb…
|
drh
|
24 |
with-see=0 => {Enable the SQLite Encryption Extension (SEE)} |
|
b9a6e1a…
|
danshearer
|
25 |
print-minimum-sqlite-version=0 |
|
b9a6e1a…
|
danshearer
|
26 |
=> {print the minimum SQLite version number required, and exit} |
|
fea0402…
|
jan.nijtmans
|
27 |
internal-sqlite=1 => {Don't use the internal SQLite, use the system one} |
|
f476744…
|
drh
|
28 |
static=0 => {Link a static executable} |
|
4bf670e…
|
drh
|
29 |
fusefs=1 => {Disable the Fuse Filesystem} |
|
f476744…
|
drh
|
30 |
fossil-debug=0 => {Build with fossil debugging enabled} |
|
189adb9…
|
drh
|
31 |
no-opt=0 => {Build without optimization} |
|
3154536…
|
stephan
|
32 |
json=0 => {Build with fossil JSON API enabled} |
|
7fcb462…
|
stephan
|
33 |
with-emsdk:path => {Directory containing the Emscripten SDK} |
|
5cf0da6…
|
stephan
|
34 |
compile-commands=0 => |
|
5cf0da6…
|
stephan
|
35 |
"Check for compile_commands.json support." |
|
b9a6e1a…
|
danshearer
|
36 |
} |
|
b9a6e1a…
|
danshearer
|
37 |
|
|
7018d7c…
|
drh
|
38 |
# Update the minimum required SQLite version number here, and also |
|
7018d7c…
|
drh
|
39 |
# in src/main.c near the sqlite3_libversion_number() call. Take care |
|
7018d7c…
|
drh
|
40 |
# that both places agree! |
|
4e23c2a…
|
drh
|
41 |
define MINIMUM_SQLITE_VERSION "3.49.0" |
|
b9a6e1a…
|
danshearer
|
42 |
|
|
834f651…
|
danshearer
|
43 |
# This is useful for people wanting Fossil to use an external SQLite library |
|
834f651…
|
danshearer
|
44 |
# to compare the one they have against the minimum required |
|
b9a6e1a…
|
danshearer
|
45 |
if {[opt-bool print-minimum-sqlite-version]} { |
|
a76b48c…
|
stephan
|
46 |
puts [get-define MINIMUM_SQLITE_VERSION] |
|
a76b48c…
|
stephan
|
47 |
exit 0 |
|
b9f57f5…
|
drh
|
48 |
} |
|
b9f57f5…
|
drh
|
49 |
|
|
b9f57f5…
|
drh
|
50 |
# Space characters have never been allowed in either the source |
|
b9f57f5…
|
drh
|
51 |
# tree nor the build directory. But the resulting error messages |
|
b9f57f5…
|
drh
|
52 |
# could be confusing. The following checks make the reason for the |
|
b9f57f5…
|
drh
|
53 |
# failure clear. |
|
b9f57f5…
|
drh
|
54 |
# |
|
b9f57f5…
|
drh
|
55 |
if {[string first " " $autosetup(srcdir)] != -1} { |
|
b9f57f5…
|
drh
|
56 |
user-error "The pathname of the source tree\ |
|
b9f57f5…
|
drh
|
57 |
may not contain space characters" |
|
b9f57f5…
|
drh
|
58 |
} |
|
b9f57f5…
|
drh
|
59 |
if {[string first " " $autosetup(builddir)] != -1} { |
|
b9f57f5…
|
drh
|
60 |
user-error "The pathname of the build directory\ |
|
b9f57f5…
|
drh
|
61 |
may not contain space characters" |
|
35f3e5b…
|
stephan
|
62 |
} |
|
35f3e5b…
|
stephan
|
63 |
|
|
35f3e5b…
|
stephan
|
64 |
set outOfTreeBuild 0 |
|
35f3e5b…
|
stephan
|
65 |
if {![file exists fossil.1]} { |
|
35f3e5b…
|
stephan
|
66 |
puts "This appears to be an out-of-tree build." |
|
35f3e5b…
|
stephan
|
67 |
set outOfTreeBuild 1 |
|
65c7196…
|
wyoung
|
68 |
} |
|
f476744…
|
drh
|
69 |
|
|
f476744…
|
drh
|
70 |
# sqlite wants these types if possible |
|
f476744…
|
drh
|
71 |
cc-with {-includes {stdint.h inttypes.h}} { |
|
a76b48c…
|
stephan
|
72 |
cc-check-types uint32_t uint16_t int16_t uint8_t |
|
f476744…
|
drh
|
73 |
} |
|
f476744…
|
drh
|
74 |
|
|
f476744…
|
drh
|
75 |
# Use pread/pwrite system calls in place of seek + read/write if possible |
|
f476744…
|
drh
|
76 |
define USE_PREAD [cc-check-functions pread] |
|
ebb67be…
|
wyoung
|
77 |
|
|
ebb67be…
|
wyoung
|
78 |
# If we have cscope here, we'll use it in the "tags" target |
|
4211165…
|
wyoung
|
79 |
if {[cc-check-progs cscope]} { |
|
a76b48c…
|
stephan
|
80 |
define COLLECT_CSCOPE_DATA "cscope -bR $::autosetup(srcdir)/src/*.\[ch\]" |
|
4211165…
|
wyoung
|
81 |
} else { |
|
a76b48c…
|
stephan
|
82 |
define COLLECT_CSCOPE_DATA "" |
|
4211165…
|
wyoung
|
83 |
} |
|
ee2ffe3…
|
wyoung
|
84 |
|
|
ee2ffe3…
|
wyoung
|
85 |
# Find tclsh for the test suite. |
|
ee2ffe3…
|
wyoung
|
86 |
# |
|
ee2ffe3…
|
wyoung
|
87 |
# We can't use jimsh for this: the test suite uses features of Tcl that |
|
ee2ffe3…
|
wyoung
|
88 |
# Jim doesn't support, either statically or due to the way it's built by |
|
ee2ffe3…
|
wyoung
|
89 |
# autosetup. For example, Jim supports `file normalize`, but only if |
|
ee2ffe3…
|
wyoung
|
90 |
# you build it with HAVE_REALPATH, which won't ever be defined in this |
|
ee2ffe3…
|
wyoung
|
91 |
# context because autosetup doesn't try to discover platform-specific |
|
ee2ffe3…
|
wyoung
|
92 |
# details like that before it decides to build jimsh0. Besides which, |
|
ee2ffe3…
|
wyoung
|
93 |
# autosetup won't build jimsh0 at all if it can find tclsh itself. |
|
ee2ffe3…
|
wyoung
|
94 |
# Ironically, this means we may right now be running under either jimsh0 |
|
ee2ffe3…
|
wyoung
|
95 |
# or a version of tclsh that we find unsuitable below! |
|
f476744…
|
drh
|
96 |
cc-check-progs tclsh |
|
ee2ffe3…
|
wyoung
|
97 |
set hbtd /usr/local/Cellar/tcl-tk |
|
ee2ffe3…
|
wyoung
|
98 |
if {[string equal false [get-define TCLSH]]} { |
|
a76b48c…
|
stephan
|
99 |
msg-result "WARNING: 'make test' will not run here." |
|
7a43dcb…
|
jan.nijtmans
|
100 |
set v 8.6 |
|
a76b48c…
|
stephan
|
101 |
} else { |
|
a76b48c…
|
stephan
|
102 |
set v [exec sh -c "echo 'puts \$tcl_version' | tclsh"] |
|
7a43dcb…
|
jan.nijtmans
|
103 |
if {$v >= 8.6} { |
|
a76b48c…
|
stephan
|
104 |
msg-result "Found Tclsh version $v in the PATH." |
|
a76b48c…
|
stephan
|
105 |
define TCLSH tclsh |
|
a76b48c…
|
stephan
|
106 |
} elseif {[file isdirectory $hbtd]} { |
|
a76b48c…
|
stephan
|
107 |
# This is a macOS system with the Homebrew version of Tcl/Tk |
|
a76b48c…
|
stephan
|
108 |
# installed. Select the newest version. It won't normally be |
|
a76b48c…
|
stephan
|
109 |
# in the PATH to avoid shadowing /usr/bin/tclsh, and even if it |
|
a76b48c…
|
stephan
|
110 |
# were in the PATH, it's bad practice to put /usr/local/bin (the |
|
a76b48c…
|
stephan
|
111 |
# Homebrew default) ahead of /usr/bin, especially given that |
|
a76b48c…
|
stephan
|
112 |
# it's user-writeable by default with Homebrew. Thus, we can be |
|
a76b48c…
|
stephan
|
113 |
# pretty sure the only way to call it is with an absolute path. |
|
a76b48c…
|
stephan
|
114 |
set v [exec ls -tr $hbtd | tail -1] |
|
a76b48c…
|
stephan
|
115 |
set path "$hbtd/$v/bin/tclsh" |
|
a76b48c…
|
stephan
|
116 |
define TCLSH $path |
|
a76b48c…
|
stephan
|
117 |
msg-result "Using Homebrew Tcl/Tk version $path." |
|
a76b48c…
|
stephan
|
118 |
} else { |
|
a76b48c…
|
stephan
|
119 |
msg-result "WARNING: tclsh $v found; need >= 8.6 for 'make test'." |
|
a76b48c…
|
stephan
|
120 |
define TCLSH false ;# force "make test" failure via /usr/bin/false |
|
a76b48c…
|
stephan
|
121 |
} |
|
57da8e2…
|
drh
|
122 |
} |
|
57da8e2…
|
drh
|
123 |
|
|
57da8e2…
|
drh
|
124 |
define CFLAGS [get-env CFLAGS "-g -Os"] |
|
3f2cde2…
|
drh
|
125 |
define EXTRA_CFLAGS "-Wall" |
|
f476744…
|
drh
|
126 |
define EXTRA_LDFLAGS "" |
|
a13c373…
|
jan.nijtmans
|
127 |
define USE_SYSTEM_SQLITE 0 |
|
a0061bb…
|
mistachkin
|
128 |
define USE_LINENOISE 0 |
|
d5ca538…
|
mistachkin
|
129 |
define USE_MMAN_H 0 |
|
ed871fb…
|
drh
|
130 |
define USE_SEE 0 |
|
31d431e…
|
stephan
|
131 |
define SQLITE3_ORIGIN 0 |
|
31d431e…
|
stephan
|
132 |
# SQLITE3_ORIGIN 0 = src/sqlite3, 1=src/sqlite3-see.c, 2=client-provided |
|
ac3e326…
|
stephan
|
133 |
define SQLITE_OPTIONS_EXT "" |
|
ac3e326…
|
stephan
|
134 |
# SQLITE_OPTIONS_EXT => build-dependent CFLAGS for sqlite3.c and shell.c |
|
da9f362…
|
ashepilko
|
135 |
|
|
da9f362…
|
ashepilko
|
136 |
# Maintain the C89/C90-style order of variable declarations before statements. |
|
da9f362…
|
ashepilko
|
137 |
# Check if the compiler supports the respective warning flag. |
|
da9f362…
|
ashepilko
|
138 |
if {[cctest -cflags -Wdeclaration-after-statement]} { |
|
a76b48c…
|
stephan
|
139 |
define-append EXTRA_CFLAGS -Wdeclaration-after-statement |
|
da9f362…
|
ashepilko
|
140 |
} |
|
da9f362…
|
ashepilko
|
141 |
|
|
b41f428…
|
mistachkin
|
142 |
|
|
b41f428…
|
mistachkin
|
143 |
# This procedure is a customized version of "cc-check-function-in-lib", |
|
b41f428…
|
mistachkin
|
144 |
# that does not modify the LIBS variable. Its use prevents prematurely |
|
b41f428…
|
mistachkin
|
145 |
# pulling in libraries that will be added later anyhow (e.g. "-ldl"). |
|
b41f428…
|
mistachkin
|
146 |
proc check-function-in-lib {function libs {otherlibs {}}} { |
|
a76b48c…
|
stephan
|
147 |
if {[string length $otherlibs]} { |
|
a76b48c…
|
stephan
|
148 |
msg-checking "Checking for $function in $libs with $otherlibs..." |
|
a76b48c…
|
stephan
|
149 |
} else { |
|
a76b48c…
|
stephan
|
150 |
msg-checking "Checking for $function in $libs..." |
|
a76b48c…
|
stephan
|
151 |
} |
|
a76b48c…
|
stephan
|
152 |
set found 0 |
|
a76b48c…
|
stephan
|
153 |
cc-with [list -libs $otherlibs] { |
|
a76b48c…
|
stephan
|
154 |
if {[cctest_function $function]} { |
|
a76b48c…
|
stephan
|
155 |
msg-result "none needed" |
|
a76b48c…
|
stephan
|
156 |
define lib_$function "" |
|
a76b48c…
|
stephan
|
157 |
incr found |
|
a76b48c…
|
stephan
|
158 |
} else { |
|
a76b48c…
|
stephan
|
159 |
foreach lib $libs { |
|
a76b48c…
|
stephan
|
160 |
cc-with [list -libs -l$lib] { |
|
a76b48c…
|
stephan
|
161 |
if {[cctest_function $function]} { |
|
a76b48c…
|
stephan
|
162 |
msg-result -l$lib |
|
a76b48c…
|
stephan
|
163 |
define lib_$function -l$lib |
|
a76b48c…
|
stephan
|
164 |
incr found |
|
a76b48c…
|
stephan
|
165 |
break |
|
a76b48c…
|
stephan
|
166 |
} |
|
a76b48c…
|
stephan
|
167 |
} |
|
a76b48c…
|
stephan
|
168 |
} |
|
a76b48c…
|
stephan
|
169 |
} |
|
a76b48c…
|
stephan
|
170 |
} |
|
a76b48c…
|
stephan
|
171 |
if {$found} { |
|
a76b48c…
|
stephan
|
172 |
define [feature-define-name $function] |
|
a76b48c…
|
stephan
|
173 |
} else { |
|
a76b48c…
|
stephan
|
174 |
msg-result "no" |
|
a76b48c…
|
stephan
|
175 |
} |
|
a76b48c…
|
stephan
|
176 |
return $found |
|
b41f428…
|
mistachkin
|
177 |
} |
|
f476744…
|
drh
|
178 |
|
|
f476744…
|
drh
|
179 |
if {![opt-bool internal-sqlite]} { |
|
350c627…
|
drh
|
180 |
proc find_system_sqlite {} { |
|
5fe55cb…
|
dan
|
181 |
|
|
5fe55cb…
|
dan
|
182 |
# On some systems (slackware), libsqlite3 requires -ldl to link. So |
|
5fe55cb…
|
dan
|
183 |
# search for the system SQLite once with -ldl, and once without. If |
|
25f7fa1…
|
drh
|
184 |
# the library can only be found with $extralibs set to -ldl, then |
|
5fe55cb…
|
dan
|
185 |
# the code below will append -ldl to LIBS. |
|
5fe55cb…
|
dan
|
186 |
# |
|
5fe55cb…
|
dan
|
187 |
foreach extralibs {{} {-ldl}} { |
|
5fe55cb…
|
dan
|
188 |
|
|
5fe55cb…
|
dan
|
189 |
# Locate the system SQLite by searching for sqlite3_open(). Then check |
|
e3258f1…
|
jan.nijtmans
|
190 |
# if sqlite3_stmt_isexplain can be found as well. If we can find open() but |
|
e3258f1…
|
jan.nijtmans
|
191 |
# not stmt_isexplain(), then the system SQLite is too old to link against |
|
7829abd…
|
jan.nijtmans
|
192 |
# fossil. |
|
7829abd…
|
jan.nijtmans
|
193 |
# |
|
b41f428…
|
mistachkin
|
194 |
if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} { |
|
5fe55cb…
|
dan
|
195 |
# Success. Update symbols and return. |
|
5fe55cb…
|
dan
|
196 |
# |
|
5fe55cb…
|
dan
|
197 |
define USE_SYSTEM_SQLITE 1 |
|
b41f428…
|
mistachkin
|
198 |
define-append LIBS -lsqlite3 |
|
5fe55cb…
|
dan
|
199 |
define-append LIBS $extralibs |
|
5fe55cb…
|
dan
|
200 |
return |
|
5fe55cb…
|
dan
|
201 |
} |
|
5fe55cb…
|
dan
|
202 |
} |
|
5fe55cb…
|
dan
|
203 |
user-error "system sqlite3 not found" |
|
5fe55cb…
|
dan
|
204 |
} |
|
5fe55cb…
|
dan
|
205 |
|
|
350c627…
|
drh
|
206 |
find_system_sqlite |
|
350c627…
|
drh
|
207 |
|
|
350c627…
|
drh
|
208 |
proc test_system_sqlite {} { |
|
cbd27f2…
|
stephan
|
209 |
# Check compatibility of the system SQLite library by running the |
|
cbd27f2…
|
stephan
|
210 |
# sqlcompttest.c program in the source tree passes |
|
cbd27f2…
|
stephan
|
211 |
# MINIMUM_SQLITE_VERSION set at the top of this file to |
|
cbd27f2…
|
stephan
|
212 |
# sqlcompttest.c |
|
350c627…
|
drh
|
213 |
# |
|
350c627…
|
drh
|
214 |
set cmdline {} |
|
350c627…
|
drh
|
215 |
lappend cmdline {*}[get-define CCACHE] |
|
350c627…
|
drh
|
216 |
lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS] |
|
b62f651…
|
stephan
|
217 |
lappend cmdline $::autosetup(dir)/../tools/sqlcompattest.c -o conftest__ |
|
4a15ccd…
|
drh
|
218 |
lappend cmdline {*}[get-define LDFLAGS] |
|
350c627…
|
drh
|
219 |
lappend cmdline {*}[get-define LIBS] |
|
834f651…
|
danshearer
|
220 |
set sqlite-version [string cat "-D MINIMUM_SQLITE_VERSION=" [get-define MINIMUM_SQLITE_VERSION]] |
|
834f651…
|
danshearer
|
221 |
lappend cmdline {*}[set sqlite-version] |
|
350c627…
|
drh
|
222 |
set ok 1 |
|
350c627…
|
drh
|
223 |
set err [catch {exec-with-stderr {*}$cmdline} result errinfo] |
|
350c627…
|
drh
|
224 |
if {$err} { |
|
a76b48c…
|
stephan
|
225 |
configlog "Failed: [join $cmdline]" |
|
a76b48c…
|
stephan
|
226 |
if {[string length $result]>0} {configlog $result} |
|
a76b48c…
|
stephan
|
227 |
configlog "============" |
|
a76b48c…
|
stephan
|
228 |
set ok 0 |
|
350c627…
|
drh
|
229 |
} elseif {$::autosetup(debug)} { |
|
a76b48c…
|
stephan
|
230 |
configlog "Compiled OK: [join $cmdline]" |
|
a76b48c…
|
stephan
|
231 |
configlog "============" |
|
350c627…
|
drh
|
232 |
} |
|
350c627…
|
drh
|
233 |
if {!$ok} { |
|
350c627…
|
drh
|
234 |
user-error "unable to compile SQLite compatibility test program" |
|
350c627…
|
drh
|
235 |
} |
|
350c627…
|
drh
|
236 |
set err [catch {exec-with-stderr ./conftest__} result errinfo] |
|
e6de5ec…
|
drh
|
237 |
if {[get-define build] eq [get-define host]} { |
|
e6de5ec…
|
drh
|
238 |
set err [catch {exec-with-stderr ./conftest__} result errinfo] |
|
e6de5ec…
|
drh
|
239 |
if {$err} { |
|
e6de5ec…
|
drh
|
240 |
user-error $result |
|
e6de5ec…
|
drh
|
241 |
} |
|
350c627…
|
drh
|
242 |
} |
|
350c627…
|
drh
|
243 |
file delete ./conftest__ |
|
350c627…
|
drh
|
244 |
} |
|
350c627…
|
drh
|
245 |
test_system_sqlite |
|
918bcfc…
|
jan.nijtmans
|
246 |
|
|
a0061bb…
|
mistachkin
|
247 |
} |
|
a0061bb…
|
mistachkin
|
248 |
|
|
a0061bb…
|
mistachkin
|
249 |
proc is_mingw {} { |
|
5c6dee5…
|
wyoung
|
250 |
return [expr { |
|
5c6dee5…
|
wyoung
|
251 |
[string match *mingw* [get-define host]] && |
|
5c6dee5…
|
wyoung
|
252 |
![file exists "/dev/null"] |
|
5c6dee5…
|
wyoung
|
253 |
}] |
|
5c6dee5…
|
wyoung
|
254 |
} |
|
5c6dee5…
|
wyoung
|
255 |
|
|
5c6dee5…
|
wyoung
|
256 |
if {[is_mingw]} { |
|
a76b48c…
|
stephan
|
257 |
define-append EXTRA_CFLAGS -DBROKEN_MINGW_CMDLINE |
|
a76b48c…
|
stephan
|
258 |
define-append LIBS -lkernel32 -lws2_32 |
|
a76b48c…
|
stephan
|
259 |
} else { |
|
a76b48c…
|
stephan
|
260 |
# |
|
a76b48c…
|
stephan
|
261 |
# NOTE: All platforms except MinGW should use the linenoise |
|
a76b48c…
|
stephan
|
262 |
# package. It is currently unsupported on Win32. |
|
a76b48c…
|
stephan
|
263 |
# |
|
a76b48c…
|
stephan
|
264 |
define USE_LINENOISE 1 |
|
a76b48c…
|
stephan
|
265 |
} |
|
a76b48c…
|
stephan
|
266 |
|
|
a76b48c…
|
stephan
|
267 |
if {[string match *-solaris* [get-define host]]} { |
|
a76b48c…
|
stephan
|
268 |
define-append EXTRA_CFLAGS {-D__EXTENSIONS__} |
|
a76b48c…
|
stephan
|
269 |
} |
|
a76b48c…
|
stephan
|
270 |
|
|
a76b48c…
|
stephan
|
271 |
if {[opt-bool fossil-debug]} { |
|
a76b48c…
|
stephan
|
272 |
define CFLAGS {-g -O0 -Wall} |
|
a76b48c…
|
stephan
|
273 |
define-append CFLAGS -DFOSSIL_DEBUG |
|
a76b48c…
|
stephan
|
274 |
msg-result "Debugging support enabled" |
|
a76b48c…
|
stephan
|
275 |
} |
|
a76b48c…
|
stephan
|
276 |
|
|
a76b48c…
|
stephan
|
277 |
if {[opt-bool no-opt]} { |
|
a76b48c…
|
stephan
|
278 |
define CFLAGS {-g -O0 -Wall} |
|
a76b48c…
|
stephan
|
279 |
msg-result "Builting without compiler optimization" |
|
a76b48c…
|
stephan
|
280 |
if {[opt-bool fossil-debug]} { |
|
a76b48c…
|
stephan
|
281 |
define-append CFLAGS -DFOSSIL_DEBUG |
|
a76b48c…
|
stephan
|
282 |
} |
|
a76b48c…
|
stephan
|
283 |
} |
|
a76b48c…
|
stephan
|
284 |
|
|
a76b48c…
|
stephan
|
285 |
if {[opt-bool with-mman]} { |
|
a76b48c…
|
stephan
|
286 |
define-append EXTRA_CFLAGS -DUSE_MMAN_H |
|
a76b48c…
|
stephan
|
287 |
define USE_MMAN_H 1 |
|
a76b48c…
|
stephan
|
288 |
msg-result "Enabling \"sys/mman.h\" support" |
|
ed871fb…
|
drh
|
289 |
} |
|
ed871fb…
|
drh
|
290 |
|
|
ed871fb…
|
drh
|
291 |
if {[opt-bool with-see]} { |
|
a76b48c…
|
stephan
|
292 |
define-append EXTRA_CFLAGS -DUSE_SEE |
|
a76b48c…
|
stephan
|
293 |
define USE_SEE 1 |
|
a76b48c…
|
stephan
|
294 |
define SQLITE3_ORIGIN 1 |
|
a76b48c…
|
stephan
|
295 |
msg-result "Enabling encryption support" |
|
796dcfe…
|
drh
|
296 |
} |
|
796dcfe…
|
drh
|
297 |
|
|
796dcfe…
|
drh
|
298 |
if {[opt-bool json]} { |
|
a76b48c…
|
stephan
|
299 |
# Reminder/FIXME (stephan): FOSSIL_ENABLE_JSON |
|
a76b48c…
|
stephan
|
300 |
# is required in the CFLAGS because json*.c |
|
a76b48c…
|
stephan
|
301 |
# have #ifdef guards around the whole file without |
|
a76b48c…
|
stephan
|
302 |
# reading config.h first. |
|
a76b48c…
|
stephan
|
303 |
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_JSON |
|
a76b48c…
|
stephan
|
304 |
define FOSSIL_ENABLE_JSON |
|
a76b48c…
|
stephan
|
305 |
msg-result "JSON support enabled" |
|
3c941dd…
|
drh
|
306 |
} |
|
3c941dd…
|
drh
|
307 |
|
|
825d78b…
|
mistachkin
|
308 |
if {[opt-bool with-exec-rel-paths]} { |
|
a76b48c…
|
stephan
|
309 |
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_EXEC_REL_PATHS |
|
a76b48c…
|
stephan
|
310 |
define FOSSIL_ENABLE_EXEC_REL_PATHS |
|
a76b48c…
|
stephan
|
311 |
msg-result "Relative paths in external diff/gdiff enabled" |
|
c91bafc…
|
mistachkin
|
312 |
} |
|
c91bafc…
|
mistachkin
|
313 |
|
|
c91bafc…
|
mistachkin
|
314 |
if {[opt-bool with-th1-docs]} { |
|
a76b48c…
|
stephan
|
315 |
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_DOCS |
|
a76b48c…
|
stephan
|
316 |
define FOSSIL_ENABLE_TH1_DOCS |
|
a76b48c…
|
stephan
|
317 |
msg-result "TH1 embedded documentation support enabled" |
|
1c528d3…
|
mistachkin
|
318 |
} |
|
1c528d3…
|
mistachkin
|
319 |
|
|
1c528d3…
|
mistachkin
|
320 |
if {[opt-bool with-th1-hooks]} { |
|
a76b48c…
|
stephan
|
321 |
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_HOOKS |
|
a76b48c…
|
stephan
|
322 |
define FOSSIL_ENABLE_TH1_HOOKS |
|
a76b48c…
|
stephan
|
323 |
msg-result "TH1 hooks support enabled" |
|
f476744…
|
drh
|
324 |
} |
|
61079c3…
|
mistachkin
|
325 |
|
|
ce93b46…
|
drh
|
326 |
#if {[opt-bool markdown]} { |
|
ce93b46…
|
drh
|
327 |
# # no-op. Markdown is now enabled by default. |
|
166fa7e…
|
mistachkin
|
328 |
# msg-result "Markdown support enabled" |
|
ce93b46…
|
drh
|
329 |
#} |
|
f476744…
|
drh
|
330 |
|
|
f476744…
|
drh
|
331 |
if {[opt-bool static]} { |
|
a76b48c…
|
stephan
|
332 |
# XXX: This will not work on all systems. |
|
a76b48c…
|
stephan
|
333 |
define-append EXTRA_LDFLAGS -static |
|
a76b48c…
|
stephan
|
334 |
msg-result "Trying to link statically" |
|
b41f428…
|
mistachkin
|
335 |
} else { |
|
a76b48c…
|
stephan
|
336 |
define-append EXTRA_CFLAGS -DFOSSIL_DYNAMIC_BUILD=1 |
|
a76b48c…
|
stephan
|
337 |
define FOSSIL_DYNAMIC_BUILD |
|
b41f428…
|
mistachkin
|
338 |
} |
|
e6f64f5…
|
wyoung
|
339 |
|
|
e6f64f5…
|
wyoung
|
340 |
# Check for libraries that need to be sorted out early |
|
e6f64f5…
|
wyoung
|
341 |
cc-check-function-in-lib iconv iconv |
|
e6f64f5…
|
wyoung
|
342 |
|
|
374e73c…
|
stephan
|
343 |
cc-check-function-in-lib sin m |
|
374e73c…
|
stephan
|
344 |
cc-check-function-in-lib dlopen dl |
|
04e2f64…
|
stephan
|
345 |
|
|
19f11a8…
|
drh
|
346 |
# Helper for OpenSSL checking |
|
19f11a8…
|
drh
|
347 |
proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto -lpthread}}} { |
|
a76b48c…
|
stephan
|
348 |
msg-checking "Checking for $msg..." |
|
a76b48c…
|
stephan
|
349 |
set rc 0 |
|
a76b48c…
|
stephan
|
350 |
if {[is_mingw]} { |
|
a76b48c…
|
stephan
|
351 |
lappend libs -lgdi32 -lwsock32 -lcrypt32 |
|
a76b48c…
|
stephan
|
352 |
} |
|
a76b48c…
|
stephan
|
353 |
if {[info exists ::zlib_lib]} { |
|
a76b48c…
|
stephan
|
354 |
lappend libs $::zlib_lib |
|
a76b48c…
|
stephan
|
355 |
} |
|
a76b48c…
|
stephan
|
356 |
msg-quiet cc-with [list -cflags $cflags -libs $libs] { |
|
a76b48c…
|
stephan
|
357 |
if {[cc-check-includes openssl/ssl.h] && \ |
|
a76b48c…
|
stephan
|
358 |
[cc-check-functions SSL_new]} { |
|
a76b48c…
|
stephan
|
359 |
incr rc |
|
a76b48c…
|
stephan
|
360 |
} |
|
a76b48c…
|
stephan
|
361 |
} |
|
a76b48c…
|
stephan
|
362 |
if {!$rc && ![is_mingw]} { |
|
a76b48c…
|
stephan
|
363 |
# On some systems, OpenSSL appears to require -ldl to link. |
|
a76b48c…
|
stephan
|
364 |
lappend libs -ldl |
|
a76b48c…
|
stephan
|
365 |
msg-quiet cc-with [list -cflags $cflags -libs $libs] { |
|
a76b48c…
|
stephan
|
366 |
if {[cc-check-includes openssl/ssl.h] && \ |
|
a76b48c…
|
stephan
|
367 |
[cc-check-functions SSL_new]} { |
|
a76b48c…
|
stephan
|
368 |
incr rc |
|
a76b48c…
|
stephan
|
369 |
} |
|
a76b48c…
|
stephan
|
370 |
} |
|
a76b48c…
|
stephan
|
371 |
} |
|
a76b48c…
|
stephan
|
372 |
if {$rc} { |
|
a76b48c…
|
stephan
|
373 |
msg-result "ok" |
|
a76b48c…
|
stephan
|
374 |
return 1 |
|
a76b48c…
|
stephan
|
375 |
} else { |
|
a76b48c…
|
stephan
|
376 |
msg-result "no" |
|
a76b48c…
|
stephan
|
377 |
return 0 |
|
a76b48c…
|
stephan
|
378 |
} |
|
a76b48c…
|
stephan
|
379 |
} |
|
a76b48c…
|
stephan
|
380 |
|
|
d84494f…
|
stephan
|
381 |
# |
|
af7475c…
|
stephan
|
382 |
# Check for zlib, using the given location if specified |
|
d84494f…
|
stephan
|
383 |
# |
|
d84494f…
|
stephan
|
384 |
proc handle-zlib {} { |
|
d84494f…
|
stephan
|
385 |
set ::zlibpath [opt-val with-zlib]; # used by downstream tcl tests |
|
d84494f…
|
stephan
|
386 |
if {$::zlibpath eq "tree"} { |
|
d84494f…
|
stephan
|
387 |
set ::zlibdir [file dirname $::autosetup(dir)]/compat/zlib |
|
d84494f…
|
stephan
|
388 |
if {![file isdirectory $::zlibdir]} { |
|
d84494f…
|
stephan
|
389 |
user-error "The zlib in source tree directory does not exist" |
|
d84494f…
|
stephan
|
390 |
} elseif { ([llength [glob -nocomplain -directory $::zlibdir libz*]] == 0) } { |
|
d84494f…
|
stephan
|
391 |
user-error "With --with-zlib=tree, $::zlibdir must be configured and built first." |
|
d84494f…
|
stephan
|
392 |
} |
|
d84494f…
|
stephan
|
393 |
cc-with [list -cflags "-I$::zlibdir -L$::zlibdir"] |
|
d84494f…
|
stephan
|
394 |
define-append EXTRA_CFLAGS -I$::zlibdir |
|
d84494f…
|
stephan
|
395 |
define-append LIBS $::zlibdir/libz.a |
|
d84494f…
|
stephan
|
396 |
set ::zlib_lib $::zlibdir/libz.a |
|
d84494f…
|
stephan
|
397 |
msg-result "Using zlib in source tree" |
|
d84494f…
|
stephan
|
398 |
} else { |
|
d84494f…
|
stephan
|
399 |
set cftry {""} |
|
d84494f…
|
stephan
|
400 |
set ldtry {""} |
|
d84494f…
|
stephan
|
401 |
if {$::zlibpath ni {auto ""}} { |
|
d84494f…
|
stephan
|
402 |
lappend cftry "-I$::zlibpath" |
|
d84494f…
|
stephan
|
403 |
lappend cftry "-I$::zlibpath/include" |
|
d84494f…
|
stephan
|
404 |
lappend ldtry "-L$::zlibpath" |
|
d84494f…
|
stephan
|
405 |
lappend ldtry "-L$::zlibpath/lib" |
|
d84494f…
|
stephan
|
406 |
} |
|
d84494f…
|
stephan
|
407 |
|
|
d84494f…
|
stephan
|
408 |
# Reverse the list of tests so we check most-specific to least, else |
|
d84494f…
|
stephan
|
409 |
# platform devel files will shadow local --with-zlib overrides. |
|
d84494f…
|
stephan
|
410 |
foreach c [lreverse $cftry] { |
|
d84494f…
|
stephan
|
411 |
if {[cc-with [list -cflags $c] {cc-check-includes zlib.h}]} { |
|
d84494f…
|
stephan
|
412 |
if {$c eq ""} { |
|
d84494f…
|
stephan
|
413 |
msg-result "Found zlib.h in default include path" |
|
d84494f…
|
stephan
|
414 |
} else { |
|
d84494f…
|
stephan
|
415 |
define-append EXTRA_CFLAGS "$c" |
|
d84494f…
|
stephan
|
416 |
msg-result "Found zlib.h via $c" |
|
d84494f…
|
stephan
|
417 |
} |
|
d84494f…
|
stephan
|
418 |
set cfound $c |
|
d84494f…
|
stephan
|
419 |
break |
|
d84494f…
|
stephan
|
420 |
} |
|
d84494f…
|
stephan
|
421 |
} |
|
d84494f…
|
stephan
|
422 |
if {![info exists cfound]} { |
|
d84494f…
|
stephan
|
423 |
user-error "zlib.h not found; either install it or specify its location via --with-zlib" |
|
d84494f…
|
stephan
|
424 |
} |
|
d84494f…
|
stephan
|
425 |
foreach lcheck [lreverse $ldtry] { |
|
d84494f…
|
stephan
|
426 |
if {[cc-with [list -cflags "$cfound $lcheck"] {check-function-in-lib inflateEnd z}]} { |
|
d84494f…
|
stephan
|
427 |
if {$lcheck eq ""} { |
|
d84494f…
|
stephan
|
428 |
msg-result "Linked to zlib via default library path" |
|
d84494f…
|
stephan
|
429 |
} else { |
|
d84494f…
|
stephan
|
430 |
define-append EXTRA_LDFLAGS "$lcheck" |
|
d84494f…
|
stephan
|
431 |
msg-result "Linked to zlib via $lcheck" |
|
d84494f…
|
stephan
|
432 |
} |
|
d84494f…
|
stephan
|
433 |
if {![check-function-in-lib compressBound z]} { |
|
d84494f…
|
stephan
|
434 |
puts "Notice: disabling zlib compression in the SQL shell" |
|
d84494f…
|
stephan
|
435 |
define-append SQLITE_OPTIONS_EXT {-USQLITE_HAVE_ZLIB} |
|
d84494f…
|
stephan
|
436 |
} |
|
d84494f…
|
stephan
|
437 |
break |
|
d84494f…
|
stephan
|
438 |
} |
|
d84494f…
|
stephan
|
439 |
} |
|
d84494f…
|
stephan
|
440 |
set ::zlib_lib -lz |
|
d84494f…
|
stephan
|
441 |
} |
|
d84494f…
|
stephan
|
442 |
}; # handle-zlib |
|
d84494f…
|
stephan
|
443 |
handle-zlib |
|
af7475c…
|
stephan
|
444 |
|
|
af7475c…
|
stephan
|
445 |
# |
|
af7475c…
|
stephan
|
446 |
# Handle the --with-openssl flag and, incidentally, update @LIBS@ for |
|
af7475c…
|
stephan
|
447 |
# zlib if openssl is _not_ used (if it is, we get zlib via libssl). |
|
af7475c…
|
stephan
|
448 |
# |
|
af7475c…
|
stephan
|
449 |
# This function should be called as late as possible in the configure |
|
af7475c…
|
stephan
|
450 |
# script to avoid that its updates to @LIBS@ break tests which follow |
|
af7475c…
|
stephan
|
451 |
# it when a custom local build of openssl is used, as discussed in |
|
af7475c…
|
stephan
|
452 |
# <https://fossil-scm.org/forum/forumpost/15e3d9cdc137030c>. |
|
af7475c…
|
stephan
|
453 |
# |
|
af7475c…
|
stephan
|
454 |
proc handle-with-openssl {} { |
|
af7475c…
|
stephan
|
455 |
set ssldirs [opt-val with-openssl] |
|
af7475c…
|
stephan
|
456 |
if {$ssldirs ne "none"} { |
|
af7475c…
|
stephan
|
457 |
set found 0 |
|
af7475c…
|
stephan
|
458 |
if {$ssldirs eq "tree"} { |
|
d84494f…
|
stephan
|
459 |
set ssldir [file dirname $::autosetup(dir)]/compat/openssl |
|
af7475c…
|
stephan
|
460 |
if {![file isdirectory $ssldir]} { |
|
af7475c…
|
stephan
|
461 |
user-error "The OpenSSL in source tree directory does not exist" |
|
af7475c…
|
stephan
|
462 |
} |
|
af7475c…
|
stephan
|
463 |
set msg "openssl in $ssldir" |
|
af7475c…
|
stephan
|
464 |
set cflags "-I$ssldir/include" |
|
af7475c…
|
stephan
|
465 |
set ldflags "-L$ssldir" |
|
af7475c…
|
stephan
|
466 |
set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a -lpthread" |
|
af7475c…
|
stephan
|
467 |
set found [check-for-openssl "openssl in source tree" "$cflags $ldflags" $ssllibs] |
|
af7475c…
|
stephan
|
468 |
} else { |
|
af7475c…
|
stephan
|
469 |
if {$ssldirs in {auto ""}} { |
|
af7475c…
|
stephan
|
470 |
catch { |
|
d84494f…
|
stephan
|
471 |
# TODO?: use autosetup's pkg-config support |
|
af7475c…
|
stephan
|
472 |
set cflags [exec pkg-config openssl --cflags-only-I] |
|
af7475c…
|
stephan
|
473 |
set ldflags [exec pkg-config openssl --libs-only-L] |
|
af7475c…
|
stephan
|
474 |
set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"] |
|
af7475c…
|
stephan
|
475 |
} msg |
|
af7475c…
|
stephan
|
476 |
if {!$found} { |
|
af7475c…
|
stephan
|
477 |
set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl \ |
|
af7475c…
|
stephan
|
478 |
/usr/pkg /usr/local /usr /usr/local/opt/openssl \ |
|
af7475c…
|
stephan
|
479 |
/opt/homebrew/opt/openssl" |
|
af7475c…
|
stephan
|
480 |
} |
|
af7475c…
|
stephan
|
481 |
} |
|
af7475c…
|
stephan
|
482 |
if {!$found} { |
|
af7475c…
|
stephan
|
483 |
foreach dir $ssldirs { |
|
af7475c…
|
stephan
|
484 |
if {$dir eq ""} { |
|
af7475c…
|
stephan
|
485 |
set msg "system openssl" |
|
af7475c…
|
stephan
|
486 |
set cflags "" |
|
af7475c…
|
stephan
|
487 |
set ldflags "" |
|
af7475c…
|
stephan
|
488 |
} else { |
|
af7475c…
|
stephan
|
489 |
set msg "openssl in $dir" |
|
af7475c…
|
stephan
|
490 |
set cflags "-I$dir/include" |
|
af7475c…
|
stephan
|
491 |
if {[file readable $dir/libssl.a]} { |
|
af7475c…
|
stephan
|
492 |
set ldflags -L$dir |
|
af7475c…
|
stephan
|
493 |
} elseif {[file readable $dir/lib/libssl.a]} { |
|
af7475c…
|
stephan
|
494 |
set ldflags -L$dir/lib |
|
af7475c…
|
stephan
|
495 |
} elseif {[file isdir $dir/lib]} { |
|
af7475c…
|
stephan
|
496 |
set ldflags "-L$dir -L$dir/lib" |
|
af7475c…
|
stephan
|
497 |
} else { |
|
af7475c…
|
stephan
|
498 |
set ldflags -L$dir |
|
af7475c…
|
stephan
|
499 |
} |
|
af7475c…
|
stephan
|
500 |
} |
|
af7475c…
|
stephan
|
501 |
if {[check-for-openssl $msg "$cflags $ldflags"]} { |
|
af7475c…
|
stephan
|
502 |
incr found |
|
af7475c…
|
stephan
|
503 |
break |
|
af7475c…
|
stephan
|
504 |
} |
|
af7475c…
|
stephan
|
505 |
if {$dir ne ""} { |
|
af7475c…
|
stephan
|
506 |
set ldflags "" |
|
af7475c…
|
stephan
|
507 |
set msg "static build of openssl in $dir" |
|
af7475c…
|
stephan
|
508 |
set ssllibs "$dir/libssl.a $dir/libcrypto.a -lpthread" |
|
af7475c…
|
stephan
|
509 |
if {[check-for-openssl $msg "$cflags $ldflags" $ssllibs]} { |
|
af7475c…
|
stephan
|
510 |
incr found |
|
af7475c…
|
stephan
|
511 |
break |
|
af7475c…
|
stephan
|
512 |
} |
|
8d3b9bf…
|
drh
|
513 |
# This test should arguably fail here if --with-openssl=X |
|
8d3b9bf…
|
drh
|
514 |
# points to an invalid X. |
|
af7475c…
|
stephan
|
515 |
} |
|
af7475c…
|
stephan
|
516 |
} |
|
af7475c…
|
stephan
|
517 |
} |
|
af7475c…
|
stephan
|
518 |
} |
|
af7475c…
|
stephan
|
519 |
if {$found} { |
|
af7475c…
|
stephan
|
520 |
define FOSSIL_ENABLE_SSL |
|
af7475c…
|
stephan
|
521 |
define-append EXTRA_CFLAGS $cflags |
|
af7475c…
|
stephan
|
522 |
define-append EXTRA_LDFLAGS $ldflags |
|
af7475c…
|
stephan
|
523 |
if {[info exists ssllibs]} { |
|
af7475c…
|
stephan
|
524 |
define-append LIBS $ssllibs |
|
af7475c…
|
stephan
|
525 |
} else { |
|
af7475c…
|
stephan
|
526 |
define-append LIBS -lssl -lcrypto |
|
af7475c…
|
stephan
|
527 |
} |
|
af7475c…
|
stephan
|
528 |
if {[info exists ::zlib_lib]} { |
|
af7475c…
|
stephan
|
529 |
define-append LIBS $::zlib_lib |
|
af7475c…
|
stephan
|
530 |
} |
|
af7475c…
|
stephan
|
531 |
if {[is_mingw]} { |
|
af7475c…
|
stephan
|
532 |
define-append LIBS -lgdi32 -lwsock32 -lcrypt32 |
|
af7475c…
|
stephan
|
533 |
} |
|
af7475c…
|
stephan
|
534 |
msg-result "HTTPS support enabled" |
|
af7475c…
|
stephan
|
535 |
|
|
af7475c…
|
stephan
|
536 |
# Silence OpenSSL deprecation warnings on Mac OS X 10.7. |
|
af7475c…
|
stephan
|
537 |
if {[string match *-darwin* [get-define host]]} { |
|
af7475c…
|
stephan
|
538 |
if {[cctest -cflags {-Wdeprecated-declarations}]} { |
|
af7475c…
|
stephan
|
539 |
define-append EXTRA_CFLAGS -Wdeprecated-declarations |
|
af7475c…
|
stephan
|
540 |
} |
|
af7475c…
|
stephan
|
541 |
} |
|
af7475c…
|
stephan
|
542 |
} else { |
|
af7475c…
|
stephan
|
543 |
user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support" |
|
af7475c…
|
stephan
|
544 |
} |
|
af7475c…
|
stephan
|
545 |
} else { |
|
af7475c…
|
stephan
|
546 |
if {[info exists ::zlib_lib]} { |
|
af7475c…
|
stephan
|
547 |
define-append LIBS $::zlib_lib |
|
af7475c…
|
stephan
|
548 |
} |
|
af7475c…
|
stephan
|
549 |
} |
|
af7475c…
|
stephan
|
550 |
}; # handle-with-openssl |
|
af7475c…
|
stephan
|
551 |
|
|
d84494f…
|
stephan
|
552 |
# |
|
d84494f…
|
stephan
|
553 |
# CFLAGS_INCLUDE is ONLY for -I... flags and their order is |
|
d84494f…
|
stephan
|
554 |
# significant so that --with-sqlite=PATH's header can shadow our |
|
d84494f…
|
stephan
|
555 |
# own. <s>One caveat with this is that we cannot point |
|
d84494f…
|
stephan
|
556 |
# --with-sqlite=PATH to the root of sqlite3's own build tree because |
|
d84494f…
|
stephan
|
557 |
# that dir has a config.h which ends up shadowing src/config.h, |
|
d84494f…
|
stephan
|
558 |
# breaking our build.</s> (That is no longer true: that that config.h |
|
d84494f…
|
stephan
|
559 |
# was renamed to sqlite_cfg.h at some point.) |
|
d84494f…
|
stephan
|
560 |
# |
|
d84494f…
|
stephan
|
561 |
define CFLAGS_INCLUDE {} |
|
d84494f…
|
stephan
|
562 |
|
|
31d431e…
|
stephan
|
563 |
######################################################################## |
|
31d431e…
|
stephan
|
564 |
# --with-sqlite=PATH checks for the first it finds of the following... |
|
31d431e…
|
stephan
|
565 |
# - PATH/sqlite3.c and PATH/sqlite3.h |
|
31d431e…
|
stephan
|
566 |
# - PATH/sqlite3.o (and assumes sqlite3.h is with it) |
|
31d431e…
|
stephan
|
567 |
# - PATH/lib/libsqlite3* and PATH/include/sqlite3.h |
|
d84494f…
|
stephan
|
568 |
proc handle-with-sqlite {} { |
|
d84494f…
|
stephan
|
569 |
set sq3path [opt-val with-sqlite] |
|
d84494f…
|
stephan
|
570 |
define SQLITE3_SRC.2 {} |
|
d84494f…
|
stephan
|
571 |
define SQLITE3_OBJ.2 {} |
|
d84494f…
|
stephan
|
572 |
define SQLITE3_SHELL_SRC.2 {$(SQLITE3_SHELL_SRC.0)} |
|
d84494f…
|
stephan
|
573 |
if {$sq3path in {tree ""}} { |
|
d84494f…
|
stephan
|
574 |
msg-result "Using sqlite3.c from this source tree." |
|
d84494f…
|
stephan
|
575 |
} else { |
|
d84494f…
|
stephan
|
576 |
# SQLITE3_ORIGIN: |
|
d84494f…
|
stephan
|
577 |
# 0 = local source tree |
|
d84494f…
|
stephan
|
578 |
# 1 = use external lib or sqlite3.o |
|
d84494f…
|
stephan
|
579 |
# 2 = use external sqlite3.c and (if found) shell.c |
|
d84494f…
|
stephan
|
580 |
define USE_SYSTEM_SQLITE 1 |
|
d84494f…
|
stephan
|
581 |
define SQLITE3_ORIGIN 2 |
|
d84494f…
|
stephan
|
582 |
if {$sq3path != "auto"} { |
|
d84494f…
|
stephan
|
583 |
if {([file exists $sq3path/sqlite3.c]) && |
|
d84494f…
|
stephan
|
584 |
([file exists $sq3path/sqlite3.h]) } { |
|
d84494f…
|
stephan
|
585 |
# Prefer sqlite3.[ch] if found. |
|
d84494f…
|
stephan
|
586 |
define SQLITE3_SRC.2 $sq3path/sqlite3.c |
|
d84494f…
|
stephan
|
587 |
define SQLITE3_OBJ.2 {$(SQLITE3_OBJ.0)} |
|
d84494f…
|
stephan
|
588 |
define USE_SYSTEM_SQLITE 2 |
|
d84494f…
|
stephan
|
589 |
define SQLITE3_ORIGIN 2 |
|
d84494f…
|
stephan
|
590 |
if {[file exists $sq3path/shell.c]} { |
|
d84494f…
|
stephan
|
591 |
define SQLITE3_SHELL_SRC.2 $sq3path/shell.c |
|
d84494f…
|
stephan
|
592 |
} |
|
d84494f…
|
stephan
|
593 |
define-append CFLAGS_INCLUDE -I$sq3path |
|
d84494f…
|
stephan
|
594 |
define-append EXTRA_LDFLAGS -lpthread |
|
d84494f…
|
stephan
|
595 |
# ^^^ additional -lXXX flags are conservative estimates |
|
d84494f…
|
stephan
|
596 |
msg-result "Using sqlite3.c and sqlite3.h from $sq3path" |
|
d84494f…
|
stephan
|
597 |
} elseif {[file exists $sq3path/sqlite3.o]} { |
|
d84494f…
|
stephan
|
598 |
# Use sqlite3.o if found. |
|
d84494f…
|
stephan
|
599 |
define SQLITE3_OBJ.2 $sq3path/sqlite3.o |
|
d84494f…
|
stephan
|
600 |
define-append CFLAGS_INCLUDE -I$sq3path |
|
d84494f…
|
stephan
|
601 |
define-append EXTRA_LDFLAGS $sq3path/sqlite3.o -lpthread |
|
d84494f…
|
stephan
|
602 |
# ^^^ additional -lXXX flags are conservative estimates |
|
d84494f…
|
stephan
|
603 |
msg-result "Using sqlite3.o from $sq3path" |
|
d84494f…
|
stephan
|
604 |
} elseif { ([llength [glob -nocomplain -directory $sq3path/lib libsqlite3*]] != 0) \ |
|
d84494f…
|
stephan
|
605 |
&& ([file exists $sq3path/include/sqlite3.h]) } { |
|
d84494f…
|
stephan
|
606 |
# e.g. --with-sqlite=/usr/local. Try $sq3path/lib/libsqlite3* |
|
d84494f…
|
stephan
|
607 |
# and $sq3path/include/sqlite3.h |
|
d84494f…
|
stephan
|
608 |
define-append CFLAGS_INCLUDE -I$sq3path/include |
|
d84494f…
|
stephan
|
609 |
define-append EXTRA_LDFLAGS -L$sq3path/lib -lsqlite3 -lpthread |
|
d84494f…
|
stephan
|
610 |
# ^^^ additional -lXXX flags are conservative estimates |
|
d84494f…
|
stephan
|
611 |
msg-result "Using -lsqlite3 from $sq3path" |
|
d84494f…
|
stephan
|
612 |
} else { |
|
d84494f…
|
stephan
|
613 |
# Assume $sq3path holds both the lib and header |
|
d84494f…
|
stephan
|
614 |
cc-with [list -cflags "-I$sq3path -L$sq3path"] |
|
d84494f…
|
stephan
|
615 |
define-append CFLAGS_INCLUDE -I$sq3path |
|
d84494f…
|
stephan
|
616 |
define-append EXTRA_LDFLAGS -L$sq3path -lsqlite3 -lpthread |
|
d84494f…
|
stephan
|
617 |
# ^^^ additional -lXXX flags are conservative estimates |
|
d84494f…
|
stephan
|
618 |
msg-result "Using -lsqlite3 from $sq3path" |
|
d84494f…
|
stephan
|
619 |
} |
|
d84494f…
|
stephan
|
620 |
} elseif {![cc-check-includes sqlite3.h] || ![check-function-in-lib sqlite3_open_v2 sqlite3]} { |
|
d84494f…
|
stephan
|
621 |
user-error "libsqlite3 not found please install it or specify the location with --with-sqlite" |
|
d84494f…
|
stephan
|
622 |
} |
|
d84494f…
|
stephan
|
623 |
} |
|
d84494f…
|
stephan
|
624 |
}; # handle-with-sqlite |
|
d84494f…
|
stephan
|
625 |
handle-with-sqlite |
|
d84494f…
|
stephan
|
626 |
define-append CFLAGS_INCLUDE {-I. -I$(SRCDIR) -I$(SRCDIR_extsrc)}; # must be after handle-with-sqlite |
|
d84494f…
|
stephan
|
627 |
|
|
d84494f…
|
stephan
|
628 |
# |
|
d84494f…
|
stephan
|
629 |
# Handle the --with-tcl flag. |
|
d84494f…
|
stephan
|
630 |
# |
|
d84494f…
|
stephan
|
631 |
proc handle-with-tcl {} { |
|
7a43dcb…
|
jan.nijtmans
|
632 |
global v |
|
d84494f…
|
stephan
|
633 |
set tclpath [opt-val with-tcl] |
|
d84494f…
|
stephan
|
634 |
if {$tclpath eq ""} { |
|
d84494f…
|
stephan
|
635 |
return |
|
d84494f…
|
stephan
|
636 |
} |
|
a76b48c…
|
stephan
|
637 |
set tclprivatestubs [opt-bool with-tcl-private-stubs] |
|
a76b48c…
|
stephan
|
638 |
# Note parse-tclconfig-sh is in autosetup/local.tcl |
|
a76b48c…
|
stephan
|
639 |
if {$tclpath eq "1"} { |
|
7a43dcb…
|
jan.nijtmans
|
640 |
if {$v >= 9.0} { |
|
7a43dcb…
|
jan.nijtmans
|
641 |
set tcldir [file dirname $::autosetup(dir)]/compat/tcl-9.0 |
|
7a43dcb…
|
jan.nijtmans
|
642 |
} else { |
|
7a43dcb…
|
jan.nijtmans
|
643 |
set tcldir [file dirname $::autosetup(dir)]/compat/tcl-8.6 |
|
7a43dcb…
|
jan.nijtmans
|
644 |
} |
|
a76b48c…
|
stephan
|
645 |
if {$tclprivatestubs} { |
|
a76b48c…
|
stephan
|
646 |
set tclconfig(TCL_INCLUDE_SPEC) -I$tcldir/generic |
|
a76b48c…
|
stephan
|
647 |
set tclconfig(TCL_VERSION) {Private Stubs} |
|
a76b48c…
|
stephan
|
648 |
set tclconfig(TCL_PATCH_LEVEL) {} |
|
a76b48c…
|
stephan
|
649 |
set tclconfig(TCL_PREFIX) $tcldir |
|
a76b48c…
|
stephan
|
650 |
set tclconfig(TCL_LD_FLAGS) { } |
|
a76b48c…
|
stephan
|
651 |
} else { |
|
a76b48c…
|
stephan
|
652 |
# Use the system Tcl. Look in some likely places. |
|
a76b48c…
|
stephan
|
653 |
array set tclconfig [parse-tclconfig-sh \ |
|
d84494f…
|
stephan
|
654 |
$tcldir/unix $tcldir/win \ |
|
d84494f…
|
stephan
|
655 |
/usr /usr/local /usr/share /opt/local] |
|
a76b48c…
|
stephan
|
656 |
set msg "on your system" |
|
a76b48c…
|
stephan
|
657 |
} |
|
a76b48c…
|
stephan
|
658 |
} else { |
|
a76b48c…
|
stephan
|
659 |
array set tclconfig [parse-tclconfig-sh $tclpath] |
|
a76b48c…
|
stephan
|
660 |
set msg "at $tclpath" |
|
a76b48c…
|
stephan
|
661 |
} |
|
a76b48c…
|
stephan
|
662 |
if {[opt-bool static]} { |
|
a76b48c…
|
stephan
|
663 |
set tclconfig(TCL_LD_FLAGS) { } |
|
a76b48c…
|
stephan
|
664 |
} |
|
a76b48c…
|
stephan
|
665 |
if {![info exists tclconfig(TCL_INCLUDE_SPEC)]} { |
|
a76b48c…
|
stephan
|
666 |
user-error "Cannot find Tcl $msg" |
|
a76b48c…
|
stephan
|
667 |
} |
|
a76b48c…
|
stephan
|
668 |
set tclstubs [opt-bool with-tcl-stubs] |
|
a76b48c…
|
stephan
|
669 |
if {$tclprivatestubs} { |
|
a76b48c…
|
stephan
|
670 |
define FOSSIL_ENABLE_TCL_PRIVATE_STUBS |
|
a76b48c…
|
stephan
|
671 |
define USE_TCL_STUBS |
|
a76b48c…
|
stephan
|
672 |
} elseif {$tclstubs && $tclconfig(TCL_SUPPORTS_STUBS)} { |
|
a76b48c…
|
stephan
|
673 |
set libs "$tclconfig(TCL_STUB_LIB_SPEC)" |
|
a76b48c…
|
stephan
|
674 |
define FOSSIL_ENABLE_TCL_STUBS |
|
a76b48c…
|
stephan
|
675 |
define USE_TCL_STUBS |
|
a76b48c…
|
stephan
|
676 |
} else { |
|
a76b48c…
|
stephan
|
677 |
set libs "$tclconfig(TCL_LIB_SPEC) $tclconfig(TCL_LIBS)" |
|
a76b48c…
|
stephan
|
678 |
} |
|
a76b48c…
|
stephan
|
679 |
set cflags $tclconfig(TCL_INCLUDE_SPEC) |
|
a76b48c…
|
stephan
|
680 |
if {!$tclprivatestubs} { |
|
a76b48c…
|
stephan
|
681 |
set foundtcl 0; # Did we find a working Tcl library? |
|
a76b48c…
|
stephan
|
682 |
cc-with [list -cflags $cflags -libs $libs] { |
|
a76b48c…
|
stephan
|
683 |
if {$tclstubs} { |
|
a76b48c…
|
stephan
|
684 |
if {[cc-check-functions Tcl_InitStubs]} { |
|
a76b48c…
|
stephan
|
685 |
set foundtcl 1 |
|
a76b48c…
|
stephan
|
686 |
} |
|
a76b48c…
|
stephan
|
687 |
} else { |
|
a76b48c…
|
stephan
|
688 |
if {[cc-check-functions Tcl_CreateInterp]} { |
|
a76b48c…
|
stephan
|
689 |
set foundtcl 1 |
|
a76b48c…
|
stephan
|
690 |
} |
|
a76b48c…
|
stephan
|
691 |
} |
|
a76b48c…
|
stephan
|
692 |
} |
|
a76b48c…
|
stephan
|
693 |
if {!$foundtcl && [string match *-lieee* $libs]} { |
|
a76b48c…
|
stephan
|
694 |
# On some systems, using "-lieee" from TCL_LIB_SPEC appears |
|
a76b48c…
|
stephan
|
695 |
# to cause issues. |
|
a76b48c…
|
stephan
|
696 |
msg-result "Removing \"-lieee\" and retrying for Tcl..." |
|
a76b48c…
|
stephan
|
697 |
set libs [string map [list -lieee ""] $libs] |
|
a76b48c…
|
stephan
|
698 |
cc-with [list -cflags $cflags -libs $libs] { |
|
a76b48c…
|
stephan
|
699 |
if {$tclstubs} { |
|
a76b48c…
|
stephan
|
700 |
if {[cc-check-functions Tcl_InitStubs]} { |
|
a76b48c…
|
stephan
|
701 |
set foundtcl 1 |
|
a76b48c…
|
stephan
|
702 |
} |
|
a76b48c…
|
stephan
|
703 |
} else { |
|
a76b48c…
|
stephan
|
704 |
if {[cc-check-functions Tcl_CreateInterp]} { |
|
a76b48c…
|
stephan
|
705 |
set foundtcl 1 |
|
a76b48c…
|
stephan
|
706 |
} |
|
a76b48c…
|
stephan
|
707 |
} |
|
a76b48c…
|
stephan
|
708 |
} |
|
a76b48c…
|
stephan
|
709 |
} |
|
a76b48c…
|
stephan
|
710 |
if {!$foundtcl && ![string match *-lpthread* $libs]} { |
|
a76b48c…
|
stephan
|
711 |
# On some systems, TCL_LIB_SPEC appears to be missing |
|
a76b48c…
|
stephan
|
712 |
# "-lpthread". Try adding it. |
|
a76b48c…
|
stephan
|
713 |
msg-result "Adding \"-lpthread\" and retrying for Tcl..." |
|
a76b48c…
|
stephan
|
714 |
set libs "$libs -lpthread" |
|
a76b48c…
|
stephan
|
715 |
cc-with [list -cflags $cflags -libs $libs] { |
|
a76b48c…
|
stephan
|
716 |
if {$tclstubs} { |
|
a76b48c…
|
stephan
|
717 |
if {[cc-check-functions Tcl_InitStubs]} { |
|
a76b48c…
|
stephan
|
718 |
set foundtcl 1 |
|
a76b48c…
|
stephan
|
719 |
} |
|
a76b48c…
|
stephan
|
720 |
} else { |
|
a76b48c…
|
stephan
|
721 |
if {[cc-check-functions Tcl_CreateInterp]} { |
|
a76b48c…
|
stephan
|
722 |
set foundtcl 1 |
|
a76b48c…
|
stephan
|
723 |
} |
|
a76b48c…
|
stephan
|
724 |
} |
|
a76b48c…
|
stephan
|
725 |
} |
|
a76b48c…
|
stephan
|
726 |
} |
|
a76b48c…
|
stephan
|
727 |
if {!$foundtcl} { |
|
a76b48c…
|
stephan
|
728 |
if {$tclstubs} { |
|
a76b48c…
|
stephan
|
729 |
user-error "Cannot find a usable Tcl stubs library $msg" |
|
a76b48c…
|
stephan
|
730 |
} else { |
|
a76b48c…
|
stephan
|
731 |
user-error "Cannot find a usable Tcl library $msg" |
|
a76b48c…
|
stephan
|
732 |
} |
|
a76b48c…
|
stephan
|
733 |
} |
|
a76b48c…
|
stephan
|
734 |
} |
|
a76b48c…
|
stephan
|
735 |
set version $tclconfig(TCL_VERSION)$tclconfig(TCL_PATCH_LEVEL) |
|
a76b48c…
|
stephan
|
736 |
msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)" |
|
a76b48c…
|
stephan
|
737 |
if {!$tclprivatestubs} { |
|
a76b48c…
|
stephan
|
738 |
define-append LIBS $libs |
|
a76b48c…
|
stephan
|
739 |
} |
|
a76b48c…
|
stephan
|
740 |
define-append EXTRA_CFLAGS $cflags |
|
a76b48c…
|
stephan
|
741 |
define-append CFLAGS $cflags |
|
d84494f…
|
stephan
|
742 |
if {[info exists ::zlibpath] && $::zlibpath eq "tree"} { |
|
a76b48c…
|
stephan
|
743 |
# |
|
a76b48c…
|
stephan
|
744 |
# NOTE: When using zlib in the source tree, prevent Tcl from |
|
a76b48c…
|
stephan
|
745 |
# pulling in the system one. |
|
a76b48c…
|
stephan
|
746 |
# |
|
a76b48c…
|
stephan
|
747 |
set tclconfig(TCL_LD_FLAGS) [string map [list -lz ""] \ |
|
d84494f…
|
stephan
|
748 |
$tclconfig(TCL_LD_FLAGS)] |
|
a76b48c…
|
stephan
|
749 |
} |
|
a76b48c…
|
stephan
|
750 |
# |
|
a76b48c…
|
stephan
|
751 |
# NOTE: Remove "-ldl" from the TCL_LD_FLAGS because it will be |
|
a76b48c…
|
stephan
|
752 |
# be checked for near the bottom of this file. |
|
a76b48c…
|
stephan
|
753 |
# |
|
a76b48c…
|
stephan
|
754 |
set tclconfig(TCL_LD_FLAGS) [string map [list -ldl ""] \ |
|
d84494f…
|
stephan
|
755 |
$tclconfig(TCL_LD_FLAGS)] |
|
a76b48c…
|
stephan
|
756 |
define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS) |
|
a76b48c…
|
stephan
|
757 |
define FOSSIL_ENABLE_TCL |
|
d84494f…
|
stephan
|
758 |
}; # handle-with-tcl |
|
d84494f…
|
stephan
|
759 |
handle-with-tcl |
|
f476744…
|
drh
|
760 |
|
|
f476744…
|
drh
|
761 |
# Network functions require libraries on some systems |
|
f476744…
|
drh
|
762 |
cc-check-function-in-lib gethostbyname nsl |
|
f476744…
|
drh
|
763 |
if {![cc-check-function-in-lib socket {socket network}]} { |
|
a76b48c…
|
stephan
|
764 |
# Last resort, may be Windows |
|
a76b48c…
|
stephan
|
765 |
if {[is_mingw]} { |
|
a76b48c…
|
stephan
|
766 |
define-append LIBS -lwsock32 |
|
a76b48c…
|
stephan
|
767 |
} |
|
71c298f…
|
wyoung
|
768 |
} |
|
3bff7b9…
|
drh
|
769 |
|
|
3bff7b9…
|
drh
|
770 |
# Some systems (ex: SunOS) require -lrt in order to use nanosleep |
|
3bff7b9…
|
drh
|
771 |
cc-check-function-in-lib nanosleep rt |
|
71c298f…
|
wyoung
|
772 |
|
|
71c298f…
|
wyoung
|
773 |
# The SMTP module requires special libraries and headers for MX DNS |
|
71c298f…
|
wyoung
|
774 |
# record lookups and such. |
|
71c298f…
|
wyoung
|
775 |
cc-check-includes arpa/nameser.h |
|
71c298f…
|
wyoung
|
776 |
cc-include-needs bind/resolv.h netinet/in.h |
|
71c298f…
|
wyoung
|
777 |
cc-check-includes bind/resolv.h |
|
71c298f…
|
wyoung
|
778 |
cc-check-includes resolv.h |
|
71c298f…
|
wyoung
|
779 |
if { !(([cc-check-function-in-lib dn_expand resolv] || |
|
71c298f…
|
wyoung
|
780 |
[cc-check-function-in-lib ns_name_uncompress {bind resolv}] || |
|
71c298f…
|
wyoung
|
781 |
[cc-check-function-in-lib __ns_name_uncompress {bind resolv}]) && |
|
71c298f…
|
wyoung
|
782 |
([cc-check-function-in-lib ns_parserr {bind resolv}] || |
|
71c298f…
|
wyoung
|
783 |
[cc-check-function-in-lib __ns_parserr {bind resolv}]) && |
|
71c298f…
|
wyoung
|
784 |
([cc-check-function-in-lib res_query {bind resolv}] || |
|
71c298f…
|
wyoung
|
785 |
[cc-check-function-in-lib __res_query {bind resolv}]))} { |
|
a76b48c…
|
stephan
|
786 |
msg-result "WARNING: SMTP feature will not be able to look up local MX." |
|
7023de9…
|
jan.nijtmans
|
787 |
} |
|
71c298f…
|
wyoung
|
788 |
cc-check-function-in-lib res_9_ns_initparse resolv |
|
71c298f…
|
wyoung
|
789 |
|
|
71c298f…
|
wyoung
|
790 |
# Other nonstandard function checks |
|
16f1076…
|
jan.nijtmans
|
791 |
cc-check-functions utime |
|
16f1076…
|
jan.nijtmans
|
792 |
cc-check-functions usleep |
|
9a9ef1d…
|
jan.nijtmans
|
793 |
cc-check-functions strchrnul |
|
64def88…
|
drh
|
794 |
cc-check-functions pledge |
|
a8d220b…
|
drh
|
795 |
cc-check-functions backtrace |
|
a8d220b…
|
drh
|
796 |
|
|
f2aa77c…
|
danield
|
797 |
# Termux on Android adds "getpass(char *)" to unistd.h, so check this so we |
|
a3843d4…
|
stephan
|
798 |
# guard against including it again; use cctest as cc-check-functions and |
|
f2aa77c…
|
danield
|
799 |
# cctest_function check for "getpass()" with no args and fail |
|
f2aa77c…
|
danield
|
800 |
if {[cctest -link 1 -includes {unistd.h} -code "getpass(0);"]} { |
|
a76b48c…
|
stephan
|
801 |
define FOSSIL_HAVE_GETPASS 1 |
|
a76b48c…
|
stephan
|
802 |
msg-result "Found getpass() with unistd.h" |
|
f2aa77c…
|
danield
|
803 |
} |
|
f2aa77c…
|
danield
|
804 |
|
|
7023de9…
|
jan.nijtmans
|
805 |
# Check for getloadavg(), and if it doesn't exist, define FOSSIL_OMIT_LOAD_AVERAGE |
|
50ba8d8…
|
danield
|
806 |
if {![cc-check-functions getloadavg] || |
|
50ba8d8…
|
danield
|
807 |
![cctest -link 1 -includes {unistd.h} -code "double a\[3\]; getloadavg(a,3);"]} { |
|
7023de9…
|
jan.nijtmans
|
808 |
define FOSSIL_OMIT_LOAD_AVERAGE 1 |
|
166fa7e…
|
mistachkin
|
809 |
msg-result "Load average support unavailable" |
|
7023de9…
|
jan.nijtmans
|
810 |
} |
|
f476744…
|
drh
|
811 |
|
|
f476744…
|
drh
|
812 |
# Check for getpassphrase() for Solaris 10 where getpass() truncates to 10 chars |
|
f476744…
|
drh
|
813 |
if {![cc-check-functions getpassphrase]} { |
|
a76b48c…
|
stephan
|
814 |
# Haiku needs this |
|
a76b48c…
|
stephan
|
815 |
cc-check-function-in-lib getpass bsd |
|
4bf670e…
|
drh
|
816 |
} |
|
4bf670e…
|
drh
|
817 |
|
|
4bf670e…
|
drh
|
818 |
# Check for the FuseFS library |
|
4bf670e…
|
drh
|
819 |
if {[opt-bool fusefs]} { |
|
6f9d265…
|
drh
|
820 |
if {[opt-bool static]} { |
|
a76b48c…
|
stephan
|
821 |
msg-result "FuseFS support disabled due to -static" |
|
6f9d265…
|
drh
|
822 |
} elseif {[cc-check-function-in-lib fuse_mount fuse]} { |
|
a76b48c…
|
stephan
|
823 |
define-append EXTRA_CFLAGS -DFOSSIL_HAVE_FUSEFS |
|
a76b48c…
|
stephan
|
824 |
define FOSSIL_HAVE_FUSEFS 1 |
|
a76b48c…
|
stephan
|
825 |
msg-result "FuseFS support enabled" |
|
91f0f00…
|
mark
|
826 |
} |
|
91f0f00…
|
mark
|
827 |
} |
|
91f0f00…
|
mark
|
828 |
|
|
91f0f00…
|
mark
|
829 |
######################################################################## |
|
bb66461…
|
stephan
|
830 |
# Checks the compiler for compile_commands.json support. |
|
91f0f00…
|
mark
|
831 |
# |
|
91f0f00…
|
mark
|
832 |
# Returns 1 if supported, else 0. Defines MAKE_COMPILATION_DB to "yes" |
|
91f0f00…
|
mark
|
833 |
# if supported, "no" if not. |
|
5cf0da6…
|
stephan
|
834 |
proc check-compile-commands {} { |
|
a76b48c…
|
stephan
|
835 |
msg-checking "compile_commands.json support... " |
|
a76b48c…
|
stephan
|
836 |
if {[cctest -lang c -cflags {/dev/null -MJ} -source {}]} { |
|
a76b48c…
|
stephan
|
837 |
# This test reportedly incorrectly succeeds on one of |
|
a76b48c…
|
stephan
|
838 |
# Martin G.'s older systems. |
|
a76b48c…
|
stephan
|
839 |
msg-result "compiler supports compile_commands.json" |
|
a76b48c…
|
stephan
|
840 |
define MAKE_COMPILATION_DB yes |
|
a76b48c…
|
stephan
|
841 |
return 1 |
|
a76b48c…
|
stephan
|
842 |
} else { |
|
a76b48c…
|
stephan
|
843 |
msg-result "compiler does not support compile_commands.json" |
|
a76b48c…
|
stephan
|
844 |
define MAKE_COMPILATION_DB no |
|
a76b48c…
|
stephan
|
845 |
return 0 |
|
a76b48c…
|
stephan
|
846 |
} |
|
5cf0da6…
|
stephan
|
847 |
} |
|
5cf0da6…
|
stephan
|
848 |
|
|
5cf0da6…
|
stephan
|
849 |
define MAKE_COMPILATION_DB no |
|
5cf0da6…
|
stephan
|
850 |
if {!$outOfTreeBuild} { |
|
5cf0da6…
|
stephan
|
851 |
if {[opt-bool compile-commands]} { |
|
5cf0da6…
|
stephan
|
852 |
check-compile-commands |
|
5cf0da6…
|
stephan
|
853 |
} else { |
|
5cf0da6…
|
stephan
|
854 |
puts "Use --compile-commands to enable check for compile-commands-capable compiler." |
|
5cf0da6…
|
stephan
|
855 |
} |
|
5cf0da6…
|
stephan
|
856 |
} else { |
|
35f3e5b…
|
stephan
|
857 |
puts "Disabling compile_commands.json check for out-of-tree build." |
|
35f3e5b…
|
stephan
|
858 |
# This is an attempt to resolve the problem reported at |
|
35f3e5b…
|
stephan
|
859 |
# https://fossil-scm.org/forum/forumpost/d19061d09a8179d0 |
|
35f3e5b…
|
stephan
|
860 |
} |
|
231d693…
|
drh
|
861 |
|
|
231d693…
|
drh
|
862 |
# Add -fsanitize compile and link options late: we don't want the C |
|
231d693…
|
drh
|
863 |
# checks above to run with those sanitizers enabled. It can not only |
|
231d693…
|
drh
|
864 |
# be pointless, it can actually break correct tests. |
|
231d693…
|
drh
|
865 |
set fsan [opt-val with-sanitizer] |
|
231d693…
|
drh
|
866 |
if {[string length $fsan]} { |
|
a76b48c…
|
stephan
|
867 |
define-append EXTRA_CFLAGS -fsanitize=$fsan |
|
a76b48c…
|
stephan
|
868 |
define-append EXTRA_LDFLAGS -fsanitize=$fsan |
|
a76b48c…
|
stephan
|
869 |
if {[string first "undefined" $fsan] != -1} { |
|
a76b48c…
|
stephan
|
870 |
# We need to link with libubsan if we're compiling under |
|
a76b48c…
|
stephan
|
871 |
# GCC with -fsanitize=undefined. |
|
a76b48c…
|
stephan
|
872 |
cc-check-function-in-lib __ubsan_handle_add_overflow ubsan |
|
a76b48c…
|
stephan
|
873 |
} |
|
a76b48c…
|
stephan
|
874 |
} |
|
a3843d4…
|
stephan
|
875 |
|
|
a3843d4…
|
stephan
|
876 |
######################################################################## |
|
a3843d4…
|
stephan
|
877 |
# @proj-check-emsdk |
|
a3843d4…
|
stephan
|
878 |
# |
|
a3843d4…
|
stephan
|
879 |
# Emscripten is used for doing in-tree builds of web-based WASM stuff, |
|
a3843d4…
|
stephan
|
880 |
# as opposed to WASI-based WASM or WASM binaries we import from other |
|
a3843d4…
|
stephan
|
881 |
# places. This is only set up for Unix-style OSes and is untested |
|
a3843d4…
|
stephan
|
882 |
# anywhere but Linux. Requires that the --with-emsdk flag be |
|
a3843d4…
|
stephan
|
883 |
# registered with autosetup. |
|
a3843d4…
|
stephan
|
884 |
# |
|
a3843d4…
|
stephan
|
885 |
# It looks for the SDK in the location specified by --with-emsdk. |
|
a3843d4…
|
stephan
|
886 |
# Values of "" or "auto" mean to check for the environment var EMSDK |
|
a3843d4…
|
stephan
|
887 |
# (which gets set by the emsdk_env.sh script from the SDK) or that |
|
a3843d4…
|
stephan
|
888 |
# same var passed to configure. |
|
a3843d4…
|
stephan
|
889 |
# |
|
a3843d4…
|
stephan
|
890 |
# If the given directory is found, it expects to find emsdk_env.sh in |
|
a3843d4…
|
stephan
|
891 |
# that directory, as well as the emcc compiler somewhere under there. |
|
a3843d4…
|
stephan
|
892 |
# |
|
a3843d4…
|
stephan
|
893 |
# If the --with-emsdk flag is explicitly provided and the SDK is not |
|
a3843d4…
|
stephan
|
894 |
# found then a fatal error is generated, otherwise failure to find the |
|
a3843d4…
|
stephan
|
895 |
# SDK is not fatal. |
|
a3843d4…
|
stephan
|
896 |
# |
|
a3843d4…
|
stephan
|
897 |
# Defines the following: |
|
a3843d4…
|
stephan
|
898 |
# |
|
a3843d4…
|
stephan
|
899 |
# - EMSDK_HOME = top dir of the emsdk or "". |
|
a3843d4…
|
stephan
|
900 |
# - EMSDK_ENV_SH = path to EMSDK_HOME/emsdk_env.sh or "" |
|
a3843d4…
|
stephan
|
901 |
# - BIN_EMCC = $EMSDK_HOME/upstream/emscripten/emcc or "" |
|
a3843d4…
|
stephan
|
902 |
# - HAVE_EMSDK = 0 or 1 (this function's return value) |
|
a3843d4…
|
stephan
|
903 |
# |
|
a3843d4…
|
stephan
|
904 |
# Returns 1 if EMSDK_ENV_SH is found, else 0. If EMSDK_HOME is not empty |
|
a3843d4…
|
stephan
|
905 |
# but BIN_EMCC is then emcc was not found in the EMSDK_HOME, in which |
|
a3843d4…
|
stephan
|
906 |
# case we have to rely on the fact that sourcing $EMSDK_ENV_SH from a |
|
a3843d4…
|
stephan
|
907 |
# shell will add emcc to the $PATH. |
|
a3843d4…
|
stephan
|
908 |
proc proj-check-emsdk {} { |
|
a3843d4…
|
stephan
|
909 |
set emsdkHome [opt-val with-emsdk] |
|
a3843d4…
|
stephan
|
910 |
define EMSDK_HOME "" |
|
a3843d4…
|
stephan
|
911 |
define EMSDK_ENV_SH "" |
|
a3843d4…
|
stephan
|
912 |
define BIN_EMCC "" |
|
a3843d4…
|
stephan
|
913 |
set hadValue [llength $emsdkHome] |
|
a3843d4…
|
stephan
|
914 |
msg-checking "Emscripten SDK? " |
|
a3843d4…
|
stephan
|
915 |
if {$emsdkHome in {"" "auto"}} { |
|
a3843d4…
|
stephan
|
916 |
# Check the environment. $EMSDK gets set by sourcing emsdk_env.sh. |
|
a3843d4…
|
stephan
|
917 |
set emsdkHome [get-env EMSDK ""] |
|
a3843d4…
|
stephan
|
918 |
} |
|
a3843d4…
|
stephan
|
919 |
set rc 0 |
|
a3843d4…
|
stephan
|
920 |
if {$emsdkHome ne ""} { |
|
a3843d4…
|
stephan
|
921 |
define EMSDK_HOME $emsdkHome |
|
a3843d4…
|
stephan
|
922 |
set emsdkEnv "$emsdkHome/emsdk_env.sh" |
|
a3843d4…
|
stephan
|
923 |
if {[file exists $emsdkEnv]} { |
|
a3843d4…
|
stephan
|
924 |
msg-result "$emsdkHome" |
|
a3843d4…
|
stephan
|
925 |
define EMSDK_ENV_SH $emsdkEnv |
|
a3843d4…
|
stephan
|
926 |
set rc 1 |
|
a3843d4…
|
stephan
|
927 |
set emcc "$emsdkHome/upstream/emscripten/emcc" |
|
a3843d4…
|
stephan
|
928 |
if {[file exists $emcc]} { |
|
a3843d4…
|
stephan
|
929 |
define BIN_EMCC $emcc |
|
a3843d4…
|
stephan
|
930 |
} |
|
a3843d4…
|
stephan
|
931 |
} else { |
|
a3843d4…
|
stephan
|
932 |
msg-result "emsdk_env.sh not found in $emsdkHome" |
|
a3843d4…
|
stephan
|
933 |
} |
|
a3843d4…
|
stephan
|
934 |
} else { |
|
a3843d4…
|
stephan
|
935 |
msg-result "not found" |
|
a3843d4…
|
stephan
|
936 |
} |
|
a3843d4…
|
stephan
|
937 |
if {$hadValue && 0 == $rc} { |
|
a3843d4…
|
stephan
|
938 |
# Fail if it was explicitly requested but not found |
|
a3843d4…
|
stephan
|
939 |
proj-fatal "Cannot find the Emscripten SDK" |
|
a3843d4…
|
stephan
|
940 |
} |
|
a3843d4…
|
stephan
|
941 |
define HAVE_EMSDK $rc |
|
a3843d4…
|
stephan
|
942 |
return $rc |
|
a3843d4…
|
stephan
|
943 |
} |
|
a3843d4…
|
stephan
|
944 |
|
|
a3843d4…
|
stephan
|
945 |
if {[proj-check-emsdk]} { |
|
a3843d4…
|
stephan
|
946 |
define EMCC_WRAPPER $::autosetup(dir)/../tools/emcc.sh |
|
a3843d4…
|
stephan
|
947 |
define EMCC_OPT [get-env EMCC_OPT "-Oz"]; # optional flags to pass to emcc |
|
7fcb462…
|
stephan
|
948 |
make-template tools/emcc.sh.in |
|
7fcb462…
|
stephan
|
949 |
catch {exec chmod u+x tools/emcc.sh} |
|
7fcb462…
|
stephan
|
950 |
} else { |
|
7fcb462…
|
stephan
|
951 |
define EMCC_WRAPPER "" |
|
a3843d4…
|
stephan
|
952 |
define EMCC_OPT "" |
|
7fcb462…
|
stephan
|
953 |
catch {exec rm -f tools/emcc.sh} |
|
7fcb462…
|
stephan
|
954 |
} |
|
af7475c…
|
stephan
|
955 |
|
|
af7475c…
|
stephan
|
956 |
handle-with-openssl |
|
ea2fbaf…
|
stephan
|
957 |
|
|
ea2fbaf…
|
stephan
|
958 |
# Finally, append libraries that must be last. This matters more on some |
|
ea2fbaf…
|
stephan
|
959 |
# OSes than others, but is most broadly required for static linking. |
|
ea2fbaf…
|
stephan
|
960 |
if {[opt-bool static]} { |
|
ea2fbaf…
|
stephan
|
961 |
# Linux can only infer the dependency on pthread from OpenSSL when |
|
ea2fbaf…
|
stephan
|
962 |
# doing dynamic linkage. |
|
ea2fbaf…
|
stephan
|
963 |
define-append LIBS -lpthread |
|
ea2fbaf…
|
stephan
|
964 |
} |
|
8d3b9bf…
|
drh
|
965 |
|
|
8d3b9bf…
|
drh
|
966 |
apply {{} { |
|
374e73c…
|
stephan
|
967 |
# This started out as a workaround for getting the ordering of -ldl |
|
374e73c…
|
stephan
|
968 |
# correct in conjunction with openssl in some environments. Then it |
|
374e73c…
|
stephan
|
969 |
# evolved into a more generic preemptive portability workaround to |
|
374e73c…
|
stephan
|
970 |
# ensure that certain libraries are always appended to the global |
|
374e73c…
|
stephan
|
971 |
# LIBS list if they exist on the system. Based on a /chat discussion |
|
374e73c…
|
stephan
|
972 |
# on 2025-02-27 in the context of check-in [8d3b9bf4d4]. |
|
374e73c…
|
stephan
|
973 |
# |
|
374e73c…
|
stephan
|
974 |
# Note that [move-lib-to-end] and [lib-actually-exists] are in |
|
374e73c…
|
stephan
|
975 |
# autosetup/local.tcl. |
|
8d3b9bf…
|
drh
|
976 |
set libs [get-define LIBS] |
|
374e73c…
|
stephan
|
977 |
#puts "**** 1 LIBS: $libs" |
|
374e73c…
|
stephan
|
978 |
foreach ll {-ldl -lpthread -lm} { |
|
374e73c…
|
stephan
|
979 |
if {![move-lib-to-end $ll $libs libs]} { |
|
374e73c…
|
stephan
|
980 |
# $ll was not in the list |
|
374e73c…
|
stephan
|
981 |
if {[lib-actually-exists $ll]} { |
|
374e73c…
|
stephan
|
982 |
# Add it to the list "just in case." This will be a no-op on |
|
374e73c…
|
stephan
|
983 |
# systems where the lib is not actually used. |
|
374e73c…
|
stephan
|
984 |
lappend libs $ll |
|
374e73c…
|
stephan
|
985 |
} |
|
374e73c…
|
stephan
|
986 |
} |
|
374e73c…
|
stephan
|
987 |
} |
|
374e73c…
|
stephan
|
988 |
#puts "**** 2 LIBS: $libs" |
|
374e73c…
|
stephan
|
989 |
define LIBS [join $libs " "] |
|
8d3b9bf…
|
drh
|
990 |
}} |
|
b0c9c26…
|
wyoung
|
991 |
|
|
b0c9c26…
|
wyoung
|
992 |
# Tag container builds with a prefix of the checkin ID of the version |
|
b0c9c26…
|
wyoung
|
993 |
# of Fossil each one contains. This not only allows multiple images |
|
b0c9c26…
|
wyoung
|
994 |
# to coexist and multiple containers to be created unamgiguosly from |
|
b0c9c26…
|
wyoung
|
995 |
# them, it also changes the URL we fetch the source tarball from, so |
|
b0c9c26…
|
wyoung
|
996 |
# repeated builds of a given version generate and fetch the source |
|
b0c9c26…
|
wyoung
|
997 |
# tarball once only, keeping it in the local Docker/Podman cache. |
|
f938438…
|
wyoung
|
998 |
set ci [readfile "$::autosetup(srcdir)/manifest.uuid"] |
|
7ecd23e…
|
wyoung
|
999 |
define FOSSIL_CI_PFX [string range $ci 0 11] |
|
75f0294…
|
drh
|
1000 |
|
|
75f0294…
|
drh
|
1001 |
make-template Makefile.in |
|
f476744…
|
drh
|
1002 |
make-config-header autoconfig.h -auto {USE_* FOSSIL_*} |