Browse Source

build: add support for PKG_SUBDIRS variable

Add support for overriding the SUBDIRS variable while invoking Make
by defining it after Make in the command line.

This is useful for builds that have previously patched out
the building of certain subdirectories in projects
that use recursive and independent Makefiles,
for example, to block the building of docs or test suites.

The wildcard function is used in the case of there being
subdirectories within any of the subdirectories,
for example, in the building of gengetopt,
in order to avoid the problem where Make will attempt
to execute a Makefile in a subdirectory that does not exist
within the subdirectory it is currently running from
because it really exists at the top-level, or one that exists
within one of the subdirectories when ran from top-level.
There are also cases where the Makefiles in the subdirectories
have the recursive building rules even though there are no more
subdirectories beyond that point, for example, with gnulib.

Signed-off-by: Michael Pratt <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/15853
Signed-off-by: Robert Marko <[email protected]>
Michael Pratt 1 year ago
parent
commit
3de19697fd
3 changed files with 4 additions and 3 deletions
  1. 2 2
      include/host-build.mk
  2. 1 0
      include/package-defaults.mk
  3. 1 1
      include/package.mk

+ 2 - 2
include/host-build.mk

@@ -110,11 +110,11 @@ define Host/Compile/Default
 endef
 endef
 
 
 define Host/Compile
 define Host/Compile
-  $(call Host/Compile/Default)
+  $(call Host/Compile/Default,$(if $(PKG_SUBDIRS),SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))'))
 endef
 endef
 
 
 define Host/Install/Default
 define Host/Install/Default
-	$(call Host/Compile/Default,install)
+  $(call Host/Compile/Default,$(if $(PKG_SUBDIRS),SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))') install)
 endef
 endef
 
 
 define Host/Install
 define Host/Install

+ 1 - 0
include/package-defaults.mk

@@ -151,6 +151,7 @@ define Build/Install/Default
 	$(MAKE_VARS) \
 	$(MAKE_VARS) \
 	$(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
 	$(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
 		$(MAKE_INSTALL_FLAGS) \
 		$(MAKE_INSTALL_FLAGS) \
+		$(if $(PKG_SUBDIRS),SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))') \
 		$(if $(1), $(1), install);
 		$(if $(1), $(1), install);
 endef
 endef
 
 

+ 1 - 1
include/package.mk

@@ -343,7 +343,7 @@ endef
 
 
 Build/Prepare=$(call Build/Prepare/Default,)
 Build/Prepare=$(call Build/Prepare/Default,)
 Build/Configure=$(call Build/Configure/Default,)
 Build/Configure=$(call Build/Configure/Default,)
-Build/Compile=$(call Build/Compile/Default,)
+Build/Compile=$(call Build/Compile/Default,$(if $(PKG_SUBDIRS),SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))'))
 Build/Install=$(if $(PKG_INSTALL),$(call Build/Install/Default,))
 Build/Install=$(if $(PKG_INSTALL),$(call Build/Install/Default,))
 Build/Dist=$(call Build/Dist/Default,)
 Build/Dist=$(call Build/Dist/Default,)
 Build/DistCheck=$(call Build/DistCheck/Default,)
 Build/DistCheck=$(call Build/DistCheck/Default,)