Fossil SCM

fossil-scm / auto.def
Blame History Raw 398 lines
1
# System autoconfiguration. Try: ./configure --help
2
3
# This must be above "options" below because it implicitly brings in the
4
# default Autosetup options, things like --prefix.
5
use cc cc-lib local
6
7
options {
8
with-openssl:path|auto|tree|none
9
=> {Look for OpenSSL in the given path, automatically, in the source tree, or none}
10
with-zlib:path|auto|tree
11
=> {Look for zlib in the given path, automatically, or in the source tree}
12
with-sqlite:path|auto|tree
13
=> {Look for sqlite in the given path, automatically, or in the source tree.}
14
with-exec-rel-paths=0
15
=> {Enable relative paths for external diff/gdiff}
16
with-sanitizer: => {Build with C compiler's -fsanitize=LIST; e.g. address,enum,null,undefined}
17
with-th1-docs=0 => {Enable TH1 for embedded documentation pages}
18
with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages}
19
with-tcl:path => {Enable Tcl integration, with Tcl in the specified path}
20
with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
21
with-tcl-private-stubs=0
22
=> {Enable Tcl integration via private stubs mechanism}
23
with-mman=0 => {Enable use of POSIX memory APIs from "sys/mman.h"}
24
with-see=0 => {Enable the SQLite Encryption Extension (SEE)}
25
print-minimum-sqlite-version=0
26
=> {print the minimum SQLite version number required, and exit}
27
internal-sqlite=1 => {Don't use the internal SQLite, use the system one}
28
static=0 => {Link a static executable}
29
fusefs=1 => {Disable the Fuse Filesystem}
30
fossil-debug=0 => {Build with fossil debugging enabled}
31
no-opt=0 => {Build without optimization}
32
json=0 => {Build with fossil JSON API enabled}
33
with-emsdk:path => {Directory containing the Emscripten SDK}
34
compile-commands=0 =>
35
"Check for compile_commands.json support."
36
}
37
38
# Update the minimum required SQLite version number here, and also
39
# in src/main.c near the sqlite3_libversion_number() call. Take care
40
# that both places agree!
41
define MINIMUM_SQLITE_VERSION "3.54.0"
42
43
# This is useful for people wanting Fossil to use an external SQLite library
44
# to compare the one they have against the minimum required
45
if {[opt-bool print-minimum-sqlite-version]} {
46
puts [get-define MINIMUM_SQLITE_VERSION]
47
exit 0
48
}
49
50
# Space characters have never been allowed in either the source
51
# tree nor the build directory. But the resulting error messages
52
# could be confusing. The following checks make the reason for the
53
# failure clear.
54
#
55
set ::dirSrc $::autosetup(srcdir)
56
if {[string first " " $$::dirSrc] != -1} {
57
user-error "The pathname of the source tree\
58
may not contain space characters"
59
}
60
if {[string first " " $autosetup(builddir)] != -1} {
61
user-error "The pathname of the build directory\
62
may not contain space characters"
63
}
64
65
set outOfTreeBuild 0
66
if {![file exists fossil.1]} {
67
puts "This appears to be an out-of-tree build."
68
set outOfTreeBuild 1
69
}
70
71
# sqlite wants these types if possible
72
cc-with {-includes {stdint.h inttypes.h}} {
73
cc-check-types uint32_t uint16_t int16_t uint8_t
74
}
75
76
# Use pread/pwrite system calls in place of seek + read/write if possible
77
define USE_PREAD [cc-check-functions pread]
78
79
# If we have cscope here, we'll use it in the "tags" target
80
if {[cc-check-progs cscope]} {
81
define COLLECT_CSCOPE_DATA "cscope -bR $$::dirSrc/src/*.\[ch\]"
82
} else {
83
define COLLECT_CSCOPE_DATA ""
84
}
85
86
# Find tclsh for the test suite.
87
#
88
# We can't use jimsh for this: the test suite uses features of Tcl that
89
# Jim doesn't support, either statically or due to the way it's built by
90
# autosetup. For example, Jim supports `file normalize`, but only if
91
# you build it with HAVE_REALPATH, which won't ever be defined in this
92
# context because autosetup doesn't try to discover platform-specific
93
# details like that before it decides to build jimsh0. Besides which,
94
# autosetup won't build jimsh0 at all if it can find tclsh itself.
95
# Ironically, this means we may right now be running under either jimsh0
96
# or a version of tclsh that we find unsuitable below!
97
cc-check-progs tclsh
98
set hbtd /usr/local/Cellar/tcl-tk
99
if {[string equal false [get-define TCLSH]]} {
100
msg-result "WARNING: 'make test' will not run here."
101
set v 8.6
102
} else {
103
set v [exec sh -c "echo 'puts \$tcl_version' | tclsh"]
104
if {$v >= 8.6} {
105
msg-result "Found Tclsh version $v in the PATH."
106
define TCLSH tclsh
107
} elseif {[file isdirectory $hbtd]} {
108
# This is a macOS system with the Homebrew version of Tcl/Tk
109
# installed. Select the newest version. It won't normally be
110
# in the PATH to avoid shadowing /usr/bin/tclsh, and even if it
111
# were in the PATH, it's bad practice to put /usr/local/bin (the
112
# Homebrew default) ahead of /usr/bin, especially given that
113
# it's user-writeable by default with Homebrew. Thus, we can be
114
# pretty sure the only way to call it is with an absolute path.
115
set v [exec ls -tr $hbtd | tail -1]
116
set path "$hbtd/$v/bin/tclsh"
117
define TCLSH $path
118
msg-result "Using Homebrew Tcl/Tk version $path."
119
} else {
120
msg-result "WARNING: tclsh $v found; need >= 8.6 for 'make test'."
121
define TCLSH false ;# force "make test" failure via /usr/bin/false
122
}
123
}
124
125
define CFLAGS [get-env CFLAGS "-g -Os"]
126
define EXTRA_CFLAGS "-Wall"
127
define EXTRA_LDFLAGS ""
128
define USE_SYSTEM_SQLITE 0
129
define USE_LINENOISE 0
130
define USE_MMAN_H 0
131
define USE_SEE 0
132
define SQLITE3_ORIGIN 0
133
# SQLITE3_ORIGIN 0 = src/sqlite3, 1=src/sqlite3-see.c, 2=client-provided
134
define SQLITE_OPTIONS_EXT ""
135
# SQLITE_OPTIONS_EXT => build-dependent CFLAGS for sqlite3.c and shell.c
136
137
# Maintain the C89/C90-style order of variable declarations before statements.
138
# Check if the compiler supports the respective warning flag.
139
if {[cctest -cflags -Wdeclaration-after-statement]} {
140
define-append EXTRA_CFLAGS -Wdeclaration-after-statement
141
}
142
143
144
# This procedure is a customized version of "cc-check-function-in-lib",
145
# that does not modify the LIBS variable. Its use prevents prematurely
146
# pulling in libraries that will be added later anyhow (e.g. "-ldl").
147
proc check-function-in-lib {function libs {otherlibs {}}} {
148
if {[string length $otherlibs]} {
149
msg-checking "Checking for $function in $libs with $otherlibs..."
150
} else {
151
msg-checking "Checking for $function in $libs..."
152
}
153
set found 0
154
cc-with [list -libs $otherlibs] {
155
if {[cctest_function $function]} {
156
msg-result "none needed"
157
define lib_$function ""
158
incr found
159
} else {
160
foreach lib $libs {
161
cc-with [list -libs -l$lib] {
162
if {[cctest_function $function]} {
163
msg-result -l$lib
164
define lib_$function -l$lib
165
incr found
166
break
167
}
168
}
169
}
170
}
171
}
172
if {$found} {
173
define [feature-define-name $function]
174
} else {
175
msg-result "no"
176
}
177
return $found
178
}
179
180
if {![opt-bool internal-sqlite]} {
181
proc find_system_sqlite {} {
182
183
# On some systems (slackware), libsqlite3 requires -ldl to link. So
184
# search for the system SQLite once with -ldl, and once without. If
185
# the library can only be found with $extralibs set to -ldl, then
186
# the code below will append -ldl to LIBS.
187
#
188
foreach extralibs {{} {-ldl}} {
189
190
# Locate the system SQLite by searching for sqlite3_open(). Then check
191
# if sqlite3_stmt_isexplain can be found as well. If we can find open() but
192
# not stmt_isexplain(), then the system SQLite is too old to link against
193
# fossil.
194
#
195
if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
196
# Success. Update symbols and return.
197
#
198
define USE_SYSTEM_SQLITE 1
199
define-append LIBS -lsqlite3
200
define-append LIBS $extralibs
201
return
202
}
203
}
204
user-error "system sqlite3 not found"
205
}
206
207
find_system_sqlite
208
209
proc test_system_sqlite {} {
210
# Check compatibility of the system SQLite library by running the
211
# sqlcompttest.c program in the source tree passes
212
# MINIMUM_SQLITE_VERSION set at the top of this file to
213
# sqlcompttest.c
214
#
215
set cmdline {}
216
lappend cmdline {*}[get-define CCACHE]
217
lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS]
218
lappend cmdline $::dirSrc/tools/sqlcompattest.c
219
lappend cmdline -o conftest__
220
lappend cmdline {*}[get-define LDFLAGS]
221
lappend cmdline {*}[get-define LIBS]
222
set sqlite-version [string cat "-D MINIMUM_SQLITE_VERSION=" [get-define MINIMUM_SQLITE_VERSION]]
223
lappend cmdline {*}[set sqlite-version]
224
set ok 1
225
set err [catch {exec-with-stderr {*}$cmdline} result errinfo]
226
if {$err} {
227
configlog "Failed: [join $cmdline]"
228
if {[string length $result]>0} {configlog $result}
229
configlog "============"
230
set ok 0
231
} elseif {$::autosetup(debug)} {
232
configlog "Compiled OK: [join $cmdline]"
233
configlog "============"
234
}
235
if {!$ok} {
236
user-error "unable to compile SQLite compatibility test program"
237
}
238
set err [catch {exec-with-stderr ./conftest__} result errinfo]
239
if {[get-define build] eq [get-define host]} {
240
set err [catch {exec-with-stderr ./conftest__} result errinfo]
241
if {$err} {
242
user-error $result
243
}
244
}
245
file delete ./conftest__
246
}
247
test_system_sqlite
248
249
}
250
251
proc is_mingw {} {
252
return [expr {
253
[string match *mingw* [get-define host]] &&
254
![file exists "/dev/null"]
255
}]
256
}
257
258
if {[is_mingw]} {
259
define-append EXTRA_CFLAGS -DBROKEN_MINGW_CMDLINE
260
define-append LIBS -lkernel32 -lws2_32
261
} else {
262
#
263
# NOTE: All platforms except MinGW should use the linenoise
264
# package. It is currently unsupported on Win32.
265
#
266
define USE_LINENOISE 1
267
}
268
269
if {[string match *-solaris* [get-define host]]} {
270
define-append EXTRA_CFLAGS {-D__EXTENSIONS__}
271
}
272
273
if {[opt-bool fossil-debug]} {
274
define CFLAGS {-g -O0 -Wall}
275
define-append CFLAGS -DFOSSIL_DEBUG
276
msg-result "Debugging support enabled"
277
}
278
279
if {[opt-bool no-opt]} {
280
define CFLAGS {-g -O0 -Wall}
281
msg-result "Builting without compiler optimization"
282
if {[opt-bool fossil-debug]} {
283
define-append CFLAGS -DFOSSIL_DEBUG
284
}
285
}
286
287
if {[opt-bool with-mman]} {
288
define-append EXTRA_CFLAGS -DUSE_MMAN_H
289
define USE_MMAN_H 1
290
msg-result "Enabling \"sys/mman.h\" support"
291
}
292
293
if {[opt-bool with-see]} {
294
define-append EXTRA_CFLAGS -DUSE_SEE
295
define USE_SEE 1
296
define SQLITE3_ORIGIN 1
297
msg-result "Enabling encryption support"
298
}
299
300
if {[opt-bool json]} {
301
# Reminder/FIXME (stephan): FOSSIL_ENABLE_JSON
302
# is required in the CFLAGS because json*.c
303
# have #ifdef guards around the whole file without
304
# reading config.h first.
305
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_JSON
306
define FOSSIL_ENABLE_JSON
307
msg-result "JSON support enabled"
308
}
309
310
if {[opt-bool with-exec-rel-paths]} {
311
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_EXEC_REL_PATHS
312
define FOSSIL_ENABLE_EXEC_REL_PATHS
313
msg-result "Relative paths in external diff/gdiff enabled"
314
}
315
316
if {[opt-bool with-th1-docs]} {
317
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_DOCS
318
define FOSSIL_ENABLE_TH1_DOCS
319
msg-result "TH1 embedded documentation support enabled"
320
}
321
322
if {[opt-bool with-th1-hooks]} {
323
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_HOOKS
324
define FOSSIL_ENABLE_TH1_HOOKS
325
msg-result "TH1 hooks support enabled"
326
}
327
328
#if {[opt-bool markdown]} {
329
# # no-op. Markdown is now enabled by default.
330
# msg-result "Markdown support enabled"
331
#}
332
333
if {[opt-bool static]} {
334
# XXX: This will not work on all systems.
335
define-append EXTRA_LDFLAGS -static
336
msg-result "Trying to link statically"
337
} else {
338
define-append EXTRA_CFLAGS -DFOSSIL_DYNAMIC_BUILD=1
339
define FOSSIL_DYNAMIC_BUILD
340
}
341
342
# Check for libraries that need to be sorted out early
343
cc-check-function-in-lib iconv iconv
344
345
cc-check-function-in-lib sin m
346
cc-check-function-in-lib dlopen dl
347
348
# Helper for OpenSSL checking
349
proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto -lpthread}}} {
350
msg-checking "Checking for $msg..."
351
set rc 0
352
if {[is_mingw]} {
353
lappend libs -lgdi32 -lwsock32 -lcrypt32
354
}
355
if {[info exists ::zlib_lib]} {
356
lappend libs $::zlib_lib
357
}
358
msg-quiet cc-with [list -cflags $cflags -libs $libs] {
359
if {[cc-check-includes openssl/ssl.h] && \
360
[cc-check-functions SSL_new]} {
361
incr rc
362
}
363
}
364
if {!$rc && ![is_mingw]} {
365
# On some systems, OpenSSL appears to require -ldl to link.
366
lappend libs -ldl
367
msg-quiet cc-with [list -cflags $cflags -libs $libs] {
368
if {[cc-check-includes openssl/ssl.h] && \
369
[cc-check-functions SSL_new]} {
370
incr rc
371
}
372
}
373
}
374
if {$rc} {
375
msg-result "ok"
376
return 1
377
} else {
378
msg-result "no"
379
return 0
380
}
381
}
382
ime search path: $rv"
383
}
384
}
385
#
386
# Check for zlib, using the given location if specified
387
#
388
proc handle-zlib {} {
389
set ::zlibpath [opt-val with-zlib]; # used by downstream tcl tests
390
if {$::zlibpath eq "tree"} {
391
set ::zlibdir [file dirname $::autosetupif {![g-result "Found Tcl $v/libz.a
392
msg-result "Using zlib in source tree"
393
} else {
394
set cftry {""}
395
set ldtry {""}
396
if {$::zlibpath ni {auto ""}} {
397
lappend cftry "-I$::zlibpath"
398
lappend cftry "-I# Reverse the list of tests so we

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button