[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 210257a 7/9: Source a script in a makefile
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 210257a 7/9: Source a script in a makefile |
Date: |
Sat, 18 May 2019 14:50:02 -0400 (EDT) |
branch: master
commit 210257aee9f89d99c270e494f8122837e3e10d21
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Source a script in a makefile
The idea of using 'eval' has been mentioned here:
https://lists.gnu.org/archive/html/help-make/2006-04/msg00142.html
and used here:
https://blog.153.io/2016/04/18/source-a-shell-script-in-make/
but neither of those authors actually sources a script per se. This
implementation is an original work. See lmi's
odd/source_script_in_makefile
git branch for a minimalistic standalone implementation.
* GNUmakefile: Incidentally removed an assignment to $PATH that had
hereby been made redundant.
* set_toolchain.sh: Exported $WINEPATH unconditionally, because doing
so conditionally would have increased complexity with no real benefit.
---
GNUmakefile | 10 ++++++----
set_toolchain.sh | 14 +++++++++-----
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/GNUmakefile b/GNUmakefile
index 9c56108..1f143f7 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -134,11 +134,15 @@ touchstone_dir := $(prefix)/touchstone
# Remake this file to "source" a script.
-GNUmakefile $(srcdir)/GNUmakefile:: source_env_vars ;
+export LMI_ENV_FILE := env_$(shell date -u +'%s_%N').eraseme
+
+GNUmakefile $(srcdir)/GNUmakefile:: source_env_vars
+ $(eval include $(LMI_ENV_FILE))
+ @rm $(LMI_ENV_FILE)
.PHONY: source_env_vars
source_env_vars:
- @# nothing here yet
+ @. ./set_toolchain.sh
# Included files that don't need to be remade are given explicit empty
# commands, which significantly reduces the number of lines emitted by
@@ -192,8 +196,6 @@ gpl_files := \
# the 'make' command line to override any definition of the same
# variable in $(local_options).
-export PATH := $(localbindir):$(locallibdir):$(PATH)
-
MAKETARGET = \
$(MAKE) \
--directory=$@ \
diff --git a/set_toolchain.sh b/set_toolchain.sh
index 73d3547..319fd17 100755
--- a/set_toolchain.sh
+++ b/set_toolchain.sh
@@ -108,12 +108,9 @@ local winebindir="$prefix"/third_party/bin
minimal_path=${MINIMAL_PATH:-"/usr/bin:/bin:/usr/sbin:/sbin"}
export PATH="$localbindir":"$locallibdir":"$minimal_path"
-# It is appropriate to unset $WINEPATH because no lmi script ever uses
-# it directly--it's used, implicitly, only by 'wine'. But $PERFORM is
-# used directly, so it's always exported, even if empty--though that's
-# probably just a matter of taste.
+# It is okay to export these two variables unconditionally.
-unset -v WINEPATH
+export WINEPATH
export PERFORM
# Are double quotes inside double quotes inside $() dubious? I.e.,
@@ -140,6 +137,13 @@ case "$lmi_build_type" in
;;
(*) ;;
esac
+if [ -n "$LMI_ENV_FILE" ]; then
+ {
+ echo "export PATH := $PATH"
+ echo "export WINEPATH := $WINEPATH"
+ echo "export PERFORM := $PERFORM"
+ } > "$LMI_ENV_FILE"
+fi
}
# This script is to be sourced, so it can't use a builtin command like
- [lmi-commits] [lmi] master updated (f2caa81 -> e0988be), Greg Chicares, 2019/05/18
- [lmi-commits] [lmi] master 210257a 7/9: Source a script in a makefile,
Greg Chicares <=
- [lmi-commits] [lmi] master e0988be 9/9: Prefer xz to bzip2, Greg Chicares, 2019/05/18
- [lmi-commits] [lmi] master 7ea9aff 3/9: Import a terminal-tab setup script from branch odd/multiarch, Greg Chicares, 2019/05/18
- [lmi-commits] [lmi] master f28084a 6/9: Prepare to "source" a script in a makefile, Greg Chicares, 2019/05/18
- [lmi-commits] [lmi] master 8cb87e1 8/9: Remove redundant duplication, Greg Chicares, 2019/05/18
- [lmi-commits] [lmi] master 67d4657 5/9: Fix defect introduced 20190420T2117: non-minimal $PATH, Greg Chicares, 2019/05/18
- [lmi-commits] [lmi] master f52f6e1 4/9: Invoke 'set_toolchain.sh' instead of duplicating parts of it, Greg Chicares, 2019/05/18
- [lmi-commits] [lmi] master e2e8d43 2/9: Adapt imported script to current directory structure, Greg Chicares, 2019/05/18
- [lmi-commits] [lmi] master b03530f 1/9: Improve documentation, Greg Chicares, 2019/05/18