-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
90 lines (78 loc) · 2.76 KB
/
Makefile
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
########################################################################
# Copyright (C) 2018
# Illini RoboMaster @ University of Illinois at Urbana-Champaign.
#
# This program is free software: you can redistribute it and/or 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
########################################################################
BUILD_DIR = build
TOOLCHAIN_FILE = STM32F427xx.cmake
DEBUG ?= 0
ifneq ($(DEBUG), 0)
DEBUG_FLAG = -DDEBUG=ON
FILE_NAME_DEBUG = _debug
endif
RUNTEST ?= 0
ifneq ($(RUNTEST), 0)
RUNTEST_FLAG = -DRUNTEST=ON
endif
USE_REMOTE ?= 0
ifneq ($(USE_REMOTE), 0)
USEREMOTE_FLAG = -DUSE_REMOTE=ON
endif
.PHONY: clean how remake cmake infantry1 infantry2 infantry3
# Rules to create all
all: infantry1 infantry2 infantry3 engineering hero
# Rules to create each robot and inject macros.
# Do not forget to add cooresponding macros to rm_config.h and CMakeLists.txt
infantry1: ROBOT = -DINFANTRY1=ON
infantry1: FILE_NAME = Infantry1
infantry1: cmake
infantry2: ROBOT = -DINFANTRY2=ON
infantry2: FILE_NAME = Infantry2
infantry2: cmake
infantry3: ROBOT = -DINFANTRY3=ON
infantry3: FILE_NAME = Infantry3
infantry3: cmake
engineering: ROBOT = -DENGINEERING=ON
engineering: FILE_NAME = Engineering
engineering: cmake
hero: ROBOT = -DHERO=ON
hero: FILE_NAME = hero
hero: cmake
# Rules to clean
clean:
rm -rf ${BUILD_DIR}
rm -f *.elf
rm -f *.bin
# Rules to display helper
how:
@echo "Available targets:"
@echo ""
@echo "all: Build All Robot Images"
@echo "infantry1: Build Infantry1.elf"
@echo "infantry2: Build Infantry2.elf"
@echo "infantry3: Build Infantry3.elf"
@echo "engineering: Build Engineering.elf"
@echo "hero: Build hero.elf"
@echo ""
@echo "Add \"DEBUG=1\" to inject DEBUG macro"
@echo "ADD \"RUNTEST=1\" to inject TEST macro"
@echo "ADD \"USE_REMOTE=1\" to inject USE_REMOTE marco"
# Rules to remake
remake: clean all
# Actual rule to make the targets
cmake:
mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} && cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} ${ROBOT} ${DEBUG_FLAG} ${RUNTEST_FLAG} ${USEREMOTE_FLAG} .. && make -j && mv iRM2018.elf ../${FILE_NAME}${FILE_NAME_DEBUG}.elf && mv iRM2018.bin ../${FILE_NAME}${FILE_NAME_DEBUG}.bin && cd ..
@echo ""
@echo "${FILE_NAME}${FILE_NAME_DEBUG}.elf created."