From: Michael Pratt Date: Thu, 25 May 2023 06:31:17 +0000 (-0400) Subject: treewide: add ORIG_PATH variable X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=d87a8aa148ddf93b199a759deb088fff73787025;p=openwrt%2Fstaging%2Fldir.git treewide: add ORIG_PATH variable 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 --- diff --git a/Makefile b/Makefile index cff0e1d8d4..c325034bb9 100644 --- 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) diff --git a/include/scan.mk b/include/scan.mk index 12ef5d1dc7..33a5832ff5 100644 --- a/include/scan.mk +++ b/include/scan.mk @@ -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 diff --git a/include/toplevel.mk b/include/toplevel.mk index 2fda7ed223..328214be1b 100644 --- a/include/toplevel.mk +++ b/include/toplevel.mk @@ -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) diff --git a/rules.mk b/rules.mk index dcac49667b..58c53705a2 100644 --- 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; diff --git a/target/imagebuilder/files/Makefile b/target/imagebuilder/files/Makefile index 5aeedb74da..5020373792 100644 --- a/target/imagebuilder/files/Makefile +++ b/target/imagebuilder/files/Makefile @@ -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) diff --git a/target/sdk/files/Makefile b/target/sdk/files/Makefile index dca8bbe20e..89c6a109ee 100644 --- a/target/sdk/files/Makefile +++ b/target/sdk/files/Makefile @@ -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) diff --git a/target/toolchain/files/wrapper.sh b/target/toolchain/files/wrapper.sh index 4b3f8f911a..09a9cac928 100755 --- a/target/toolchain/files/wrapper.sh +++ b/target/toolchain/files/wrapper.sh @@ -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