SQLite

Check-in [6b1494ce]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Calculate TCLLIBDIR in the makefile targets which use it, rather than via the configure script. This enables its use in static makefiles.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6b1494cecb48535b909f8a48ccb56e147221601380a1457ff85ab861fa576ea1
User & Date: stephan 2024-10-28 18:30:46
Context
2024-10-28
18:41
Minor makefile formatting cleanups. No functional changes. (check-in: 10b2cfdc user: stephan tags: trunk)
18:30
Calculate TCLLIBDIR in the makefile targets which use it, rather than via the configure script. This enables its use in static makefiles. (check-in: 6b1494ce user: stephan tags: trunk)
17:30
Remove the ltmain.sh autotools remnant. (check-in: dad5eb93 user: stephan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Makefile.in.

210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#TCL_STUB_LIB_SPEC = @TCL_STUB_LIB_SPEC@
#TCL_EXEC_PREFIX = @TCL_EXEC_PREFIX@
#TCL_VERSION = @TCL_VERSION@
#TCLLIB_RPATH = @TCLLIB_RPATH@
#
# Where do we want to install the tcl plugin
#
TCLLIBDIR = @TCLLIBDIR@

#
# Additional options when running tests using testrunner.tcl
# This is usually either blank, or else --status
#
TSTRNNR_OPTS = @TSTRNNR_OPTS@








|







210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#TCL_STUB_LIB_SPEC = @TCL_STUB_LIB_SPEC@
#TCL_EXEC_PREFIX = @TCL_EXEC_PREFIX@
#TCL_VERSION = @TCL_VERSION@
#TCLLIB_RPATH = @TCLLIB_RPATH@
#
# Where do we want to install the tcl plugin
#
#TCLLIBDIR = @TCLLIBDIR@

#
# Additional options when running tests using testrunner.tcl
# This is usually either blank, or else --status
#
TSTRNNR_OPTS = @TSTRNNR_OPTS@

Changes to auto.def.

576
577
578
579
580
581
582





583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616

617
618
619
620
621
622
623
      } else {
        set with_tclsh $with_tclsh2
      }
    }
  }
  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
          }
        }
      } 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 ""
  }


  if {[file exists $with_tclsh]} {
    msg-result "Using tclsh: $with_tclsh"
    define HAVE_TCL 1
  } else {
    proj-warn "Cannot find a usable tclsh, so cannot run tests."
  }







>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>







576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
      } else {
        set with_tclsh $with_tclsh2
      }
    }
  }
  define TCLSH_CMD $with_tclsh

  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"
        }
      }
      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"
    define HAVE_TCL 1
  } else {
    proj-warn "Cannot find a usable tclsh, so cannot run tests."
  }

Changes to main.mk.

210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#
# CFLAGS specific to the sqlite3 CLI shell app and its close cousins.
#
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:
#
# 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
# libsqlite3, and will usually differ from $(LDFLAGS.rpath).
#
TCLLIB_RPATH ?=
#







|

<
<
<
<
<







210
211
212
213
214
215
216
217
218





219
220
221
222
223
224
225
#
# CFLAGS specific to the sqlite3 CLI shell app and its close cousins.
#
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.
#





TCL_CONFIG_SH ?=
#
# $(TCLLIB_RPATH) is the -rpath flag for libtclsqlite3, not
# libsqlite3, and will usually differ from $(LDFLAGS.rpath).
#
TCLLIB_RPATH ?=
#
925
926
927
928
929
930
931


















932
933
934
935
936
937
938

#
# SOURCE_TCLCONFIG is shell code to be run as part of any compilation
# or link step which requires vars from $(TCL_CONFIG_SH). All targets
# which use this should also have a dependency on has_tclconfig.
#
SOURCE_TCLCONFIG = . $(TCL_CONFIG_SH) || exit $$?


















T.compile.tcl = $(SOURCE_TCLCONFIG); $(T.compile)
T.link.tcl = $(SOURCE_TCLCONFIG); $(T.link)

has_tclconfig:
	@if [ x = "x$(TCL_CONFIG_SH)" ]; then \
		echo 'TCL_CONFIG_SH must be set to point to a "tclConfig.sh"' 1>&2; exit 1; \
	fi







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951

#
# SOURCE_TCLCONFIG is shell code to be run as part of any compilation
# or link step which requires vars from $(TCL_CONFIG_SH). All targets
# 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)

has_tclconfig:
	@if [ x = "x$(TCL_CONFIG_SH)" ]; then \
		echo 'TCL_CONFIG_SH must be set to point to a "tclConfig.sh"' 1>&2; exit 1; \
	fi
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
#
# libtclsqlite3...
#
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.link.shared) -o $@ tclsqlite.o \
		$$TCL_INCLUDE_SPEC $$TCL_STUB_LIB_SPEC $(LDFLAGS.libsqlite3) \
		$(libsqlite3.SO) -Wl,-rpath,$$libdir/sqlite3
# ^^^ 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.
$(libtclsqlite3.SO)-1: $(libtclsqlite3.SO)
$(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)
install-tcl-0 install-tcl-:
install-tcl: install-tcl-$(HAVE_TCL)
install: install-tcl

tclsqlite3.c:	sqlite3.c
	echo '#ifndef USE_SYSTEM_SQLITE' >tclsqlite3.c
	cat sqlite3.c >>tclsqlite3.c







|
|


|








<

|
|
|
|







1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428

1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
#
# libtclsqlite3...
#
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)
	@$(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,$$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.
$(libtclsqlite3.SO)-1: $(libtclsqlite3.SO)
$(libtclsqlite3.SO)-0 $(libtclsqlite3.SO)-:
libtcl: $(libtclsqlite3.SO)-$(HAVE_TCL)
all: libtcl


install-tcl-1: $(libtclsqlite3.SO) pkgIndex.tcl
	@$(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

tclsqlite3.c:	sqlite3.c
	echo '#ifndef USE_SYSTEM_SQLITE' >tclsqlite3.c
	cat sqlite3.c >>tclsqlite3.c