treewide: derive host and hostpkg path from STAGING_DIR

STAGING_DIR may be provided from command line. We currently hardcoded
STAGING_DIR_HOST and STAGING_DIR_HOSTPKG to the default location but we
currently have some relocatable patch that derive the path from
STAGING_DIR.

Fix this and correctly derive STAGING_DIR_HOST and STAGING_DIR_HOSTPKG
from STAGING_DIR.

The intention is to fix inconsistency from the relocatable patch and the
use of STAGING_DIR_HOST that is always hardcoded.
This with a wrong configuration may end up in broken state with some
host tools expecing a PATH from STAGING_DIR and others using library
from the default staging_dir/host path.

To save downstream project the original implementation is saved while
fixing the inconsistency between patch and .mk.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
This commit is contained in:
Christian Marangi 2022-12-02 20:56:12 +01:00
parent d10e6591d1
commit 2a3283643c
No known key found for this signature in database
GPG Key ID: AC001D09ADBFEAD7
4 changed files with 12 additions and 12 deletions

View File

@ -15,7 +15,7 @@ $(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the OpenWrt dir
world: world:
DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep '/usr' -m 1) DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep '/usr' -m 1)
export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH) export PATH:=$(if $(STAGING_DIR),$(abspath $(STAGING_DIR)/../host/bin),$(TOPDIR)/staging_dir/host/bin):$(PATH)
ifneq ($(OPENWRT_BUILD),1) ifneq ($(OPENWRT_BUILD),1)
_SINGLE=export MAKEFLAGS=$(space); _SINGLE=export MAKEFLAGS=$(space);

View File

@ -11,7 +11,7 @@ TARGET_STAMP:=$(TMP_DIR)/info/.files-$(SCAN_TARGET).stamp
FILELIST:=$(TMP_DIR)/info/.files-$(SCAN_TARGET)-$(SCAN_COOKIE) FILELIST:=$(TMP_DIR)/info/.files-$(SCAN_TARGET)-$(SCAN_COOKIE)
OVERRIDELIST:=$(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-$(SCAN_COOKIE) OVERRIDELIST:=$(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-$(SCAN_COOKIE)
export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH) export PATH:=$(STAGING_DIR_HOST)/bin:$(PATH)
define feedname define feedname
$(if $(patsubst feeds/%,,$(1)),,$(word 2,$(subst /, ,$(1)))) $(if $(patsubst feeds/%,,$(1)),,$(word 2,$(subst /, ,$(1))))

View File

@ -51,22 +51,22 @@ path:=$(subst :,$(space),$(PATH))
path:=$(filter-out .%,$(path)) path:=$(filter-out .%,$(path))
path:=$(subst $(space),:,$(path)) path:=$(subst $(space),:,$(path))
export PATH:=$(path) export PATH:=$(path)
export STAGING_DIR_HOST:=$(if $(STAGING_DIR),$(abspath $(STAGING_DIR)/../host),$(TOPDIR)/staging_dir/host)
unexport TAR_OPTIONS unexport TAR_OPTIONS
ifeq ($(FORCE),) ifeq ($(FORCE),)
.config scripts/config/conf scripts/config/mconf: staging_dir/host/.prereq-build .config scripts/config/conf scripts/config/mconf: $(STAGING_DIR_HOST)/.prereq-build
endif endif
SCAN_COOKIE?=$(shell echo $$$$) SCAN_COOKIE?=$(shell echo $$$$)
export SCAN_COOKIE export SCAN_COOKIE
export STAGING_DIR_HOST=$(TOPDIR)/staging_dir/host
SUBMAKE:=umask 022; $(SUBMAKE) SUBMAKE:=umask 022; $(SUBMAKE)
ULIMIT_FIX=_limit=`ulimit -n`; [ "$$_limit" = "unlimited" -o "$$_limit" -ge 1024 ] || ulimit -n 1024; ULIMIT_FIX=_limit=`ulimit -n`; [ "$$_limit" = "unlimited" -o "$$_limit" -ge 1024 ] || ulimit -n 1024;
prepare-mk: staging_dir/host/.prereq-build FORCE ; prepare-mk: $(STAGING_DIR_HOST)/.prereq-build FORCE ;
ifdef SDK ifdef SDK
IGNORE_PACKAGES = linux IGNORE_PACKAGES = linux
@ -75,7 +75,7 @@ endif
_ignore = $(foreach p,$(IGNORE_PACKAGES),--ignore $(p)) _ignore = $(foreach p,$(IGNORE_PACKAGES),--ignore $(p))
prepare-tmpinfo: FORCE prepare-tmpinfo: FORCE
@+$(MAKE) -r -s staging_dir/host/.prereq-build $(PREP_MK) @+$(MAKE) -r -s $(STAGING_DIR_HOST)/.prereq-build $(PREP_MK)
mkdir -p tmp/info mkdir -p tmp/info
$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPTH=5 SCAN_EXTRA="" $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPTH=5 SCAN_EXTRA=""
$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPTH=3 SCAN_EXTRA="" SCAN_MAKEOPTS="TARGET_BUILD=1" $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPTH=3 SCAN_EXTRA="" SCAN_MAKEOPTS="TARGET_BUILD=1"
@ -152,7 +152,7 @@ xconfig: scripts/config/qconf prepare-tmpinfo FORCE
prepare_kernel_conf: .config toolchain/install FORCE prepare_kernel_conf: .config toolchain/install FORCE
ifeq ($(wildcard staging_dir/host/bin/quilt),) ifeq ($(wildcard $(STAGING_DIR_HOST)/bin/quilt),)
prepare_kernel_conf: prepare_kernel_conf:
@+$(SUBMAKE) -r tools/quilt/compile @+$(SUBMAKE) -r tools/quilt/compile
else else
@ -176,7 +176,7 @@ kernel_nconfig: prepare_kernel_conf
kernel_xconfig: prepare_kernel_conf kernel_xconfig: prepare_kernel_conf
$(_SINGLE)$(NO_TRACE_MAKE) -C target/linux xconfig $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux xconfig
staging_dir/host/.prereq-build: include/prereq-build.mk $(STAGING_DIR_HOST)/.prereq-build: include/prereq-build.mk
mkdir -p tmp mkdir -p tmp
@$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \ @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
echo "Prerequisite check failed. Use FORCE=1 to override."; \ echo "Prerequisite check failed. Use FORCE=1 to override."; \
@ -199,7 +199,7 @@ else
DOWNLOAD_DIRS = package/download DOWNLOAD_DIRS = package/download
endif endif
download: .config FORCE $(if $(wildcard $(TOPDIR)/staging_dir/host/bin/flock),,tools/flock/compile) download: .config FORCE $(if $(wildcard $(STAGING_DIR_HOST)/bin/flock),,tools/flock/compile)
@+$(foreach dir,$(DOWNLOAD_DIRS),$(SUBMAKE) $(dir);) @+$(foreach dir,$(DOWNLOAD_DIRS),$(SUBMAKE) $(dir);)
clean dirclean: .config clean dirclean: .config
@ -263,7 +263,7 @@ distclean:
@$(_SINGLE)$(SUBMAKE) -C scripts/config clean @$(_SINGLE)$(SUBMAKE) -C scripts/config clean
ifeq ($(findstring v,$(DEBUG)),) ifeq ($(findstring v,$(DEBUG)),)
.SILENT: symlinkclean clean dirclean distclean config-clean download help tmpinfo-clean .config scripts/config/mconf scripts/config/conf menuconfig staging_dir/host/.prereq-build tmp/.prereq-package prepare-tmpinfo .SILENT: symlinkclean clean dirclean distclean config-clean download help tmpinfo-clean .config scripts/config/mconf scripts/config/conf menuconfig $(STAGING_DIR_HOST)/.prereq-build tmp/.prereq-package prepare-tmpinfo
endif endif
.PHONY: help FORCE .PHONY: help FORCE
.NOTPARALLEL: .NOTPARALLEL:

View File

@ -156,8 +156,8 @@ BUILD_LOG_DIR:=$(if $(call qstrip,$(CONFIG_BUILD_LOG_DIR)),$(call qstrip,$(CONFI
PKG_INFO_DIR := $(STAGING_DIR)/pkginfo PKG_INFO_DIR := $(STAGING_DIR)/pkginfo
BUILD_DIR_HOST:=$(if $(IS_PACKAGE_BUILD),$(BUILD_DIR_BASE)/hostpkg,$(BUILD_DIR_BASE)/host) BUILD_DIR_HOST:=$(if $(IS_PACKAGE_BUILD),$(BUILD_DIR_BASE)/hostpkg,$(BUILD_DIR_BASE)/host)
STAGING_DIR_HOST:=$(TOPDIR)/staging_dir/host STAGING_DIR_HOST:=$(abspath $(STAGING_DIR)/../host)
STAGING_DIR_HOSTPKG:=$(TOPDIR)/staging_dir/hostpkg STAGING_DIR_HOSTPKG:=$(abspath $(STAGING_DIR)/../hostpkg)
TARGET_PATH:=$(subst $(space),:,$(filter-out .,$(filter-out ./,$(subst :,$(space),$(PATH))))) TARGET_PATH:=$(subst $(space),:,$(filter-out .,$(filter-out ./,$(subst :,$(space),$(PATH)))))
TARGET_INIT_PATH:=$(call qstrip,$(CONFIG_TARGET_INIT_PATH)) TARGET_INIT_PATH:=$(call qstrip,$(CONFIG_TARGET_INIT_PATH))