forked from embedded2014/rtenv-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (59 loc) · 1.84 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
TARGET = main
.DEFAULT_GOAL = all
CROSS_COMPILE ?= arm-none-eabi-
CC := $(CROSS_COMPILE)gcc
CFLAGS = -fno-common -ffreestanding -O0 \
-gdwarf-2 -g3 -Wall -Werror \
-mcpu=cortex-m3 -mthumb \
-Wl,-Tmain.ld -nostartfiles \
-DUSER_NAME=\"$(USER)\"
ARCH = CM3
VENDOR = ST
PLAT = STM32F10x
LIBDIR = .
CMSIS_LIB=$(LIBDIR)/libraries/CMSIS/$(ARCH)
STM32_LIB=$(LIBDIR)/libraries/STM32F10x_StdPeriph_Driver
CMSIS_PLAT_SRC = $(CMSIS_LIB)/DeviceSupport/$(VENDOR)/$(PLAT)
OUTDIR = build
SRCDIR = src \
$(CMSIS_LIB)/CoreSupport \
$(STM32_LIB)/src \
$(CMSIS_PLAT_SRC)
INCDIR = include \
$(CMSIS_LIB)/CoreSupport \
$(STM32_LIB)/inc \
$(CMSIS_PLAT_SRC)
INCLUDES = $(addprefix -I,$(INCDIR))
DATDIR = data
TOOLDIR = tool
SRC = $(wildcard $(addsuffix /*.c,$(SRCDIR))) \
$(wildcard $(addsuffix /*.s,$(SRCDIR))) \
$(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)
-include $(DEP)