rules: attempt rebuild of library of not found

Based on https://github.com/libopencm3/libopencm3-examples/pull/90
This commit is contained in:
Karl Palsson
2018-08-29 11:54:43 +00:00
parent f09dd550fd
commit dc2142b729

View File

@@ -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