diff mbox series

build: rebuild libs all the time

Message ID 1602495053-I2ceef662f483f65ca9e75f3dd5db975a00fc9a91@changeid
State Accepted
Headers show
Series build: rebuild libs all the time | expand

Commit Message

Johannes Berg Oct. 12, 2020, 9:30 a.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

When files change that go into a static library such as
libutils.a, then libutils.a doesn't get rebuilt from e.g.
wlantest because the top-level Makefile just calls the
library make if the library doesn't exist yet.

Change that by making the library depend on a phony target
(cannot make it itself phony due to the pattern) so that
the build will always recurse into the library build, and
check there if the library needs to be rebuilt.

While at it, remove the (actually unnecessary) mkdir so it
doesn't get done each and every time you do 'make'.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 src/build.rules | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Jouni Malinen Oct. 12, 2020, 8:27 p.m. UTC | #1
On Mon, Oct 12, 2020 at 11:30:53AM +0200, Johannes Berg wrote:
> When files change that go into a static library such as
> libutils.a, then libutils.a doesn't get rebuilt from e.g.
> wlantest because the top-level Makefile just calls the
> library make if the library doesn't exist yet.
> 
> Change that by making the library depend on a phony target
> (cannot make it itself phony due to the pattern) so that
> the build will always recurse into the library build, and
> check there if the library needs to be rebuilt.
> 
> While at it, remove the (actually unnecessary) mkdir so it
> doesn't get done each and every time you do 'make'.

Thanks, applied.
diff mbox series

Patch

diff --git a/src/build.rules b/src/build.rules
index ec1cd66ce2a6..acda8847284d 100644
--- a/src/build.rules
+++ b/src/build.rules
@@ -94,8 +94,12 @@  $(BUILDDIR)/$(PROJ)/wpa_supplicant/%.o: $(ROOTDIR)wpa_supplicant/%.c $(CONFIG_FI
 	@$(E) "  CC " $<
 
 # libraries - they know how to build themselves
-$(BUILDDIR)/$(PROJ)/%.a: $(CONFIG_FILE)
-	$(Q)mkdir -p $(BUILDDIR)/$(PROJ)/$(dir $(@:$(BUILDDIR)/$(PROJ)/%=%))
+# (lib_phony so we recurse all the time)
+.PHONY: lib_phony
+lib_phony:
+# nothing
+
+$(BUILDDIR)/$(PROJ)/%.a: $(CONFIG_FILE) lib_phony
 	$(Q)$(MAKE) -C $(ROOTDIR)$(dir $(@:$(BUILDDIR)/$(PROJ)/%=%)) OUT=$(abspath $(dir $@))/
 
 BUILDOBJ = $(patsubst %,$(BUILDDIR)/$(PROJ)/%,$(patsubst $(ROOTDIR)%,%,$(1)))