Fossil SCM

Move the openssl check to the end of the configure process, as discussed in/around [forum:9430c163139f78ee|forum post 9430c163139f78ee]. Tested on three Linux flavors, including one using a local openssl build, OpenBSD 7.6, and an msys2 (Windows) environment.

stephan 2025-02-26 07:32 trunk
Commit af7475cda699462f4ec4d2288816e7c42ef2f7baae28e350d80a19d270489172
1 file changed +107 -94
+107 -94
--- auto.def
+++ auto.def
@@ -434,104 +434,113 @@
434434
}
435435
}
436436
set ::zlib_lib -lz
437437
}
438438
439
-set ssldirs [opt-val with-openssl]
440
-if {$ssldirs ne "none"} {
441
- set found 0
442
- if {$ssldirs eq "tree"} {
443
- set ssldir [file dirname $autosetup(dir)]/compat/openssl
444
- if {![file isdirectory $ssldir]} {
445
- user-error "The OpenSSL in source tree directory does not exist"
446
- }
447
- set msg "openssl in $ssldir"
448
- set cflags "-I$ssldir/include"
449
- set ldflags "-L$ssldir"
450
- set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a -lpthread"
451
- set found [check-for-openssl "openssl in source tree" "$cflags $ldflags" $ssllibs]
452
- } else {
453
- if {$ssldirs in {auto ""}} {
454
- catch {
455
- set cflags [exec pkg-config openssl --cflags-only-I]
456
- set ldflags [exec pkg-config openssl --libs-only-L]
457
- set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
458
- } msg
459
- if {!$found} {
460
- set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl \
461
- /usr/pkg /usr/local /usr /usr/local/opt/openssl \
462
- /opt/homebrew/opt/openssl"
463
- }
464
- }
465
- if {!$found} {
466
- foreach dir $ssldirs {
467
- if {$dir eq ""} {
468
- set msg "system openssl"
469
- set cflags ""
470
- set ldflags ""
471
- } else {
472
- set msg "openssl in $dir"
473
- set cflags "-I$dir/include"
474
- if {[file readable $dir/libssl.a]} {
475
- set ldflags -L$dir
476
- } elseif {[file readable $dir/lib/libssl.a]} {
477
- set ldflags -L$dir/lib
478
- } elseif {[file isdir $dir/lib]} {
479
- set ldflags "-L$dir -L$dir/lib"
480
- } else {
481
- set ldflags -L$dir
482
- }
483
- }
484
- if {[check-for-openssl $msg "$cflags $ldflags"]} {
485
- incr found
486
- break
487
- }
488
- if {$dir ne ""} {
489
- set ldflags ""
490
- set msg "static build of openssl in $dir"
491
- set ssllibs "$dir/libssl.a $dir/libcrypto.a -lpthread"
492
- if {[check-for-openssl $msg "$cflags $ldflags" $ssllibs]} {
493
- incr found
494
- break
495
- }
496
- }
497
- }
498
- }
499
- }
500
- if {$found} {
501
- define FOSSIL_ENABLE_SSL
502
- define-append EXTRA_CFLAGS $cflags
503
- define-append EXTRA_LDFLAGS $ldflags
504
- if {[info exists ssllibs]} {
505
- define-append LIBS $ssllibs
506
- } else {
507
- define-append LIBS -lssl -lcrypto
508
- }
509
- if {[info exists ::zlib_lib]} {
510
- define-append LIBS $::zlib_lib
511
- }
512
- if {[is_mingw]} {
513
- define-append LIBS -lgdi32 -lwsock32 -lcrypt32
514
- }
515
- msg-result "HTTPS support enabled"
516
-
517
- # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
518
- if {[string match *-darwin* [get-define host]]} {
519
- if {[cctest -cflags {-Wdeprecated-declarations}]} {
520
- define-append EXTRA_CFLAGS -Wdeprecated-declarations
521
- }
522
- }
523
- } else {
524
- user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
525
- }
526
-} else {
527
- if {[info exists ::zlib_lib]} {
528
- define-append LIBS $::zlib_lib
529
- }
530
-}
531
-
532
-
439
+#
440
+# Handle the --with-openssl flag and, incidentally, update @LIBS@ for
441
+# zlib if openssl is _not_ used (if it is, we get zlib via libssl).
442
+#
443
+# This function should be called as late as possible in the configure
444
+# script to avoid that its updates to @LIBS@ break tests which follow
445
+# it when a custom local build of openssl is used, as discussed in
446
+# <https://fossil-scm.org/forum/forumpost/15e3d9cdc137030c>.
447
+#
448
+proc handle-with-openssl {} {
449
+ set ssldirs [opt-val with-openssl]
450
+ if {$ssldirs ne "none"} {
451
+ set found 0
452
+ if {$ssldirs eq "tree"} {
453
+ set ssldir [file dirname $autosetup(dir)]/compat/openssl
454
+ if {![file isdirectory $ssldir]} {
455
+ user-error "The OpenSSL in source tree directory does not exist"
456
+ }
457
+ set msg "openssl in $ssldir"
458
+ set cflags "-I$ssldir/include"
459
+ set ldflags "-L$ssldir"
460
+ set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a -lpthread"
461
+ set found [check-for-openssl "openssl in source tree" "$cflags $ldflags" $ssllibs]
462
+ } else {
463
+ if {$ssldirs in {auto ""}} {
464
+ catch {
465
+ set cflags [exec pkg-config openssl --cflags-only-I]
466
+ set ldflags [exec pkg-config openssl --libs-only-L]
467
+ set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
468
+ } msg
469
+ if {!$found} {
470
+ set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl \
471
+ /usr/pkg /usr/local /usr /usr/local/opt/openssl \
472
+ /opt/homebrew/opt/openssl"
473
+ }
474
+ }
475
+ if {!$found} {
476
+ foreach dir $ssldirs {
477
+ if {$dir eq ""} {
478
+ set msg "system openssl"
479
+ set cflags ""
480
+ set ldflags ""
481
+ } else {
482
+ set msg "openssl in $dir"
483
+ set cflags "-I$dir/include"
484
+ if {[file readable $dir/libssl.a]} {
485
+ set ldflags -L$dir
486
+ } elseif {[file readable $dir/lib/libssl.a]} {
487
+ set ldflags -L$dir/lib
488
+ } elseif {[file isdir $dir/lib]} {
489
+ set ldflags "-L$dir -L$dir/lib"
490
+ } else {
491
+ set ldflags -L$dir
492
+ }
493
+ }
494
+ if {[check-for-openssl $msg "$cflags $ldflags"]} {
495
+ incr found
496
+ break
497
+ }
498
+ if {$dir ne ""} {
499
+ set ldflags ""
500
+ set msg "static build of openssl in $dir"
501
+ set ssllibs "$dir/libssl.a $dir/libcrypto.a -lpthread"
502
+ if {[check-for-openssl $msg "$cflags $ldflags" $ssllibs]} {
503
+ incr found
504
+ break
505
+ }
506
+ }
507
+ }
508
+ }
509
+ }
510
+ if {$found} {
511
+ define FOSSIL_ENABLE_SSL
512
+ define-append EXTRA_CFLAGS $cflags
513
+ define-append EXTRA_LDFLAGS $ldflags
514
+ if {[info exists ssllibs]} {
515
+ define-append LIBS $ssllibs
516
+ } else {
517
+ define-append LIBS -lssl -lcrypto
518
+ }
519
+ if {[info exists ::zlib_lib]} {
520
+ define-append LIBS $::zlib_lib
521
+ }
522
+ if {[is_mingw]} {
523
+ define-append LIBS -lgdi32 -lwsock32 -lcrypt32
524
+ }
525
+ msg-result "HTTPS support enabled"
526
+
527
+ # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
528
+ if {[string match *-darwin* [get-define host]]} {
529
+ if {[cctest -cflags {-Wdeprecated-declarations}]} {
530
+ define-append EXTRA_CFLAGS -Wdeprecated-declarations
531
+ }
532
+ }
533
+ } else {
534
+ user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
535
+ }
536
+ } else {
537
+ if {[info exists ::zlib_lib]} {
538
+ define-append LIBS $::zlib_lib
539
+ }
540
+ }
541
+}; # handle-with-openssl
533542
534543
########################################################################
535544
# --with-sqlite=PATH checks for the first it finds of the following...
536545
# - PATH/sqlite3.c and PATH/sqlite3.h
537546
# - PATH/sqlite3.o (and assumes sqlite3.h is with it)
@@ -540,10 +549,12 @@
540549
# ^^^ CFLAGS_INCLUDE is ONLY for -I... flags and their order is
541550
# significant so that --with-sqlite=PATH's header can shadow our
542551
# own. One caveat with this is that we cannot point --with-sqlite=PATH
543552
# to the root of sqlite3's own build tree because that dir has a
544553
# config.h which ends up shadowing src/config.h, breaking our build.
554
+# (That is no longer true: that that config.h was renamed to
555
+# sqlite_cfg.h at some point.)
545556
set sq3path [opt-val with-sqlite]
546557
define SQLITE3_SRC.2 {}
547558
define SQLITE3_OBJ.2 {}
548559
define SQLITE3_SHELL_SRC.2 {$(SQLITE3_SHELL_SRC.0)}
549560
if {$sq3path in {tree ""}} {
@@ -926,10 +937,12 @@
926937
} else {
927938
define EMCC_WRAPPER ""
928939
define EMCC_OPT ""
929940
catch {exec rm -f tools/emcc.sh}
930941
}
942
+
943
+handle-with-openssl
931944
932945
# Tag container builds with a prefix of the checkin ID of the version
933946
# of Fossil each one contains. This not only allows multiple images
934947
# to coexist and multiple containers to be created unamgiguosly from
935948
# them, it also changes the URL we fetch the source tarball from, so
936949
--- auto.def
+++ auto.def
@@ -434,104 +434,113 @@
434 }
435 }
436 set ::zlib_lib -lz
437 }
438
439 set ssldirs [opt-val with-openssl]
440 if {$ssldirs ne "none"} {
441 set found 0
442 if {$ssldirs eq "tree"} {
443 set ssldir [file dirname $autosetup(dir)]/compat/openssl
444 if {![file isdirectory $ssldir]} {
445 user-error "The OpenSSL in source tree directory does not exist"
446 }
447 set msg "openssl in $ssldir"
448 set cflags "-I$ssldir/include"
449 set ldflags "-L$ssldir"
450 set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a -lpthread"
451 set found [check-for-openssl "openssl in source tree" "$cflags $ldflags" $ssllibs]
452 } else {
453 if {$ssldirs in {auto ""}} {
454 catch {
455 set cflags [exec pkg-config openssl --cflags-only-I]
456 set ldflags [exec pkg-config openssl --libs-only-L]
457 set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
458 } msg
459 if {!$found} {
460 set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl \
461 /usr/pkg /usr/local /usr /usr/local/opt/openssl \
462 /opt/homebrew/opt/openssl"
463 }
464 }
465 if {!$found} {
466 foreach dir $ssldirs {
467 if {$dir eq ""} {
468 set msg "system openssl"
469 set cflags ""
470 set ldflags ""
471 } else {
472 set msg "openssl in $dir"
473 set cflags "-I$dir/include"
474 if {[file readable $dir/libssl.a]} {
475 set ldflags -L$dir
476 } elseif {[file readable $dir/lib/libssl.a]} {
477 set ldflags -L$dir/lib
478 } elseif {[file isdir $dir/lib]} {
479 set ldflags "-L$dir -L$dir/lib"
480 } else {
481 set ldflags -L$dir
482 }
483 }
484 if {[check-for-openssl $msg "$cflags $ldflags"]} {
485 incr found
486 break
487 }
488 if {$dir ne ""} {
489 set ldflags ""
490 set msg "static build of openssl in $dir"
491 set ssllibs "$dir/libssl.a $dir/libcrypto.a -lpthread"
492 if {[check-for-openssl $msg "$cflags $ldflags" $ssllibs]} {
493 incr found
494 break
495 }
496 }
497 }
498 }
499 }
500 if {$found} {
501 define FOSSIL_ENABLE_SSL
502 define-append EXTRA_CFLAGS $cflags
503 define-append EXTRA_LDFLAGS $ldflags
504 if {[info exists ssllibs]} {
505 define-append LIBS $ssllibs
506 } else {
507 define-append LIBS -lssl -lcrypto
508 }
509 if {[info exists ::zlib_lib]} {
510 define-append LIBS $::zlib_lib
511 }
512 if {[is_mingw]} {
513 define-append LIBS -lgdi32 -lwsock32 -lcrypt32
514 }
515 msg-result "HTTPS support enabled"
516
517 # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
518 if {[string match *-darwin* [get-define host]]} {
519 if {[cctest -cflags {-Wdeprecated-declarations}]} {
520 define-append EXTRA_CFLAGS -Wdeprecated-declarations
521 }
522 }
523 } else {
524 user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
525 }
526 } else {
527 if {[info exists ::zlib_lib]} {
528 define-append LIBS $::zlib_lib
529 }
530 }
531
532
 
 
 
 
 
 
 
 
 
533
534 ########################################################################
535 # --with-sqlite=PATH checks for the first it finds of the following...
536 # - PATH/sqlite3.c and PATH/sqlite3.h
537 # - PATH/sqlite3.o (and assumes sqlite3.h is with it)
@@ -540,10 +549,12 @@
540 # ^^^ CFLAGS_INCLUDE is ONLY for -I... flags and their order is
541 # significant so that --with-sqlite=PATH's header can shadow our
542 # own. One caveat with this is that we cannot point --with-sqlite=PATH
543 # to the root of sqlite3's own build tree because that dir has a
544 # config.h which ends up shadowing src/config.h, breaking our build.
 
 
545 set sq3path [opt-val with-sqlite]
546 define SQLITE3_SRC.2 {}
547 define SQLITE3_OBJ.2 {}
548 define SQLITE3_SHELL_SRC.2 {$(SQLITE3_SHELL_SRC.0)}
549 if {$sq3path in {tree ""}} {
@@ -926,10 +937,12 @@
926 } else {
927 define EMCC_WRAPPER ""
928 define EMCC_OPT ""
929 catch {exec rm -f tools/emcc.sh}
930 }
 
 
931
932 # Tag container builds with a prefix of the checkin ID of the version
933 # of Fossil each one contains. This not only allows multiple images
934 # to coexist and multiple containers to be created unamgiguosly from
935 # them, it also changes the URL we fetch the source tarball from, so
936
--- auto.def
+++ auto.def
@@ -434,104 +434,113 @@
434 }
435 }
436 set ::zlib_lib -lz
437 }
438
439 #
440 # Handle the --with-openssl flag and, incidentally, update @LIBS@ for
441 # zlib if openssl is _not_ used (if it is, we get zlib via libssl).
442 #
443 # This function should be called as late as possible in the configure
444 # script to avoid that its updates to @LIBS@ break tests which follow
445 # it when a custom local build of openssl is used, as discussed in
446 # <https://fossil-scm.org/forum/forumpost/15e3d9cdc137030c>.
447 #
448 proc handle-with-openssl {} {
449 set ssldirs [opt-val with-openssl]
450 if {$ssldirs ne "none"} {
451 set found 0
452 if {$ssldirs eq "tree"} {
453 set ssldir [file dirname $autosetup(dir)]/compat/openssl
454 if {![file isdirectory $ssldir]} {
455 user-error "The OpenSSL in source tree directory does not exist"
456 }
457 set msg "openssl in $ssldir"
458 set cflags "-I$ssldir/include"
459 set ldflags "-L$ssldir"
460 set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a -lpthread"
461 set found [check-for-openssl "openssl in source tree" "$cflags $ldflags" $ssllibs]
462 } else {
463 if {$ssldirs in {auto ""}} {
464 catch {
465 set cflags [exec pkg-config openssl --cflags-only-I]
466 set ldflags [exec pkg-config openssl --libs-only-L]
467 set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
468 } msg
469 if {!$found} {
470 set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl \
471 /usr/pkg /usr/local /usr /usr/local/opt/openssl \
472 /opt/homebrew/opt/openssl"
473 }
474 }
475 if {!$found} {
476 foreach dir $ssldirs {
477 if {$dir eq ""} {
478 set msg "system openssl"
479 set cflags ""
480 set ldflags ""
481 } else {
482 set msg "openssl in $dir"
483 set cflags "-I$dir/include"
484 if {[file readable $dir/libssl.a]} {
485 set ldflags -L$dir
486 } elseif {[file readable $dir/lib/libssl.a]} {
487 set ldflags -L$dir/lib
488 } elseif {[file isdir $dir/lib]} {
489 set ldflags "-L$dir -L$dir/lib"
490 } else {
491 set ldflags -L$dir
492 }
493 }
494 if {[check-for-openssl $msg "$cflags $ldflags"]} {
495 incr found
496 break
497 }
498 if {$dir ne ""} {
499 set ldflags ""
500 set msg "static build of openssl in $dir"
501 set ssllibs "$dir/libssl.a $dir/libcrypto.a -lpthread"
502 if {[check-for-openssl $msg "$cflags $ldflags" $ssllibs]} {
503 incr found
504 break
505 }
506 }
507 }
508 }
509 }
510 if {$found} {
511 define FOSSIL_ENABLE_SSL
512 define-append EXTRA_CFLAGS $cflags
513 define-append EXTRA_LDFLAGS $ldflags
514 if {[info exists ssllibs]} {
515 define-append LIBS $ssllibs
516 } else {
517 define-append LIBS -lssl -lcrypto
518 }
519 if {[info exists ::zlib_lib]} {
520 define-append LIBS $::zlib_lib
521 }
522 if {[is_mingw]} {
523 define-append LIBS -lgdi32 -lwsock32 -lcrypt32
524 }
525 msg-result "HTTPS support enabled"
526
527 # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
528 if {[string match *-darwin* [get-define host]]} {
529 if {[cctest -cflags {-Wdeprecated-declarations}]} {
530 define-append EXTRA_CFLAGS -Wdeprecated-declarations
531 }
532 }
533 } else {
534 user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
535 }
536 } else {
537 if {[info exists ::zlib_lib]} {
538 define-append LIBS $::zlib_lib
539 }
540 }
541 }; # handle-with-openssl
542
543 ########################################################################
544 # --with-sqlite=PATH checks for the first it finds of the following...
545 # - PATH/sqlite3.c and PATH/sqlite3.h
546 # - PATH/sqlite3.o (and assumes sqlite3.h is with it)
@@ -540,10 +549,12 @@
549 # ^^^ CFLAGS_INCLUDE is ONLY for -I... flags and their order is
550 # significant so that --with-sqlite=PATH's header can shadow our
551 # own. One caveat with this is that we cannot point --with-sqlite=PATH
552 # to the root of sqlite3's own build tree because that dir has a
553 # config.h which ends up shadowing src/config.h, breaking our build.
554 # (That is no longer true: that that config.h was renamed to
555 # sqlite_cfg.h at some point.)
556 set sq3path [opt-val with-sqlite]
557 define SQLITE3_SRC.2 {}
558 define SQLITE3_OBJ.2 {}
559 define SQLITE3_SHELL_SRC.2 {$(SQLITE3_SHELL_SRC.0)}
560 if {$sq3path in {tree ""}} {
@@ -926,10 +937,12 @@
937 } else {
938 define EMCC_WRAPPER ""
939 define EMCC_OPT ""
940 catch {exec rm -f tools/emcc.sh}
941 }
942
943 handle-with-openssl
944
945 # Tag container builds with a prefix of the checkin ID of the version
946 # of Fossil each one contains. This not only allows multiple images
947 # to coexist and multiple containers to be created unamgiguosly from
948 # them, it also changes the URL we fetch the source tarball from, so
949

Keyboard Shortcuts

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