make: allow multiple source files
This commit is contained in:
parent
05a9cb09f4
commit
19f3e27cd6
12
Makefile
12
Makefile
|
@ -1,15 +1,21 @@
|
||||||
CC := sdcc
|
CC := sdcc
|
||||||
CFLAGS := -mstm8 --std-c99 --opt-code-size --Werror
|
CFLAGS := -mstm8 --std-c99 --opt-code-size --Werror
|
||||||
|
LDFLAGS = -mstm8 --out-fmt-ihx -lstm8
|
||||||
FIRMWARE := main
|
FIRMWARE := main
|
||||||
|
SRC_FILES := $(wildcard *.c)
|
||||||
|
OBJ_FILES := $(patsubst %.c,%.rel,$(SRC_FILES))
|
||||||
|
|
||||||
all: $(FIRMWARE).ihx
|
all: $(FIRMWARE).ihx
|
||||||
|
|
||||||
%.ihx: %.c stm8s.h
|
$(FIRMWARE).ihx: $(OBJ_FILES)
|
||||||
$(CC) $(CFLAGS) --out-fmt-ihx $<
|
$(CC) $(LDFLAGS) $^ -o $@
|
||||||
size $@
|
size $@
|
||||||
|
|
||||||
|
%.rel: %.c %.h
|
||||||
|
$(CC) $(CFLAGS) --compile-only $<
|
||||||
|
|
||||||
flash: $(FIRMWARE).ihx
|
flash: $(FIRMWARE).ihx
|
||||||
stm8flash -c stlinkv2 -p stm8s103f3 -w $<
|
stm8flash -c stlinkv2 -p stm8s103f3 -w $<
|
||||||
|
|
||||||
clean:
|
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)
|
||||||
|
|
Loading…
Reference in New Issue