mirror of
https://github.com/avem-labs/Avem.git
synced 2023-09-01 15:18:49 +08:00
102 lines
3.7 KiB
Makefile
102 lines
3.7 KiB
Makefile
# 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
|
||
|
||
TOP=$(shell greadlink -f "$(dir $(lastword $(MAKEFILE_LIST)))")
|
||
PROGRAM=main
|
||
LIBDIR=$(TOP)/libs
|
||
|
||
#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
|
||
#STM32F103ZET (512KB FLASH, 64KB RAM) --> STM32F10X_HD
|
||
#============================================================================#
|
||
TypeOfMCU=STM32F10X_HD
|
||
#============================================================================#
|
||
|
||
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/STM32F10x/Include
|
||
INCLUDE+=-I$(STMLIB)/CMSIS/Device/ST/STM32F10x/Source/Templates
|
||
INCLUDE+=-I$(STMLIB)/STM32F10x_StdPeriph_Driver/inc
|
||
INCLUDE+=-I$(STMLIB)/STM32_USB-FS-Device_Driver/inc
|
||
COMMONFLAGS=-g -mcpu=cortex-m3 -mthumb
|
||
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),s)
|
||
COMMONFLAGS+=-Os
|
||
InfoTextSrc=src (optimize size++, -Os)
|
||
else
|
||
COMMONFLAGS+=-O3
|
||
InfoTextSrc=src (full optimize, -O3)
|
||
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),s)
|
||
COMMONFLAGSlib+=-Os
|
||
InfoTextLib=libs (optimize size++, -Os)
|
||
else
|
||
COMMONFLAGSlib+=-O3
|
||
InfoTextLib=libs (full optimize, -O3)
|
||
endif
|
||
CFLAGSlib+=$(COMMONFLAGSlib) -Wall -Werror $(INCLUDE)
|
||
CFLAGSlib+=-D $(TypeOfMCU)
|
||
CFLAGSlib+=-D VECT_TAB_FLASH
|