make: allow multiple source files

This commit is contained in:
King Kévin 2021-07-21 23:30:49 +02:00
parent b3b2eb4782
commit 9b5e9bb2b3
1 changed files with 9 additions and 3 deletions

View File

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