forked from embedded2015/freertos-basic
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
93 lines (72 loc) · 2.24 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
TARGET = main
.DEFAULT_GOAL = all
CROSS_COMPILE ?= arm-none-eabi-
CC := $(CROSS_COMPILE)gcc
CFLAGS = -fno-common -O0 \
-std=c99 -pedantic \
-gdwarf-2 -ffreestanding -g3 \
-mcpu=cortex-m3 -mthumb \
-Wall -Werror \
-Tmain.ld -nostartfiles \
-DUSER_NAME=\"$(USER)\"
ARCH = CM3
VENDOR = ST
PLAT = STM32F10x
LIBDIR = .
CODEBASE = freertos
CMSIS_LIB = $(CODEBASE)/CMSIS/$(ARCH)
STM32_LIB = $(CODEBASE)/STM32F10x_StdPeriph_Driver
CMSIS_PLAT_SRC = $(CMSIS_LIB)/DeviceSupport/$(VENDOR)/$(PLAT)
FREERTOS_SRC = $(CODEBASE)/FreeRTOS
FREERTOS_INC = $(FREERTOS_SRC)/include/
FREERTOS_PORT_INC = $(FREERTOS_SRC)/portable/GCC/ARM_$(ARCH)/
OUTDIR = build
SRCDIR = src\
$(CMSIS_LIB)/CoreSupport \
$(STM32_LIB)/src \
$(CMSIS_PLAT_SRC) \
$(FREERTOS_SRC)
INCDIR = include \
$(CMSIS_LIB)/CoreSupport \
$(STM32_LIB)/inc \
$(CMSIS_PLAT_SRC) \
$(FREERTOS_INC) \
$(FREERTOS_PORT_INC)
INCLUDES = $(addprefix -I,$(INCDIR))
DATDIR = data
TOOLDIR = tool
TMPDiR = output
HEAP_IMPL = heap_ww
SRC = $(wildcard $(addsuffix /*.c,$(SRCDIR))) \
$(wildcard $(addsuffix /*.s,$(SRCDIR))) \
$(FREERTOS_SRC)/portable/MemMang/$(HEAP_IMPL).c \
$(FREERTOS_SRC)/portable/GCC/ARM_CM3/port.c \
$(CMSIS_PLAT_SRC)/startup/gcc_ride7/startup_stm32f10x_md.s
OBJ := $(addprefix $(OUTDIR)/,$(patsubst %.s,%.o,$(SRC:.c=.o)))
DEP = $(OBJ:.o=.o.d)
DAT =
MAKDIR = mk
MAK = $(wildcard $(MAKDIR)/*.mk)
include $(MAK)
all: $(OUTDIR)/$(TARGET).bin $(OUTDIR)/$(TARGET).lst
$(OUTDIR)/$(TARGET).bin: $(OUTDIR)/$(TARGET).elf
@echo " OBJCOPY "$@
@$(CROSS_COMPILE)objcopy -Obinary $< $@
$(OUTDIR)/$(TARGET).lst: $(OUTDIR)/$(TARGET).elf
@echo " LIST "$@
@$(CROSS_COMPILE)objdump -S $< > $@
$(OUTDIR)/$(TARGET).elf: $(OBJ) $(DAT)
@echo " LD "$@
@echo " MAP "$(OUTDIR)/$(TARGET).map
@$(CROSS_COMPILE)gcc $(CFLAGS) -Wl,-Map=$(OUTDIR)/$(TARGET).map -o $@ $^
$(OUTDIR)/%.o: %.c
@mkdir -p $(dir $@)
@echo " CC "$@
@$(CROSS_COMPILE)gcc $(CFLAGS) -MMD -MF [email protected] -o $@ -c $(INCLUDES) $<
$(OUTDIR)/%.o: %.s
@mkdir -p $(dir $@)
@echo " CC "$@
@$(CROSS_COMPILE)gcc $(CFLAGS) -MMD -MF [email protected] -o $@ -c $(INCLUDES) $<
clean:
rm -rf $(OUTDIR) $(TMPDIR)
-include $(DEP)