2015-08-12 08:48:40 -07:00
|
|
|
#****************************************************************************************
|
|
|
|
#| Description: Makefile for STM32 using CodeSourcery GNU GCC compiler toolset
|
|
|
|
#| File Name: makefile
|
|
|
|
#|
|
|
|
|
#|---------------------------------------------------------------------------------------
|
|
|
|
#| C O P Y R I G H T
|
|
|
|
#|---------------------------------------------------------------------------------------
|
|
|
|
#| Copyright (c) 2011 by Feaser http://www.feaser.com All rights reserved
|
|
|
|
#|
|
|
|
|
#|---------------------------------------------------------------------------------------
|
|
|
|
#| L I C E N S E
|
|
|
|
#|---------------------------------------------------------------------------------------
|
2016-05-17 08:12:27 -07:00
|
|
|
#| This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
|
2015-08-12 08:48:40 -07:00
|
|
|
#| modify it under the terms of the GNU General Public License as published by the Free
|
|
|
|
#| Software Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
#| version.
|
|
|
|
#|
|
2016-05-17 08:12:27 -07:00
|
|
|
#| OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
2015-08-12 08:48:40 -07:00
|
|
|
#| without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
#| PURPOSE. See the GNU General Public License for more details.
|
|
|
|
#|
|
2016-04-30 15:52:15 -07:00
|
|
|
#| You have received a copy of the GNU General Public License along with OpenBLT. It
|
|
|
|
#| should be located in ".\Doc\license.html". If not, contact Feaser to obtain a copy.
|
2015-08-12 08:48:40 -07:00
|
|
|
#|
|
|
|
|
#****************************************************************************************
|
|
|
|
SHELL = sh
|
|
|
|
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
#| Configure project name |
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
PROJ_NAME=openblt_demoprog_nucleo_stm32f103rb
|
|
|
|
|
|
|
|
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
#| Speficy project source files |
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
PROJ_FILES= \
|
|
|
|
blt_conf.h \
|
|
|
|
hooks.c \
|
|
|
|
main.c \
|
|
|
|
./lib/fatfs/ffconf.h \
|
|
|
|
./lib/fatfs/mmc.c \
|
|
|
|
./lib/CMSIS/CM3/CoreSupport/core_cm3.c \
|
|
|
|
./lib/CMSIS/CM3/CoreSupport/core_cm3.h \
|
|
|
|
./lib/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h \
|
|
|
|
./lib/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c \
|
|
|
|
./lib/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.h \
|
|
|
|
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_gpio.h \
|
|
|
|
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_rcc.h \
|
|
|
|
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_spi.h \
|
|
|
|
./lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_usart.h \
|
|
|
|
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_gpio.c \
|
|
|
|
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_rcc.c \
|
|
|
|
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_spi.c \
|
|
|
|
./lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c \
|
|
|
|
./lib/STM32F10x_StdPeriph_Driver/stm32f10x_conf.h \
|
|
|
|
../../../Source/third_party/fatfs/src/diskio.h \
|
|
|
|
../../../Source/third_party/fatfs/src/ff.c \
|
|
|
|
../../../Source/third_party/fatfs/src/ff.h \
|
|
|
|
../../../Source/third_party/fatfs/src/integer.h \
|
|
|
|
../../../Source/third_party/fatfs/src/option/unicode.c \
|
|
|
|
../../../Source/boot.c \
|
|
|
|
../../../Source/boot.h \
|
|
|
|
../../../Source/com.c \
|
|
|
|
../../../Source/com.h \
|
|
|
|
../../../Source/xcp.c \
|
|
|
|
../../../Source/xcp.h \
|
|
|
|
../../../Source/backdoor.c \
|
|
|
|
../../../Source/backdoor.h \
|
|
|
|
../../../Source/cop.c \
|
|
|
|
../../../Source/cop.h \
|
|
|
|
../../../Source/file.c \
|
|
|
|
../../../Source/file.h \
|
|
|
|
../../../Source/assert.c \
|
|
|
|
../../../Source/assert.h \
|
2016-02-25 05:51:12 -08:00
|
|
|
../../../Source/cpu.h \
|
|
|
|
../../../Source/can.h \
|
|
|
|
../../../Source/uart.h \
|
|
|
|
../../../Source/nvm.h \
|
|
|
|
../../../Source/timer.h \
|
2015-08-12 08:48:40 -07:00
|
|
|
../../../Source/plausibility.h \
|
2016-10-24 04:08:54 -07:00
|
|
|
../../../Source/ARMCM3_STM32F1/types.h \
|
|
|
|
../../../Source/ARMCM3_STM32F1/cpu.c \
|
|
|
|
../../../Source/ARMCM3_STM32F1/can.c \
|
|
|
|
../../../Source/ARMCM3_STM32F1/uart.c \
|
|
|
|
../../../Source/ARMCM3_STM32F1/nvm.c \
|
|
|
|
../../../Source/ARMCM3_STM32F1/timer.c \
|
|
|
|
../../../Source/ARMCM3_STM32F1/flash.c \
|
|
|
|
../../../Source/ARMCM3_STM32F1/flash.h \
|
|
|
|
../../../Source/ARMCM3_STM32F1/GCC/vectors.c \
|
|
|
|
../../../Source/ARMCM3_STM32F1/GCC/cpu_comp.c \
|
|
|
|
../../../Source/ARMCM3_STM32F1/GCC/cstart.c
|
2015-08-12 08:48:40 -07:00
|
|
|
|
|
|
|
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
#| Compiler binaries |
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
CC = arm-none-eabi-gcc
|
|
|
|
LN = arm-none-eabi-gcc
|
|
|
|
OC = arm-none-eabi-objcopy
|
|
|
|
OD = arm-none-eabi-objdump
|
|
|
|
AS = arm-none-eabi-as
|
|
|
|
SZ = arm-none-eabi-size
|
|
|
|
|
|
|
|
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
#| Extract file names |
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
PROJ_ASRCS = $(filter %.s,$(foreach file,$(PROJ_FILES),$(notdir $(file))))
|
|
|
|
PROJ_CSRCS = $(filter %.c,$(foreach file,$(PROJ_FILES),$(notdir $(file))))
|
|
|
|
PROJ_CHDRS = $(filter %.h,$(foreach file,$(PROJ_FILES),$(notdir $(file))))
|
|
|
|
PROJ_CCMPL = $(patsubst %.c,%.cpl,$(PROJ_CSRCS))
|
|
|
|
PROJ_ACMPL = $(patsubst %.s,%.cpl,$(PROJ_ASRCS))
|
|
|
|
|
|
|
|
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
#| Set important path variables |
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
VPATH = $(foreach path,$(sort $(foreach file,$(PROJ_FILES),$(dir $(file)))) $(subst \,/,$(OBJ_PATH)),$(path) :)
|
|
|
|
OBJ_PATH = obj
|
|
|
|
BIN_PATH = bin
|
|
|
|
INC_PATH = $(patsubst %,-I%,$(sort $(foreach file,$(filter %.h,$(PROJ_FILES)),$(dir $(file)))))
|
|
|
|
INC_PATH += -I.
|
2016-10-24 04:08:54 -07:00
|
|
|
LIB_PATH = -L../../../Source/ARMCM3_STM32F1/GCC/
|
2015-08-12 08:48:40 -07:00
|
|
|
|
|
|
|
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
#| Options for compiler binaries |
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
CFLAGS = -g -D inline= -mthumb -mcpu=cortex-m3 -O1 -T memory.x
|
|
|
|
CFLAGS += -D PACK_STRUCT_END=__attribute\(\(packed\)\) -Wno-main
|
|
|
|
CFLAGS += -D ALIGN_STRUCT_END=__attribute\(\(aligned\(4\)\)\)
|
|
|
|
CFLAGS += -ffunction-sections -fdata-sections $(INC_PATH) -D STM32F10X_MD -D GCC_ARMCM3
|
|
|
|
CFLAGS += -D USE_STDPERIPH_DRIVER -D VECT_TAB_FLASH -Wa,-adhlns="$(OBJ_PATH)/$(subst .o,.lst,$@)"
|
|
|
|
LFLAGS = -nostartfiles -Xlinker -M -Xlinker -Map=$(BIN_PATH)/$(PROJ_NAME).map
|
|
|
|
LFLAGS += $(LIB_PATH) -Xlinker --gc-sections
|
|
|
|
OFLAGS = -O srec
|
|
|
|
ODFLAGS = -x
|
|
|
|
SZFLAGS = -B -d
|
|
|
|
|
|
|
|
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
#| Specify library files |
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
LIBS =
|
|
|
|
|
|
|
|
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
#| Define targets |
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
AOBJS = $(patsubst %.s,%.o,$(PROJ_ASRCS))
|
|
|
|
COBJS = $(patsubst %.c,%.o,$(PROJ_CSRCS))
|
|
|
|
|
|
|
|
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
#| Make ALL |
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
all : $(BIN_PATH)/$(PROJ_NAME).srec
|
|
|
|
|
|
|
|
|
|
|
|
$(BIN_PATH)/$(PROJ_NAME).srec : $(BIN_PATH)/$(PROJ_NAME).elf
|
|
|
|
@$(OC) $< $(OFLAGS) $@
|
|
|
|
@$(OD) $(ODFLAGS) $< > $(BIN_PATH)/$(PROJ_NAME).map
|
|
|
|
@echo +++ Summary of memory consumption:
|
|
|
|
@$(SZ) $(SZFLAGS) $<
|
|
|
|
@echo +++ Build complete [$(notdir $@)]
|
|
|
|
|
|
|
|
$(BIN_PATH)/$(PROJ_NAME).elf : $(AOBJS) $(COBJS)
|
|
|
|
@echo +++ Linking [$(notdir $@)]
|
|
|
|
@$(LN) $(CFLAGS) -o $@ $(patsubst %.o,$(OBJ_PATH)/%.o,$(^F)) $(LIBS) $(LFLAGS)
|
|
|
|
|
|
|
|
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
#| Compile and assemble |
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
$(AOBJS): %.o: %.s $(PROJ_CHDRS)
|
|
|
|
@echo +++ Assembling [$(notdir $<)]
|
|
|
|
@$(AS) $(AFLAGS) $< -o $(OBJ_PATH)/$(@F)
|
|
|
|
|
|
|
|
$(COBJS): %.o: %.c $(PROJ_CHDRS)
|
|
|
|
@echo +++ Compiling [$(notdir $<)]
|
|
|
|
@$(CC) $(CFLAGS) -c $< -o $(OBJ_PATH)/$(@F)
|
|
|
|
|
|
|
|
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
#| Make CLEAN |
|
|
|
|
#|---------------------------------------------------------------------------------------|
|
|
|
|
clean :
|
|
|
|
@echo +++ Cleaning build environment
|
2016-04-30 12:34:25 -07:00
|
|
|
@cs-rm -f $(foreach file,$(AOBJS),$(OBJ_PATH)/$(file))
|
|
|
|
@cs-rm -f $(foreach file,$(COBJS),$(OBJ_PATH)/$(file))
|
|
|
|
@cs-rm -f $(patsubst %.o,%.lst,$(foreach file,$(COBJS),$(OBJ_PATH)/$(file)))
|
|
|
|
@cs-rm -f $(BIN_PATH)/$(PROJ_NAME).elf $(BIN_PATH)/$(PROJ_NAME).map
|
|
|
|
@cs-rm -f $(BIN_PATH)/$(PROJ_NAME).srec
|
2015-08-12 08:48:40 -07:00
|
|
|
@echo +++ Clean complete
|
|
|
|
|
|
|
|
|