From: Andre Heider Date: Thu, 2 Feb 2023 18:20:42 +0000 (+0100) Subject: build: introduce PKG_BUILD_FLAGS and move PKG_IREMAP to it X-Git-Tag: v23.05.0-rc1~720 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=0a44c579a1ab3f699ad84728cc6cde78c99ba1d1;p=openwrt%2Fstaging%2Fhauke.git build: introduce PKG_BUILD_FLAGS and move PKG_IREMAP to it PKG_BUILD_FLAGS is a new variable for package Makefiles similar to PKG_FLAGS. It's a whitespace separated list of flags to control various aspects of how a package is build. The build system and/or .config defines the default for each, but every package has the means to override it. Using $flagname enables a flag, no-$flagname disables it. Start with PKG_IREMAP as "iremap". That's easy as no package here nor in any package feed uses it. The default is unchanged: enabled. Packages can opt-out via: PKG_BUILD_FLAGS:=no-iremap (Not that any should, just to illustrate how to use it) Signed-off-by: Andre Heider --- diff --git a/include/package.mk b/include/package.mk index 368bf0d7ca..8d14c17dbd 100644 --- a/include/package.mk +++ b/include/package.mk @@ -12,7 +12,6 @@ PKG_BUILD_DIR ?= $(BUILD_DIR)/$(if $(BUILD_VARIANT),$(PKG_NAME)-$(BUILD_VARIANT) PKG_INSTALL_DIR ?= $(PKG_BUILD_DIR)/ipkg-install PKG_BUILD_PARALLEL ?= PKG_USE_MIPS16 ?= 1 -PKG_IREMAP ?= 1 PKG_SKIP_DOWNLOAD=$(USE_SOURCE_DIR)$(USE_GIT_TREE)$(USE_GIT_SRC_CHECKOUT) MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) $(if $(filter 3.% 4.0 4.1,$(MAKE_VERSION)),-j)) @@ -30,7 +29,20 @@ ifdef CONFIG_USE_MIPS16 TARGET_CFLAGS += -mips16 -minterlink-mips16 endif endif -ifeq ($(strip $(PKG_IREMAP)),1) + +PKG_BUILD_FLAGS?= + +__unknown_flags=$(filter-out no-iremap,$(PKG_BUILD_FLAGS)) +ifneq ($(__unknown_flags),) + $(error unknown PKG_BUILD_FLAGS: $(__unknown_flags)) +endif + +# $1=flagname, $2=default (0/1) +define pkg_build_flag +$(if $(filter no-$(1),$(PKG_BUILD_FLAGS)),0,$(if $(filter $(1),$(PKG_BUILD_FLAGS)),1,$(2))) +endef + +ifeq ($(call pkg_build_flag,iremap,1),1) IREMAP_CFLAGS = $(call iremap,$(PKG_BUILD_DIR),$(notdir $(PKG_BUILD_DIR))) TARGET_CFLAGS += $(IREMAP_CFLAGS) endif