lmi-commits
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]