-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
93 lines (73 loc) · 2.36 KB
/
Copy pathMakefile
File metadata and controls
93 lines (73 loc) · 2.36 KB
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
##############################################################################
BUILD = build
BIN = emonTH
OUT = bin
##############################################################################
.PHONY: all directory clean size
# Path to toolchain, e.g. /path/to/bin/ Leave empty if already on path.
TC_PATH =
CC = $(TC_PATH)arm-none-eabi-gcc
OBJCOPY = $(TC_PATH)arm-none-eabi-objcopy
SIZE = $(TC_PATH)arm-none-eabi-size
ifeq ($(OS), Windows_NT)
MKDIR = gmkdir
else
MKDIR = mkdir
endif
CFLAGS += -W -Wall -Wextra -Wpedantic --std=c17 -Os -g3
CFLAGS += -fno-diagnostics-show-caret -fno-common
CFLAGS += -fdata-sections -ffunction-sections
CFLAGS += -funsigned-char -funsigned-bitfields
CFLAGS += -Wuninitialized -Wsign-conversion
CFLAGS += -Wshadow -Wdouble-promotion -Wundef
CFLAGS += -mcpu=cortex-m23 -mthumb
CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d
LDFLAGS += -mcpu=cortex-m23 -mthumb -nostartfiles
LDFLAGS += -Wl,--gc-sections
LDFLAGS += -Wl,--print-memory-usage
LDFLAGS += -Wl,--script=./linker/saml10e15.ld
INCLUDES += \
-I./include/saml10 \
-I./third_party/RFM69 \
-I./src/
SRCS += $(wildcard ./src/*.c)
DEFINES += \
-D__SAML10E15A__ \
-DDONT_USE_CMSIS_INIT \
-D__ARM_FEATURE_DSP=0
CFLAGS += $(INCLUDES) $(DEFINES)
OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS))))
# Always update the build information. This forces this to run every time. Exit
# if this fails - likely to be a path of Python version issue.
BUILD_INFO := $(shell python3 ./scripts/build_info.py ./src/emonTH_build_info.c)
ifeq ($(strip $(BUILD_INFO)), )
$(error 1)
endif
VERSION_INFO := $(shell python3 ./scripts/version_info.py)
all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin size
$(BUILD)/$(BIN).elf: $(OBJS)
@echo LD $@
@$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
@cp $@ $(OUT)/$(VERSION_INFO).elf
$(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf
@echo OBJCOPY $@
@$(OBJCOPY) -O ihex $^ $@
@cp $@ $(OUT)/$(VERSION_INFO).hex
$(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf
@echo OBJCOPY $@
@$(OBJCOPY) -O binary $^ $@
@cp $@ $(OUT)/$(VERSION_INFO).bin
%.o:
@echo CC $@
@$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@
directory:
@$(MKDIR) -p $(BUILD)
@$(MKDIR) -p $(OUT)
size: $(BUILD)/$(BIN).elf
@echo size:
@$(SIZE) -t $^
clean:
@echo clean
@-rm -rf $(BUILD)
@-rm -f $(OUT)/emonTH*
-include $(wildcard $(BUILD)/*.d)