Index: Makefile.in ================================================================== --- Makefile.in +++ Makefile.in @@ -100,10 +100,11 @@ CFLAGS.core = @SH_CFLAGS@ LDFLAGS.shlib = @SH_LDFLAGS@ LDFLAGS.zlib = @LDFLAGS_ZLIB@ LDFLAGS.math = @LDFLAGS_MATH@ LDFLAGS.rpath = @LDFLAGS_RPATH@ +LDFLAGS.libtclsqlite3.rpath = @LDFLAGS_TCLLIBDIR_RPATH@ LDFLAGS.pthread = @LDFLAGS_PTHREAD@ LDFLAGS.dlopen = @LDFLAGS_DLOPEN@ LDFLAGS.readline = @LDFLAGS_READLINE@ CFLAGS.readline = @CFLAGS_READLINE@ LDFLAGS.icu = @LDFLAGS_ICU@ Index: autosetup/proj.tcl ================================================================== --- autosetup/proj.tcl +++ autosetup/proj.tcl @@ -1156,27 +1156,33 @@ || [proj-opt-was-provided exec-prefix]} { set lp "[get-define libdir]" } else { set lp "[get-define prefix]/lib" } + # If we _don't_ use cc-with {} here (to avoid updating the global # CFLAGS or LIBS or whatever it is that cc-check-flags updates) then # downstream tests may fail because the resulting rpath gets # implicitly injected into them. cc-with {-link 1} { if {[cc-check-flags "-rpath $lp"]} { define LDFLAGS_RPATH "-rpath $lp" + define LDFLAGS_TCLLIBDIR_RPATH "-rpath \$\$TCLLIBDIR" } else { set wl [proj-cc-check-Wl-flag -rpath $lp] + set wlt [proj-cc-check-Wl-flag -rpath {$$TCLLIBDIR}] if {"" eq $wl} { set wl [proj-cc-check-Wl-flag -R$lp] + set wlt [proj-cc-check-Wl-flag -R{$$TCLLIBDIR}] } if {"" eq $wl} { # HP-UX: https://sqlite.org/forum/forumpost/d80ecdaddd set wl [proj-cc-check-Wl-flag +b $lp] + set wlt [proj-cc-check-Wl-flag +b {$$TCLLIBDIR}] } define LDFLAGS_RPATH $wl + define LDFLAGS_TCLLIBDIR_RPATH $wlt } } expr {"" ne [get-define LDFLAGS_RPATH]} } Index: autosetup/sqlite-config.tcl ================================================================== --- autosetup/sqlite-config.tcl +++ autosetup/sqlite-config.tcl @@ -2258,10 +2258,11 @@ if {[proj-opt-truthy rpath]} { proj-check-rpath } else { msg-result "Disabling use of rpath." define LDFLAGS_RPATH "" + define LDFLAGS_TCLLIBDIR_RPATH "" } } ######################################################################## # If the --dump-defines configure flag is provided then emit a list of Index: main.mk ================================================================== --- main.mk +++ main.mk @@ -163,10 +163,11 @@ # to use the one(s) it needs. # LDFLAGS.zlib ?= -lz LDFLAGS.math ?= -lm LDFLAGS.rpath ?= -Wl,-rpath -Wl,$(prefix)/lib +LDFLAGS.libtclsqlite3.rpath ?= -Wl,-rpath,$$TCLLIBDIR LDFLAGS.pthread ?= -lpthread LDFLAGS.dlopen ?= -ldl LDFLAGS.shlib ?= -shared LDFLAGS.rt ?= # nanosleep on some platforms LDFLAGS.icu ?= # -licui18n -licuuc -licudata @@ -1647,11 +1648,11 @@ $(libtclsqlite3.DLL): $(T.tcl.env.sh) tclsqlite.o $(LIBOBJ) $(T.tcl.env.source); \ $(T.link.shared) -o $@ tclsqlite.o \ $$TCL_INCLUDE_SPEC $$TCL_STUB_LIB_SPEC $(LDFLAGS.libsqlite3) \ - $(LIBOBJ) -Wl,-rpath,$$TCLLIBDIR + $(LIBOBJ) $(LDFLAGS.libtclsqlite3.rpath) # ^^^ 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.DLL)-1: $(libtclsqlite3.DLL) $(libtclsqlite3.DLL)-0 $(libtclsqlite3.DLL)-: