1 | #include Makefile
|
2 |
|
3 | #This file is included in the general Makefile, the libs Makefile and the src Makefile
|
4 | #Different optimize settings for library and source files can be realized by using arguments
|
5 | #Compiler optimize settings:
|
6 | # -O0 no optimize, reduce compilation time and make debugging produce the expected results (default).
|
7 | # -O1 optimize, reduce code size and execution time, without much increase of compilation time.
|
8 | # -O2 optimize, reduce code execution time compared to ‘O1’, increase of compilation time.
|
9 | # -O3 optimize, turns on all optimizations, further increase of compilation time.
|
10 | # -Os optimize for size, enables all ‘-O2’ optimizations that do not typically increase code size and other code size optimizations.
|
11 | #Recommended optimize settings for release version: -O3
|
12 | #Recommended optimize settings for debug version: -O0
|
13 | #Valid parameters :
|
14 | # OptLIB=0 --> optimize library files using the -O0 setting
|
15 | # OptLIB=1 --> optimize library files using the -O1 setting
|
16 | # OptLIB=2 --> optimize library files using the -O2 setting
|
17 | # OptLIB=3 --> optimize library files using the -O3 setting
|
18 | # OptLIB=s --> optimize library files using the -Os setting
|
19 | # OptSRC=0 --> optimize source files using the -O0 setting
|
20 | # OptSRC=1 --> optimize source files using the -O1 setting
|
21 | # OptSRC=2 --> optimize source files using the -O2 setting
|
22 | # OptSRC=3 --> optimize source files using the -O3 setting
|
23 | # OptSRC=s --> optimize source files using the -Os setting
|
24 | # all --> build all
|
25 | # libs --> build libs only
|
26 | # src --> build src only
|
27 | # clean --> clean project
|
28 | # tshow --> show optimize settings
|
29 | #Example:
|
30 | # make OptLIB=3 OptSRC=0 all tshow
|
31 |
|
32 | #TOP=$(shell readlink -f "$(dir $(lastword $(MAKEFILE_LIST)))")
|
33 | TOP=E:/git/FigoShot/FigoShot
|
34 | PROGRAM=main
|
35 | LIBDIR=$(TOP)/Libs
|
36 |
|
37 | #Adust the following line to the library in use
|
38 | #STMLIB=$(LIBDIR)/STM32F10x_StdPeriph_Lib_V3.6.1/Libraries
|
39 | STMLIB=$(LIBDIR)/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries
|
40 |
|
41 | #Adjust TypeOfMCU in use, see CMSIS file "stm32f10x.h"
|
42 | #STM32F103RBT (128KB FLASH, 20KB RAM) --> STM32F10X_MD
|
43 | TypeOfMCU=STM32F10X_LD_VL
|
44 | #STM32F103RET (512KB FLASH, 64KB RAM) --> STM32F10X_HD
|
45 | #TypeOfMCU=STM32F10X_HD
|
46 |
|
47 | TC=arm-none-eabi
|
48 | CC=$(TC)-gcc
|
49 | LD=$(TC)-ld -v
|
50 | OBJCOPY=$(TC)-objcopy
|
51 | AR=$(TC)-ar
|
52 | GDB=$(TC)-gdb
|
53 |
|
54 | INCLUDE=-I$(TOP)/inc
|
55 | INCLUDE+=-I$(STMLIB)/CMSIS/CM3/CoreSupport
|
56 | INCLUDE+=-I$(STMLIB)/CMSIS/CM3/DeviceSupport/ST/STM32F10x
|
57 | INCLUDE+=-I$(STMLIB)/STM32F10x_StdPeriph_Driver/inc
|
58 | INCLUDE+=-I$(TOP)/app
|
59 |
|
60 |
|
61 | COMMONFLAGS=-g -mcpu=cortex-m3 -mthumb
|
62 | COMMONFLAGSlib=$(COMMONFLAGS)
|
63 |
|
64 | #Commands for general Makefile and src Makefile
|
65 | ifeq ($(OptSRC),0)
|
66 | COMMONFLAGS+=-O0
|
67 | InfoTextSrc=src (no optimize, -O0)
|
68 | else ifeq ($(OptSRC),1)
|
69 | COMMONFLAGS+=-O1
|
70 | InfoTextSrc=src (optimize time+ size+, -O1)
|
71 | else ifeq ($(OptSRC),2)
|
72 | COMMONFLAGS+=-O2
|
73 | InfoTextSrc=src (optimize time++ size+, -O2)
|
74 | else ifeq ($(OptSRC),s)
|
75 | COMMONFLAGS+=-Os
|
76 | InfoTextSrc=src (optimize size++, -Os)
|
77 | else
|
78 | COMMONFLAGS+=-O3
|
79 | InfoTextSrc=src (full optimize, -O3)
|
80 | endif
|
81 | CFLAGS+=$(COMMONFLAGS) -Wall -Werror $(INCLUDE)
|
82 | CFLAGS+=-D $(TypeOfMCU)
|
83 | CFLAGS+=-D VECT_TAB_FLASH
|
84 |
|
85 | #Commands for libs Makefile
|
86 | ifeq ($(OptLIB),0)
|
87 | COMMONFLAGSlib+=-O0
|
88 | InfoTextLib=libs (no optimize, -O0)
|
89 | else ifeq ($(OptLIB),1)
|
90 | COMMONFLAGSlib+=-O1
|
91 | InfoTextLib=libs (optimize time+ size+, -O1)
|
92 | else ifeq ($(OptLIB),2)
|
93 | COMMONFLAGSlib+=-O2
|
94 | InfoTextLib=libs (optimize time++ size+, -O2)
|
95 | else ifeq ($(OptLIB),s)
|
96 | COMMONFLAGSlib+=-Os
|
97 | InfoTextLib=libs (optimize size++, -Os)
|
98 | else
|
99 | COMMONFLAGSlib+=-O3
|
100 | InfoTextLib=libs (full optimize, -O3)
|
101 | endif
|
102 | CFLAGSlib+=$(COMMONFLAGSlib) -Wall -Werror $(INCLUDE)
|
103 | CFLAGSlib+=-D $(TypeOfMCU)
|
104 | CFLAGSlib+=-D VECT_TAB_FLASH
|