-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
102 lines (83 loc) · 2.1 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
BINARY = spectrum-sensor
VERSION = $(shell git describe --always)
PREFIX ?= arm-none-eabi
CC = $(PREFIX)-gcc
LD = $(PREFIX)-gcc
OBJCOPY = $(PREFIX)-objcopy
CFLAGS += -Os -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include \
-fno-common -mcpu=cortex-m3 -mthumb -msoft-float -MD -DSTM32F1 \
-DVERSION=\"$(VERSION)\"
LDSCRIPT ?= vesna.ld
LDFLAGS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group \
-L$(TOOLCHAIN_DIR)/lib -L$(TOOLCHAIN_DIR)/lib/stm32/f1 \
-T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections \
-mthumb -march=armv7 -mfix-cortex-m3-ldrd -msoft-float
OBJS += main.o spectrum.o
LIBS += -lopencm3_stm32f1
OPENOCD ?= openocd
OPENOCD_PARAMS ?= -f interface/olimex-arm-usb-ocd.cfg -f target/stm32f1x.cfg
ifeq ($(MODEL),sne-crewtv)
LIBS += -ltda18219
OBJS += dev-tda18219.o
CFLAGS += -DTUNER_TDA18219 -DMODEL_SNE_CREWTV
MODEL_OK = ok
endif
ifeq ($(MODEL),sne-ismtv-uhf)
LIBS += -ltda18219
OBJS += dev-tda18219.o
CFLAGS += -DTUNER_TDA18219 -DMODEL_SNE_ISMTV_UHF
MODEL_OK = ok
endif
ifeq ($(MODEL),sne-ismtv-868)
OBJS += dev-cc.o
CFLAGS += -DTUNER_CC -DMODEL_SNE_ISMTV_868
MODEL_OK = ok
endif
ifeq ($(MODEL),sne-ismtv-2400)
OBJS += dev-cc.o
CFLAGS += -DTUNER_CC -DMODEL_SNE_ISMTV_2400
MODEL_OK = ok
endif
ifeq ($(MODEL),snr-trx-868)
OBJS += dev-cc.o
CFLAGS += -DTUNER_CC -DMODEL_SNR_TRX_868
MODEL_OK = ok
endif
ifeq ($(MODEL),snr-trx-2400)
OBJS += dev-cc.o
CFLAGS += -DTUNER_CC -DMODEL_SNR_TRX_2400
MODEL_OK = ok
endif
ifeq ($(MODEL),null)
OBJS += dev-dummy.o
CFLAGS += -DTUNER_NULL
MODEL_OK = ok
endif
all: $(BINARY).elf
%.bin: %.elf
$(OBJCOPY) -Obinary $(*).elf $(*).bin
%.elf: $(OBJS) $(LDSCRIPT)
$(LD) -o $(*).elf $(OBJS) $(LIBS) $(LDFLAGS)
%.o: %.c check-model
$(CC) $(CFLAGS) -o $@ -c $<
clean:
rm -f *.o
rm -f *.d
rm -f *.elf
rm -f *.bin
%.u: %.elf
$(OPENOCD) $(OPENOCD_PARAMS) -c "\
reset_config trst_and_srst; \
init; \
reset halt; \
poll; \
flash write_image erase $< 0 elf; \
reset run; \
shutdown \
"
check-model:
ifndef MODEL_OK
$(error Please select hardware model with MODEL environment)
endif
.PHONY: clean check-model
-include $(OBJS:.o=.d)