-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
74 lines (55 loc) · 1.35 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
PROJECT = pass_led
SRCS += \
$(wildcard src/*.c) \
$(wildcard common/src/*.c) \
$(wildcard chipsets/$(CHIPSET)/src/*.c) \
$(wildcard boards/$(BOARD)/src/*.c)
INCLUDES += \
include \
common/include \
chipsets/$(CHIPSET)/include \
boards/$(BOARD)/include
CFLAGS += \
-mthumb \
-mcpu=cortex-m4 \
-mfloat-abi=hard \
-mfpu=fpv4-sp-d16 \
-std=c99 \
-Og \
-g \
-ffreestanding \
-ffunction-sections \
-fdata-sections
CFLAGS += $(foreach i,$(INCLUDES),-I $(i))
DEPFLAGS = \
-MMD \
-MP
CFLAGS += $(DEPFLAGS)
LDFLAGS += \
-specs=nosys.specs \
-Wl,--print-memory-usage \
-Wl,-Map=flash.map \
-Wl,--gc-sections \
-Wl,-T link.ld
OBJ_DIR := .objects
OBJS := $(SRCS:%.c=$(OBJ_DIR)/%.o)
DEPS := $(OBJS:%.o=%.d)
CC := arm-none-eabi-gcc
BUILD_DIR := build
$(BUILD_DIR)/$(PROJECT).bin: $(BUILD_DIR)/$(PROJECT).elf $(BUILD_DIR)/$(PROJECT).lst | $(BUILD_DIR)
@arm-none-eabi-objcopy $< $@ -O binary
@arm-none-eabi-size $<
$(BUILD_DIR)/$(PROJECT).lst: $(BUILD_DIR)/$(PROJECT).elf | $(BUILD_DIR)
@arm-none-eabi-objdump -D $< > $@
$(BUILD_DIR)/$(PROJECT).elf: $(OBJS) | $(BUILD_DIR)
@echo "Linking $@"
@$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
@echo
$(OBJ_DIR)/%.o: %.c | $(OBJ_DIR)
@mkdir -p $(@D)
@echo "Compiling $<"
@$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD_DIR): ; @mkdir -p $@
$(OBJ_DIR): ; @mkdir -p $@
clean: ; $(RM) -r $(OBJ_DIR) $(BUILD_DIR)
-include $(DEPS)