From 19f3e27cd64c3ff7ad8656072578867fb919f8d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Wed, 21 Jul 2021 23:30:49 +0200 Subject: [PATCH] make: allow multiple source files --- Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 956190e..063aec6 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,21 @@ CC := sdcc CFLAGS := -mstm8 --std-c99 --opt-code-size --Werror +LDFLAGS = -mstm8 --out-fmt-ihx -lstm8 FIRMWARE := main +SRC_FILES := $(wildcard *.c) +OBJ_FILES := $(patsubst %.c,%.rel,$(SRC_FILES)) all: $(FIRMWARE).ihx -%.ihx: %.c stm8s.h - $(CC) $(CFLAGS) --out-fmt-ihx $< +$(FIRMWARE).ihx: $(OBJ_FILES) + $(CC) $(LDFLAGS) $^ -o $@ size $@ +%.rel: %.c %.h + $(CC) $(CFLAGS) --compile-only $< + flash: $(FIRMWARE).ihx stm8flash -c stlinkv2 -p stm8s103f3 -w $< clean: - rm -f $(FIRMWARE).asm $(FIRMWARE).ihx $(FIRMWARE).cdb $(FIRMWARE).lst $(FIRMWARE).map $(FIRMWARE).lk $(FIRMWARE).rel $(FIRMWARE).rst $(FIRMWARE).sym + rm -f $(FIRMWARE).asm $(FIRMWARE).ihx $(FIRMWARE).cdb $(FIRMWARE).lst $(FIRMWARE).map $(FIRMWARE).lk $(FIRMWARE).rel $(FIRMWARE).rst $(FIRMWARE).sym $(OBJ_FILES)