[dpdk-dev] [RFC PATCH] mk: symlink every headers first

Thomas Monjalon thomas at monjalon.net
Tue Jun 20 23:21:39 CEST 2017


If a library or a build tool uses a definition from a driver,
there is a build ordering issue, like seen when moving PCI code
into a bus driver.

One option is to keep PCI helpers and some common definitions in EAL.
The other option is to symlink every headers at the beginning of
the build so they can be included by any other component.

This patch shows how to achieve the second option.

Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
---
 mk/internal/rte.install-post.mk | 2 ++
 mk/rte.sdkbuild.mk              | 9 ++++++++-
 mk/rte.subdir.mk                | 7 +++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/mk/internal/rte.install-post.mk b/mk/internal/rte.install-post.mk
index b99e2b2f7..61804561f 100644
--- a/mk/internal/rte.install-post.mk
+++ b/mk/internal/rte.install-post.mk
@@ -55,7 +55,9 @@ $(foreach dir,$(INSTALL-DIRS-y),\
 # arg1: relative install dir in RTE_OUTPUT
 # arg2: relative file name in a source dir (VPATH)
 #
+.PHONY: headers
 define symlink_rule
+headers: $(addprefix $(RTE_OUTPUT)/$(1)/,$(notdir $(2)))
 $(addprefix $(RTE_OUTPUT)/$(1)/,$(notdir $(2))): $(2)
 	@echo "  SYMLINK-FILE $(addprefix $(1)/,$(notdir $(2)))"
 	@[ -d $(RTE_OUTPUT)/$(1) ] || mkdir -p $(RTE_OUTPUT)/$(1)
diff --git a/mk/rte.sdkbuild.mk b/mk/rte.sdkbuild.mk
index 0bf909e9e..ec04ccb2b 100644
--- a/mk/rte.sdkbuild.mk
+++ b/mk/rte.sdkbuild.mk
@@ -67,9 +67,16 @@ clean: $(CLEANDIRS)
 .PHONY: test-build
 test-build: test
 
+.PHONY: headers
+headers: $(addprefix headers-, $(ROOTDIRS-y))
+headers-%:
+	@[ -d $(BUILDDIR)/$* ] || mkdir -p $(BUILDDIR)/$*
+	$(Q)$(MAKE) S=$* -f $(RTE_SRCDIR)/$*/Makefile -C $(BUILDDIR)/$* \
+		-srR headers
+
 .SECONDEXPANSION:
 .PHONY: $(ROOTDIRS-y) $(ROOTDIRS-)
-$(ROOTDIRS-y) $(ROOTDIRS-):
+$(ROOTDIRS-y) $(ROOTDIRS-): headers
 	@[ -d $(BUILDDIR)/$@ ] || mkdir -p $(BUILDDIR)/$@
 	@echo "== Build $@"
 	$(Q)$(MAKE) S=$@ -f $(RTE_SRCDIR)/$@/Makefile -C $(BUILDDIR)/$@ all
diff --git a/mk/rte.subdir.mk b/mk/rte.subdir.mk
index 92f5de4c8..3ae4ce525 100644
--- a/mk/rte.subdir.mk
+++ b/mk/rte.subdir.mk
@@ -57,6 +57,13 @@ _postinstall: build
 .PHONY: build
 build: _postbuild
 
+.PHONY: headers
+headers: $(addprefix headers-, $(DIRS-y))
+headers-%:
+	@[ -d $(CURDIR)/$* ] || mkdir -p $(CURDIR)/$*
+	@$(MAKE) S=$S/$* -f $(SRCDIR)/$*/Makefile -C $(CURDIR)/$* \
+		-srR headers
+
 .SECONDEXPANSION:
 .PHONY: $(DIRS-y)
 $(DIRS-y):
-- 
2.13.1



More information about the dev mailing list