From 3e6acd43fdde938044cf30dcab69dbe37b7a0e72 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Mon, 5 Oct 2020 01:51:37 -0400 Subject: [PATCH] Make bash wrapper relocatable By having the build system put in a relative path rather than an absolute path. Unfortunately, make does not support computing relative paths manually, so a small bash script is needed that will do this for us. --- tcltk/Makefile | 11 ++++++++--- tcltk/ext2sim.sh.in | 8 +++++++- tcltk/ext2spice.sh.in | 8 +++++++- tcltk/magic.sh.in | 18 ++++++++++++------ tcltk/relpath.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 11 deletions(-) create mode 100755 tcltk/relpath.sh diff --git a/tcltk/Makefile b/tcltk/Makefile index f79924c9..c233daff 100644 --- a/tcltk/Makefile +++ b/tcltk/Makefile @@ -32,6 +32,11 @@ TCL_FILES = \ readspice.tcl \ magic.tcl +TCL_DIR_REL_OR_ABS = $(shell ${MAGICDIR}/tcltk/relpath.sh "$(DESTDIR)${INSTALL_BINDIR}" ${TCLDIR}) +ifeq ($(TCL_DIR_REL_OR_ABS),) +TCL_DIR_REL_OR_ABS = ${TCLDIR} +endif + BIN_FILES = \ $(DESTDIR)${INSTALL_BINDIR}/magic.sh \ $(DESTDIR)${INSTALL_BINDIR}/ext2spice.sh \ @@ -66,15 +71,15 @@ magic.tcl: magic.tcl.in ${MAGICDIR}/defs.mak ${MAGICDIR}/VERSION -e /SHDLIB_EXT/s%SHDLIB_EXT%${SHDLIB_EXT}%g magic.tcl.in > magic.tcl magic.sh: magic.sh.in ${MAGICDIR}/defs.mak - sed -e /TCL_DIR/s%TCL_DIR%${TCLDIR}%g \ + sed -e /TCL_DIR_REL_OR_ABS/s%TCL_DIR_REL_OR_ABS%${TCL_DIR_REL_OR_ABS}%g \ -e /TCLLIB_DIR/s%TCLLIB_DIR%${TCL_LIB_DIR}%g \ -e /WISH_EXE/s%WISH_EXE%${WISH_EXE}%g magic.sh.in > magic.sh ext2spice.sh: ext2spice.sh.in ${MAGICDIR}/defs.mak - sed -e /TCL_DIR/s%TCL_DIR%${TCLDIR}%g ext2spice.sh.in > ext2spice.sh + sed -e /TCL_DIR_REL_OR_ABS/s%TCL_DIR_REL_OR_ABS%${TCL_DIR_REL_OR_ABS}%g ext2spice.sh.in > ext2spice.sh ext2sim.sh: ext2sim.sh.in ${MAGICDIR}/defs.mak - sed -e /TCL_DIR/s%TCL_DIR%${TCLDIR}%g ext2sim.sh.in > ext2sim.sh + sed -e /TCL_DIR_REL_OR_ABS/s%TCL_DIR_REL_OR_ABS%${TCL_DIR_REL_OR_ABS}%g ext2sim.sh.in > ext2sim.sh $(DESTDIR)${INSTALL_TCLDIR}/%: % ${RM} $(DESTDIR)${INSTALL_TCLDIR}/$* diff --git a/tcltk/ext2sim.sh.in b/tcltk/ext2sim.sh.in index 548657ae..1ac1aad1 100755 --- a/tcltk/ext2sim.sh.in +++ b/tcltk/ext2sim.sh.in @@ -14,8 +14,14 @@ for i in $@; do *) esargs="$esargs $i" ;; esac done +TCL_REL_OR_ABS=TCL_DIR_REL_OR_ABS +if [ "${TCL_REL_OR_ABS:0:1}" = "/" ]; then +TCL_DIR=$TCL_REL_OR_ABS +else +TCL_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))/$TCL_REL_OR_ABS +fi # -eval TCL_DIR/magicdnull -dnull -noconsole -nowrapper $mgargs <