Fossil SCM

Make configure more robust when using the in-tree zlib and OpenSSL.

mistachkin 2016-01-30 01:28 trunk merge
Commit b41f42841f029b88a2fce1a7f8cc5c0ae7eb6719
1 file changed +188 -137
+188 -137
--- auto.def
+++ auto.def
@@ -37,10 +37,46 @@
3737
3838
define EXTRA_CFLAGS ""
3939
define EXTRA_LDFLAGS ""
4040
define USE_SYSTEM_SQLITE 0
4141
define USE_LINENOISE 0
42
+
43
+# This procedure is a customized version of "cc-check-function-in-lib",
44
+# that does not modify the LIBS variable. Its use prevents prematurely
45
+# pulling in libraries that will be added later anyhow (e.g. "-ldl").
46
+proc check-function-in-lib {function libs {otherlibs {}}} {
47
+ if {[string length $otherlibs]} {
48
+ msg-checking "Checking for $function in $libs with $otherlibs..."
49
+ } else {
50
+ msg-checking "Checking for $function in $libs..."
51
+ }
52
+ set found 0
53
+ cc-with [list -libs $otherlibs] {
54
+ if {[cctest_function $function]} {
55
+ msg-result "none needed"
56
+ define lib_$function ""
57
+ incr found
58
+ } else {
59
+ foreach lib $libs {
60
+ cc-with [list -libs -l$lib] {
61
+ if {[cctest_function $function]} {
62
+ msg-result -l$lib
63
+ define lib_$function -l$lib
64
+ incr found
65
+ break
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ if {$found} {
72
+ define [feature-define-name $function]
73
+ } else {
74
+ msg-result "no"
75
+ }
76
+ return $found
77
+}
4278
4379
if {![opt-bool internal-sqlite]} {
4480
proc find_internal_sqlite {} {
4581
4682
# On some systems (slackware), libsqlite3 requires -ldl to link. So
@@ -53,18 +89,19 @@
5389
# Locate the system SQLite by searching for sqlite3_open(). Then check
5490
# if sqlite3_strglob() can be found as well. If we can find open() but
5591
# not strglob(), then the system SQLite is too old to link against
5692
# fossil.
5793
#
58
- if {[cc-check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
59
- if {![cc-check-function-in-lib sqlite3_malloc64 sqlite3 $extralibs]} {
94
+ if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
95
+ if {![check-function-in-lib sqlite3_malloc64 sqlite3 $extralibs]} {
6096
user-error "system sqlite3 too old (require >= 3.8.7)"
6197
}
6298
6399
# Success. Update symbols and return.
64100
#
65101
define USE_SYSTEM_SQLITE 1
102
+ define-append LIBS -lsqlite3
66103
define-append LIBS $extralibs
67104
return
68105
}
69106
}
70107
user-error "system sqlite3 not found"
@@ -142,10 +179,145 @@
142179
msg-result "Trying to link statically"
143180
} else {
144181
define-append EXTRA_CFLAGS -DFOSSIL_DYNAMIC_BUILD=1
145182
define FOSSIL_DYNAMIC_BUILD
146183
}
184
+
185
+# Helper for OpenSSL checking
186
+proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} {
187
+ msg-checking "Checking for $msg..."
188
+ set rc 0
189
+ if {[is_mingw]} {
190
+ lappend libs -lgdi32 -lwsock32
191
+ }
192
+ if {[info exists ::zlib_for_ssl]} {
193
+ lappend libs $::zlib_for_ssl
194
+ }
195
+ msg-quiet cc-with [list -cflags $cflags -libs $libs] {
196
+ if {[cc-check-includes openssl/ssl.h] && \
197
+ [cc-check-functions SSL_new]} {
198
+ incr rc
199
+ }
200
+ }
201
+ if {!$rc && ![is_mingw]} {
202
+ # On some systems, OpenSSL appears to require -ldl to link.
203
+ lappend libs -ldl
204
+ msg-quiet cc-with [list -cflags $cflags -libs $libs] {
205
+ if {[cc-check-includes openssl/ssl.h] && \
206
+ [cc-check-functions SSL_new]} {
207
+ incr rc
208
+ }
209
+ }
210
+ }
211
+ if {$rc} {
212
+ msg-result "ok"
213
+ return 1
214
+ } else {
215
+ msg-result "no"
216
+ return 0
217
+ }
218
+}
219
+
220
+if {[opt-bool with-miniz]} {
221
+ define FOSSIL_ENABLE_MINIZ 1
222
+ msg-result "Using miniz for compression"
223
+} else {
224
+ # Check for zlib, using the given location if specified
225
+ set zlibpath [opt-val with-zlib]
226
+ if {$zlibpath eq "tree"} {
227
+ set zlibdir [file dirname $autosetup(dir)]/compat/zlib
228
+ if {![file isdirectory $zlibdir]} {
229
+ user-error "The zlib in source tree directory does not exist"
230
+ }
231
+ cc-with [list -cflags "-I$zlibdir -L$zlibdir"]
232
+ define-append EXTRA_CFLAGS -I$zlibdir
233
+ define-append LIBS $zlibdir/libz.a
234
+ set ::zlib_for_ssl $zlibdir/libz.a
235
+ msg-result "Using zlib in source tree"
236
+ } else {
237
+ if {$zlibpath ni {auto ""}} {
238
+ cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
239
+ define-append EXTRA_CFLAGS -I$zlibpath
240
+ define-append EXTRA_LDFLAGS -L$zlibpath
241
+ msg-result "Using zlib from $zlibpath"
242
+ }
243
+ if {![cc-check-includes zlib.h] || ![check-function-in-lib inflateEnd z]} {
244
+ user-error "zlib not found please install it or specify the location with --with-zlib"
245
+ }
246
+ set ::zlib_for_ssl -lz
247
+ }
248
+}
249
+
250
+set ssldirs [opt-val with-openssl]
251
+if {$ssldirs ne "none"} {
252
+ if {[opt-bool with-miniz]} {
253
+ user-error "The --with-miniz option is incompatible with OpenSSL"
254
+ }
255
+ set found 0
256
+ if {$ssldirs eq "tree"} {
257
+ set ssldir [file dirname $autosetup(dir)]/compat/openssl
258
+ if {![file isdirectory $ssldir]} {
259
+ user-error "The OpenSSL in source tree directory does not exist"
260
+ }
261
+ set msg "ssl in $ssldir"
262
+ set cflags "-I$ssldir/include"
263
+ set ldflags "-L$ssldir"
264
+ set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a"
265
+ set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs]
266
+ } else {
267
+ if {$ssldirs in {auto ""}} {
268
+ catch {
269
+ set cflags [exec pkg-config openssl --cflags-only-I]
270
+ set ldflags [exec pkg-config openssl --libs-only-L]
271
+ set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
272
+ } msg
273
+ if {!$found} {
274
+ set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
275
+ }
276
+ }
277
+ if {!$found} {
278
+ foreach dir $ssldirs {
279
+ if {$dir eq ""} {
280
+ set msg "system ssl"
281
+ set cflags ""
282
+ set ldflags ""
283
+ } else {
284
+ set msg "ssl in $dir"
285
+ set cflags "-I$dir/include"
286
+ set ldflags "-L$dir/lib"
287
+ }
288
+ if {[check-for-openssl $msg "$cflags $ldflags"]} {
289
+ incr found
290
+ break
291
+ }
292
+ }
293
+ }
294
+ }
295
+ if {$found} {
296
+ define FOSSIL_ENABLE_SSL
297
+ define-append EXTRA_CFLAGS $cflags
298
+ define-append EXTRA_LDFLAGS $ldflags
299
+ if {[info exists ssllibs]} {
300
+ define-append LIBS $ssllibs
301
+ } else {
302
+ define-append LIBS -lssl -lcrypto
303
+ }
304
+ if {[is_mingw]} {
305
+ define-append LIBS -lgdi32 -lwsock32
306
+ }
307
+ msg-result "HTTPS support enabled"
308
+
309
+ # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
310
+ if {[string match *-darwin* [get-define host]]} {
311
+ if {[cctest -cflags {-Wdeprecated-declarations}]} {
312
+ define-append EXTRA_CFLAGS -Wdeprecated-declarations
313
+ }
314
+ }
315
+ } else {
316
+ user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
317
+ }
318
+}
147319
148320
set tclpath [opt-val with-tcl]
149321
if {$tclpath ne ""} {
150322
set tclprivatestubs [opt-bool with-tcl-private-stubs]
151323
# Note parse-tclconfig-sh is in autosetup/local.tcl
@@ -225,149 +397,28 @@
225397
msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
226398
if {!$tclprivatestubs} {
227399
define-append LIBS $libs
228400
}
229401
define-append EXTRA_CFLAGS $cflags
402
+ if {[info exists zlibpath] && $zlibpath eq "tree"} {
403
+ #
404
+ # NOTE: When using zlib in the source tree, prevent Tcl from
405
+ # pulling in the system one.
406
+ #
407
+ set tclconfig(TCL_LD_FLAGS) [string map [list -lz ""] \
408
+ $tclconfig(TCL_LD_FLAGS)]
409
+ }
410
+ #
411
+ # NOTE: Remove "-ldl" from the TCL_LD_FLAGS because it will be
412
+ # be checked for near the bottom of this file.
413
+ #
414
+ set tclconfig(TCL_LD_FLAGS) [string map [list -ldl ""] \
415
+ $tclconfig(TCL_LD_FLAGS)]
230416
define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
231417
define FOSSIL_ENABLE_TCL
232418
}
233419
234
-# Helper for OpenSSL checking
235
-proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} {
236
- msg-checking "Checking for $msg..."
237
- set rc 0
238
- if {[is_mingw]} {
239
- lappend libs -lgdi32 -lwsock32
240
- }
241
- if {[info exists ::zlib_for_ssl]} {
242
- lappend libs $::zlib_for_ssl
243
- }
244
- msg-quiet cc-with [list -cflags $cflags -libs $libs] {
245
- if {[cc-check-includes openssl/ssl.h] && \
246
- [cc-check-functions SSL_new]} {
247
- incr rc
248
- }
249
- }
250
- if {!$rc && ![is_mingw]} {
251
- # On some systems, OpenSSL appears to require -ldl to link.
252
- lappend libs -ldl
253
- msg-quiet cc-with [list -cflags $cflags -libs $libs] {
254
- if {[cc-check-includes openssl/ssl.h] && \
255
- [cc-check-functions SSL_new]} {
256
- incr rc
257
- }
258
- }
259
- }
260
- if {$rc} {
261
- msg-result "ok"
262
- return 1
263
- } else {
264
- msg-result "no"
265
- return 0
266
- }
267
-}
268
-
269
-if {[opt-bool with-miniz]} {
270
- define FOSSIL_ENABLE_MINIZ 1
271
- msg-result "Using miniz for compression"
272
-} else {
273
- # Check for zlib, using the given location if specified
274
- set zlibpath [opt-val with-zlib]
275
- if {$zlibpath eq "tree"} {
276
- set zlibdir [file dirname $autosetup(dir)]/compat/zlib
277
- if {![file isdirectory $zlibdir]} {
278
- user-error "The zlib in source tree directory does not exist"
279
- }
280
- cc-with [list -cflags "-I$zlibdir -L$zlibdir"]
281
- define-append EXTRA_CFLAGS -I$zlibdir
282
- define-append LIBS $zlibdir/libz.a
283
- set ::zlib_for_ssl $zlibdir/libz.a
284
- msg-result "Using zlib in source tree"
285
- } else {
286
- if {$zlibpath ni {auto ""}} {
287
- cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
288
- define-append EXTRA_CFLAGS -I$zlibpath
289
- define-append EXTRA_LDFLAGS -L$zlibpath
290
- msg-result "Using zlib from $zlibpath"
291
- }
292
- if {![cc-check-includes zlib.h] || ![cc-check-function-in-lib inflateEnd z]} {
293
- user-error "zlib not found please install it or specify the location with --with-zlib"
294
- }
295
- set ::zlib_for_ssl -lz
296
- }
297
-}
298
-
299
-set ssldirs [opt-val with-openssl]
300
-if {$ssldirs ne "none"} {
301
- if {[opt-bool with-miniz]} {
302
- user-error "The --with-miniz option is incompatible with OpenSSL"
303
- }
304
- set found 0
305
- if {$ssldirs eq "tree"} {
306
- set ssldir [file dirname $autosetup(dir)]/compat/openssl
307
- if {![file isdirectory $ssldir]} {
308
- user-error "The OpenSSL in source tree directory does not exist"
309
- }
310
- set msg "ssl in $ssldir"
311
- set cflags "-I$ssldir/include"
312
- set ldflags "-L$ssldir"
313
- set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a"
314
- set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs]
315
- } else {
316
- if {$ssldirs in {auto ""}} {
317
- catch {
318
- set cflags [exec pkg-config openssl --cflags-only-I]
319
- set ldflags [exec pkg-config openssl --libs-only-L]
320
- set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
321
- } msg
322
- if {!$found} {
323
- set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
324
- }
325
- }
326
- if {!$found} {
327
- foreach dir $ssldirs {
328
- if {$dir eq ""} {
329
- set msg "system ssl"
330
- set cflags ""
331
- set ldflags ""
332
- } else {
333
- set msg "ssl in $dir"
334
- set cflags "-I$dir/include"
335
- set ldflags "-L$dir/lib"
336
- }
337
- if {[check-for-openssl $msg "$cflags $ldflags"]} {
338
- incr found
339
- break
340
- }
341
- }
342
- }
343
- }
344
- if {$found} {
345
- define FOSSIL_ENABLE_SSL
346
- define-append EXTRA_CFLAGS $cflags
347
- define-append EXTRA_LDFLAGS $ldflags
348
- if {[info exists ssllibs]} {
349
- define-append LIBS $ssllibs
350
- } else {
351
- define-append LIBS -lssl -lcrypto
352
- }
353
- if {[is_mingw]} {
354
- define-append LIBS -lgdi32 -lwsock32
355
- }
356
- msg-result "HTTPS support enabled"
357
-
358
- # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
359
- if {[string match *-darwin* [get-define host]]} {
360
- if {[cctest -cflags {-Wdeprecated-declarations}]} {
361
- define-append EXTRA_CFLAGS -Wdeprecated-declarations
362
- }
363
- }
364
- } else {
365
- user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
366
- }
367
-}
368
-
369420
# Network functions require libraries on some systems
370421
cc-check-function-in-lib gethostbyname nsl
371422
if {![cc-check-function-in-lib socket {socket network}]} {
372423
# Last resort, may be Windows
373424
if {[is_mingw]} {
374425
--- auto.def
+++ auto.def
@@ -37,10 +37,46 @@
37
38 define EXTRA_CFLAGS ""
39 define EXTRA_LDFLAGS ""
40 define USE_SYSTEM_SQLITE 0
41 define USE_LINENOISE 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
43 if {![opt-bool internal-sqlite]} {
44 proc find_internal_sqlite {} {
45
46 # On some systems (slackware), libsqlite3 requires -ldl to link. So
@@ -53,18 +89,19 @@
53 # Locate the system SQLite by searching for sqlite3_open(). Then check
54 # if sqlite3_strglob() can be found as well. If we can find open() but
55 # not strglob(), then the system SQLite is too old to link against
56 # fossil.
57 #
58 if {[cc-check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
59 if {![cc-check-function-in-lib sqlite3_malloc64 sqlite3 $extralibs]} {
60 user-error "system sqlite3 too old (require >= 3.8.7)"
61 }
62
63 # Success. Update symbols and return.
64 #
65 define USE_SYSTEM_SQLITE 1
 
66 define-append LIBS $extralibs
67 return
68 }
69 }
70 user-error "system sqlite3 not found"
@@ -142,10 +179,145 @@
142 msg-result "Trying to link statically"
143 } else {
144 define-append EXTRA_CFLAGS -DFOSSIL_DYNAMIC_BUILD=1
145 define FOSSIL_DYNAMIC_BUILD
146 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
148 set tclpath [opt-val with-tcl]
149 if {$tclpath ne ""} {
150 set tclprivatestubs [opt-bool with-tcl-private-stubs]
151 # Note parse-tclconfig-sh is in autosetup/local.tcl
@@ -225,149 +397,28 @@
225 msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
226 if {!$tclprivatestubs} {
227 define-append LIBS $libs
228 }
229 define-append EXTRA_CFLAGS $cflags
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230 define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
231 define FOSSIL_ENABLE_TCL
232 }
233
234 # Helper for OpenSSL checking
235 proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} {
236 msg-checking "Checking for $msg..."
237 set rc 0
238 if {[is_mingw]} {
239 lappend libs -lgdi32 -lwsock32
240 }
241 if {[info exists ::zlib_for_ssl]} {
242 lappend libs $::zlib_for_ssl
243 }
244 msg-quiet cc-with [list -cflags $cflags -libs $libs] {
245 if {[cc-check-includes openssl/ssl.h] && \
246 [cc-check-functions SSL_new]} {
247 incr rc
248 }
249 }
250 if {!$rc && ![is_mingw]} {
251 # On some systems, OpenSSL appears to require -ldl to link.
252 lappend libs -ldl
253 msg-quiet cc-with [list -cflags $cflags -libs $libs] {
254 if {[cc-check-includes openssl/ssl.h] && \
255 [cc-check-functions SSL_new]} {
256 incr rc
257 }
258 }
259 }
260 if {$rc} {
261 msg-result "ok"
262 return 1
263 } else {
264 msg-result "no"
265 return 0
266 }
267 }
268
269 if {[opt-bool with-miniz]} {
270 define FOSSIL_ENABLE_MINIZ 1
271 msg-result "Using miniz for compression"
272 } else {
273 # Check for zlib, using the given location if specified
274 set zlibpath [opt-val with-zlib]
275 if {$zlibpath eq "tree"} {
276 set zlibdir [file dirname $autosetup(dir)]/compat/zlib
277 if {![file isdirectory $zlibdir]} {
278 user-error "The zlib in source tree directory does not exist"
279 }
280 cc-with [list -cflags "-I$zlibdir -L$zlibdir"]
281 define-append EXTRA_CFLAGS -I$zlibdir
282 define-append LIBS $zlibdir/libz.a
283 set ::zlib_for_ssl $zlibdir/libz.a
284 msg-result "Using zlib in source tree"
285 } else {
286 if {$zlibpath ni {auto ""}} {
287 cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
288 define-append EXTRA_CFLAGS -I$zlibpath
289 define-append EXTRA_LDFLAGS -L$zlibpath
290 msg-result "Using zlib from $zlibpath"
291 }
292 if {![cc-check-includes zlib.h] || ![cc-check-function-in-lib inflateEnd z]} {
293 user-error "zlib not found please install it or specify the location with --with-zlib"
294 }
295 set ::zlib_for_ssl -lz
296 }
297 }
298
299 set ssldirs [opt-val with-openssl]
300 if {$ssldirs ne "none"} {
301 if {[opt-bool with-miniz]} {
302 user-error "The --with-miniz option is incompatible with OpenSSL"
303 }
304 set found 0
305 if {$ssldirs eq "tree"} {
306 set ssldir [file dirname $autosetup(dir)]/compat/openssl
307 if {![file isdirectory $ssldir]} {
308 user-error "The OpenSSL in source tree directory does not exist"
309 }
310 set msg "ssl in $ssldir"
311 set cflags "-I$ssldir/include"
312 set ldflags "-L$ssldir"
313 set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a"
314 set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs]
315 } else {
316 if {$ssldirs in {auto ""}} {
317 catch {
318 set cflags [exec pkg-config openssl --cflags-only-I]
319 set ldflags [exec pkg-config openssl --libs-only-L]
320 set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
321 } msg
322 if {!$found} {
323 set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
324 }
325 }
326 if {!$found} {
327 foreach dir $ssldirs {
328 if {$dir eq ""} {
329 set msg "system ssl"
330 set cflags ""
331 set ldflags ""
332 } else {
333 set msg "ssl in $dir"
334 set cflags "-I$dir/include"
335 set ldflags "-L$dir/lib"
336 }
337 if {[check-for-openssl $msg "$cflags $ldflags"]} {
338 incr found
339 break
340 }
341 }
342 }
343 }
344 if {$found} {
345 define FOSSIL_ENABLE_SSL
346 define-append EXTRA_CFLAGS $cflags
347 define-append EXTRA_LDFLAGS $ldflags
348 if {[info exists ssllibs]} {
349 define-append LIBS $ssllibs
350 } else {
351 define-append LIBS -lssl -lcrypto
352 }
353 if {[is_mingw]} {
354 define-append LIBS -lgdi32 -lwsock32
355 }
356 msg-result "HTTPS support enabled"
357
358 # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
359 if {[string match *-darwin* [get-define host]]} {
360 if {[cctest -cflags {-Wdeprecated-declarations}]} {
361 define-append EXTRA_CFLAGS -Wdeprecated-declarations
362 }
363 }
364 } else {
365 user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
366 }
367 }
368
369 # Network functions require libraries on some systems
370 cc-check-function-in-lib gethostbyname nsl
371 if {![cc-check-function-in-lib socket {socket network}]} {
372 # Last resort, may be Windows
373 if {[is_mingw]} {
374
--- auto.def
+++ auto.def
@@ -37,10 +37,46 @@
37
38 define EXTRA_CFLAGS ""
39 define EXTRA_LDFLAGS ""
40 define USE_SYSTEM_SQLITE 0
41 define USE_LINENOISE 0
42
43 # This procedure is a customized version of "cc-check-function-in-lib",
44 # that does not modify the LIBS variable. Its use prevents prematurely
45 # pulling in libraries that will be added later anyhow (e.g. "-ldl").
46 proc check-function-in-lib {function libs {otherlibs {}}} {
47 if {[string length $otherlibs]} {
48 msg-checking "Checking for $function in $libs with $otherlibs..."
49 } else {
50 msg-checking "Checking for $function in $libs..."
51 }
52 set found 0
53 cc-with [list -libs $otherlibs] {
54 if {[cctest_function $function]} {
55 msg-result "none needed"
56 define lib_$function ""
57 incr found
58 } else {
59 foreach lib $libs {
60 cc-with [list -libs -l$lib] {
61 if {[cctest_function $function]} {
62 msg-result -l$lib
63 define lib_$function -l$lib
64 incr found
65 break
66 }
67 }
68 }
69 }
70 }
71 if {$found} {
72 define [feature-define-name $function]
73 } else {
74 msg-result "no"
75 }
76 return $found
77 }
78
79 if {![opt-bool internal-sqlite]} {
80 proc find_internal_sqlite {} {
81
82 # On some systems (slackware), libsqlite3 requires -ldl to link. So
@@ -53,18 +89,19 @@
89 # Locate the system SQLite by searching for sqlite3_open(). Then check
90 # if sqlite3_strglob() can be found as well. If we can find open() but
91 # not strglob(), then the system SQLite is too old to link against
92 # fossil.
93 #
94 if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
95 if {![check-function-in-lib sqlite3_malloc64 sqlite3 $extralibs]} {
96 user-error "system sqlite3 too old (require >= 3.8.7)"
97 }
98
99 # Success. Update symbols and return.
100 #
101 define USE_SYSTEM_SQLITE 1
102 define-append LIBS -lsqlite3
103 define-append LIBS $extralibs
104 return
105 }
106 }
107 user-error "system sqlite3 not found"
@@ -142,10 +179,145 @@
179 msg-result "Trying to link statically"
180 } else {
181 define-append EXTRA_CFLAGS -DFOSSIL_DYNAMIC_BUILD=1
182 define FOSSIL_DYNAMIC_BUILD
183 }
184
185 # Helper for OpenSSL checking
186 proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} {
187 msg-checking "Checking for $msg..."
188 set rc 0
189 if {[is_mingw]} {
190 lappend libs -lgdi32 -lwsock32
191 }
192 if {[info exists ::zlib_for_ssl]} {
193 lappend libs $::zlib_for_ssl
194 }
195 msg-quiet cc-with [list -cflags $cflags -libs $libs] {
196 if {[cc-check-includes openssl/ssl.h] && \
197 [cc-check-functions SSL_new]} {
198 incr rc
199 }
200 }
201 if {!$rc && ![is_mingw]} {
202 # On some systems, OpenSSL appears to require -ldl to link.
203 lappend libs -ldl
204 msg-quiet cc-with [list -cflags $cflags -libs $libs] {
205 if {[cc-check-includes openssl/ssl.h] && \
206 [cc-check-functions SSL_new]} {
207 incr rc
208 }
209 }
210 }
211 if {$rc} {
212 msg-result "ok"
213 return 1
214 } else {
215 msg-result "no"
216 return 0
217 }
218 }
219
220 if {[opt-bool with-miniz]} {
221 define FOSSIL_ENABLE_MINIZ 1
222 msg-result "Using miniz for compression"
223 } else {
224 # Check for zlib, using the given location if specified
225 set zlibpath [opt-val with-zlib]
226 if {$zlibpath eq "tree"} {
227 set zlibdir [file dirname $autosetup(dir)]/compat/zlib
228 if {![file isdirectory $zlibdir]} {
229 user-error "The zlib in source tree directory does not exist"
230 }
231 cc-with [list -cflags "-I$zlibdir -L$zlibdir"]
232 define-append EXTRA_CFLAGS -I$zlibdir
233 define-append LIBS $zlibdir/libz.a
234 set ::zlib_for_ssl $zlibdir/libz.a
235 msg-result "Using zlib in source tree"
236 } else {
237 if {$zlibpath ni {auto ""}} {
238 cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
239 define-append EXTRA_CFLAGS -I$zlibpath
240 define-append EXTRA_LDFLAGS -L$zlibpath
241 msg-result "Using zlib from $zlibpath"
242 }
243 if {![cc-check-includes zlib.h] || ![check-function-in-lib inflateEnd z]} {
244 user-error "zlib not found please install it or specify the location with --with-zlib"
245 }
246 set ::zlib_for_ssl -lz
247 }
248 }
249
250 set ssldirs [opt-val with-openssl]
251 if {$ssldirs ne "none"} {
252 if {[opt-bool with-miniz]} {
253 user-error "The --with-miniz option is incompatible with OpenSSL"
254 }
255 set found 0
256 if {$ssldirs eq "tree"} {
257 set ssldir [file dirname $autosetup(dir)]/compat/openssl
258 if {![file isdirectory $ssldir]} {
259 user-error "The OpenSSL in source tree directory does not exist"
260 }
261 set msg "ssl in $ssldir"
262 set cflags "-I$ssldir/include"
263 set ldflags "-L$ssldir"
264 set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a"
265 set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs]
266 } else {
267 if {$ssldirs in {auto ""}} {
268 catch {
269 set cflags [exec pkg-config openssl --cflags-only-I]
270 set ldflags [exec pkg-config openssl --libs-only-L]
271 set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
272 } msg
273 if {!$found} {
274 set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
275 }
276 }
277 if {!$found} {
278 foreach dir $ssldirs {
279 if {$dir eq ""} {
280 set msg "system ssl"
281 set cflags ""
282 set ldflags ""
283 } else {
284 set msg "ssl in $dir"
285 set cflags "-I$dir/include"
286 set ldflags "-L$dir/lib"
287 }
288 if {[check-for-openssl $msg "$cflags $ldflags"]} {
289 incr found
290 break
291 }
292 }
293 }
294 }
295 if {$found} {
296 define FOSSIL_ENABLE_SSL
297 define-append EXTRA_CFLAGS $cflags
298 define-append EXTRA_LDFLAGS $ldflags
299 if {[info exists ssllibs]} {
300 define-append LIBS $ssllibs
301 } else {
302 define-append LIBS -lssl -lcrypto
303 }
304 if {[is_mingw]} {
305 define-append LIBS -lgdi32 -lwsock32
306 }
307 msg-result "HTTPS support enabled"
308
309 # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
310 if {[string match *-darwin* [get-define host]]} {
311 if {[cctest -cflags {-Wdeprecated-declarations}]} {
312 define-append EXTRA_CFLAGS -Wdeprecated-declarations
313 }
314 }
315 } else {
316 user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
317 }
318 }
319
320 set tclpath [opt-val with-tcl]
321 if {$tclpath ne ""} {
322 set tclprivatestubs [opt-bool with-tcl-private-stubs]
323 # Note parse-tclconfig-sh is in autosetup/local.tcl
@@ -225,149 +397,28 @@
397 msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
398 if {!$tclprivatestubs} {
399 define-append LIBS $libs
400 }
401 define-append EXTRA_CFLAGS $cflags
402 if {[info exists zlibpath] && $zlibpath eq "tree"} {
403 #
404 # NOTE: When using zlib in the source tree, prevent Tcl from
405 # pulling in the system one.
406 #
407 set tclconfig(TCL_LD_FLAGS) [string map [list -lz ""] \
408 $tclconfig(TCL_LD_FLAGS)]
409 }
410 #
411 # NOTE: Remove "-ldl" from the TCL_LD_FLAGS because it will be
412 # be checked for near the bottom of this file.
413 #
414 set tclconfig(TCL_LD_FLAGS) [string map [list -ldl ""] \
415 $tclconfig(TCL_LD_FLAGS)]
416 define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
417 define FOSSIL_ENABLE_TCL
418 }
419
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
420 # Network functions require libraries on some systems
421 cc-check-function-in-lib gethostbyname nsl
422 if {![cc-check-function-in-lib socket {socket network}]} {
423 # Last resort, may be Windows
424 if {[is_mingw]} {
425

Keyboard Shortcuts

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