]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - tmk_core/tool/chibios/chibios.mk
Merge commit '71381457fa1311dfa0b58ba882a96db740640871'
[max/tmk_keyboard.git] / tmk_core / tool / chibios / chibios.mk
1 ##############################################################################
2 # Build global options
3 # NOTE: Can be overridden externally.
4 #
5
6 # Compiler options here.
7 ifeq ($(USE_OPT),)
8   USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99 -DPROTOCOL_CHIBIOS
9 endif
10
11 # C specific options here (added to USE_OPT).
12 ifeq ($(USE_COPT),)
13   USE_COPT =
14 endif
15
16 # include specific config.h?
17 ifdef CONFIG_H
18     USE_COPT += -include $(CONFIG_H)
19 endif
20
21 # C++ specific options here (added to USE_OPT).
22 ifeq ($(USE_CPPOPT),)
23   USE_CPPOPT = -fno-rtti
24 endif
25
26 # Enable this if you want the linker to remove unused code and data
27 ifeq ($(USE_LINK_GC),)
28   USE_LINK_GC = yes
29 endif
30
31 # Linker extra options here.
32 ifeq ($(USE_LDOPT),)
33   USE_LDOPT =
34 endif
35
36 # Enable this if you want link time optimizations (LTO)
37 ifeq ($(USE_LTO),)
38   USE_LTO = no
39 endif
40
41 # If enabled, this option allows to compile the application in THUMB mode.
42 ifeq ($(USE_THUMB),)
43   USE_THUMB = yes
44 endif
45
46 # Enable this if you want to see the full log while compiling.
47 ifeq ($(USE_VERBOSE_COMPILE),)
48   USE_VERBOSE_COMPILE = no
49 endif
50
51 # If enabled, this option makes the build process faster by not compiling
52 # modules not used in the current configuration.
53 ifeq ($(USE_SMART_BUILD),)
54   USE_SMART_BUILD = yes
55 endif
56
57 #
58 # Build global options
59 ##############################################################################
60
61 ##############################################################################
62 # Architecture or project specific options
63 #
64
65 # Stack size to be allocated to the Cortex-M process stack. This stack is
66 # the stack used by the main() thread.
67 ifeq ($(USE_PROCESS_STACKSIZE),)
68   USE_PROCESS_STACKSIZE = 0x200
69 endif
70
71 # Stack size to the allocated to the Cortex-M main/exceptions stack. This
72 # stack is used for processing interrupts and exceptions.
73 ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
74   USE_EXCEPTIONS_STACKSIZE = 0x400
75 endif
76
77 #
78 # Architecture or project specific options
79 ##############################################################################
80
81 ##############################################################################
82 # Project, sources and paths
83 #
84
85 # Imported source files and paths
86 CHIBIOS ?= $(TMK_DIR)/tool/chibios/chibios
87 # Startup files. Try a few different locations, for compability with old versions and 
88 # for things hardware in the contrib repository
89 STARTUP_MK = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
90 ifeq ("$(wildcard $(STARTUP_MK))","")
91         STARTUP_MK = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
92         ifeq ("$(wildcard $(STARTUP_MK))","")
93                 STARTUP_MK = $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
94         endif
95 endif
96 include $(STARTUP_MK)
97 # HAL-OSAL files (optional).
98 include $(CHIBIOS)/os/hal/hal.mk
99
100 PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/platform.mk
101 ifeq ("$(wildcard $(PLATFORM_MK))","")
102 PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/platform.mk
103 endif
104 include $(PLATFORM_MK)
105
106
107 BOARD_MK = $(TARGET_DIR)/boards/$(BOARD)/board.mk
108 ifeq ("$(wildcard $(BOARD_MK))","")
109         BOARD_MK = $(CHIBIOS)/os/hal/boards/$(BOARD)/board.mk
110         ifeq ("$(wildcard $(BOARD_MK))","")
111                 BOARD_MK = $(CHIBIOS_CONTRIB)/os/hal/boards/$(BOARD)/board.mk
112         endif
113 endif
114 include $(BOARD_MK)
115 include $(CHIBIOS)/os/hal/osal/rt/osal.mk
116 # RTOS files (optional).
117 include $(CHIBIOS)/os/rt/rt.mk
118 # Compability with old version
119 PORT_V = $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk
120 ifeq ("$(wildcard $(PORT_V))","")
121 PORT_V = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk
122 endif
123 include $(PORT_V)
124 # Other files (optional).
125
126 # Define linker script file here
127 ifneq ("$(wildcard $(TARGET_DIR)/ld/$(MCU_LDSCRIPT).ld)","")
128 LDSCRIPT = $(TARGET_DIR)/ld/$(MCU_LDSCRIPT).ld
129 else
130 LDSCRIPT = $(STARTUPLD)/$(MCU_LDSCRIPT).ld
131 endif
132
133 # C sources that can be compiled in ARM or THUMB mode depending on the global
134 # setting.
135 CSRC = $(STARTUPSRC) \
136        $(KERNSRC) \
137        $(PORTSRC) \
138        $(OSALSRC) \
139        $(HALSRC) \
140        $(PLATFORMSRC) \
141        $(BOARDSRC) \
142        $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
143        $(TMK_DIR)/protocol/chibios/usb_main.c \
144        $(TMK_DIR)/protocol/chibios/main.c \
145        $(SRC)
146
147 # C++ sources that can be compiled in ARM or THUMB mode depending on the global
148 # setting.
149 CPPSRC =
150
151 # C sources to be compiled in ARM mode regardless of the global setting.
152 # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
153 #       option that results in lower performance and larger code size.
154 ACSRC =
155
156 # C++ sources to be compiled in ARM mode regardless of the global setting.
157 # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
158 #       option that results in lower performance and larger code size.
159 ACPPSRC =
160
161 # C sources to be compiled in THUMB mode regardless of the global setting.
162 # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
163 #       option that results in lower performance and larger code size.
164 TCSRC =
165
166 # C sources to be compiled in THUMB mode regardless of the global setting.
167 # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
168 #       option that results in lower performance and larger code size.
169 TCPPSRC =
170
171 # List ASM source files here
172 ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
173
174 INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
175          $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
176          $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various \
177          $(TMK_DIR) $(COMMON_DIR) $(TMK_DIR)/protocol/chibios \
178          $(TMK_DIR)/protocol $(TARGET_DIR)
179
180 #
181 # Project, sources and paths
182 ##############################################################################
183
184 ##############################################################################
185 # Compiler settings
186 #
187
188 #TRGT = arm-elf-
189 TRGT = arm-none-eabi-
190 CC   = $(TRGT)gcc
191 CPPC = $(TRGT)g++
192 # Enable loading with g++ only if you need C++ runtime support.
193 # NOTE: You can use C++ even without C++ support if you are careful. C++
194 #       runtime support makes code size explode.
195 LD   = $(TRGT)gcc
196 #LD   = $(TRGT)g++
197 CP   = $(TRGT)objcopy
198 AS   = $(TRGT)gcc -x assembler-with-cpp
199 AR   = $(TRGT)ar
200 OD   = $(TRGT)objdump
201 SZ   = $(TRGT)size -A
202 HEX  = $(CP) -O ihex
203 BIN  = $(CP) -O binary
204
205 # ARM-specific options here
206 AOPT =
207
208 # THUMB-specific options here
209 TOPT = -mthumb -DTHUMB
210
211 # Define C warning options here
212 CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes -Wno-missing-field-initializers
213
214 # Define C++ warning options here
215 CPPWARN = -Wall -Wextra -Wundef
216
217 #
218 # Compiler settings
219 ##############################################################################
220
221 ##############################################################################
222 # Start of user section
223 #
224
225 # List all user C define here, like -D_DEBUG=1
226 ## Select which interfaces to include here!
227 UDEFS += $(OPT_DEFS)
228
229 # Define ASM defines here
230 UADEFS += $(OPT_DEFS)
231 # bootloader definitions may be used in the startup .s file
232 ifneq ("$(wildcard $(TARGET_DIR)/bootloader_defs.h)","")
233     UADEFS += -include $(TARGET_DIR)/bootloader_defs.h
234     UDEFS += -include $(TARGET_DIR)/bootloader_defs.h
235 else ifneq ("$(wildcard $(TARGET_DIR)/boards/$(BOARD)/bootloader_defs.h)","")
236     UADEFS += -include $(TARGET_DIR)/boards/$(BOARD)/bootloader_defs.h
237     UDEFS += -include $(TARGET_DIR)/boards/$(BOARD)/bootloader_defs.h
238 endif
239
240 # List all user directories here
241 #UINCDIR =
242
243 # List the user directory to look for the libraries here
244 #ULIBDIR =
245
246 # List all user libraries here
247 #ULIBS =
248
249 #
250 # End of user defines
251 ##############################################################################
252
253 RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC
254 ifeq ("$(wildcard $(RULESPATH)/rules.mk)","")
255 RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC
256 endif
257 include $(RULESPATH)/rules.mk