From 62d4726c61ceb2fd00f74cf55a4e8466e5a3830b Mon Sep 17 00:00:00 2001 Message-Id: <62d4726c61ceb2fd00f74cf55a4e8466e5a3830b.1715285698.git.mdw@distorted.org.uk> From: Mark Wooding Date: Wed, 19 Dec 2018 12:39:59 +0000 Subject: [PATCH] Makefile, bin/ -> src/: Substitute scripts rather than chasing symlinks. Organization: Straylight/Edgeware From: Mark Wooding Move the original scripts to `src/' and leave placeholders, and have the Makefile do seddery on them to create the `bin/' versions. --- .gitignore | 1 + Makefile | 10 ++++++++++ bin/crosstool => src/crosstool.in | 0 bin/mdw-cross => src/mdw-cross.in | 17 +---------------- 4 files changed, 12 insertions(+), 16 deletions(-) rename bin/crosstool => src/crosstool.in (100%) mode change 100755 => 100644 rename bin/mdw-cross => src/mdw-cross.in (77%) mode change 100755 => 100644 diff --git a/.gitignore b/.gitignore index 047b29a..339c3b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/bin/ /inst.*/ /etc/*-setup.sh diff --git a/Makefile b/Makefile index 055b40c..1411e61 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ .SECONDEXPANSION: #sorry all:: +CROSSDIR := $(shell pwd) + FLAVOURS += linux-cross linux-cross_ARCHS = linux-armel linux-armhf linux-arm64 linux-armel_ARCH = arm-linux-gnueabi @@ -43,6 +45,14 @@ $(SETUPS): etc/%-setup.sh: $$(call setup-flavour,$$*)-setup.sh.in Makefile $(call v_tag,SED)sed 's/@arch@/$($*_ARCH)/g' $< >$@.new && \ mv $@.new $@ +SCRIPTS = mdw-cross crosstool +BINSCRIPTS = $(addprefix bin/,$(SCRIPTS)) +TARGETS += $(BINSCRIPTS) +$(BINSCRIPTS): bin/%: src/%.in + $(V_AT)mkdir -p $(dir $@) + $(call v_tag,SED)sed 's@crossdir@$(CROSSDIR)' $< >$@.new && \ + chmod +x $@.new && mv $@.new $@ + all:: $(TARGETS) CLEANFILES += $(TARGETS) diff --git a/bin/crosstool b/src/crosstool.in old mode 100755 new mode 100644 similarity index 100% rename from bin/crosstool rename to src/crosstool.in diff --git a/bin/mdw-cross b/src/mdw-cross.in old mode 100755 new mode 100644 similarity index 77% rename from bin/mdw-cross rename to src/mdw-cross.in index 16ba6f7..f7ea08a --- a/bin/mdw-cross +++ b/src/mdw-cross.in @@ -8,22 +8,7 @@ case $# in 0) set -- "$SHELL" ;; esac -case ${CROSSDIR+t} in - t) ;; - *) - dir=$(pwd) - p=$0 - while :; do - case $p in */*) f=${p##*/} p=${p%/*};; *) f=$p p=. ;; esac - cd $p - if ! [ -L "$f" ]; then break; fi - p=$(readlink "$f") - done - p=$(pwd) - CROSSDIR=${p%/bin}; export CROSSDIR - cd "$dir" - ;; -esac +: ${CROSSDIR=@crossdir@}; export CROSSDIR if ! [ -f "$CROSSDIR/etc/$env-setup.sh" ]; then echo 2>&1 "${0##*/}: cross environment \`$env' unknown"; exit 2 -- [mdw]