Fossil SCM

Fix a global var ref broken in one code path by [af7475cda699]. Move some of the larger auto.def chunks into their own functions for legibility, and to simplify eventual refactoring, but do not change any ordering or semantics (and such changes are bugs).

stephan 2025-02-26 07:58 trunk
Commit d84494f487a0c615fccf886c3e6dbd77537b5ff86db42d8c5125bc7e4be8823c
1 file changed +151 -132
+151 -132
--- auto.def
+++ auto.def
@@ -375,68 +375,73 @@
375375
msg-result "no"
376376
return 0
377377
}
378378
}
379379
380
+#
380381
# Check for zlib, using the given location if specified
381
-set zlibpath [opt-val with-zlib]
382
-if {$zlibpath eq "tree"} {
383
- set zlibdir [file dirname $autosetup(dir)]/compat/zlib
384
- if {![file isdirectory $zlibdir]} {
385
- user-error "The zlib in source tree directory does not exist"
386
- } elseif { ([llength [glob -nocomplain -directory $zlibdir libz*]] == 0) } {
387
- user-error "With --with-zlib=tree, $zlibdir must be configured and built first."
388
- }
389
- cc-with [list -cflags "-I$zlibdir -L$zlibdir"]
390
- define-append EXTRA_CFLAGS -I$zlibdir
391
- define-append LIBS $zlibdir/libz.a
392
- set ::zlib_lib $zlibdir/libz.a
393
- msg-result "Using zlib in source tree"
394
-} else {
395
- set cftry {""}
396
- set ldtry {""}
397
- if {$zlibpath ni {auto ""}} {
398
- lappend cftry "-I$zlibpath"
399
- lappend cftry "-I$zlibpath/include"
400
- lappend ldtry "-L$zlibpath"
401
- lappend ldtry "-L$zlibpath/lib"
402
- }
403
-
404
- # Reverse the list of tests so we check most-specific to least, else
405
- # platform devel files will shadow local --with-zlib overrides.
406
- foreach c [lreverse $cftry] {
407
- if {[cc-with [list -cflags $c] {cc-check-includes zlib.h}]} {
408
- if {$c eq ""} {
409
- msg-result "Found zlib.h in default include path"
410
- } else {
411
- define-append EXTRA_CFLAGS "$c"
412
- msg-result "Found zlib.h via $c"
413
- }
414
- set cfound $c
415
- break
416
- }
417
- }
418
- if {![info exists cfound]} {
419
- user-error "zlib.h not found; either install it or specify its location via --with-zlib"
420
- }
421
- foreach lcheck [lreverse $ldtry] {
422
- if {[cc-with [list -cflags "$cfound $lcheck"] {check-function-in-lib inflateEnd z}]} {
423
- if {$lcheck eq ""} {
424
- msg-result "Linked to zlib via default library path"
425
- } else {
426
- define-append EXTRA_LDFLAGS "$lcheck"
427
- msg-result "Linked to zlib via $lcheck"
428
- }
429
- if {![check-function-in-lib compressBound z]} {
430
- puts "Notice: disabling zlib compression in the SQL shell"
431
- define-append SQLITE_OPTIONS_EXT {-USQLITE_HAVE_ZLIB}
432
- }
433
- break
434
- }
435
- }
436
- set ::zlib_lib -lz
437
-}
382
+#
383
+proc handle-zlib {} {
384
+ set ::zlibpath [opt-val with-zlib]; # used by downstream tcl tests
385
+ if {$::zlibpath eq "tree"} {
386
+ set ::zlibdir [file dirname $::autosetup(dir)]/compat/zlib
387
+ if {![file isdirectory $::zlibdir]} {
388
+ user-error "The zlib in source tree directory does not exist"
389
+ } elseif { ([llength [glob -nocomplain -directory $::zlibdir libz*]] == 0) } {
390
+ user-error "With --with-zlib=tree, $::zlibdir must be configured and built first."
391
+ }
392
+ cc-with [list -cflags "-I$::zlibdir -L$::zlibdir"]
393
+ define-append EXTRA_CFLAGS -I$::zlibdir
394
+ define-append LIBS $::zlibdir/libz.a
395
+ set ::zlib_lib $::zlibdir/libz.a
396
+ msg-result "Using zlib in source tree"
397
+ } else {
398
+ set cftry {""}
399
+ set ldtry {""}
400
+ if {$::zlibpath ni {auto ""}} {
401
+ lappend cftry "-I$::zlibpath"
402
+ lappend cftry "-I$::zlibpath/include"
403
+ lappend ldtry "-L$::zlibpath"
404
+ lappend ldtry "-L$::zlibpath/lib"
405
+ }
406
+
407
+ # Reverse the list of tests so we check most-specific to least, else
408
+ # platform devel files will shadow local --with-zlib overrides.
409
+ foreach c [lreverse $cftry] {
410
+ if {[cc-with [list -cflags $c] {cc-check-includes zlib.h}]} {
411
+ if {$c eq ""} {
412
+ msg-result "Found zlib.h in default include path"
413
+ } else {
414
+ define-append EXTRA_CFLAGS "$c"
415
+ msg-result "Found zlib.h via $c"
416
+ }
417
+ set cfound $c
418
+ break
419
+ }
420
+ }
421
+ if {![info exists cfound]} {
422
+ user-error "zlib.h not found; either install it or specify its location via --with-zlib"
423
+ }
424
+ foreach lcheck [lreverse $ldtry] {
425
+ if {[cc-with [list -cflags "$cfound $lcheck"] {check-function-in-lib inflateEnd z}]} {
426
+ if {$lcheck eq ""} {
427
+ msg-result "Linked to zlib via default library path"
428
+ } else {
429
+ define-append EXTRA_LDFLAGS "$lcheck"
430
+ msg-result "Linked to zlib via $lcheck"
431
+ }
432
+ if {![check-function-in-lib compressBound z]} {
433
+ puts "Notice: disabling zlib compression in the SQL shell"
434
+ define-append SQLITE_OPTIONS_EXT {-USQLITE_HAVE_ZLIB}
435
+ }
436
+ break
437
+ }
438
+ }
439
+ set ::zlib_lib -lz
440
+ }
441
+}; # handle-zlib
442
+handle-zlib
438443
439444
#
440445
# Handle the --with-openssl flag and, incidentally, update @LIBS@ for
441446
# zlib if openssl is _not_ used (if it is, we get zlib via libssl).
442447
#
@@ -448,11 +453,11 @@
448453
proc handle-with-openssl {} {
449454
set ssldirs [opt-val with-openssl]
450455
if {$ssldirs ne "none"} {
451456
set found 0
452457
if {$ssldirs eq "tree"} {
453
- set ssldir [file dirname $autosetup(dir)]/compat/openssl
458
+ set ssldir [file dirname $::autosetup(dir)]/compat/openssl
454459
if {![file isdirectory $ssldir]} {
455460
user-error "The OpenSSL in source tree directory does not exist"
456461
}
457462
set msg "openssl in $ssldir"
458463
set cflags "-I$ssldir/include"
@@ -460,10 +465,11 @@
460465
set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a -lpthread"
461466
set found [check-for-openssl "openssl in source tree" "$cflags $ldflags" $ssllibs]
462467
} else {
463468
if {$ssldirs in {auto ""}} {
464469
catch {
470
+ # TODO?: use autosetup's pkg-config support
465471
set cflags [exec pkg-config openssl --cflags-only-I]
466472
set ldflags [exec pkg-config openssl --libs-only-L]
467473
set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
468474
} msg
469475
if {!$found} {
@@ -538,97 +544,109 @@
538544
define-append LIBS $::zlib_lib
539545
}
540546
}
541547
}; # handle-with-openssl
542548
549
+#
550
+# CFLAGS_INCLUDE is ONLY for -I... flags and their order is
551
+# significant so that --with-sqlite=PATH's header can shadow our
552
+# own. <s>One caveat with this is that we cannot point
553
+# --with-sqlite=PATH to the root of sqlite3's own build tree because
554
+# that dir has a config.h which ends up shadowing src/config.h,
555
+# breaking our build.</s> (That is no longer true: that that config.h
556
+# was renamed to sqlite_cfg.h at some point.)
557
+#
558
+define CFLAGS_INCLUDE {}
559
+
543560
########################################################################
544561
# --with-sqlite=PATH checks for the first it finds of the following...
545562
# - PATH/sqlite3.c and PATH/sqlite3.h
546563
# - PATH/sqlite3.o (and assumes sqlite3.h is with it)
547564
# - PATH/lib/libsqlite3* and PATH/include/sqlite3.h
548
-define CFLAGS_INCLUDE {}
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 ""}} {
561
- msg-result "Using sqlite3.c from this source tree."
562
-} else {
563
- # SQLITE3_ORIGIN:
564
- # 0 = local source tree
565
- # 1 = use external lib or sqlite3.o
566
- # 2 = use external sqlite3.c and (if found) shell.c
567
- define USE_SYSTEM_SQLITE 1
568
- define SQLITE3_ORIGIN 2
569
- if {$sq3path != "auto"} {
570
- if {([file exists $sq3path/sqlite3.c]) &&
571
- ([file exists $sq3path/sqlite3.h]) } {
572
- # Prefer sqlite3.[ch] if found.
573
- define SQLITE3_SRC.2 $sq3path/sqlite3.c
574
- define SQLITE3_OBJ.2 {$(SQLITE3_OBJ.0)}
575
- define USE_SYSTEM_SQLITE 2
576
- define SQLITE3_ORIGIN 2
577
- if {[file exists $sq3path/shell.c]} {
578
- define SQLITE3_SHELL_SRC.2 $sq3path/shell.c
579
- }
580
- define-append CFLAGS_INCLUDE -I$sq3path
581
- define-append EXTRA_LDFLAGS -lpthread
582
- # ^^^ additional -lXXX flags are conservative estimates
583
- msg-result "Using sqlite3.c and sqlite3.h from $sq3path"
584
- } elseif {[file exists $sq3path/sqlite3.o]} {
585
- # Use sqlite3.o if found.
586
- define SQLITE3_OBJ.2 $sq3path/sqlite3.o
587
- define-append CFLAGS_INCLUDE -I$sq3path
588
- define-append EXTRA_LDFLAGS $sq3path/sqlite3.o -lpthread
589
- # ^^^ additional -lXXX flags are conservative estimates
590
- msg-result "Using sqlite3.o from $sq3path"
591
- } elseif { ([llength [glob -nocomplain -directory $sq3path/lib libsqlite3*]] != 0) \
592
- && ([file exists $sq3path/include/sqlite3.h]) } {
593
- # e.g. --with-sqlite=/usr/local. Try $sq3path/lib/libsqlite3*
594
- # and $sq3path/include/sqlite3.h
595
- define-append CFLAGS_INCLUDE -I$sq3path/include
596
- define-append EXTRA_LDFLAGS -L$sq3path/lib -lsqlite3 -lpthread
597
- # ^^^ additional -lXXX flags are conservative estimates
598
- msg-result "Using -lsqlite3 from $sq3path"
599
- } else {
600
- # Assume $sq3path holds both the lib and header
601
- cc-with [list -cflags "-I$sq3path -L$sq3path"]
602
- define-append CFLAGS_INCLUDE -I$sq3path
603
- define-append EXTRA_LDFLAGS -L$sq3path -lsqlite3 -lpthread
604
- # ^^^ additional -lXXX flags are conservative estimates
605
- msg-result "Using -lsqlite3 from $sq3path"
606
- }
607
- } elseif {![cc-check-includes sqlite3.h] || ![check-function-in-lib sqlite3_open_v2 sqlite3]} {
608
- user-error "libsqlite3 not found please install it or specify the location with --with-sqlite"
609
- }
610
-}
611
-define-append CFLAGS_INCLUDE {-I. -I$(SRCDIR) -I$(SRCDIR_extsrc)}
612
-
613
-set tclpath [opt-val with-tcl]
614
-if {$tclpath ne ""} {
565
+proc handle-with-sqlite {} {
566
+ set sq3path [opt-val with-sqlite]
567
+ define SQLITE3_SRC.2 {}
568
+ define SQLITE3_OBJ.2 {}
569
+ define SQLITE3_SHELL_SRC.2 {$(SQLITE3_SHELL_SRC.0)}
570
+ if {$sq3path in {tree ""}} {
571
+ msg-result "Using sqlite3.c from this source tree."
572
+ } else {
573
+ # SQLITE3_ORIGIN:
574
+ # 0 = local source tree
575
+ # 1 = use external lib or sqlite3.o
576
+ # 2 = use external sqlite3.c and (if found) shell.c
577
+ define USE_SYSTEM_SQLITE 1
578
+ define SQLITE3_ORIGIN 2
579
+ if {$sq3path != "auto"} {
580
+ if {([file exists $sq3path/sqlite3.c]) &&
581
+ ([file exists $sq3path/sqlite3.h]) } {
582
+ # Prefer sqlite3.[ch] if found.
583
+ define SQLITE3_SRC.2 $sq3path/sqlite3.c
584
+ define SQLITE3_OBJ.2 {$(SQLITE3_OBJ.0)}
585
+ define USE_SYSTEM_SQLITE 2
586
+ define SQLITE3_ORIGIN 2
587
+ if {[file exists $sq3path/shell.c]} {
588
+ define SQLITE3_SHELL_SRC.2 $sq3path/shell.c
589
+ }
590
+ define-append CFLAGS_INCLUDE -I$sq3path
591
+ define-append EXTRA_LDFLAGS -lpthread
592
+ # ^^^ additional -lXXX flags are conservative estimates
593
+ msg-result "Using sqlite3.c and sqlite3.h from $sq3path"
594
+ } elseif {[file exists $sq3path/sqlite3.o]} {
595
+ # Use sqlite3.o if found.
596
+ define SQLITE3_OBJ.2 $sq3path/sqlite3.o
597
+ define-append CFLAGS_INCLUDE -I$sq3path
598
+ define-append EXTRA_LDFLAGS $sq3path/sqlite3.o -lpthread
599
+ # ^^^ additional -lXXX flags are conservative estimates
600
+ msg-result "Using sqlite3.o from $sq3path"
601
+ } elseif { ([llength [glob -nocomplain -directory $sq3path/lib libsqlite3*]] != 0) \
602
+ && ([file exists $sq3path/include/sqlite3.h]) } {
603
+ # e.g. --with-sqlite=/usr/local. Try $sq3path/lib/libsqlite3*
604
+ # and $sq3path/include/sqlite3.h
605
+ define-append CFLAGS_INCLUDE -I$sq3path/include
606
+ define-append EXTRA_LDFLAGS -L$sq3path/lib -lsqlite3 -lpthread
607
+ # ^^^ additional -lXXX flags are conservative estimates
608
+ msg-result "Using -lsqlite3 from $sq3path"
609
+ } else {
610
+ # Assume $sq3path holds both the lib and header
611
+ cc-with [list -cflags "-I$sq3path -L$sq3path"]
612
+ define-append CFLAGS_INCLUDE -I$sq3path
613
+ define-append EXTRA_LDFLAGS -L$sq3path -lsqlite3 -lpthread
614
+ # ^^^ additional -lXXX flags are conservative estimates
615
+ msg-result "Using -lsqlite3 from $sq3path"
616
+ }
617
+ } elseif {![cc-check-includes sqlite3.h] || ![check-function-in-lib sqlite3_open_v2 sqlite3]} {
618
+ user-error "libsqlite3 not found please install it or specify the location with --with-sqlite"
619
+ }
620
+ }
621
+}; # handle-with-sqlite
622
+handle-with-sqlite
623
+define-append CFLAGS_INCLUDE {-I. -I$(SRCDIR) -I$(SRCDIR_extsrc)}; # must be after handle-with-sqlite
624
+
625
+#
626
+# Handle the --with-tcl flag.
627
+#
628
+proc handle-with-tcl {} {
629
+ set tclpath [opt-val with-tcl]
630
+ if {$tclpath eq ""} {
631
+ return
632
+ }
615633
set tclprivatestubs [opt-bool with-tcl-private-stubs]
616634
# Note parse-tclconfig-sh is in autosetup/local.tcl
617635
if {$tclpath eq "1"} {
618
- set tcldir [file dirname $autosetup(dir)]/compat/tcl-8.6
636
+ set tcldir [file dirname $::autosetup(dir)]/compat/tcl-8.6
619637
if {$tclprivatestubs} {
620638
set tclconfig(TCL_INCLUDE_SPEC) -I$tcldir/generic
621639
set tclconfig(TCL_VERSION) {Private Stubs}
622640
set tclconfig(TCL_PATCH_LEVEL) {}
623641
set tclconfig(TCL_PREFIX) $tcldir
624642
set tclconfig(TCL_LD_FLAGS) { }
625643
} else {
626644
# Use the system Tcl. Look in some likely places.
627645
array set tclconfig [parse-tclconfig-sh \
628
- $tcldir/unix $tcldir/win \
629
- /usr /usr/local /usr/share /opt/local]
646
+ $tcldir/unix $tcldir/win \
647
+ /usr /usr/local /usr/share /opt/local]
630648
set msg "on your system"
631649
}
632650
} else {
633651
array set tclconfig [parse-tclconfig-sh $tclpath]
634652
set msg "at $tclpath"
@@ -711,27 +729,28 @@
711729
if {!$tclprivatestubs} {
712730
define-append LIBS $libs
713731
}
714732
define-append EXTRA_CFLAGS $cflags
715733
define-append CFLAGS $cflags
716
- if {[info exists zlibpath] && $zlibpath eq "tree"} {
734
+ if {[info exists ::zlibpath] && $::zlibpath eq "tree"} {
717735
#
718736
# NOTE: When using zlib in the source tree, prevent Tcl from
719737
# pulling in the system one.
720738
#
721739
set tclconfig(TCL_LD_FLAGS) [string map [list -lz ""] \
722
- $tclconfig(TCL_LD_FLAGS)]
740
+ $tclconfig(TCL_LD_FLAGS)]
723741
}
724742
#
725743
# NOTE: Remove "-ldl" from the TCL_LD_FLAGS because it will be
726744
# be checked for near the bottom of this file.
727745
#
728746
set tclconfig(TCL_LD_FLAGS) [string map [list -ldl ""] \
729
- $tclconfig(TCL_LD_FLAGS)]
747
+ $tclconfig(TCL_LD_FLAGS)]
730748
define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
731749
define FOSSIL_ENABLE_TCL
732
-}
750
+}; # handle-with-tcl
751
+handle-with-tcl
733752
734753
# Network functions require libraries on some systems
735754
cc-check-function-in-lib gethostbyname nsl
736755
if {![cc-check-function-in-lib socket {socket network}]} {
737756
# Last resort, may be Windows
738757
--- auto.def
+++ auto.def
@@ -375,68 +375,73 @@
375 msg-result "no"
376 return 0
377 }
378 }
379
 
380 # Check for zlib, using the given location if specified
381 set zlibpath [opt-val with-zlib]
382 if {$zlibpath eq "tree"} {
383 set zlibdir [file dirname $autosetup(dir)]/compat/zlib
384 if {![file isdirectory $zlibdir]} {
385 user-error "The zlib in source tree directory does not exist"
386 } elseif { ([llength [glob -nocomplain -directory $zlibdir libz*]] == 0) } {
387 user-error "With --with-zlib=tree, $zlibdir must be configured and built first."
388 }
389 cc-with [list -cflags "-I$zlibdir -L$zlibdir"]
390 define-append EXTRA_CFLAGS -I$zlibdir
391 define-append LIBS $zlibdir/libz.a
392 set ::zlib_lib $zlibdir/libz.a
393 msg-result "Using zlib in source tree"
394 } else {
395 set cftry {""}
396 set ldtry {""}
397 if {$zlibpath ni {auto ""}} {
398 lappend cftry "-I$zlibpath"
399 lappend cftry "-I$zlibpath/include"
400 lappend ldtry "-L$zlibpath"
401 lappend ldtry "-L$zlibpath/lib"
402 }
403
404 # Reverse the list of tests so we check most-specific to least, else
405 # platform devel files will shadow local --with-zlib overrides.
406 foreach c [lreverse $cftry] {
407 if {[cc-with [list -cflags $c] {cc-check-includes zlib.h}]} {
408 if {$c eq ""} {
409 msg-result "Found zlib.h in default include path"
410 } else {
411 define-append EXTRA_CFLAGS "$c"
412 msg-result "Found zlib.h via $c"
413 }
414 set cfound $c
415 break
416 }
417 }
418 if {![info exists cfound]} {
419 user-error "zlib.h not found; either install it or specify its location via --with-zlib"
420 }
421 foreach lcheck [lreverse $ldtry] {
422 if {[cc-with [list -cflags "$cfound $lcheck"] {check-function-in-lib inflateEnd z}]} {
423 if {$lcheck eq ""} {
424 msg-result "Linked to zlib via default library path"
425 } else {
426 define-append EXTRA_LDFLAGS "$lcheck"
427 msg-result "Linked to zlib via $lcheck"
428 }
429 if {![check-function-in-lib compressBound z]} {
430 puts "Notice: disabling zlib compression in the SQL shell"
431 define-append SQLITE_OPTIONS_EXT {-USQLITE_HAVE_ZLIB}
432 }
433 break
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 #
@@ -448,11 +453,11 @@
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"
@@ -460,10 +465,11 @@
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} {
@@ -538,97 +544,109 @@
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)
547 # - PATH/lib/libsqlite3* and PATH/include/sqlite3.h
548 define CFLAGS_INCLUDE {}
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 ""}} {
561 msg-result "Using sqlite3.c from this source tree."
562 } else {
563 # SQLITE3_ORIGIN:
564 # 0 = local source tree
565 # 1 = use external lib or sqlite3.o
566 # 2 = use external sqlite3.c and (if found) shell.c
567 define USE_SYSTEM_SQLITE 1
568 define SQLITE3_ORIGIN 2
569 if {$sq3path != "auto"} {
570 if {([file exists $sq3path/sqlite3.c]) &&
571 ([file exists $sq3path/sqlite3.h]) } {
572 # Prefer sqlite3.[ch] if found.
573 define SQLITE3_SRC.2 $sq3path/sqlite3.c
574 define SQLITE3_OBJ.2 {$(SQLITE3_OBJ.0)}
575 define USE_SYSTEM_SQLITE 2
576 define SQLITE3_ORIGIN 2
577 if {[file exists $sq3path/shell.c]} {
578 define SQLITE3_SHELL_SRC.2 $sq3path/shell.c
579 }
580 define-append CFLAGS_INCLUDE -I$sq3path
581 define-append EXTRA_LDFLAGS -lpthread
582 # ^^^ additional -lXXX flags are conservative estimates
583 msg-result "Using sqlite3.c and sqlite3.h from $sq3path"
584 } elseif {[file exists $sq3path/sqlite3.o]} {
585 # Use sqlite3.o if found.
586 define SQLITE3_OBJ.2 $sq3path/sqlite3.o
587 define-append CFLAGS_INCLUDE -I$sq3path
588 define-append EXTRA_LDFLAGS $sq3path/sqlite3.o -lpthread
589 # ^^^ additional -lXXX flags are conservative estimates
590 msg-result "Using sqlite3.o from $sq3path"
591 } elseif { ([llength [glob -nocomplain -directory $sq3path/lib libsqlite3*]] != 0) \
592 && ([file exists $sq3path/include/sqlite3.h]) } {
593 # e.g. --with-sqlite=/usr/local. Try $sq3path/lib/libsqlite3*
594 # and $sq3path/include/sqlite3.h
595 define-append CFLAGS_INCLUDE -I$sq3path/include
596 define-append EXTRA_LDFLAGS -L$sq3path/lib -lsqlite3 -lpthread
597 # ^^^ additional -lXXX flags are conservative estimates
598 msg-result "Using -lsqlite3 from $sq3path"
599 } else {
600 # Assume $sq3path holds both the lib and header
601 cc-with [list -cflags "-I$sq3path -L$sq3path"]
602 define-append CFLAGS_INCLUDE -I$sq3path
603 define-append EXTRA_LDFLAGS -L$sq3path -lsqlite3 -lpthread
604 # ^^^ additional -lXXX flags are conservative estimates
605 msg-result "Using -lsqlite3 from $sq3path"
606 }
607 } elseif {![cc-check-includes sqlite3.h] || ![check-function-in-lib sqlite3_open_v2 sqlite3]} {
608 user-error "libsqlite3 not found please install it or specify the location with --with-sqlite"
609 }
610 }
611 define-append CFLAGS_INCLUDE {-I. -I$(SRCDIR) -I$(SRCDIR_extsrc)}
612
613 set tclpath [opt-val with-tcl]
614 if {$tclpath ne ""} {
 
615 set tclprivatestubs [opt-bool with-tcl-private-stubs]
616 # Note parse-tclconfig-sh is in autosetup/local.tcl
617 if {$tclpath eq "1"} {
618 set tcldir [file dirname $autosetup(dir)]/compat/tcl-8.6
619 if {$tclprivatestubs} {
620 set tclconfig(TCL_INCLUDE_SPEC) -I$tcldir/generic
621 set tclconfig(TCL_VERSION) {Private Stubs}
622 set tclconfig(TCL_PATCH_LEVEL) {}
623 set tclconfig(TCL_PREFIX) $tcldir
624 set tclconfig(TCL_LD_FLAGS) { }
625 } else {
626 # Use the system Tcl. Look in some likely places.
627 array set tclconfig [parse-tclconfig-sh \
628 $tcldir/unix $tcldir/win \
629 /usr /usr/local /usr/share /opt/local]
630 set msg "on your system"
631 }
632 } else {
633 array set tclconfig [parse-tclconfig-sh $tclpath]
634 set msg "at $tclpath"
@@ -711,27 +729,28 @@
711 if {!$tclprivatestubs} {
712 define-append LIBS $libs
713 }
714 define-append EXTRA_CFLAGS $cflags
715 define-append CFLAGS $cflags
716 if {[info exists zlibpath] && $zlibpath eq "tree"} {
717 #
718 # NOTE: When using zlib in the source tree, prevent Tcl from
719 # pulling in the system one.
720 #
721 set tclconfig(TCL_LD_FLAGS) [string map [list -lz ""] \
722 $tclconfig(TCL_LD_FLAGS)]
723 }
724 #
725 # NOTE: Remove "-ldl" from the TCL_LD_FLAGS because it will be
726 # be checked for near the bottom of this file.
727 #
728 set tclconfig(TCL_LD_FLAGS) [string map [list -ldl ""] \
729 $tclconfig(TCL_LD_FLAGS)]
730 define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
731 define FOSSIL_ENABLE_TCL
732 }
 
733
734 # Network functions require libraries on some systems
735 cc-check-function-in-lib gethostbyname nsl
736 if {![cc-check-function-in-lib socket {socket network}]} {
737 # Last resort, may be Windows
738
--- auto.def
+++ auto.def
@@ -375,68 +375,73 @@
375 msg-result "no"
376 return 0
377 }
378 }
379
380 #
381 # Check for zlib, using the given location if specified
382 #
383 proc handle-zlib {} {
384 set ::zlibpath [opt-val with-zlib]; # used by downstream tcl tests
385 if {$::zlibpath eq "tree"} {
386 set ::zlibdir [file dirname $::autosetup(dir)]/compat/zlib
387 if {![file isdirectory $::zlibdir]} {
388 user-error "The zlib in source tree directory does not exist"
389 } elseif { ([llength [glob -nocomplain -directory $::zlibdir libz*]] == 0) } {
390 user-error "With --with-zlib=tree, $::zlibdir must be configured and built first."
391 }
392 cc-with [list -cflags "-I$::zlibdir -L$::zlibdir"]
393 define-append EXTRA_CFLAGS -I$::zlibdir
394 define-append LIBS $::zlibdir/libz.a
395 set ::zlib_lib $::zlibdir/libz.a
396 msg-result "Using zlib in source tree"
397 } else {
398 set cftry {""}
399 set ldtry {""}
400 if {$::zlibpath ni {auto ""}} {
401 lappend cftry "-I$::zlibpath"
402 lappend cftry "-I$::zlibpath/include"
403 lappend ldtry "-L$::zlibpath"
404 lappend ldtry "-L$::zlibpath/lib"
405 }
406
407 # Reverse the list of tests so we check most-specific to least, else
408 # platform devel files will shadow local --with-zlib overrides.
409 foreach c [lreverse $cftry] {
410 if {[cc-with [list -cflags $c] {cc-check-includes zlib.h}]} {
411 if {$c eq ""} {
412 msg-result "Found zlib.h in default include path"
413 } else {
414 define-append EXTRA_CFLAGS "$c"
415 msg-result "Found zlib.h via $c"
416 }
417 set cfound $c
418 break
419 }
420 }
421 if {![info exists cfound]} {
422 user-error "zlib.h not found; either install it or specify its location via --with-zlib"
423 }
424 foreach lcheck [lreverse $ldtry] {
425 if {[cc-with [list -cflags "$cfound $lcheck"] {check-function-in-lib inflateEnd z}]} {
426 if {$lcheck eq ""} {
427 msg-result "Linked to zlib via default library path"
428 } else {
429 define-append EXTRA_LDFLAGS "$lcheck"
430 msg-result "Linked to zlib via $lcheck"
431 }
432 if {![check-function-in-lib compressBound z]} {
433 puts "Notice: disabling zlib compression in the SQL shell"
434 define-append SQLITE_OPTIONS_EXT {-USQLITE_HAVE_ZLIB}
435 }
436 break
437 }
438 }
439 set ::zlib_lib -lz
440 }
441 }; # handle-zlib
442 handle-zlib
443
444 #
445 # Handle the --with-openssl flag and, incidentally, update @LIBS@ for
446 # zlib if openssl is _not_ used (if it is, we get zlib via libssl).
447 #
@@ -448,11 +453,11 @@
453 proc handle-with-openssl {} {
454 set ssldirs [opt-val with-openssl]
455 if {$ssldirs ne "none"} {
456 set found 0
457 if {$ssldirs eq "tree"} {
458 set ssldir [file dirname $::autosetup(dir)]/compat/openssl
459 if {![file isdirectory $ssldir]} {
460 user-error "The OpenSSL in source tree directory does not exist"
461 }
462 set msg "openssl in $ssldir"
463 set cflags "-I$ssldir/include"
@@ -460,10 +465,11 @@
465 set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a -lpthread"
466 set found [check-for-openssl "openssl in source tree" "$cflags $ldflags" $ssllibs]
467 } else {
468 if {$ssldirs in {auto ""}} {
469 catch {
470 # TODO?: use autosetup's pkg-config support
471 set cflags [exec pkg-config openssl --cflags-only-I]
472 set ldflags [exec pkg-config openssl --libs-only-L]
473 set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
474 } msg
475 if {!$found} {
@@ -538,97 +544,109 @@
544 define-append LIBS $::zlib_lib
545 }
546 }
547 }; # handle-with-openssl
548
549 #
550 # CFLAGS_INCLUDE is ONLY for -I... flags and their order is
551 # significant so that --with-sqlite=PATH's header can shadow our
552 # own. <s>One caveat with this is that we cannot point
553 # --with-sqlite=PATH to the root of sqlite3's own build tree because
554 # that dir has a config.h which ends up shadowing src/config.h,
555 # breaking our build.</s> (That is no longer true: that that config.h
556 # was renamed to sqlite_cfg.h at some point.)
557 #
558 define CFLAGS_INCLUDE {}
559
560 ########################################################################
561 # --with-sqlite=PATH checks for the first it finds of the following...
562 # - PATH/sqlite3.c and PATH/sqlite3.h
563 # - PATH/sqlite3.o (and assumes sqlite3.h is with it)
564 # - PATH/lib/libsqlite3* and PATH/include/sqlite3.h
565 proc handle-with-sqlite {} {
566 set sq3path [opt-val with-sqlite]
567 define SQLITE3_SRC.2 {}
568 define SQLITE3_OBJ.2 {}
569 define SQLITE3_SHELL_SRC.2 {$(SQLITE3_SHELL_SRC.0)}
570 if {$sq3path in {tree ""}} {
571 msg-result "Using sqlite3.c from this source tree."
572 } else {
573 # SQLITE3_ORIGIN:
574 # 0 = local source tree
575 # 1 = use external lib or sqlite3.o
576 # 2 = use external sqlite3.c and (if found) shell.c
577 define USE_SYSTEM_SQLITE 1
578 define SQLITE3_ORIGIN 2
579 if {$sq3path != "auto"} {
580 if {([file exists $sq3path/sqlite3.c]) &&
581 ([file exists $sq3path/sqlite3.h]) } {
582 # Prefer sqlite3.[ch] if found.
583 define SQLITE3_SRC.2 $sq3path/sqlite3.c
584 define SQLITE3_OBJ.2 {$(SQLITE3_OBJ.0)}
585 define USE_SYSTEM_SQLITE 2
586 define SQLITE3_ORIGIN 2
587 if {[file exists $sq3path/shell.c]} {
588 define SQLITE3_SHELL_SRC.2 $sq3path/shell.c
589 }
590 define-append CFLAGS_INCLUDE -I$sq3path
591 define-append EXTRA_LDFLAGS -lpthread
592 # ^^^ additional -lXXX flags are conservative estimates
593 msg-result "Using sqlite3.c and sqlite3.h from $sq3path"
594 } elseif {[file exists $sq3path/sqlite3.o]} {
595 # Use sqlite3.o if found.
596 define SQLITE3_OBJ.2 $sq3path/sqlite3.o
597 define-append CFLAGS_INCLUDE -I$sq3path
598 define-append EXTRA_LDFLAGS $sq3path/sqlite3.o -lpthread
599 # ^^^ additional -lXXX flags are conservative estimates
600 msg-result "Using sqlite3.o from $sq3path"
601 } elseif { ([llength [glob -nocomplain -directory $sq3path/lib libsqlite3*]] != 0) \
602 && ([file exists $sq3path/include/sqlite3.h]) } {
603 # e.g. --with-sqlite=/usr/local. Try $sq3path/lib/libsqlite3*
604 # and $sq3path/include/sqlite3.h
605 define-append CFLAGS_INCLUDE -I$sq3path/include
606 define-append EXTRA_LDFLAGS -L$sq3path/lib -lsqlite3 -lpthread
607 # ^^^ additional -lXXX flags are conservative estimates
608 msg-result "Using -lsqlite3 from $sq3path"
609 } else {
610 # Assume $sq3path holds both the lib and header
611 cc-with [list -cflags "-I$sq3path -L$sq3path"]
612 define-append CFLAGS_INCLUDE -I$sq3path
613 define-append EXTRA_LDFLAGS -L$sq3path -lsqlite3 -lpthread
614 # ^^^ additional -lXXX flags are conservative estimates
615 msg-result "Using -lsqlite3 from $sq3path"
616 }
617 } elseif {![cc-check-includes sqlite3.h] || ![check-function-in-lib sqlite3_open_v2 sqlite3]} {
618 user-error "libsqlite3 not found please install it or specify the location with --with-sqlite"
619 }
620 }
621 }; # handle-with-sqlite
622 handle-with-sqlite
623 define-append CFLAGS_INCLUDE {-I. -I$(SRCDIR) -I$(SRCDIR_extsrc)}; # must be after handle-with-sqlite
624
625 #
626 # Handle the --with-tcl flag.
627 #
628 proc handle-with-tcl {} {
629 set tclpath [opt-val with-tcl]
630 if {$tclpath eq ""} {
631 return
632 }
633 set tclprivatestubs [opt-bool with-tcl-private-stubs]
634 # Note parse-tclconfig-sh is in autosetup/local.tcl
635 if {$tclpath eq "1"} {
636 set tcldir [file dirname $::autosetup(dir)]/compat/tcl-8.6
637 if {$tclprivatestubs} {
638 set tclconfig(TCL_INCLUDE_SPEC) -I$tcldir/generic
639 set tclconfig(TCL_VERSION) {Private Stubs}
640 set tclconfig(TCL_PATCH_LEVEL) {}
641 set tclconfig(TCL_PREFIX) $tcldir
642 set tclconfig(TCL_LD_FLAGS) { }
643 } else {
644 # Use the system Tcl. Look in some likely places.
645 array set tclconfig [parse-tclconfig-sh \
646 $tcldir/unix $tcldir/win \
647 /usr /usr/local /usr/share /opt/local]
648 set msg "on your system"
649 }
650 } else {
651 array set tclconfig [parse-tclconfig-sh $tclpath]
652 set msg "at $tclpath"
@@ -711,27 +729,28 @@
729 if {!$tclprivatestubs} {
730 define-append LIBS $libs
731 }
732 define-append EXTRA_CFLAGS $cflags
733 define-append CFLAGS $cflags
734 if {[info exists ::zlibpath] && $::zlibpath eq "tree"} {
735 #
736 # NOTE: When using zlib in the source tree, prevent Tcl from
737 # pulling in the system one.
738 #
739 set tclconfig(TCL_LD_FLAGS) [string map [list -lz ""] \
740 $tclconfig(TCL_LD_FLAGS)]
741 }
742 #
743 # NOTE: Remove "-ldl" from the TCL_LD_FLAGS because it will be
744 # be checked for near the bottom of this file.
745 #
746 set tclconfig(TCL_LD_FLAGS) [string map [list -ldl ""] \
747 $tclconfig(TCL_LD_FLAGS)]
748 define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
749 define FOSSIL_ENABLE_TCL
750 }; # handle-with-tcl
751 handle-with-tcl
752
753 # Network functions require libraries on some systems
754 cc-check-function-in-lib gethostbyname nsl
755 if {![cc-check-function-in-lib socket {socket network}]} {
756 # Last resort, may be Windows
757

Keyboard Shortcuts

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