From 4652cb2b283fe091df9fefbcdcd0b6deae2f0e24 Mon Sep 17 00:00:00 2001 From: cladmi <gaetan.harter@fu-berlin.de> Date: Fri, 14 Sep 2018 15:03:59 +0200 Subject: [PATCH] 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 3b3afd920c..dc336ef576 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: -- GitLab