-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile.common
78 lines (46 loc) · 1.41 KB
/
Makefile.common
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
# name of executable
ELF=$(notdir $(CURDIR)).elf
# Tool path
TOOLROOT=/l/arm/arm-none-eabi/bin
# Library path
LIBROOT=/l/arm/STM32F0xx/Libraries
# Tools
CC=$(TOOLROOT)/arm-none-eabi-gcc
LD=$(TOOLROOT)/arm-none-eabi-gcc
AR=$(TOOLROOT)/arm-none-eabi-ar
AS=$(TOOLROOT)/arm-none-eabi-as
# Code Paths
CORE=$(LIBROOT)/CMSIS
DEVICE=$(LIBROOT)/CMSIS/Device/ST/STM32F0xx
PERIPH=$(LIBROOT)/STM32F0xx_StdPeriph_Driver
# Search path for standard files
vpath %.c $(TEMPLATEROOT)
# Search path for perpheral library
vpath %.c $(DEVICE)/Source/Templates
vpath %.c $(PERIPH)/src
vpath %.c $(DEVICE)
# Processor specific
PTYPE = STM32F0XX_MD
LDSCRIPT = $(TEMPLATEROOT)/stm32f0xx.ld
STARTUP= startup_stm32f0xx.o system_stm32f0xx.o
# Compilation Flags
FULLASSERT = -DUSE_FULL_ASSERT
LDFLAGS+= -T$(LDSCRIPT) -mthumb -mcpu=cortex-m0
CFLAGS+= -mcpu=cortex-m0 -mthumb
CFLAGS+= -I$(TEMPLATEROOT) -I$(CORE)/Include -I$(DEVICE)/Include -I$(CORE) -I$(PERIPH)/inc -I.
CFLAGS+= -DUSE_STDPERIPH_DRIVER $(FULLASSERT) -D$(PTYPE)
# Build executable
$(ELF) : $(OBJS)
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
# compile and generate dependency info
%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
$(CC) -MM $(CFLAGS) $< > $*.d
%.o: %.s
$(CC) -c $(CFLAGS) $< -o $@
clean:
rm -f $(OBJS) $(OBJS:.o=.d) $(ELF) startup_stm32f* $(CLEANOTHER)
debug: $(ELF)
arm-none-eabi-gdb $(ELF)
# pull in dependencies
-include $(OBJS:.o=.d)