From e082ee6766c75d17f2786d600bd42400b51fefc7 Mon Sep 17 00:00:00 2001 From: cladmi Date: Fri, 14 Sep 2018 14:54:37 +0200 Subject: [PATCH 1/3] Makefile.include: add a target name in usepkg build target Explicit the target name so the stem can be extracted. --- Makefile.include | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.include b/Makefile.include index 18abfdc4c14c..b36ad55b50c9 100644 --- a/Makefile.include +++ b/Makefile.include @@ -475,9 +475,9 @@ endif pkg-prepare: -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i prepare ; done -$(USEPKG:%=$(BINDIR)/%.a): $(BUILDDEPS) FORCE +$(USEPKG:%=$(BINDIR)/%.a): $(BINDIR)/%.a: $(BUILDDEPS) FORCE @mkdir -p $(BINDIR) - $(QQ)"$(MAKE)" -C $(RIOTPKG)/$(patsubst $(BINDIR)/%.a,%,$@) + $(QQ)"$(MAKE)" -C $(RIOTPKG)/$* clean: -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i clean ; done From 8a6771ac5059da198dc99eaa580ff0a633dda22f Mon Sep 17 00:00:00 2001 From: cladmi Date: Fri, 14 Sep 2018 14:55:43 +0200 Subject: [PATCH 2/3] Makefile.include: do not create BINDIR for usepkg build BINDIR has already have been created by `pkg-prepare` and the real build directory for the package will be created by the make target itself. --- Makefile.include | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile.include b/Makefile.include index b36ad55b50c9..3b3afd920cc4 100644 --- a/Makefile.include +++ b/Makefile.include @@ -476,7 +476,6 @@ pkg-prepare: -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i prepare ; done $(USEPKG:%=$(BINDIR)/%.a): $(BINDIR)/%.a: $(BUILDDEPS) FORCE - @mkdir -p $(BINDIR) $(QQ)"$(MAKE)" -C $(RIOTPKG)/$* clean: From 4652cb2b283fe091df9fefbcdcd0b6deae2f0e24 Mon Sep 17 00:00:00 2001 From: cladmi Date: Fri, 14 Sep 2018 15:03:59 +0200 Subject: [PATCH 3/3] Makefile.include: Replace pkg archive file targets by phony targets It fixes issues with the current rule that it is wrong that each `$(BINDIR)/pkgname.a` is built by going in the package directory: * `nordic_softdevice_ble.a` is built using `DIRS` and so the `$(APPLICATION_MODULE).a` target. * It prevents having packages that are pseudomodules, which may be required to only use one "library" part of a package. It also simplifies handling changes in 'ld -r' PR that could produce objects instead of archives for packages. Limitation of the current implementation ---------------------------------------- It removes rules being 'file' target and makes them depend on `.PHONY` targets so always forces re-build. But having a file target whose file is silently generated by another target does not trigger a rebuild in Make. They may have been declared as `order-only` prerequisites but as there are some edge-cases that may not always work and does not currently add anything, it was decided to keep them as normal prerequisites until it can be globally solved. --- Makefile.include | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile.include b/Makefile.include index 3b3afd920cc4..dc336ef576e0 100644 --- a/Makefile.include +++ b/Makefile.include @@ -430,13 +430,13 @@ endif # RIOTNOLINK $(ELFFILE): $(BASELIBS) $(Q)$(_LINK) -o $@ -$(BINDIR)/$(APPLICATION_MODULE).a: $(USEPKG:%=$(BINDIR)/%.a) $(BUILDDEPS) +$(BINDIR)/$(APPLICATION_MODULE).a: pkg-build $(BUILDDEPS) $(Q)DIRS="$(DIRS)" "$(MAKE)" -C $(APPDIR) -f $(RIOTMAKE)/application.inc.mk $(BINDIR)/$(APPLICATION_MODULE).a: FORCE # Other modules are built by application.inc.mk and packages building -_SUBMAKE_LIBS = $(filter-out $(BINDIR)/$(APPLICATION_MODULE).a $(USEPKG:%=$(BINDIR)/%.a) $(APPDEPS), $(BASELIBS)) -$(_SUBMAKE_LIBS): $(BINDIR)/$(APPLICATION_MODULE).a $(USEPKG:%=$(BINDIR)/%.a) +_SUBMAKE_LIBS = $(filter-out $(BINDIR)/$(APPLICATION_MODULE).a $(APPDEPS), $(BASELIBS)) +$(_SUBMAKE_LIBS): $(BINDIR)/$(APPLICATION_MODULE).a pkg-build # 'print-size' triggers a rebuild. Use 'info-buildsize' if you do not need to rebuild. print-size: $(ELFFILE) @@ -471,11 +471,12 @@ ifneq (, $(filter clean, $(MAKECMDGOALS))) all $(BASELIBS) $(USEPKG:%=$(RIOTPKG)/%/Makefile.include) $(BUILDDEPS): clean endif -.PHONY: pkg-prepare +.PHONY: pkg-prepare pkg-build pkg-build-% pkg-prepare: -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i prepare ; done -$(USEPKG:%=$(BINDIR)/%.a): $(BINDIR)/%.a: $(BUILDDEPS) FORCE +pkg-build: $(USEPKG:%=pkg-build-%) +pkg-build-%: $(BUILDDEPS) $(QQ)"$(MAKE)" -C $(RIOTPKG)/$* clean: