Fossil SCM

Reworked the handling of "./configure --with-zlib=FOO", yielding several benefits: * FOO can now point to both a flat directory as before or to a directory one level up with lib/ and include/ subdirs, as zlib installs to when configured with a --prefix, fixing an issue [forum:/forumpost/9c64b51d44 | reported on the forum]. * The old method would check the default paths given before trying what you gave it, preventing local overrides when you know the platform version isn't what you want and you've built from source and pointed Fossil at the replacement. It isn't always safe or advisable to remove the platform version in this case merely to get Fossil's configuration script to move on and obey your explicit directive. * The old method checked for the header and the library in a single step, resulting in unhelpful configure output, requiring that one dig through config.log to figure out what happened.

tangent 2023-10-23 00:56 trunk
Commit 9d0b52e2d24424688a3b3e7d734f22e069f8169772f84f9fad889c894e8c72d1
1 file changed +34 -6
+34 -6
--- auto.def
+++ auto.def
@@ -367,18 +367,46 @@
367367
define-append EXTRA_CFLAGS -I$zlibdir
368368
define-append LIBS $zlibdir/libz.a
369369
set ::zlib_lib $zlibdir/libz.a
370370
msg-result "Using zlib in source tree"
371371
} else {
372
+ set cftry {""}
373
+ set ldtry {""}
372374
if {$zlibpath ni {auto ""}} {
373
- cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
374
- define-append EXTRA_CFLAGS -I$zlibpath
375
- define-append EXTRA_LDFLAGS -L$zlibpath
376
- msg-result "Using zlib from $zlibpath"
375
+ lappend cftry "-I$zlibpath"
376
+ lappend cftry "-I$zlibpath/include"
377
+ lappend ldtry "-L$zlibpath"
378
+ lappend ldtry "-L$zlibpath/lib"
379
+ }
380
+
381
+ # Reverse the list of tests so we check most-specific to least, else
382
+ # platform devel files will shadow local --with-zlib overrides.
383
+ foreach c [lreverse $cftry] {
384
+ if {[cc-with [list -cflags $c] {cc-check-includes zlib.h}]} {
385
+ if {$c eq ""} {
386
+ msg-result "Found zlib.h in default include path"
387
+ } else {
388
+ define-append EXTRA_CFLAGS "$c"
389
+ msg-result "Found zlib.h via $c"
390
+ }
391
+ set cfound $c
392
+ break
393
+ }
394
+ }
395
+ if {![info exists cfound]} {
396
+ user-error "zlib.h not found; either install it or specify its location via --with-zlib"
377397
}
378
- if {![cc-check-includes zlib.h] || ![check-function-in-lib inflateEnd z]} {
379
- user-error "zlib not found please install it or specify the location with --with-zlib"
398
+ foreach lcheck [lreverse $ldtry] {
399
+ if {[cc-with [list -cflags "$cfound $lcheck"] {check-function-in-lib inflateEnd z}]} {
400
+ if {$lcheck eq ""} {
401
+ msg-result "Linked to zlib via default library path"
402
+ } else {
403
+ define-append EXTRA_LDFLAGS "$lcheck"
404
+ msg-result "Linked to zlib via $lcheck"
405
+ }
406
+ break
407
+ }
380408
}
381409
set ::zlib_lib -lz
382410
}
383411
384412
set ssldirs [opt-val with-openssl]
385413
--- auto.def
+++ auto.def
@@ -367,18 +367,46 @@
367 define-append EXTRA_CFLAGS -I$zlibdir
368 define-append LIBS $zlibdir/libz.a
369 set ::zlib_lib $zlibdir/libz.a
370 msg-result "Using zlib in source tree"
371 } else {
 
 
372 if {$zlibpath ni {auto ""}} {
373 cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
374 define-append EXTRA_CFLAGS -I$zlibpath
375 define-append EXTRA_LDFLAGS -L$zlibpath
376 msg-result "Using zlib from $zlibpath"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377 }
378 if {![cc-check-includes zlib.h] || ![check-function-in-lib inflateEnd z]} {
379 user-error "zlib not found please install it or specify the location with --with-zlib"
 
 
 
 
 
 
 
 
380 }
381 set ::zlib_lib -lz
382 }
383
384 set ssldirs [opt-val with-openssl]
385
--- auto.def
+++ auto.def
@@ -367,18 +367,46 @@
367 define-append EXTRA_CFLAGS -I$zlibdir
368 define-append LIBS $zlibdir/libz.a
369 set ::zlib_lib $zlibdir/libz.a
370 msg-result "Using zlib in source tree"
371 } else {
372 set cftry {""}
373 set ldtry {""}
374 if {$zlibpath ni {auto ""}} {
375 lappend cftry "-I$zlibpath"
376 lappend cftry "-I$zlibpath/include"
377 lappend ldtry "-L$zlibpath"
378 lappend ldtry "-L$zlibpath/lib"
379 }
380
381 # Reverse the list of tests so we check most-specific to least, else
382 # platform devel files will shadow local --with-zlib overrides.
383 foreach c [lreverse $cftry] {
384 if {[cc-with [list -cflags $c] {cc-check-includes zlib.h}]} {
385 if {$c eq ""} {
386 msg-result "Found zlib.h in default include path"
387 } else {
388 define-append EXTRA_CFLAGS "$c"
389 msg-result "Found zlib.h via $c"
390 }
391 set cfound $c
392 break
393 }
394 }
395 if {![info exists cfound]} {
396 user-error "zlib.h not found; either install it or specify its location via --with-zlib"
397 }
398 foreach lcheck [lreverse $ldtry] {
399 if {[cc-with [list -cflags "$cfound $lcheck"] {check-function-in-lib inflateEnd z}]} {
400 if {$lcheck eq ""} {
401 msg-result "Linked to zlib via default library path"
402 } else {
403 define-append EXTRA_LDFLAGS "$lcheck"
404 msg-result "Linked to zlib via $lcheck"
405 }
406 break
407 }
408 }
409 set ::zlib_lib -lz
410 }
411
412 set ssldirs [opt-val with-openssl]
413

Keyboard Shortcuts

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