Have magic.tcl look for the shared library in the script directory

Rather than having the build process embed an absolute path.
The first of a couple of steps to make the magic build relocatable.
This commit is contained in:
Keno Fischer 2020-10-05 01:34:53 -04:00 committed by Tim Edwards
parent d675076254
commit 80488a8ee9
3 changed files with 15 additions and 14 deletions

View File

@ -63,7 +63,7 @@ magic.tcl: magic.tcl.in ${MAGICDIR}/defs.mak ${MAGICDIR}/VERSION
sed -e /TCL_DIR/s%TCL_DIR%${TCLDIR}%g \ sed -e /TCL_DIR/s%TCL_DIR%${TCLDIR}%g \
-e /MAGIC_VERSION/s%MAGIC_VERSION%${MAGIC_VERSION}%g \ -e /MAGIC_VERSION/s%MAGIC_VERSION%${MAGIC_VERSION}%g \
-e /MAGIC_REVISION/s%MAGIC_REVISION%${MAGIC_REVISION}%g \ -e /MAGIC_REVISION/s%MAGIC_REVISION%${MAGIC_REVISION}%g \
-e /SHDLIB_EXT/s%SHDLIB_EXT%${SHDLIB_EXT}%g magic.tcl.in > magic.tcl -e /SHDLIB_EXT/s%SHDLIB_EXT%${SHDLIB_EXT}%g magic.tcl.in > magic.tcl
magic.sh: magic.sh.in ${MAGICDIR}/defs.mak magic.sh: magic.sh.in ${MAGICDIR}/defs.mak
sed -e /TCL_DIR/s%TCL_DIR%${TCLDIR}%g \ sed -e /TCL_DIR/s%TCL_DIR%${TCLDIR}%g \

View File

@ -1,19 +1,20 @@
# Wishrc startup for ToolScript (magic) # Wishrc startup for ToolScript (magic)
# #
# For installation: Put this file and also magicwrap.so into # For installation: Put this file and also magicwrap.so into
# directory TCL_DIR, and set the "load" line below # the same directory. Also see comments in shell script "magic.sh".
# to point to the location of magicwrap.so. Also see comments
# in shell script "magic.sh".
global Opts global Opts
# If we called magic via the non-console script, then we want to reset # If we called magic via the non-console script, then we want to reset
# the environment variable HOME to its original value. # the environment variable HOME to its original value.
variable MAGIC_TCL_DIR [file dirname [file normalize [info script]]]
variable CAD_ROOT_DEFAULT [file normalize [file join $MAGIC_TCL_DIR ../..]]
if {${tcl_version} >= 8.6} { if {${tcl_version} >= 8.6} {
load -lazy TCL_DIR/tclmagicSHDLIB_EXT load -lazy [file join $MAGIC_TCL_DIR tclmagic[info sharedlibextension]]
} else { } else {
load TCL_DIR/tclmagicSHDLIB_EXT load [file join $MAGIC_TCL_DIR tclmagic[info sharedlibextension]]
} }
# It is important to make sure no magic commands overlap with Tcl built-in # It is important to make sure no magic commands overlap with Tcl built-in

View File

@ -1224,7 +1224,7 @@ Tclmagic_Init(interp)
/* Set $CAD_ROOT as a Tcl variable */ /* Set $CAD_ROOT as a Tcl variable */
cadroot = getenv("CAD_ROOT"); cadroot = getenv("CAD_ROOT");
if (cadroot == NULL) cadroot = CAD_DIR; if (cadroot == NULL) cadroot = Tcl_GetVar(interp, "CAD_ROOT_DEFAULT", TCL_GLOBAL_ONLY);
Tcl_SetVar(interp, "CAD_ROOT", cadroot, TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "CAD_ROOT", cadroot, TCL_GLOBAL_ONLY);