genlink: provide LIBDEPS for libopencm3 itself

If $(OPENCM3_DIR)/lib/libopencm3_*.a exists, it will be linked in.
If we do that, we should also add it to the deps.
That way a newer *.a will result in a relink.

To use this, you should add a dependency to $(LIBDEPS) where you are
using $(LDFLAGS) and $(LDLIBS) now.

eg, old (wouldn't relink if the library changed)

$(PROJECT).elf: $(OBJS) $(LDSCRIPT)
        @printf "  LD\t$@\n"
        $(Q)$(LD) $(TGT_LDFLAGS) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $@

new (will relink when the library changes)

$(PROJECT).elf: $(OBJS) $(LDSCRIPT) $(LIBDEPS)
        @printf "  LD\t$@\n"
        $(Q)$(LD) $(TGT_LDFLAGS) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $@

Tested-by:  Karl Palsson <karlp@tweak.net.au>

Originally tracked via: https://github.com/libopencm3/libopencm3/pull/887
This commit is contained in:
Christian Tacke 2018-02-26 20:43:00 +01:00 committed by Karl Palsson
parent f4bbe7c5bb
commit d14033c744
1 changed files with 2 additions and 0 deletions

View File

@ -56,9 +56,11 @@ endif
# where those are provided by different means
ifneq (,$(wildcard $(OPENCM3_DIR)/lib/libopencm3_$(genlink_family).a))
LDLIBS += -lopencm3_$(genlink_family)
LIBDEPS += $(OPENCM3_DIR)/lib/libopencm3_$(genlink_family).a
else
ifneq (,$(wildcard $(OPENCM3_DIR)/lib/libopencm3_$(genlink_subfamily).a))
LDLIBS += -lopencm3_$(genlink_subfamily)
LIBDEPS += $(OPENCM3_DIR)/lib/libopencm3_$(genlink_subfamily).a
else
$(warning $(OPENCM3_DIR)/lib/libopencm3_$(genlink_family).a library variant for the selected device does not exist.)
endif