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