From dc2142b72984d5f1c46485975c6d9396e48e0f6c Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Wed, 29 Aug 2018 11:54:43 +0000 Subject: [PATCH] rules: attempt rebuild of library of not found Based on https://github.com/libopencm3/libopencm3-examples/pull/90 --- examples/rules.mk | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/rules.mk b/examples/rules.mk index 4e730ed..c1a5dad 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -167,6 +167,12 @@ else include $(OPENCM3_DIR)/mk/genlink-rules.mk endif +$(OPENCM3_DIR)/lib/lib$(LIBNAME).a: +ifeq (,$(wildcard $@)) + $(warning $(LIBNAME).a not found, attempting to rebuild in $(OPENCM3_DIR)) + $(MAKE) -C $(OPENCM3_DIR) +endif + # Define a helper macro for debugging make errors online # you can type "make print-OPENCM3_DIR" and it will show you # how that ended up being resolved by all of the included @@ -193,7 +199,7 @@ print-%: @#printf " OBJDUMP $(*).list\n" $(Q)$(OBJDUMP) -S $(*).elf > $(*).list -%.elf %.map: $(OBJS) $(LDSCRIPT) +%.elf %.map: $(OBJS) $(LDSCRIPT) $(OPENCM3_DIR)/lib/lib$(LIBNAME).a @#printf " LD $(*).elf\n" $(Q)$(LD) $(TGT_LDFLAGS) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $(*).elf