-
Notifications
You must be signed in to change notification settings - Fork 35
/
Makefile
262 lines (215 loc) · 5.33 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
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#
# Race Capture Firmware
#
# Copyright (C) 2016 Autosport Labs
#
# This file is part of the Race Capture firmware suite
#
# This 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 software 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 code. If not, see <http://www.gnu.org/licenses/>.
#
export MAJOR := $(shell git describe | cut -d \- -f 1 | cut -d . -f 1)
export MINOR := $(shell git describe | cut -d \- -f 1 | cut -d . -f 2)
export BUGFIX := $(shell git describe | cut -d \- -f 1 | cut -d . -f 3)
export API := 1.1
export VERSION := $(shell git describe --dirty --always)
#
# Gets the sha-1 hash (hex encoded string) of our build)
#
export GIT_DESCRIPTION := "\"$(VERSION)\""
#
# Build types:
#
# * RELEASE_TYPE_DEVEL - (Default) Build from a dev machine.
# * RELEASE_TYPE_OFFICIAL - Official build from our build server.
# Implies a tag is associated with this
# release.
# * RELEASE_TYPE_BETA - A beta release. One designed for user
# testing, but has no official support.
#
RELEASE_TYPE ?= RELEASE_TYPE_DEVEL
OFFICIAL_TAG := $(if $(shell ./bin/get_official_tag.sh), yes)
ifeq ($(RELEASE),BETA)
RELEASE_TYPE := RELEASE_TYPE_BETA
endif
ifneq ($(OFFICIAL_TAG),)
RELEASE_TYPE := RELEASE_TYPE_OFFICIAL
endif
export RELEASE_TYPE
# Now with basic version info, import all our sub makefiles
include make/*.mk
Q := @
PHONY :=
# Default target is all.
all: package
#
# Testing bits.
#
TEST_DIR := test
PHONY += test-run
test-run: test-build
$(MAKE) -C $(TEST_DIR) test-run
PHONY += test-build
test-build:
$(MAKE) -C $(TEST_DIR) all
PHONY += test-clean
test-clean:
$(MAKE) -C $(TEST_DIR) clean
PHONY += test-pristine
test-pristine: test-clean
$(MAKE) test-run
PHONY += test
test: test-run
#
# Lua Bits
#
LUA_DIR := lib/lua
PHONY += lua-build
lua-build:
$(MAKE) -C $(LUA_DIR) PLAT=stm32 generic
PHONY += lua-clean
lua-clean:
$(MAKE) -C $(LUA_DIR) PLAT=stm32 clean
PHONY += lua-pristine
lua-pristine: lua-clean
$(MAKE) lua-build
#
# MK2
#
MK2_DIR := platform/mk2
PHONY += mk2-build
mk2-build: lua-build
$(MAKE) -C $(MK2_DIR) all
PHONY += mk2-clean
mk2-clean:
$(MAKE) -C $(MK2_DIR) clean
PHONY += mk2-pristine
mk2-pristine: lua-pristine mk2-clean
$(MAKE) mk2-build
PHONY += mk2-package
mk2-package: mk2-pristine
./bin/package_release.sh "RaceCapturePro_MK2" $(VERSION) $(MK2_DIR)
PHONY += mk2-flash
mk2-flash: mk2-build
cd $(MK2_DIR) && openocd -f openocd_stlinkv2_flash.cfg
PHONY += mk2
mk2: mk2-build
#
# MK3
#
MK3_DIR := platform/mk3
PHONY += mk3-build
mk3-build: lua-build
$(MAKE) -C $(MK3_DIR) all
PHONY += mk3-clean
mk3-clean:
$(MAKE) -C $(MK3_DIR) clean
PHONY += mk3-pristine
mk3-pristine: lua-pristine mk3-clean
$(MAKE) mk3-build
PHONY += mk3-package
mk3-package: mk3-pristine
./bin/package_release.sh "RaceCapturePro_MK3" $(VERSION) $(MK3_DIR)
PHONY += mk3-flash
mk3-flash: mk3-build
cd $(MK3_DIR) && openocd -f openocd_stlinkv2_flash.cfg
PHONY += mk3
mk3: mk3-build
#
# RCT
#
RCT_DIR := platform/rct
PHONY += rct-build
rct-build:
$(MAKE) -C $(RCT_DIR) all
PHONY += rct-clean
rct-clean:
$(MAKE) -C $(RCT_DIR) clean
PHONY += rct-flash
rct-flash: rct-build
cd $(RCT_DIR) && openocd -f openocd_flash.cfg
PHONY += rct-pristine
rct-pristine: rct-clean
$(MAKE) rct-build
PHONY += rct-package
rct-package: rct-pristine
./bin/package_release.sh "RaceCapture_Track" $(VERSION) $(RCT_DIR)
PHONY += rct
rct: rct-build
#
# RCT_MK2
#
RCT_MK2_DIR := platform/rct_mk2
PHONY += rct_mk2-build
rct_mk2-build: lua-build
$(MAKE) -C $(RCT_MK2_DIR) all
PHONY += rct_mk2-clean
rct_mk2-clean:
$(MAKE) -C $(RCT_MK2_DIR) clean
PHONY += rct_mk2-pristine
rct_mk2-pristine: lua-pristine rct_mk2-clean
$(MAKE) rct_mk2-build
PHONY += rct_mk2-package
rct_mk2-package: rct_mk2-pristine
./bin/package_release.sh "RaceCaptureTrack_MK2" $(VERSION) $(RCT_MK2_DIR)
PHONY += rct_mk2-flash
rct_mk2-flash: rct_mk2-build
cd $(RCT_MK2_DIR) && openocd -f openocd_stlinkv2_flash.cfg
PHONY += rct_mk2
rct_mk2: rct_mk2-build
#
# Common targets.
#
PHONY += clean
clean: rct-clean mk2-clean mk3-clean test-clean lua-clean
$(Q)find . -type f \
-name "*.a" -o \
-name "*.bin" -o \
-name "*.d" -o \
-name "*.dis" -o \
-name "*.elf" -o \
-name "*.hex" -o \
-name "*.ihex" -o \
-name "*.lst" -o \
-name "*.map" -o \
-name "*.o" -o \
-name "*.sym" -o \
-name "*.zip" \
| xargs rm -f
package: clean
$(MAKE) test-pristine
$(MAKE) mk2-package
$(MAKE) mk3-package
$(MAKE) rct-package
$(MAKE) rct_mk2-package
$(MAKE) hashes
PHONY += TAGS
TAGS:
$(Q)find \
include \
platform \
src \
test \
-type f \
-name "*.c" -o \
-name "*.cpp" -o \
-name "*.h" -o \
-name "*.hh" \
| etags -
PHONY += hashes
hashes:
$(Q)echo
$(Q)echo "SHA256 Hashes for all main.* files: "
$(Q)sha256sum -b $(sort $(wildcard platform/*/main.*)) </dev/null
$(Q)echo
.PHONY: $(PHONY)