treewide: add ORIG_PATH variable
authorMichael Pratt <mcpratt@pm.me>
Thu, 25 May 2023 06:31:17 +0000 (02:31 -0400)
committerPetr Štetiar <ynezz@true.cz>
Mon, 5 Jun 2023 06:31:47 +0000 (08:31 +0200)
Add a variable that stores the original value of $PATH
in the host system's shell, before Make alters it.

This can be useful for when it is necessary
to ignore symlinks and programs made by the build system.

Define this new variable before all instances of
'export PATH:=' or similar.

Signed-off-by: Michael Pratt <mcpratt@pm.me>
Makefile
include/scan.mk
include/toplevel.mk
rules.mk
target/imagebuilder/files/Makefile
target/sdk/files/Makefile
target/toolchain/files/wrapper.sh

index cff0e1d8d482993620ba967df924f19f19027152..c325034bb9da4f8b1d1e90af7183df75a1d1c2d0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -15,6 +15,8 @@ $(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the OpenWrt dir
 world:
 
 DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep '/usr' -m 1)
+
+export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
 export PATH:=$(if $(STAGING_DIR),$(abspath $(STAGING_DIR)/../host/bin),$(TOPDIR)/staging_dir/host/bin):$(PATH)
 
 ifneq ($(OPENWRT_BUILD),1)
index 12ef5d1dc77fe9bccca5f03b817b239d8c8098cc..33a5832ff5f237c3f221aaa705681e48602cc904 100644 (file)
@@ -11,6 +11,7 @@ TARGET_STAMP:=$(TMP_DIR)/info/.files-$(SCAN_TARGET).stamp
 FILELIST:=$(TMP_DIR)/info/.files-$(SCAN_TARGET)-$(SCAN_COOKIE)
 OVERRIDELIST:=$(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-$(SCAN_COOKIE)
 
+export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
 export PATH:=$(STAGING_DIR_HOST)/bin:$(PATH)
 
 define feedname
index 2fda7ed223924b00084aba3fe79a983fd3f6a4fc..328214be1bc59fedd17a8cbcb339b364e9f5ec9f 100644 (file)
@@ -50,6 +50,7 @@ space:= $(empty) $(empty)
 path:=$(subst :,$(space),$(PATH))
 path:=$(filter-out .%,$(path))
 path:=$(subst $(space),:,$(path))
+export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
 export PATH:=$(path)
 export STAGING_DIR_HOST:=$(if $(STAGING_DIR),$(abspath $(STAGING_DIR)/../host),$(TOPDIR)/staging_dir/host)
 
index dcac49667bbfd31bce0ed0946ea2cd81abdef771..58c53705a28161a6c19afc0a49e85cab0355846e 100644 (file)
--- a/rules.mk
+++ b/rules.mk
@@ -227,6 +227,7 @@ else
   endif
 endif
 
+export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
 export PATH:=$(TARGET_PATH)
 export STAGING_DIR STAGING_DIR_HOST STAGING_DIR_HOSTPKG
 export SH_FUNC:=. $(INCLUDE_DIR)/shell.sh;
index 5aeedb74dadab41f6b3249a3ce2f1229372ef4d9..5020373792450b5c6d7f06248d42464e79ffaac8 100644 (file)
@@ -13,6 +13,7 @@ export TOPDIR LC_ALL LANG
 export OPENWRT_VERBOSE=s
 all: help
 
+export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
 export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
 
 ifneq ($(OPENWRT_BUILD),1)
index dca8bbe20e78f7d7cf9f4e2c51b81d008e5d706b..89c6a109eee02010686a10d9cd5ac77ff5edbd48 100644 (file)
@@ -15,6 +15,8 @@ export TOPDIR LC_ALL LANG SDK
 world:
 
 DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep '/usr' -m 1)
+
+export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
 export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
 
 ifneq ($(OPENWRT_BUILD),1)
index 4b3f8f911ab67ed57652c5325304e732b23bdc71..09a9cac928abd9f38e55e4b7ef6e6a0bb415f0e9 100755 (executable)
@@ -43,6 +43,7 @@ TOOLCHAIN_BIN_DIR="$REALNAME_DIR/"
 
 # Set the PATH so that our run-time location is first
 # (get_feature is run from the path, so this has to be set)
+export ORIG_PATH=${ORIG_PATH:-$PATH}
 export PATH="$TOOLCHAIN_BIN_DIR":$PATH
 export GCC_HONOUR_COPTS