forked from NUbots/robocup
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
422 lines (369 loc) · 11.7 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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# Welcome to the Makefile for the NUbot Code
#
# Copyright (c) 2009 Jason Kulk
# This file 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 file 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.
#
# Targets: NAO, NAOWebots, Cycloid, Bear, NUView
CUR_DIR = $(shell pwd)
# Make directories
MAKE_DIR = $(CUR_DIR)/Make
# Build directories
NAO_BUILD_DIR = Build/NAO
NAOWEBOTS_BUILD_DIR = Build/NAOWebots
CYCLOID_BUILD_DIR = Build/Cycloid
BEAR_BUILD_DIR = Build/Bear
NUVIEW_BUILD_DIR = Build/NUView
# Aldebaran build tools
ALD_CTC = $(AL_DIR)/crosstoolchain/toolchain-geode.cmake
# Source directory on external machine
SOURCE_EXT_DIR = naoqi/projects/robocup
BEAR_EXT_DIR = projects/robocup
.PHONY: default_target all
.PHONY: NAO NAOConfig NAOConfigInstall NAOClean NAOVeryClean
.PHONY: NAOExternal
.PHONY: NAOWebots NAOWebotsConfig NAOWebotsClean NAOWebotsVeryClean
.PHONY: Cycloid CycloidConfig CycloidConfigInstall CycloidClean CycloidVeryClean
.PHONY: Bear BearConfig BearConfigInstall BearClean BearVeryClean
.PHONY: BearExternal
.PHONY: NUView NUViewConfig NUViewClean NUViewVeryClean
.PHONY: clean veryclean
# We export an environment variable TARGET_ROBOT which tells everything
# which robot we want this build to run on.
TARGET_ROBOT = NAOWEBOTS # by default the target is Webots
NAOWebots: TARGET_ROBOT=NAOWEBOTS
NAOWebotsConfig: TARGET_ROBOT=NAOWEBOTS
NAO: TARGET_ROBOT=NAO
NAOConfig: TARGET_ROBOT=NAO
Bear: TARGET_ROBOT=BEAR
BearConfig: TARGET_ROBOT=BEAR
Cycloid: TARGET_ROBOT=CYCLOID
CycloidConfig: TARGET_ROBOT=CYCLOID
NUView: TARGET_ROBOT=NUVIEW
NUViewConfig: TARGET_ROBOT=NUVIEW
export TARGET_ROBOT
# I need to determine which platform this makefile is run on
SYSTEM = $(strip $(shell uname -s))
# If I choose to use an external machine to do the compiling; these are the username and ip address used
ifeq ($(strip $(user)), )
ifneq ($(strip $(vm)), )
LOGNAME = $(strip $(shell logname))
endif
else
LOGNAME = $(strip $(user))
endif
VM_IP = $(strip $(vm))
# so we can log into the external machine with $(LOGNAME)@$(VM_IP)
# If I choose to install it on a particular robot this is the ip used
ROBOT_IP = $(strip $(robot))
# on windows we need to use a different cmake tool to config
ifeq ($(SYSTEM), windows32)
CCMAKE = cmake-gui
else
CCMAKE = ccmake
endif
# to take advantage of multicore computers
ifeq ($(SYSTEM), Linux)
NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
endif
ifeq ($(SYSTEM), Darwin)
NPROCS := $(shell system_profiler SPHardwareDataType | awk '/Total Number/{print $$5*1.5}')
endif
MAKE_OPTIONS = --no-print-directory -j $(NPROCS) --quiet
default_target: NAOWebots
all: NAO NAOWebots Cycloid Bear NUView
################ NAO ################
NAO:
ifeq ($(VM_IP), ) ## if we have not given a virtual machine IP then use this machine to compile
ifeq ($(SYSTEM),Linux) ## can only cross-compile on linux
@echo "Cross-compiling for NAO"
ifeq ($(findstring Makefile, $(wildcard $(CUR_DIR)/$(NAO_BUILD_DIR)/*)), ) ## check if the project has already been configured
@set -e; \
echo "Configuring for first use"; \
mkdir -p $(NAO_BUILD_DIR); \
cd $(NAO_BUILD_DIR); \
cmake -DCMAKE_TOOLCHAIN_FILE=$(ALD_CTC) $(MAKE_DIR); \
ccmake .; \
make $(MAKE_OPTIONS);
else
@set -e; \
cd $(NAO_BUILD_DIR); \
make $(MAKE_OPTIONS);
endif
@echo $(ROBOT_IP)
ifneq ($(ROBOT_IP),)
@./Make/scripts/naoSendLib $(ROBOT_IP);
endif
else
@echo "Cannot cross-compile on this machine"
endif
else
@make NAOExternal
endif
NAOExternal:
@echo "Send source to external machine $(LOGNAME)@$(VM_IP)";
#log into VM_IP and make the project dir
@ssh $(LOGNAME)@$(VM_IP) mkdir -p naoqi/projects/robocup;
#copy everything in this directory except the existing .*, Build, Documentation directories
@scp -prC $(filter-out Build Documentation Autoconfig NUview, $(wildcard *)) $(LOGNAME)@$(VM_IP):$(SOURCE_EXT_DIR);
#run make inside the vm
@ssh -t $(LOGNAME)@$(VM_IP) "cd $(SOURCE_EXT_DIR); make NAO robot=$(ROBOT_IP);"
#copy the binary back
@mkdir -p ./$(NAO_BUILD_DIR)
@scp -prC $(LOGNAME)@$(VM_IP):$(SOURCE_EXT_DIR)/$(NAO_BUILD_DIR)/sdk/lib/naoqi/libnubot.so ./$(NAO_BUILD_DIR)/libnubot.so
NAOConfig:
ifeq ($(VM_IP), )
ifeq ($(SYSTEM),Linux)
@set -e; \
cd $(NAO_BUILD_DIR); \
ccmake .;
endif
else
@ssh -t $(LOGNAME)@$(VM_IP) "cd $(SOURCE_EXT_DIR); make NAOConfig;"
endif
NAOConfigInstall:
@./Make/scripts/naoSendConfig $(ROBOT_IP);
NAOClean:
ifeq ($(VM_IP), )
ifeq ($(SYSTEM),Linux)
@set -e; \
echo "Cleaning NAO Build"; \
cd $(NAO_BUILD_DIR); \
make $(MAKE_OPTIONS) clean;
endif
else
@ssh $(LOGNAME)@$(VM_IP) "cd $(SOURCE_EXT_DIR); make NAOClean;"
endif
NAOVeryClean:
ifeq ($(VM_IP), )
ifeq ($(SYSTEM),Linux)
@set -e; \
echo "Hosing NAO Build"; \
rm -rf $(NAO_BUILD_DIR)/*; \
rm -rf Autoconfig/*;
endif
else
@ssh $(LOGNAME)@$(VM_IP) "cd $(SOURCE_EXT_DIR); make NAOVeryClean;"
endif
################ NAOWebots ################
NAOWebots:
@echo "Targetting NAOWebots";
@echo "Number of Processes: ${NPROCS}"
ifeq ($(findstring Makefile, $(wildcard $(CUR_DIR)/$(NAOWEBOTS_BUILD_DIR)/*)), ) ## check if the project has already been configured
@set -e; \
echo "Configuring for first use"; \
mkdir -p $(NAOWEBOTS_BUILD_DIR); \
cd $(NAOWEBOTS_BUILD_DIR); \
cmake $(MAKE_DIR); \
$(CCMAKE) .; \
make $(MAKE_OPTIONS);
else
@set -e; \
cd $(NAOWEBOTS_BUILD_DIR); \
make $(MAKE_OPTIONS);
endif
NAOWebotsConfig:
ifeq ($(SYSTEM),Darwin)
@set -e; \
mkdir -p $(NAOWEBOTS_BUILD_DIR)/Xcode; \
cd $(NAOWEBOTS_BUILD_DIR)/Xcode; \
cmake -G Xcode $(MAKE_DIR);
endif
@set -e; \
cd $(NAOWEBOTS_BUILD_DIR); \
cmake $(MAKE_DIR); \
$(CCMAKE) .;
NAOWebotsClean:
@echo "Cleaning NAOWebots Build";
@set -e; \
cd $(NAOWEBOTS_BUILD_DIR); \
make $(MAKE_OPTIONS) clean;
NAOWebotsVeryClean:
@echo "Hosing NAOWebots Build";
@set -e; \
rm -rf $(NAOWEBOTS_BUILD_DIR)/*; \
rm -rf Autoconfig/*;
################ Cycloid ################
Cycloid:
ifeq ($(VM_IP), ) ## if we have not given a virtual machine IP then use this machine to compile
ifeq ($(SYSTEM),Linux) ## can only compile on linux
@echo "Compiling for Cycloid"
ifeq ($(findstring Makefile, $(wildcard $(CUR_DIR)/$(CYCLOID_BUILD_DIR)/*)), ) ## check if the project has already been configured
@set -e; \
echo "Configuring for first use"; \
mkdir -p $(CYCLOID_BUILD_DIR); \
cd $(CYCLOID_BUILD_DIR); \
cmake $(MAKE_DIR); \
ccmake .; \
make $(MAKE_OPTIONS);
else
@set -e; \
cd $(CYCLOID_BUILD_DIR); \
make $(MAKE_OPTIONS);
endif
@echo $(ROBOT_IP)
ifneq ($(ROBOT_IP),)
@./Make/scripts/cycloidSendLib $(ROBOT_IP);
endif
else
@echo "Cannot compile on this operating system"
endif
else
@make CycloidExternal
endif
CycloidExternal:
@echo "Send source to external machine $(LOGNAME)@$(VM_IP)";
#log into VM_IP and make the project dir
@ssh $(LOGNAME)@$(VM_IP) mkdir -p $(BEAR_EXT_DIR);
#copy everything in this directory except the existing .*, Build, Documentation directories
@scp -prC $(filter-out Build Documentation Autoconfig NUview, $(wildcard *)) $(LOGNAME)@$(VM_IP):$(BEAR_EXT_DIR);
#run make inside the vm
@ssh -t $(LOGNAME)@$(VM_IP) "cd $(BEAR_EXT_DIR); make Cycloid robot=$(ROBOT_IP);"
#copy the binary back
@mkdir -p ./$(CYCLOID_BUILD_DIR)
@scp -prC $(LOGNAME)@$(VM_IP):$(BEAR_EXT_DIR)/$(CYCLOID_BUILD_DIR)/nubot ./$(CYCLOID_BUILD_DIR)/nubot
CycloidConfig:
ifeq ($(VM_IP), )
ifeq ($(SYSTEM),Linux)
@set -e; \
cd $(CYCLOID_BUILD_DIR); \
ccmake .;
endif
else
@ssh -t $(LOGNAME)@$(VM_IP) "cd $(BEAR_EXT_DIR); make CycloidConfig;"
endif
CycloidConfigInstall:
@./Make/scripts/cycloidSendConfig $(ROBOT_IP);
CycloidClean:
ifeq ($(VM_IP), )
ifeq ($(SYSTEM),Linux)
@set -e; \
echo "Cleaning Cyclioid Build"; \
cd $(CYCLOID_BUILD_DIR); \
make $(MAKE_OPTIONS) clean;
endif
else
@ssh $(LOGNAME)@$(VM_IP) "cd $(BEAR_EXT_DIR); make CycloidClean;"
endif
CycloidVeryClean:
ifeq ($(VM_IP), )
ifeq ($(SYSTEM),Linux)
@set -e; \
echo "Hosing Cycloid Build"; \
rm -rf $(CYCLOID_BUILD_DIR)/*; \
rm -rf Autoconfig/*;
endif
else
@ssh $(LOGNAME)@$(VM_IP) "cd $(BEAR_EXT_DIR); make CycloidVeryClean;"
endif
################ Bear ################
Bear:
ifeq ($(VM_IP), ) ## if we have not given a virtual machine IP then use this machine to compile
ifeq ($(SYSTEM),Linux) ## can only compile on linux
@echo "Compiling for Bear"
ifeq ($(findstring Makefile, $(wildcard $(CUR_DIR)/$(BEAR_BUILD_DIR)/*)), ) ## check if the project has already been configured
@set -e; \
echo "Configuring for first use"; \
mkdir -p $(BEAR_BUILD_DIR); \
cd $(BEAR_BUILD_DIR); \
cmake $(MAKE_DIR); \
ccmake .; \
make $(MAKE_OPTIONS);
else
@set -e; \
cd $(BEAR_BUILD_DIR); \
make $(MAKE_OPTIONS);
endif
@echo $(ROBOT_IP)
ifneq ($(ROBOT_IP),)
@./Make/scripts/bearSendLib $(ROBOT_IP);
endif
else
@echo "Cannot compile on this operating system"
endif
else
@make BearExternal
endif
BearExternal:
@echo "Send source to external machine $(LOGNAME)@$(VM_IP)";
#log into VM_IP and make the project dir
@ssh $(LOGNAME)@$(VM_IP) mkdir -p $(BEAR_EXT_DIR);
#copy everything in this directory except the existing .*, Build, Documentation directories
@scp -prC $(filter-out Build Documentation Autoconfig NUview, $(wildcard *)) $(LOGNAME)@$(VM_IP):$(BEAR_EXT_DIR);
#run make inside the vm
@ssh -t $(LOGNAME)@$(VM_IP) "cd $(BEAR_EXT_DIR); make Bear robot=$(ROBOT_IP);"
#copy the binary back
@mkdir -p ./$(BEAR_BUILD_DIR)
@scp -prC $(LOGNAME)@$(VM_IP):$(BEAR_EXT_DIR)/$(BEAR_BUILD_DIR)/nubot ./$(BEAR_BUILD_DIR)/nubot
BearConfig:
ifeq ($(VM_IP), )
ifeq ($(SYSTEM),Linux)
@set -e; \
cd $(BEAR_BUILD_DIR); \
ccmake .;
endif
else
@ssh -t $(LOGNAME)@$(VM_IP) "cd $(BEAR_EXT_DIR); make BearConfig;"
endif
BearConfigInstall:
@./Make/scripts/bearSendConfig $(ROBOT_IP);
BearClean:
ifeq ($(VM_IP), )
ifeq ($(SYSTEM),Linux)
@set -e; \
echo "Cleaning Bear Build"; \
cd $(BEAR_BUILD_DIR); \
make $(MAKE_OPTIONS) clean;
endif
else
@ssh $(LOGNAME)@$(VM_IP) "cd $(BEAR_EXT_DIR); make BearClean;"
endif
BearVeryClean:
ifeq ($(VM_IP), )
ifeq ($(SYSTEM),Linux)
@set -e; \
echo "Hosing Bear Build"; \
rm -rf $(BEAR_BUILD_DIR)/*; \
rm -rf Autoconfig/*;
endif
else
@ssh $(LOGNAME)@$(VM_IP) "cd $(BEAR_EXT_DIR); make BearVeryClean;"
endif
################ NUView ################
NUView:
@echo "Building NUView"
# now qmake and then make the NUview project
@set -e; \
cd $(CUR_DIR)/NUview; \
qmake -spec macx-g++; \
make all $(MAKE_OPTIONS); \
echo "Completed"; \
NUViewConfig:
@echo "Configuring NUView Build"
NUViewClean:
@echo "Cleaning NUView Build"
@set -e; \
cd $(CUR_DIR)/NUview; \
make clean; \
rm -rf NUview.app; \
NUViewVeryClean:
@echo "Hosing NUView Build"
@set -e; \
cd $(CUR_DIR)/NUview; \
make clean; \
rm -rf NUview.app; \
rm -f Makefile; \
########################################
clean: NAOClean NAOWebotsClean CycloidClean NUViewClean
veryclean: NAOVeryClean NAOWebotsVeryClean CycloidVeryClean NUViewVeryClean
# Helpful tips:
# 1. Makefile uses actual tabs as separators, so you'll get a missing separator
# with editors that use spaces instead
# 2. Make sure there is no white space after the \