-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.common~
123 lines (108 loc) · 3.93 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# include Makefile
#
# This file is included in the general Makefile, the libs Makefile and the src Makefile
# Different optimize settings for library and source files can be realized by using arguments
#
# Compiler optimize settings:
# -O0 no optimize, reduce compilation time and make debugging produce the expected results (default).
# -O1 optimize, reduce code size and execution time, without much increase of compilation time.
# -O2 optimize, reduce code execution time compared to ‘O1’, increase of compilation time.
# -O3 optimize, turns on all optimizations, further increase of compilation time.
# -Os optimize for size, enables all ‘-O2’ optimizations that do not typically increase code size and other code size optimizations.
#
# Recommended optimize settings for release version: -O3
# Recommended optimize settings for debug version: -O0
#
# Valid parameters :
# optLIB=0 --> optimize library files using the -O0 setting
# optLIB=1 --> optimize library files using the -O1 setting
# optLIB=2 --> optimize library files using the -O2 setting
# optLIB=3 --> optimize library files using the -O3 setting
# optLIB=s --> optimize library files using the -Os setting
# optSRC=0 --> optimize source files using the -O0 setting
# optSRC=1 --> optimize source files using the -O1 setting
# optSRC=2 --> optimize source files using the -O2 setting
# optSRC=3 --> optimize source files using the -O3 setting
# optSRC=s --> optimize source files using the -Os setting
# all --> build all
# libs --> build libs only
# src --> build src only
# clean --> clean project
# tshow --> show optimize settings
#
# Example:
# make optLIB=3 optSRC=0 all tshow
LIBDIR=$(shell readlink -f "$(dir $(lastword $(MAKEFILE_LIST)))")
#Adust the following line to the library in use
STMLIB=$(LIBDIR)/STM32_USB-FS-Device_Lib_V4.0.0/Libraries
#Adjust TypeOfMCU in use, see CMSIS file "stm32f10x.h"
#STM32F103RBT (128KB FLASH, 20KB RAM) --> STM32F10X_MD
#TypeOfMCU=STM32F10X_MD
#STM32F103RET (512KB FLASH, 64KB RAM) --> STM32F10X_HD
#TypeOfMCU=STM32F10X_HD
#STM32F372CCT (512KB FLASH, 32KB RAM)
TypeOfMCU = STM32F37X
#Define which series of mcu in use
SERIES = STM32F37x
series = stm32f37x
TC=arm-none-eabi
CC=$(TC)-gcc
LD=$(TC)-ld -v
OBJCOPY=$(TC)-objcopy
AR=$(TC)-ar
GDB=$(TC)-gdb
INCLUDE=-I$(TOP)/inc
INCLUDE+=-I$(STMLIB)/CMSIS/Include
INCLUDE+=-I$(STMLIB)/CMSIS/Device/ST/$(SERIES)/Include
INCLUDE+=-I$(STMLIB)/CMSIS/Device/ST/$(SERIES)/Source/Templates
INCLUDE+=-I$(STMLIB)/$(SERIES)_StdPeriph_Driver/inc
INCLUDE+=-I$(STMLIB)/STM32_USB-FS-Device_Driver/inc
COMMONFLAGS = -g -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m
COMMONFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
COMMONFLAGSlib = $(COMMONFLAGS)
#Commands for general Makefile and src Makefile
ifeq ($(optSRC),0)
COMMONFLAGS+=-O0
InfoTextSrc=src (no optimize, -O0)
else ifeq ($(optSRC),1)
COMMONFLAGS+=-O1
InfoTextSrc=src (optimize time+ size+, -O1)
else ifeq ($(optSRC),2)
COMMONFLAGS+=-O2
InfoTextSrc=src (optimize time++ size+, -O2)
else ifeq ($(optSRC),3)
COMMONFLAGS+=-O3
InfoTextSrc=src (full optimize, -O3)
else ifeq ($(optSRC),s)
COMMONFLAGS+=-Os
InfoTextSrc=src (optimize size++, -Os)
else
COMMONFLAGS+=-O0
InfoTextSrc=src (no optimize, -O0)
endif
CFLAGS+=$(COMMONFLAGS) -Wall -Werror $(INCLUDE)
CFLAGS+=-D $(TypeOfMCU)
CFLAGS+=-D VECT_TAB_FLASH
#Commands for libs Makefile
ifeq ($(optLIB),0)
COMMONFLAGSlib+=-O0
InfoTextLib=libs (no optimize, -O0)
else ifeq ($(optLIB),1)
COMMONFLAGSlib+=-O1
InfoTextLib=libs (optimize time+ size+, -O1)
else ifeq ($(optLIB),2)
COMMONFLAGSlib+=-O2
InfoTextLib=libs (optimize time++ size+, -O2)
else ifeq ($(optLIB),3)
COMMONFLAGSlib+=-O3
InfoTextLib=libs (full optimize, -O3)
else ifeq ($(optLIB),s)
COMMONFLAGSlib+=-Os
InfoTextLib=libs (optimize size++, -Os)
else
COMMONFLAGSlib+=-O0
InfoTextLib=libs (no optimize, -O0)
endif
CFLAGSlib+=$(COMMONFLAGSlib) -Wall -Werror $(INCLUDE)
CFLAGSlib+=-D $(TypeOfMCU)
CFLAGSlib+=-D VECT_TAB_FLASH