Fossil SCM

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

mistachkin 2016-01-29 22:36 UTC trunk
Commit 0e342184654d37bedc7762477203048f5aa3c8ad
1 file changed +187 -137
+187 -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,12 +89,12 @@
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
#
@@ -142,10 +178,145 @@
142178
msg-result "Trying to link statically"
143179
} else {
144180
define-append EXTRA_CFLAGS -DFOSSIL_DYNAMIC_BUILD=1
145181
define FOSSIL_DYNAMIC_BUILD
146182
}
183
+
184
+# Helper for OpenSSL checking
185
+proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} {
186
+ msg-checking "Checking for $msg..."
187
+ set rc 0
188
+ if {[is_mingw]} {
189
+ lappend libs -lgdi32 -lwsock32
190
+ }
191
+ if {[info exists ::zlib_for_ssl]} {
192
+ lappend libs $::zlib_for_ssl
193
+ }
194
+ msg-quiet cc-with [list -cflags $cflags -libs $libs] {
195
+ if {[cc-check-includes openssl/ssl.h] && \
196
+ [cc-check-functions SSL_new]} {
197
+ incr rc
198
+ }
199
+ }
200
+ if {!$rc && ![is_mingw]} {
201
+ # On some systems, OpenSSL appears to require -ldl to link.
202
+ lappend libs -ldl
203
+ msg-quiet cc-with [list -cflags $cflags -libs $libs] {
204
+ if {[cc-check-includes openssl/ssl.h] && \
205
+ [cc-check-functions SSL_new]} {
206
+ incr rc
207
+ }
208
+ }
209
+ }
210
+ if {$rc} {
211
+ msg-result "ok"
212
+ return 1
213
+ } else {
214
+ msg-result "no"
215
+ return 0
216
+ }
217
+}
218
+
219
+if {[opt-bool with-miniz]} {
220
+ define FOSSIL_ENABLE_MINIZ 1
221
+ msg-result "Using miniz for compression"
222
+} else {
223
+ # Check for zlib, using the given location if specified
224
+ set zlibpath [opt-val with-zlib]
225
+ if {$zlibpath eq "tree"} {
226
+ set zlibdir [file dirname $autosetup(dir)]/compat/zlib
227
+ if {![file isdirectory $zlibdir]} {
228
+ user-error "The zlib in source tree directory does not exist"
229
+ }
230
+ cc-with [list -cflags "-I$zlibdir -L$zlibdir"]
231
+ define-append EXTRA_CFLAGS -I$zlibdir
232
+ define-append LIBS $zlibdir/libz.a
233
+ set ::zlib_for_ssl $zlibdir/libz.a
234
+ msg-result "Using zlib in source tree"
235
+ } else {
236
+ if {$zlibpath ni {auto ""}} {
237
+ cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
238
+ define-append EXTRA_CFLAGS -I$zlibpath
239
+ define-append EXTRA_LDFLAGS -L$zlibpath
240
+ msg-result "Using zlib from $zlibpath"
241
+ }
242
+ if {![cc-check-includes zlib.h] || ![check-function-in-lib inflateEnd z]} {
243
+ user-error "zlib not found please install it or specify the location with --with-zlib"
244
+ }
245
+ set ::zlib_for_ssl -lz
246
+ }
247
+}
248
+
249
+set ssldirs [opt-val with-openssl]
250
+if {$ssldirs ne "none"} {
251
+ if {[opt-bool with-miniz]} {
252
+ user-error "The --with-miniz option is incompatible with OpenSSL"
253
+ }
254
+ set found 0
255
+ if {$ssldirs eq "tree"} {
256
+ set ssldir [file dirname $autosetup(dir)]/compat/openssl
257
+ if {![file isdirectory $ssldir]} {
258
+ user-error "The OpenSSL in source tree directory does not exist"
259
+ }
260
+ set msg "ssl in $ssldir"
261
+ set cflags "-I$ssldir/include"
262
+ set ldflags "-L$ssldir"
263
+ set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a"
264
+ set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs]
265
+ } else {
266
+ if {$ssldirs in {auto ""}} {
267
+ catch {
268
+ set cflags [exec pkg-config openssl --cflags-only-I]
269
+ set ldflags [exec pkg-config openssl --libs-only-L]
270
+ set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
271
+ } msg
272
+ if {!$found} {
273
+ set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
274
+ }
275
+ }
276
+ if {!$found} {
277
+ foreach dir $ssldirs {
278
+ if {$dir eq ""} {
279
+ set msg "system ssl"
280
+ set cflags ""
281
+ set ldflags ""
282
+ } else {
283
+ set msg "ssl in $dir"
284
+ set cflags "-I$dir/include"
285
+ set ldflags "-L$dir/lib"
286
+ }
287
+ if {[check-for-openssl $msg "$cflags $ldflags"]} {
288
+ incr found
289
+ break
290
+ }
291
+ }
292
+ }
293
+ }
294
+ if {$found} {
295
+ define FOSSIL_ENABLE_SSL
296
+ define-append EXTRA_CFLAGS $cflags
297
+ define-append EXTRA_LDFLAGS $ldflags
298
+ if {[info exists ssllibs]} {
299
+ define-append LIBS $ssllibs
300
+ } else {
301
+ define-append LIBS -lssl -lcrypto
302
+ }
303
+ if {[is_mingw]} {
304
+ define-append LIBS -lgdi32 -lwsock32
305
+ }
306
+ msg-result "HTTPS support enabled"
307
+
308
+ # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
309
+ if {[string match *-darwin* [get-define host]]} {
310
+ if {[cctest -cflags {-Wdeprecated-declarations}]} {
311
+ define-append EXTRA_CFLAGS -Wdeprecated-declarations
312
+ }
313
+ }
314
+ } else {
315
+ user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
316
+ }
317
+}
147318
148319
set tclpath [opt-val with-tcl]
149320
if {$tclpath ne ""} {
150321
set tclprivatestubs [opt-bool with-tcl-private-stubs]
151322
# Note parse-tclconfig-sh is in autosetup/local.tcl
@@ -225,149 +396,28 @@
225396
msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
226397
if {!$tclprivatestubs} {
227398
define-append LIBS $libs
228399
}
229400
define-append EXTRA_CFLAGS $cflags
401
+ if {[info exists zlibpath] && $zlibpath eq "tree"} {
402
+ #
403
+ # NOTE: When using zlib in the source tree, prevent Tcl from
404
+ # pulling in the system one.
405
+ #
406
+ set tclconfig(TCL_LD_FLAGS) [string map [list -lz ""] \
407
+ $tclconfig(TCL_LD_FLAGS)]
408
+ }
409
+ #
410
+ # NOTE: Remove "-ldl" from the TCL_LD_FLAGS because it will be
411
+ # be checked for near the bottom of this file.
412
+ #
413
+ set tclconfig(TCL_LD_FLAGS) [string map [list -ldl ""] \
414
+ $tclconfig(TCL_LD_FLAGS)]
230415
define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
231416
define FOSSIL_ENABLE_TCL
232417
}
233418
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
-
369419
# Network functions require libraries on some systems
370420
cc-check-function-in-lib gethostbyname nsl
371421
if {![cc-check-function-in-lib socket {socket network}]} {
372422
# Last resort, may be Windows
373423
if {[is_mingw]} {
374424
--- 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,12 +89,12 @@
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 #
@@ -142,10 +178,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 +396,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,12 +89,12 @@
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 #
@@ -142,10 +178,145 @@
178 msg-result "Trying to link statically"
179 } else {
180 define-append EXTRA_CFLAGS -DFOSSIL_DYNAMIC_BUILD=1
181 define FOSSIL_DYNAMIC_BUILD
182 }
183
184 # Helper for OpenSSL checking
185 proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} {
186 msg-checking "Checking for $msg..."
187 set rc 0
188 if {[is_mingw]} {
189 lappend libs -lgdi32 -lwsock32
190 }
191 if {[info exists ::zlib_for_ssl]} {
192 lappend libs $::zlib_for_ssl
193 }
194 msg-quiet cc-with [list -cflags $cflags -libs $libs] {
195 if {[cc-check-includes openssl/ssl.h] && \
196 [cc-check-functions SSL_new]} {
197 incr rc
198 }
199 }
200 if {!$rc && ![is_mingw]} {
201 # On some systems, OpenSSL appears to require -ldl to link.
202 lappend libs -ldl
203 msg-quiet cc-with [list -cflags $cflags -libs $libs] {
204 if {[cc-check-includes openssl/ssl.h] && \
205 [cc-check-functions SSL_new]} {
206 incr rc
207 }
208 }
209 }
210 if {$rc} {
211 msg-result "ok"
212 return 1
213 } else {
214 msg-result "no"
215 return 0
216 }
217 }
218
219 if {[opt-bool with-miniz]} {
220 define FOSSIL_ENABLE_MINIZ 1
221 msg-result "Using miniz for compression"
222 } else {
223 # Check for zlib, using the given location if specified
224 set zlibpath [opt-val with-zlib]
225 if {$zlibpath eq "tree"} {
226 set zlibdir [file dirname $autosetup(dir)]/compat/zlib
227 if {![file isdirectory $zlibdir]} {
228 user-error "The zlib in source tree directory does not exist"
229 }
230 cc-with [list -cflags "-I$zlibdir -L$zlibdir"]
231 define-append EXTRA_CFLAGS -I$zlibdir
232 define-append LIBS $zlibdir/libz.a
233 set ::zlib_for_ssl $zlibdir/libz.a
234 msg-result "Using zlib in source tree"
235 } else {
236 if {$zlibpath ni {auto ""}} {
237 cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
238 define-append EXTRA_CFLAGS -I$zlibpath
239 define-append EXTRA_LDFLAGS -L$zlibpath
240 msg-result "Using zlib from $zlibpath"
241 }
242 if {![cc-check-includes zlib.h] || ![check-function-in-lib inflateEnd z]} {
243 user-error "zlib not found please install it or specify the location with --with-zlib"
244 }
245 set ::zlib_for_ssl -lz
246 }
247 }
248
249 set ssldirs [opt-val with-openssl]
250 if {$ssldirs ne "none"} {
251 if {[opt-bool with-miniz]} {
252 user-error "The --with-miniz option is incompatible with OpenSSL"
253 }
254 set found 0
255 if {$ssldirs eq "tree"} {
256 set ssldir [file dirname $autosetup(dir)]/compat/openssl
257 if {![file isdirectory $ssldir]} {
258 user-error "The OpenSSL in source tree directory does not exist"
259 }
260 set msg "ssl in $ssldir"
261 set cflags "-I$ssldir/include"
262 set ldflags "-L$ssldir"
263 set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a"
264 set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs]
265 } else {
266 if {$ssldirs in {auto ""}} {
267 catch {
268 set cflags [exec pkg-config openssl --cflags-only-I]
269 set ldflags [exec pkg-config openssl --libs-only-L]
270 set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
271 } msg
272 if {!$found} {
273 set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
274 }
275 }
276 if {!$found} {
277 foreach dir $ssldirs {
278 if {$dir eq ""} {
279 set msg "system ssl"
280 set cflags ""
281 set ldflags ""
282 } else {
283 set msg "ssl in $dir"
284 set cflags "-I$dir/include"
285 set ldflags "-L$dir/lib"
286 }
287 if {[check-for-openssl $msg "$cflags $ldflags"]} {
288 incr found
289 break
290 }
291 }
292 }
293 }
294 if {$found} {
295 define FOSSIL_ENABLE_SSL
296 define-append EXTRA_CFLAGS $cflags
297 define-append EXTRA_LDFLAGS $ldflags
298 if {[info exists ssllibs]} {
299 define-append LIBS $ssllibs
300 } else {
301 define-append LIBS -lssl -lcrypto
302 }
303 if {[is_mingw]} {
304 define-append LIBS -lgdi32 -lwsock32
305 }
306 msg-result "HTTPS support enabled"
307
308 # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
309 if {[string match *-darwin* [get-define host]]} {
310 if {[cctest -cflags {-Wdeprecated-declarations}]} {
311 define-append EXTRA_CFLAGS -Wdeprecated-declarations
312 }
313 }
314 } else {
315 user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
316 }
317 }
318
319 set tclpath [opt-val with-tcl]
320 if {$tclpath ne ""} {
321 set tclprivatestubs [opt-bool with-tcl-private-stubs]
322 # Note parse-tclconfig-sh is in autosetup/local.tcl
@@ -225,149 +396,28 @@
396 msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
397 if {!$tclprivatestubs} {
398 define-append LIBS $libs
399 }
400 define-append EXTRA_CFLAGS $cflags
401 if {[info exists zlibpath] && $zlibpath eq "tree"} {
402 #
403 # NOTE: When using zlib in the source tree, prevent Tcl from
404 # pulling in the system one.
405 #
406 set tclconfig(TCL_LD_FLAGS) [string map [list -lz ""] \
407 $tclconfig(TCL_LD_FLAGS)]
408 }
409 #
410 # NOTE: Remove "-ldl" from the TCL_LD_FLAGS because it will be
411 # be checked for near the bottom of this file.
412 #
413 set tclconfig(TCL_LD_FLAGS) [string map [list -ldl ""] \
414 $tclconfig(TCL_LD_FLAGS)]
415 define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
416 define FOSSIL_ENABLE_TCL
417 }
418
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419 # Network functions require libraries on some systems
420 cc-check-function-in-lib gethostbyname nsl
421 if {![cc-check-function-in-lib socket {socket network}]} {
422 # Last resort, may be Windows
423 if {[is_mingw]} {
424

Keyboard Shortcuts

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