Statistics
| Branch: | Tag: | Revision:

amiro-blt / Target / Modules / LightRing_1-0 / Boot / makefile @ 31d314a9

History | View | Annotate | Download (10.913 KB)

1
#****************************************************************************************
2
#|  Description: Makefile for STM32 using CodeSourcery GNU GCC compiler toolset
3
#|    File Name: makefile
4
#|
5
#|---------------------------------------------------------------------------------------
6
#|                          C O P Y R I G H T
7
#|---------------------------------------------------------------------------------------
8
#|   Copyright (c) 2011  by Feaser    http://www.feaser.com    All rights reserved
9
#|
10
#|---------------------------------------------------------------------------------------
11
#|                            L I C E N S E
12
#|---------------------------------------------------------------------------------------
13
#| This file is part of OpenBTL. OpenBTL is free software: you can redistribute it and/or
14
#| modify it under the terms of the GNU General Public License as published by the Free
15
#| Software Foundation, either version 3 of the License, or (at your option) any later
16
#| version.
17
#|
18
#| OpenBTL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19
#| without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20
#| PURPOSE. See the GNU General Public License for more details.
21
#|
22
#| You should have received a copy of the GNU General Public License along with OpenBTL.
23
#| If not, see <http://www.gnu.org/licenses/>.
24
#|
25
#****************************************************************************************
26
SHELL = sh
27

    
28
#|---------------------------------------------------------------------------------------|
29
#| Configure project name                                                                |
30
#|---------------------------------------------------------------------------------------|
31
PROJ_NAME=AMiRo-BLT_LightRing_v1-0_stm32f103
32

    
33

    
34
#|---------------------------------------------------------------------------------------|
35
#| Speficy project source files                                                          |
36
#|---------------------------------------------------------------------------------------|
37
PROJ_FILES= \
38
blt_conf.h \
39
hooks.c \
40
main.c \
41
./lib/CMSIS/CM3/CoreSupport/core_cm3.c \
42
./lib/CMSIS/CM3/CoreSupport/core_cm3.h \
43
./lib/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h \
44
./lib/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c \
45
./lib/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.h \
46
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_adc.h \
47
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_bkp.h \
48
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_can.h \
49
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_cec.h \
50
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_crc.h \
51
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_dac.h \
52
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_dbgmcu.h \
53
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_dma.h \
54
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_exti.h \
55
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_flash.h \
56
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_fsmc.h \
57
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_gpio.h \
58
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_i2c.h \
59
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_iwdg.h \
60
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_pwr.h \
61
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_rcc.h \
62
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_rtc.h \
63
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_sdio.h \
64
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_spi.h \
65
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_tim.h \
66
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_usart.h \
67
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_wwdg.h \
68
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_adc.c \
69
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_bkp.c \
70
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_can.c \
71
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_cec.c \
72
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_crc.c \
73
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_dac.c \
74
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_dbgmcu.c \
75
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_dma.c \
76
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_exti.c \
77
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c \
78
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_fsmc.c \
79
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_gpio.c \
80
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c \
81
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_iwdg.c \
82
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_pwr.c \
83
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_rcc.c \
84
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_rtc.c \
85
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_sdio.c \
86
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_spi.c \
87
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_tim.c \
88
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c \
89
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_wwdg.c \
90
./lib/STM32F10x_StdPeriph_Driver/stm32f10x_conf.h \
91
../../../Source/boot.c \
92
../../../Source/boot.h \
93
../../../Source/com.c \
94
../../../Source/com.h \
95
../../../Source/gateway.c \
96
../../../Source/gateway.h \
97
../../../Source/xcp.c \
98
../../../Source/xcp.h \
99
../../../Source/backdoor.c \
100
../../../Source/backdoor.h \
101
../../../Source/cop.c \
102
../../../Source/cop.h \
103
../../../Source/file.c \
104
../../../Source/file.h \
105
../../../Source/assert.c \
106
../../../Source/assert.h \
107
../../../Source/helper.h \
108
../../../Source/plausibility.h \
109
../../../Source/ARMCM3_STM32/types.h \
110
../../../Source/ARMCM3_STM32/cpu.c \
111
../../../Source/ARMCM3_STM32/cpu.h \
112
../../../Source/ARMCM3_STM32/can.c \
113
../../../Source/ARMCM3_STM32/can.h \
114
../../../Source/ARMCM3_STM32/uart.c \
115
../../../Source/ARMCM3_STM32/uart.h \
116
../../../Source/ARMCM3_STM32/nvm.c \
117
../../../Source/ARMCM3_STM32/nvm.h \
118
../../../Source/ARMCM3_STM32/timer.c \
119
../../../Source/ARMCM3_STM32/timer.h \
120
../../../Source/ARMCM3_STM32/flash.c \
121
../../../Source/ARMCM3_STM32/flash.h \
122
../../../Source/ARMCM3_STM32/GCC/vectors.c \
123
../../../Source/ARMCM3_STM32/GCC/cstart.c \
124
../../../Source/AMiRo/amiroblt.h \
125
../../../Source/AMiRo/helper.h \
126
../../../Source/AMiRo/helper.c
127

    
128

    
129
#|---------------------------------------------------------------------------------------|
130
#| Compiler binaries                                                                     |
131
#|---------------------------------------------------------------------------------------|
132
CC = arm-none-eabi-gcc
133
LN = arm-none-eabi-gcc
134
OC = arm-none-eabi-objcopy
135
OD = arm-none-eabi-objdump
136
AS = arm-none-eabi-as
137
SZ = arm-none-eabi-size
138

    
139

    
140
#|---------------------------------------------------------------------------------------|
141
#| Extract file names                                                                    |
142
#|---------------------------------------------------------------------------------------|
143
PROJ_ASRCS  = $(filter %.s,$(foreach file,$(PROJ_FILES),$(notdir $(file))))
144
PROJ_CSRCS  = $(filter %.c,$(foreach file,$(PROJ_FILES),$(notdir $(file))))
145
PROJ_CHDRS  = $(filter %.h,$(foreach file,$(PROJ_FILES),$(notdir $(file))))
146
PROJ_CCMPL  = $(patsubst %.c,%.cpl,$(PROJ_CSRCS))
147
PROJ_ACMPL  = $(patsubst %.s,%.cpl,$(PROJ_ASRCS))
148

    
149

    
150
#|---------------------------------------------------------------------------------------|
151
#| Set important path variables                                                          |
152
#|---------------------------------------------------------------------------------------|
153
VPATH    = $(foreach path,$(sort $(foreach file,$(PROJ_FILES),$(dir $(file)))) $(subst \,/,$(OBJ_PATH)),$(path) :)
154
OBJ_PATH = obj
155
BIN_PATH = bin
156
INC_PATH = $(patsubst %,-I%,$(sort $(foreach file,$(filter %.h,$(PROJ_FILES)),$(dir $(file)))))
157
INC_PATH += -I.
158
LIB_PATH  = -L../../../Source/ARMCM3_STM32/GCC/
159

    
160

    
161
#|---------------------------------------------------------------------------------------|
162
#| Options for compiler binaries                                                         |
163
#|---------------------------------------------------------------------------------------|
164
CFLAGS   = -g -D inline= -mthumb -mcpu=cortex-m3 -O1 -T memory.x
165
CFLAGS  += -D PACK_STRUCT_END=__attribute\(\(packed\)\) -Wno-main
166
CFLAGS  += -D ALIGN_STRUCT_END=__attribute\(\(aligned\(4\)\)\) 
167
CFLAGS  += -ffunction-sections -fdata-sections $(INC_PATH) -D STM32F10X_MD -D GCC_ARMCM3
168
CFLAGS  += -D USE_STDPERIPH_DRIVER -D VECT_TAB_FLASH -Wa,-adhlns="$(OBJ_PATH)/$(subst .o,.lst,$@)"
169
LFLAGS   = -nostartfiles -Xlinker -M -Xlinker -Map=$(BIN_PATH)/$(PROJ_NAME).map
170
LFLAGS  += $(LIB_PATH) -Xlinker --gc-sections
171
OFLAGS   = -O ihex
172
ODFLAGS  = -x
173
SZFLAGS  = -B -d
174
CFLAGS  +=
175

    
176

    
177
#|---------------------------------------------------------------------------------------|
178
#| Specify library files                                                                 |
179
#|---------------------------------------------------------------------------------------|
180
LIBS = 
181

    
182

    
183
#|---------------------------------------------------------------------------------------|
184
#| Define targets                                                                        |
185
#|---------------------------------------------------------------------------------------|
186
AOBJS = $(patsubst %.s,%.o,$(PROJ_ASRCS))
187
COBJS = $(patsubst %.c,%.o,$(PROJ_CSRCS))
188

    
189

    
190
#|---------------------------------------------------------------------------------------|
191
#| Make ALL                                                                              |
192
#|---------------------------------------------------------------------------------------|
193
all : $(BIN_PATH)/$(PROJ_NAME).hex
194

    
195

    
196
$(BIN_PATH)/$(PROJ_NAME).hex : $(BIN_PATH)/$(PROJ_NAME).elf
197
	@$(OC) $< $(OFLAGS) $@
198
	@$(OD) $(ODFLAGS) $< > $(BIN_PATH)/$(PROJ_NAME).map
199
	@echo +++ Summary of memory consumption:
200
	@$(SZ) $(SZFLAGS) $<
201
	@echo +++ Build complete [$(notdir $@)]
202

    
203
$(BIN_PATH)/$(PROJ_NAME).elf : $(AOBJS) $(COBJS) 
204
	@if [ ! -d $(BIN_PATH) ]; then mkdir $(BIN_PATH); fi
205
	@echo +++ Linking [$(notdir $@)]
206
	@$(LN) $(CFLAGS) -o $@ $(patsubst %.o,$(OBJ_PATH)/%.o,$(^F)) $(LIBS) $(LFLAGS)
207

    
208

    
209
#|---------------------------------------------------------------------------------------|
210
#| Compile and assemble                                                                  |
211
#|---------------------------------------------------------------------------------------|
212
$(AOBJS): %.o: %.s $(PROJ_CHDRS)
213
	@if [ ! -d $(OBJ_PATH) ]; then mkdir $(OBJ_PATH); fi
214
	@echo +++ Assembling [$(notdir $<)]
215
	@$(AS) $(AFLAGS) $< -o $(OBJ_PATH)/$(@F)
216

    
217
$(COBJS): %.o: %.c $(PROJ_CHDRS)
218
	@if [ ! -d $(OBJ_PATH) ]; then mkdir $(OBJ_PATH); fi
219
	@echo +++ Compiling [$(notdir $<)]
220
	@$(CC) $(CFLAGS) -c $< -o $(OBJ_PATH)/$(@F)
221

    
222

    
223
#|---------------------------------------------------------------------------------------|
224
#| Make CLEAN                                                                            |
225
#|---------------------------------------------------------------------------------------|
226
clean : 
227
	@echo +++ Cleaning build environment
228
	@rm -rf $(OBJ_PATH)
229
	@rm -rf $(BIN_PATH)
230
	@echo +++ Clean complete
231

    
232
include ../../flash.mk
233