-
Notifications
You must be signed in to change notification settings - Fork 34
/
Makefile
47 lines (34 loc) · 1.18 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
SRC=main.c display.c uart.c eeprom.c outputs.c config.c fixedpoint.c parse.c adc.c
CFLAGS= -lstm8 -mstm8 --opt-code-size --std-c99
OBJ=$(SRC:.c=.rel)
DEP=$(SRC:%.c=.%.c.d)
V=0
ACTUAL_SDCC=sdcc $(CFLAGS)
SDCC_0 = @echo SDCC $<; $(ACTUAL_SDCC)
SDCC_1 = $(ACTUAL_SDCC)
SDCC = $(SDCC_$(V))
LINK_0 = @echo LINK $@; $(ACTUAL_SDCC)
LINK_1 = $(ACTUAL_SDCC)
LINK = $(LINK_$(V))
all: b3603.ihx check_size
-include $(DEP)
check_size: b3603.ihx
@CODESIZE=$$(grep '^CODE' b3603.map |head -n1 | sed -e 's/^.*=\s*\([0-9]\+\).*$$/\1/'); \
if [ "$$CODESIZE" -gt 8192 ]; then echo "Code is too large, it is $$CODESIZE bytes"; exit 1; \
else echo "Code fits the flash, it is $$CODESIZE"; \
fi
b3603.ihx: $(OBJ)
$(LINK) --out-fmt-ihx --code-size 8192 -o $@ $^
%.rel: %.c
@$(SDCC) -M $< > .$<.tmp.d
@mv .$<.tmp.d .$<.d
$(SDCC) -c -o $@ $<
test_pwm_accuracy: test_pwm_accuracy.c outputs.c config.c fixedpoint.c
gcc -g -Wall -o $@ $< -DTEST=1
test_adc_accuracy: test_adc_accuracy.c config.c adc.c fixedpoint.c
gcc -g -Wall -o $@ $< -DTEST=1
test_parse: test_parse.c parse.c
gcc -g -Wall -o $@ $< -DTEST=1
clean:
-rm -f *.rel *.ihx *.lk *.map *.rst *.lst *.asm *.sym .*.d
.PHONY: all clean check_size