From 9061ccdf080a22d6a66d9a9b8bd72bdfe2ca986b Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Sun, 22 Nov 2020 15:53:49 +0000 Subject: [PATCH] ALL: Fix m4 Dockerfiles dependency Don't depend on all m4 files but build the list dynamically for each file --- Makefile | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 25875d9..316fced 100644 --- a/Makefile +++ b/Makefile @@ -25,8 +25,11 @@ M4_DEBUG := -dcxaeq # Create dependencies list based on docker context contents define MAKE_DEPS $(BUILDDIR)/$(1): $(shell find $(1)/ -type f) | $(BUILDDIR)/$(patsubst %/,%,$(dir $(1))) +$(if $(wildcard $(1)/Dockerfile.m4),$(BUILDDIR)/$(1): \ + $(shell $(call m4_cmdline,$(1),$(1)/Dockerfile.m4,-di) 2>&1 >/dev/null | sed -e '/^m4debug: input read from /!d; s///;' | tr '\n' ' ') \ +,) endef -# Create a dependency on common (used by toolchains) except when target is common +# Create a dependency on common (used by toolchains) except when target is not common define DEPEND_COMMON $(BUILDDIR)/$(1): \ $(if $(filter-out common,$(notdir $(1))), \ @@ -47,6 +50,9 @@ $(BUILDDIR)/$(1): \ $(BUILDDIR)/toolchains/$(notdir $(1)) \ ) endef + +m4_cmdline = m4 -P -EE $(3) -I $(dir $(1))m4 -I $(1) toolchains/m4/library.m4 $(2) + # Return the docker URL with path sanitized build_docker_url = $(DOCKER_REGISTRY)$(DOCKER_SEPARATOR)$(subst /,-,$(1)) @@ -199,12 +205,12 @@ $(TOOLCHAINS_DOC_TS): $(BUILDDIR)/%: %/Dockerfile | $(BUILDDIR)/toolchains # toolchains/m4/library.m4 is automatically included at start for common functions # Using VERBOSE=1 makes rule generate a Dockerfile.debug file with preprocessed content and optional trace (m4_traceon instruction) # They generate a timestamp file in $(BUILDDIR) -$(TOOLCHAINS_M4_TS): $(BUILDDIR)/%: %/Dockerfile.m4 $(shell find toolchains/m4 -type f) | $(BUILDDIR)/toolchains +$(TOOLCHAINS_M4_TS): $(BUILDDIR)/%: %/Dockerfile.m4 | $(BUILDDIR)/toolchains @echo "Building $*" ifeq ($(VERBOSE),1) - m4 -P -EE $(M4_DEBUG) -I toolchains/m4 -I $( $(&1 + $(call m4_cmdline,$( $(&1 endif - m4 -P -EE -I toolchains/m4 -I $( $(&1 + $(call m4_cmdline,$( $(&1 endif - m4 -P -EE -I workers/m4 -I $(