gnumake: Provide cc_rule and as_rule constructors

Use these to dynamically construct a rule for at32f4/fpec.o
This commit is contained in:
Keir Fraser
2024-11-21 15:53:41 +00:00
parent b1fa16d429
commit 98fc55679d
3 changed files with 15 additions and 10 deletions

View File

@@ -46,6 +46,18 @@ CFLAGS += $(CFLAGS-y) $(FLAGS) -include decls.h
AFLAGS += $(AFLAGS-y) $(FLAGS) -D__ASSEMBLY__
LDFLAGS += $(LDFLAGS-y) $(FLAGS) -Wl,--gc-sections
define cc_rule
$(1): $(SRCDIR)/$(2) $(SRCDIR)/Makefile
@echo CC $$@
$(CC) $$(CFLAGS) -c $$< -o $$@
endef
define as_rule
$(1): $(SRCDIR)/$(2) $(SRCDIR)/Makefile
@echo AS $$@
$(CC) $$(AFLAGS) -c $$< -o $$@
endef
SRCDIR := $(shell $(PYTHON) $(ROOT)/scripts/srcdir.py $(CURDIR))
include $(SRCDIR)/Makefile
@@ -93,12 +105,7 @@ endif
$(PYTHON) $(ROOT)/scripts/mk_update.py new $@ \
$< $(mcu)-$(FW_MAJOR).$(FW_MINOR)-$(bootloader)
%.o: $(SRCDIR)/%.c $(SRCDIR)/Makefile
@echo CC $@
$(CC) $(CFLAGS) -c $< -o $@
%.o: $(SRCDIR)/%.S $(SRCDIR)/Makefile
@echo AS $@
$(CC) $(AFLAGS) -c $< -o $@
$(eval $(call cc_rule,%.o,%.c))
$(eval $(call as_rule,%.o,%.S))
-include $(DEPS)

View File

@@ -2,5 +2,4 @@ OBJS += stm32.o
OBJS += fpec.o
OBJS += testmode.o
fpec.c:
ln -sf ../stm32f1/$@ $@
$(eval $(call cc_rule,fpec.o,../stm32f1/fpec.c))

View File

@@ -1 +0,0 @@
../stm32f1/fpec.c