-
Notifications
You must be signed in to change notification settings - Fork 87
/
Makefile
95 lines (75 loc) · 2.6 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
# paths to libraries
MCULIB ?= mculib
OPENCM3_DIR ?= libopencm3
BOOTLOAD_PORT ?= /dev/ttyACM0
# device config
BOARDNAME ?= board_v2_plus4
EXTRA_CFLAGS ?= -DDISPLAY_ST7796
DEVICE = gd32f303cc_nofpu
OBJS += $(BOARDNAME)/board.o \
Font5x7.o \
Font7x13b.o \
command_parser.o \
common.o \
fft.o \
flash.o \
gain_cal.o \
gitversion.hpp \
globals.o \
ili9341.o \
main2.o \
numfont20x22.o \
plot.o \
sin_rom.o \
stream_fifo.o \
synthesizers.o \
ui.o \
uihw.o \
vna_measurement.o \
xpt2046.o \
$(NULL)
OBJS += \
$(MCULIB)/dma_adc.o \
$(MCULIB)/dma_driver.o \
$(MCULIB)/fastwiring.o \
$(MCULIB)/message_log.o \
$(MCULIB)/printf.o \
$(MCULIB)/si5351.o \
$(MCULIB)/usbserial.o
CFLAGS += -O2 -g
CPPFLAGS += $(EXTRA_CFLAGS) -O2 -g -ffast-math -fstack-protector-strong -I$(BOARDNAME) -I$(MCULIB)/include -DMCULIB_DEVICE_STM32F103 -DSTM32F103 -DSTM32F1 -D_XOPEN_SOURCE=600
CPPFLAGS += -Wall -Wno-unused-function -Werror=implicit-fallthrough
# CPPFLAGS += -DDISPLAY_ST7796
CPPFLAGS += -ffunction-sections -fdata-sections
# C++ only flags, CPP is used for both C++ and C files
CXXFLAGS += --std=c++17 -fno-exceptions -fno-rtti
# safe g++ flags
CPPFLAGS += -funsigned-char -fwrapv -fno-delete-null-pointer-checks -fno-strict-aliasing
LDFLAGS += -static -nostartfiles -Wl,--exclude-libs,libssp -Wl,--print-memory-usage
LDFLAGS += -Wl,--gc-sections
LDLIBS += -Wl,--start-group -lgcc -lnosys -Wl,--end-group -lm
GITVERSION = "$(shell git log -n 1 --pretty=format:"git-%ad%h" --date=format:"%Y%m%d-")"
GITURL = "$(shell git config --get remote.origin.url)"
# This is needed for the included genlink-config.mk to work properly
LIBNAME = opencm3_$(genlink_family)
OPENCM3_LIB = $(OPENCM3_DIR)/lib/lib$(LIBNAME).a
include $(OPENCM3_DIR)/mk/genlink-config.mk
include $(OPENCM3_DIR)/mk/gcc-config.mk
LDSCRIPT=./gd32f303cc_with_bootloader_plus4.ld
.PHONY: dist-clean clean all
all: $(OPENCM3_LIB) binary.elf binary.hex binary.bin
$(OPENCM3_LIB):
$(MAKE) -C $(OPENCM3_DIR)
gitversion.hpp: .git/HEAD .git/index
echo "#define GITVERSION \"$(GITVERSION)\"" > $@
echo "#define GITURL \"$(GITURL)\"" >> $@
clean:
$(Q)$(RM) -rf binary.* *.o $(BOARDNAME)/*.o
dist-clean: clean
make -C $(OPENCM3_DIR) clean
flash: binary.hex
./st-flash --reset --format ihex write binary.hex
bootload_firmware dfu: binary.bin
python3 bootload_firmware.py --file $< --serial $(BOOTLOAD_PORT)
include $(OPENCM3_DIR)/mk/genlink-rules.mk
include $(OPENCM3_DIR)/mk/gcc-rules.mk