-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
75 lines (58 loc) · 1.71 KB
/
Makefile
File metadata and controls
75 lines (58 loc) · 1.71 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
CC := arm-none-eabi-gcc
CP := arm-none-eabi-objcopy
OD := arm-none-eabi-objdump
CONFIG ?= release
ifndef BOARD
$(error BOARD is not set)
endif
BUILDDIR := build
OBJDIR := $(BUILDDIR)/$(BOARD)/$(CONFIG)/obj
DEPDIR := $(BUILDDIR)/$(BOARD)/$(CONFIG)/dep
BINDIR := $(BUILDDIR)/$(BOARD)/$(CONFIG)/bin
TARGET := multithreading
SRCS := main.c scheduler.c startup.c
SRCS := $(SRCS:%=src/%)
OBJS := $(SRCS:%.c=$(OBJDIR)/%.o)
DEPS := $(SRCS:%.c=$(DEPDIR)/%.d)
include boards/$(BOARD)/Makefile.board
CFLAGS += -mthumb -mthumb-interwork
LDFLAGS += -mthumb -mthumb-interwork
CFLAGS += -Wall -Wextra -std=c11
CFLAGS += -ffreestanding
CFLAGS += -ffunction-sections -fdata-sections
CFLAGS += -I CMSIS/Include -I src
DEPFLAGS = -MMD -MP -MF $(@:$(OBJDIR)/%.o=$(DEPDIR)/%.d)
LDFLAGS += -Wl,--gc-sections
LDFLAGS += -Wl,-Map=$(BINDIR)/$(TARGET).map
LDFLAGS += -specs=nosys.specs
LDFLAGS += -nostartfiles
ifeq ($(CONFIG),release)
CFLAGS += -O2 -fno-delete-null-pointer-checks
LDFLAGS += -O2 -fno-delete-null-pointer-checks
else ifeq ($(CONFIG),debug)
CFLAGS += -ggdb -g3
LDFLAGS += -ggdb -g3
endif
$(BINDIR)/$(TARGET).hex: $(BINDIR)/$(TARGET).elf
$(CP) -O ihex $< $@
$(BINDIR)/$(TARGET).elf: $(OBJS)
@mkdir -p $(@D)
$(CC) $(LDFLAGS) $^ -o $@
$(OD) -DwS $@ > $(BINDIR)/$(TARGET).dis
$(OBJDIR)/%.o: %.c
@mkdir -p $(OBJDIR)/$(<D)
@mkdir -p $(DEPDIR)/$(<D)
$(CC) $(CPFFLAGS) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
.PHONY: flash-target
flash-target: $(BINDIR)/$(TARGET).hex
$(CURDIR)/tools/flash.sh ${JLINK_DEVICE} $^
.PHONY: debug-target
debug-target: flash-target
$(CURDIR)/tools/debug.sh ${JLINK_DEVICE} $(BINDIR)/$(TARGET).elf
.PHONY: clean
clean:
rm -rf $(BUILDDIR)/$(BOARD)/$(CONFIG)
.PHONY: distclean
distclean:
rm -rf $(BUILDDIR)
-include $(DEPS)