-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile.IMXRT1062
244 lines (190 loc) · 12.1 KB
/
makefile.IMXRT1062
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#-------------------------------------------------------------------------------------------------------------------------------------------------
# Generated by Make me a Makefile (https://github.com/Orion-CanSat/Make-me-a-Makefile)
#
# Board: Teensy 4.1
# CPU Speed: 600000000
# Optimization: -O3
#
# Time of creation: 2020/12/05 12:57
#-------------------------------------------------------------------------------------------------------------------------------------------------
#MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMMMMMMMMMMMMMMMWNX0OOkkxk0KXNWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMMMMMMMMMMMWXOdlc;'.';;..;lodxO0XWWMMMMMMMMMWNXKKXNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMMMMMMMMWNOl,...,'..':c::llllllclox0NMWNKOxollccc:l0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMMMMMMWXk:..........',cllllllllcc:,;odolcloxMKXKOc,OMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMMMMMW0c.........',;cccllllllllll:,,:::x0kMMMMKo;;dNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMMMMNk:........,::ccccclllllllllll:,,,:ddcxMNk::okNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMMMXkc'..''..,:::cccccclllllllllllc,..,:;l0Oc:dXWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMMNkl:..:cc:;:ccccccccclllllllllloc;;;:c;clcdKWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMW0olc,',;:c:;:::cccccllllllllloddl;,,;;;:cdOOMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMNxlllc:,',clc:::ccccllllllllloddc,'''''';cldMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMXdclllll:;;;,',,;:ccllllllllloddc,'''',:clOWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMXdcllllllc:'......,;:cllllllllc;;:cc:;lxockMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMXXXXNWMMM
#MMMMMMMMMNdclllllll;'.........,:clllc;'.,:ldxlcxkdlkMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMc::::lOWMM
#MMMMMMMMMWkclooollc,'..........',,,'.';clooddodkkdlMMMMNNNNNNNNNWWMMMWNWWMMMWWNNNNWWMMMMWWWMMMMMMWNNMMMM:;;dNMM
#MMMMMMMMMMKl:loooolc;''''''''''.....'coooooodxkOklxMMOddooooooodkXWMkoxKMWKkdoooodxONWMOdxKNMMMXkoxkM;;::MMMMMM
#MMMMMMMMMWO:':loooool:;''','......';loooooodxkOkldXMNd::;:cccc::cxNMd:l0MMo:;:ccc::cxXMxcclxKWWKo:okM,;;;;:xNMM
#MMMMMMMWOl:odc:looooool:,.....'',,;coooooodxkOxldXMMNd:ccoMMMxoc;oXMo;l0Mx::dXNNNOl;lKMx:;,;lxK0l;l0MOOOOOOKWMM
#MMMMMWKl;o0WWKo::lool:,'...'',,;:cloooooodxkxolkNMMMXd;;,,,;;:;;:kWMo;c0Mx;:kWMMMKl;l0Md;:ll;;ldc;lKMMMMMMMMMMM
#MMMMNx;cOWMMMMNk:,,''',;,',,;:cloooooddddxdlcdKWMMMMNo;;:oxc,,:oMMMMo,c0Mx;:xKXXXOl;cKMd;:kXOc,;:;lKMMMMMMMMMMM
#MMMWx,oXMMWX0kdl:::,,;cl:,;cooddddddddolcclxKWMMMMMMXo,:lMMXx:,;lMMMl,:0MO:,;::::;,,dNMd,;kWMXx:,'cKMMMMMMMMMMM
#MMMNo,oxxolccldkKNNXOdlc:,,:ccccccc:::clx0NWMMMMMMMMNkldkKMMWXxlldKMkldXMM0dllccclokNMMOloKMMMWKxldXMMMMMMMMMMM
#MMMWKxdddxOKXWMMMMMMMMWX0kxdddoodddxOKNWMMMMMMMMMMMMMWWWWMMMMMWWWWWMWWWMMMMMWWWWWWWMMMMWWWWMMMMMWWWMMMMMMMMMMMM
#MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
ifeq ($(OS),Windows_NT)
SHELL := cmd.exe
export SHELL
DateTime := $(shell powershell [int](Get-Date -UFormat +%s)[0])
else
SHELL := bash
export SHELL
DateTime := $(shell date +%s)
endif
TARGET_NAME := Orion2
BOARD_ID := TEENSY41
MCU := imxrt1062_t41
LIBS_DIR := lib
LIBS_NAMES := Adafruit_BME280 Adafruit_BMP280 Adafruit_BNO055 Adafruit_GPS Adafruit_Sensor ArduCAM Crypto DRV8835 EEPROM Orion-Libraries RadioHead SD SoftwareSerial SPI TeensyThreads Wire
CORE_BASE := Core/teensy4
#-------------------------------------------------------------------------------------------------------------------------------------------------
# Flags
#-------------------------------------------------------------------------------------------------------------------------------------------------
FLAGS_CPU := -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -fsingle-precision-constant
FLAGS_OPT := -O3
FLAGS_COM := -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD
FLAGS_LSP :=
FLAGS_CPP := -fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
FLAGS_C :=
FLAGS_S := -x assembler-with-cpp
FLAGS_LD := -Wl,--print-memory-usage,--gc-sections,--relax,--defsym=__rtc_localtime=$(DateTime) -T$(CORE_BASE)/imxrt1062_t41.ld
LIBS := -larm_cortexM7lfsp_math -lm -lstdc++
DEFINES := -D__IMXRT1062__ -DTEENSYDUINO=153 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DARDUINO=10807 -D_DEBUG
CPP_FLAGS := $(FLAGS_CPU) $(FLAGS_OPT) $(FLAGS_COM) $(DEFINES) $(FLAGS_CPP)
C_FLAGS := $(FLAGS_CPU) $(FLAGS_OPT) $(FLAGS_COM) $(DEFINES) $(FLAGS_C)
S_FLAGS := $(FLAGS_CPU) $(FLAGS_OPT) $(FLAGS_COM) $(DEFINES) $(FLAGS_S)
LD_FLAGS := $(FLAGS_CPU) $(FLAGS_OPT) $(FLAGS_LSP) $(FLAGS_LD)
AR_FLAGS := rcs
#-------------------------------------------------------------------------------------------------------------------------------------------------
# Files & Folders
#-------------------------------------------------------------------------------------------------------------------------------------------------
SRC_SRC := src
LIB_SRC := $(LIBS_DIR)
CORE_SRC := $(CORE_BASE)
BIN := bin
SRC_BIN := $(BIN)/src
CORE_BIN := $(BIN)/core
LIB_BIN := $(BIN)/lib
CORE_LIB := $(BIN)/core.a
TARGET_HEX := $(BIN)/$(TARGET_NAME).hex
TARGET_ELF := $(BIN)/$(TARGET_NAME).elf
TARGET_LST := $(BIN)/$(TARGET_NAME).lst
#-------------------------------------------------------------------------------------------------------------------------------------------------
# Toolchains
#-------------------------------------------------------------------------------------------------------------------------------------------------
CC := arm-none-eabi-gcc
CXX := arm-none-eabi-g++
AR := arm-none-eabi-gcc-ar
OBJCOPY := arm-none-eabi-objcopy
SIZE := arm-none-eabi-size
OBJDUMP := arm-none-eabi-objdump
#-------------------------------------------------------------------------------------------------------------------------------------------------
# Source Files & Library Files
#-------------------------------------------------------------------------------------------------------------------------------------------------
rwildcard =$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
SRC_C_FILES := $(call rwildcard,$(SRC_SRC)/,*.c)
SRC_CPP_FILES := $(call rwildcard,$(SRC_SRC)/,*.cpp)
SRC_S_FILES := $(call rwildcard,$(SRC_SRC)/,*.S)
SRC_OBJ := $(SRC_S_FILES:$(SRC_SRC)/%.S=$(SRC_BIN)/%.o) $(SRC_C_FILES:$(SRC_SRC)/%.c=$(SRC_BIN)/%.o) $(SRC_CPP_FILES:$(SRC_SRC)/%.cpp=$(SRC_BIN)/%.o)
CORE_CPP_FILES := $(call rwildcard,$(CORE_SRC)/,*.cpp)
CORE_C_FILES := $(call rwildcard,$(CORE_SRC)/,*.c)
CORE_S_FILES := $(call rwildcard,$(CORE_SRC)/,*.S)
CORE_OBJ := $(CORE_S_FILES:$(CORE_SRC)/%.S=$(CORE_BIN)/%.o) $(CORE_C_FILES:$(CORE_SRC)/%.c=$(CORE_BIN)/%.o) $(CORE_CPP_FILES:$(CORE_SRC)/%.cpp=$(CORE_BIN)/%.o)
LIB_DIRS := $(foreach d, $(LIBS_NAMES), $(LIBS_DIR)/$d/ $(LIBS_DIR)/$d/utility/ ) # base and /utility
LIB_DIRS += $(foreach d, $(LIBS_NAMES), $(LIBS_DIR)/$d/src/ $(dir $(call rwildcard,$(LIBS_DIR)/$d/src/,*/.)))
LIB_CPP_LOCAL := $(foreach d, $(LIB_DIRS),$(call wildcard,$d/*.cpp))
LIB_C_LOCAL := $(foreach d, $(LIB_DIRS_),$(call wildcard,$d/*.c))
LIB_S_LOCAL := $(foreach d, $(LIB_DIRS),$(call wildcard,$d/*.S))
LIB_OBJ := $(LIB_CPP_LOCAL:$(LIBS_DIR)/%.cpp=$(LIB_BIN)/%.o)
LIB_OBJ += $(LIB_C_LOCAL:$(LIBS_DIR)/%.c=$(LIB_BIN)/%.o)
LIB_OBJ += $(LIB_S_LOCAL:$(LIBS_DIR)/%.S=$(LIB_BIN)/%.o)
#-------------------------------------------------------------------------------------------------------------------------------------------------
# Includes
#-------------------------------------------------------------------------------------------------------------------------------------------------
INCLUDE := -I./$(SRC_SRC) -I$(CORE_SRC) -Iinclude
INCLUDE += $(foreach d, $(LIB_DIRS), -I$d)
#-------------------------------------------------------------------------------------------------------------------------------------------------
# Creation of Directories
#-------------------------------------------------------------------------------------------------------------------------------------------------
DIRECTORIES := $(sort $(dir $(CORE_OBJ) $(SRC_OBJ) $(LIB_OBJ)))
generateDirs := $(foreach d, $(DIRECTORIES), $(shell if not exist "$d" mkdir "$d"))
#-------------------------------------------------------------------------------------------------------------------------------------------------
# Targets
#-------------------------------------------------------------------------------------------------------------------------------------------------
.PHONY: directories all rebuild clean cleanUser cleanCore
all: $(TARGET_LST) $(TARGET_HEX)
rebuild: cleanUser all
clean: cleanUser cleanCore cleanLib
@echo Cleaning done &&echo.
$(CORE_BIN)/%.o: $(CORE_SRC)/%.S
@echo CORE [ASM] $(notdir $<)
@"$(CC)" $(S_FLAGS) $(INCLUDE) -o $@ -c $<
$(CORE_BIN)/%.o: $(CORE_SRC)/%.c
@echo CORE [CC] $(notdir $<)
@"$(CC)" $(C_FLAGS) $(INCLUDE) -o $@ -c $<
$(CORE_BIN)/%.o: $(CORE_SRC)/%.cpp
@echo CORE [CPP] $(notdir $<)
@"$(CXX)" $(CPP_FLAGS) $(INCLUDE) -o $@ -c $<
$(CORE_LIB) : $(CORE_OBJ)
@echo CORE [AR] $@
@$(AR) $(AR_FLAGS) $@ $^
@echo Teensy core built successfully &&echo.
$(LIB_BIN)/%.o: $(LIBS_DIR)/%.S
@echo LIB [ASM] $(notdir $<)
@"$(CC)" $(S_FLAGS) $(INCLUDE) -o $@ -c $<
$(LIB_BIN)/%.o: $(LIBS_DIR)/%.cpp
@echo LIB [CPP] $(notdir $<)
@"$(CXX)" $(CPP_FLAGS) $(INCLUDE) -o $@ -c $<
$(LIB_BIN)/%.o: $(LIBS_DIR)/%.c
@echo LIB [CC] $(notdir $<)
@"$(CC)" $(C_FLAGS) $(INCLUDE) -o $@ -c $<
$(SRC_BIN)/%.o: $(SRC_SRC)/%.S
@echo SRC [ASM] $<
@"$(CC)" $(S_FLAGS) $(INCLUDE) -o $@ -c $<
$(SRC_BIN)/%.o: $(SRC_SRC)/%.c
@echo SRC [CC] $(notdir $<)
@"$(CC)" $(C_FLAGS) $(INCLUDE) -o "$@" -c $<
$(SRC_BIN)/%.o: $(SRC_SRC)/%.cpp
@echo SRC [CPP] $(notdir $<)
@"$(CXX)" $(CPP_FLAGS) $(INCLUDE) -o "$@" -c $<
$(TARGET_ELF): $(CORE_LIB) $(LIB_OBJ) $(SRC_OBJ)
@echo [LD] $@
@$(CC) $(LD_FLAGS) -o "$@" $(SRC_OBJ) $(LIB_OBJ) $(CORE_LIB) $(LIBS)
@echo Src code built and linked to libraries &&echo.
%.lst: %.elf
@echo [LST] $@
@$(OBJDUMP) -d -S --demangle --no-show-raw-insn --syms "$<" > "$@"
@echo Sucessfully built project &&echo.
%.hex: %.elf
@echo [HEX] $@
@$(OBJCOPY) -O ihex -R.eeprom "$<" "$@"
@echo Sucessfully build project HEX file&&echo.
#-------------------------------------------------------------------------------------------------------------------------------------------------
# Cleaning
#-------------------------------------------------------------------------------------------------------------------------------------------------
cleanUser:
@echo Cleaning user binaries...
@if exist $(SRC_BIN) rd /s/q "$(SRC_BIN)"
@if exist "$(TARGET_LST)" del $(subst /,\,$(TARGET_LST))
cleanCore:
@echo Cleaning core binaries...
@if exist $(CORE_BIN) rd /s/q "$(CORE_BIN)"
@if exist $(CORE_LIB) del $(subst /,\,$(CORE_LIB))
cleanLib:
@echo Cleaning user library binaries...
@if exist $(LIB_BIN) rd /s/q "$(LIB_BIN)"
-include $(CORE_OBJ:.o=.d)
-include $(SRC_OBJ:.o=.d)
-include $(LIB_OBJ:.o=.d)