From 51d5aa0915fcc759ef01ada8f694faa4d0d62c87 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 28 Oct 2024 18:30:46 +0000 Subject: [PATCH] Calculate TCLLIBDIR in the makefile targets which use it, rather than via the configure script. This enables its use in static makefiles. FossilOrigin-Name: 6b1494cecb48535b909f8a48ccb56e147221601380a1457ff85ab861fa576ea1 --- Makefile.in | 2 +- auto.def | 66 ++++++++++++++++++++++++++++----------------------- main.mk | 40 ++++++++++++++++++++----------- manifest | 16 ++++++------- manifest.uuid | 2 +- 5 files changed, 72 insertions(+), 54 deletions(-) diff --git a/Makefile.in b/Makefile.in index 688b3ff062..c705318113 100644 --- a/Makefile.in +++ b/Makefile.in @@ -214,7 +214,7 @@ TCL_CONFIG_SH = @TCL_CONFIG_SH@ # # Where do we want to install the tcl plugin # -TCLLIBDIR = @TCLLIBDIR@ +#TCLLIBDIR = @TCLLIBDIR@ # # Additional options when running tests using testrunner.tcl diff --git a/auto.def b/auto.def index 042656ff3c..d246a84086 100644 --- a/auto.def +++ b/auto.def @@ -580,40 +580,46 @@ proc sqlite-check-tcl {} { } define TCLSH_CMD $with_tclsh - if {$use_tcl} { - # Set up the TCLLIBDIR and TCLLIB_RPATH - set tcllibdir [get-env TCLLIBDIR ""] - if {"" eq $tcllibdir} { - if {[catch {exec echo "puts stdout \$auto_path" | "$with_tclsh"} result] == 0} { - foreach i $result { - if {[file isdir $i]} { - set tcllibdir $i - break + if {0} { + # 2024-10-28: calculation of TCLLIBDIR is now done via the shell + # in the makefile rules which need it (search main.mk for + # T.tcllibdir). This code block is kept around as a basis for + # comparison while the new makefile-side rules get battle-tested. + if {$use_tcl} { + # Set up the TCLLIBDIR and TCLLIB_RPATH + set tcllibdir [get-env TCLLIBDIR ""] + if {"" eq $tcllibdir} { + if {[catch {exec echo "puts stdout \$auto_path" | "$with_tclsh"} result] == 0} { + foreach i $result { + if {[file isdir $i]} { + set tcllibdir $i + break + } } + } else { + proj-warn "Cannot determine TCLLIBDIR" } - } else { - proj-warn "Cannot determine TCLLIBDIR" } + set tclrpath "" + if {"" ne $tcllibdir} { + set tcllibdir "${tcllibdir}/sqlite3" + set rp [get-define SH_LINKRPATH] + set tclrpath [string map [list "%s" $tcllibdir] $rp] + # Reminder: tclConfig.sh has TCL_LD_SEARCH_FLAGS to set the + # rpath but (A) it includes an unexpand var ref to + # ${LIB_RUNTIME_DIR}, which must be set in the makefile and (B) + # that flag is inherently compiler-dependent so it's not as + # portable as tclConfig.sh assumes. We'll instead use the rpath + # flag which autosetup determines for the current compiler. + } + define TCLLIBDIR $tcllibdir + define TCLLIB_RPATH $tclrpath + #proj-fatal "TCLLIB_RPATH = [get-define TCLLIB_RPATH]" + } else { + define TCLLIBDIR "" + define TCLLIB_RPATH "" } - set tclrpath "" - if {"" ne $tcllibdir} { - set tcllibdir "${tcllibdir}/sqlite3" - set rp [get-define SH_LINKRPATH] - set tclrpath [string map [list "%s" $tcllibdir] $rp] - # Reminder: tclConfig.sh has TCL_LD_SEARCH_FLAGS to set the - # rpath but (A) it includes an unexpand var ref to - # ${LIB_RUNTIME_DIR}, which must be set in the makefile and (B) - # that flag is inherently compiler-dependent so it's not as - # portable as tclConfig.sh assumes. We'll instead use the rpath - # flag which autosetup determines for the current compiler. - } - define TCLLIBDIR $tcllibdir - define TCLLIB_RPATH $tclrpath - #proj-fatal "TCLLIB_RPATH = [get-define TCLLIB_RPATH]" - } else { - define TCLLIBDIR "" - define TCLLIB_RPATH "" - } + }; # find TCLLIBDIR if {[file exists $with_tclsh]} { msg-result "Using tclsh: $with_tclsh" diff --git a/main.mk b/main.mk index 139245830f..38f92af360 100644 --- a/main.mk +++ b/main.mk @@ -214,13 +214,8 @@ SHELL_OPT ?= # # TCL_CONFIG_SH must, for some of the build targets, refer to a valid # tclConfig.sh. That script will be used to populate most of the other -# TCL-related vars the build needs, the one exception being: +# TCL-related vars the build needs. # -# TCLLIBDIR is required for installing (but not building) the TCL -# deliverables. It must currently be set by the makefile which -# imports this one or as an argument to it from the user. -# -TCLLIBDIR ?= TCL_CONFIG_SH ?= # # $(TCLLIB_RPATH) is the -rpath flag for libtclsqlite3, not @@ -929,6 +924,24 @@ has_tclsh85: # which use this should also have a dependency on has_tclconfig. # SOURCE_TCLCONFIG = . $(TCL_CONFIG_SH) || exit $$? +# +# T.tcllibdir = shell code to extract the TCLLIBDIR to the tcllibdir +# shell var and exit with !0 if it cannot be determined. It must be +# part of a chained series of commands so that the var survives for +# the following rules in the same recipe. +# +# Algo: tcllibdir = the first entry from TCL's $auto_path which refers +# to an existing dir, then append /sqlite3 to it. +# +T.tcllibdir = \ + for tcllibdir in `echo "puts stdout \\$$auto_path" | $(TCLSH_CMD)`; do \ + [ -d "$$tcllibdir" ] && break; done; \ + if [ x = "x$$tcllibdir" ]; then echo "Cannot determine TCLLIBDIR" 1>&2; exit 1; fi; \ + tcllibdir="$$tcllibdir/sqlite3"; echo "TCLLIBDIR=$$tcllibdir" +# +# $(T.compile.tcl) and $(T.link.tcl) are TCL-specific counterparts for $(T.compile) +# and $(T.link) which first invoke $(SOURCE_TCLCONFIG). +# T.compile.tcl = $(SOURCE_TCLCONFIG); $(T.compile) T.link.tcl = $(SOURCE_TCLCONFIG); $(T.link) @@ -1400,11 +1413,11 @@ pkgIndex.tcl: echo 'package ifneeded sqlite3 $(PACKAGE_VERSION) [list load [file join $$dir libtclsqlite3[info sharedlibextension]] sqlite3]' > $@ libtclsqlite3.SO = libtclsqlite3$(T.dll) $(libtclsqlite3.SO): has_tclconfig tclsqlite.o $(libsqlite3.SO) - libdir=`echo "puts stdout [lindex \\$$auto_path 0]" | $(TCLSH_CMD)` || exit $$?; \ - $(SOURCE_TCLCONFIG); \ + @$(T.tcllibdir); \ + $(SOURCE_TCLCONFIG); set -x; \ $(T.link.shared) -o $@ tclsqlite.o \ $$TCL_INCLUDE_SPEC $$TCL_STUB_LIB_SPEC $(LDFLAGS.libsqlite3) \ - $(libsqlite3.SO) -Wl,-rpath,$$libdir/sqlite3 + $(libsqlite3.SO) -Wl,-rpath,$$tcllibdir # ^^^ that rpath bit is defined as TCL_LD_SEARCH_FLAGS in # tclConfig.sh, but it's defined in such a way as to be useless for a # _static_ makefile. @@ -1413,12 +1426,11 @@ $(libtclsqlite3.SO)-0 $(libtclsqlite3.SO)-: libtcl: $(libtclsqlite3.SO)-$(HAVE_TCL) all: libtcl -install.tcldir = $(DESTDIR)$(TCLLIBDIR) install-tcl-1: $(libtclsqlite3.SO) pkgIndex.tcl - @if [ "x$(DESTDIR)" = "x$(install.tcldir)" ]; then echo "TCLLIBDIR is not set." 1>&2; exit 1; fi - $(INSTALL) -d $(install.tcldir) - $(INSTALL) $(libtclsqlite3.SO) $(install.tcldir) - $(INSTALL.noexec) pkgIndex.tcl $(install.tcldir) + @$(T.tcllibdir); set -x; dest="$(DESTDIR)$$tcllibdir"; \ + $(INSTALL) -d $$dest; \ + $(INSTALL) $(libtclsqlite3.SO) $$dest; \ + $(INSTALL.noexec) pkgIndex.tcl $$dest install-tcl-0 install-tcl-: install-tcl: install-tcl-$(HAVE_TCL) install: install-tcl diff --git a/manifest b/manifest index d2fe1f68f2..0044c55208 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Remove\sthe\sltmain.sh\sautotools\sremnant. -D 2024-10-28T17:30:11.295 +C Calculate\sTCLLIBDIR\sin\sthe\smakefile\stargets\swhich\suse\sit,\srather\sthan\svia\sthe\sconfigure\sscript.\sThis\senables\sits\suse\sin\sstatic\smakefiles. +D 2024-10-28T18:30:46.768 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md b6e6c1baf38e4339bd3f1e0e5e5bfd0a9a93d133360691b2785c2d4b2f2dcec2 -F Makefile.in e4a6a12767fd297b5359ca4190141ec6f925e64dd8d5a1067a220e41b7dbf7a8 +F Makefile.in cdf1c8db0b33fa83f400bcd63742113a727517adc55b322d2e004339c012cac2 F Makefile.linux-generic 69b54c58ab2424a0d30f340d9defd7e87c25690a55b77acb9bdc657bd9a223f1 F Makefile.msc a92237976eb92c5efaa0dd2524746aec12c196e12df8d4dbff9543a4648c3312 F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 @@ -13,7 +13,7 @@ F art/icon-80x90.gif 65509ce3e5f86a9cd64fe7fca2d23954199f31fe44c1e09e208c80fb83d F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 -F auto.def 537d9e3cd85ed5a454ee6055585a4eadedde921fbb686fcb40c8446933be2b5a +F auto.def cf550c649ffa1d6ed383e627b3f5cdbd98e04708cf3b27632483caccd6b55cab F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am adedc1324b6a87fdd1265ddd336d2fb7d4f36a0e77b86ea553ae7cc4ea239347 F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac @@ -698,7 +698,7 @@ F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d F ext/wasm/wasmfs.make bc8bb227f35d5bd3863a7bd2233437c37472a0d81585979f058f9b9b503bef35 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk 79392fb2e964f1359518d71df364182d7e53cc26a8fc4b25362ded9aeb4a17f7 +F main.mk aba8a5877a848898c309862d6d19d80a0ccad4459641017dc377ca23c640aaad F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -2200,8 +2200,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3a3f7bf4307c27e56546e51da06ecc9a262cdf155fda2dd359aa2326d207a147 -R cd9b1bec596be837269b2e695c7b5245 +P dad5eb9393e87403b932ddfb9da6db0ce1d6ed75c4771f22e87fbce1b0c206c2 +R 20ebbf6e3d71220bc2b3e267520cf726 U stephan -Z 92ad112c447ec4600daf66fcdd05b35c +Z 3602e361ae1b37fbb57c835a7dbf6ec8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4794168bfe..5dac689438 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dad5eb9393e87403b932ddfb9da6db0ce1d6ed75c4771f22e87fbce1b0c206c2 +6b1494cecb48535b909f8a48ccb56e147221601380a1457ff85ab861fa576ea1