-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
501 lines (373 loc) · 12.7 KB
/
Makefile
File metadata and controls
501 lines (373 loc) · 12.7 KB
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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
#!/usr/bin/env make
#
# To develop for dbwebb.se, clone, pull & push all repos within a single
# directory structure, aided by this Makefile.
# One repo to rule them all.
# See organisation on GitHub: https://github.com/dbwebb-se
# ------------------------------------------------------------------------
#
# General stuff, reusable for all Makefiles.
#
# Detect OS
OS = $(shell uname -s)
# Defaults
ECHO = echo
# Make adjustments based on OS
# http://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux/27776822#27776822
ifneq (, $(findstring CYGWIN, $(OS)))
ECHO = /bin/echo -e
endif
# Colors and helptext
NO_COLOR = \033[0m
ACTION = \033[32;01m
OK_COLOR = \033[32;01m
ERROR_COLOR = \033[31;01m
WARN_COLOR = \033[33;01m
# Which makefile am I in?
WHERE-AM-I = $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
THIS_MAKEFILE := $(call WHERE-AM-I)
# Echo some nice helptext based on the target comment
HELPTEXT = $(ECHO) "$(ACTION)--->" `egrep "^\# target: $(1) " $(THIS_MAKEFILE) | sed "s/\# target: $(1)[ ]*-[ ]* / /g"` "$(NO_COLOR)"
# Check version and path to command and display on one line
CHECK_VERSION = printf "%-15s %-10s %s\n" "`basename $(1)`" "`$(1) --version $(2)`" "`which $(1)`"
# Print out colored action message
ACTION_MESSAGE = $(ECHO) "$(ACTION)---> $(1)$(NO_COLOR)"
# target: help - Displays help.
.PHONY: help
help:
@$(call HELPTEXT,$@)
@sed '/^$$/q' $(THIS_MAKEFILE) | tail +3 | sed 's/#\s*//g'
@$(ECHO) "Usage:"
@$(ECHO) " make [target] ..."
@$(ECHO) "target:"
@egrep "^# target:" $(THIS_MAKEFILE) | sed 's/# target: / /g'
# ------------------------------------------------------------------------
#
# Specifics for this project.
#
BIN := .bin
NODEMODBIN := node_modules/.bin
ORG := [email protected]:dbwebb-se
REPOS := website website-11ty dbwebb-cli lab slides tomato docker ctf ctf-website inspect-gui # sstatic
COURSES := python htmlphp js-v2 javascript1 design linux oopython databas databas-v2 dbjs linux oophp ramverk1 ramverk2 exjobb matmod databas webgl webapp itsec vlinux design-v3 webtec mvc pattern owasp courserepo-v2 webtec2
WEB_ORG := [email protected]:Webbprogrammering
WEB := websoft websoft.wiki
GITLABMOS_ORG := [email protected]:mosbth
GITLABMOS := pedagogic-portfolio
# # target: prepare - Prepare for tests and build
# .PHONY: prepare
# prepare:
# @$(call HELPTEXT,$@)
# [ -d .bin ] || mkdir .bin
# [ -d build ] || mkdir build
# rm -rf build/*
#
#
#
# target: clone - Clone all repos
.PHONY: clone
clone: clone-repos clone-courses clone-web clone-gitlabmos clone-2025
@$(call HELPTEXT,$@)
# target: pull - Pull latest from all repos
.PHONY: pull
pull: pull-repos pull-courses pull-web pull-gitlabmos pull-2025
@$(call HELPTEXT,$@)
git pull
# target: status - Check status on all repos
.PHONY: status
status: status-repos status-courses status-web status-gitlabmos
@$(call HELPTEXT,$@)
git status
# # target: install - Install all repos
# .PHONY: install
# install:
# @$(call HELPTEXT,$@)
#
#
#
# target: update - Update the repos and essentials.
.PHONY: update
update:
@$(call HELPTEXT,$@)
git pull
$(MAKE) pull
# [ ! -f composer.json ] || composer update
# [ ! -f package.json ] || npm update
# target: clean - Removes generated files and directories.
.PHONY: clean
clean:
@$(call HELPTEXT,$@)
# target: clean-cache - Clean the cache.
.PHONY: clean-cache
clean-cache:
@$(call HELPTEXT,$@)
# target: clean-all - Removes generated files and directories.
.PHONY: clean-all
clean-all: clean clean-cache clean-repos clean-courses clean-web clean-gitlabmos
@$(call HELPTEXT,$@)
#rm -rf .bin vendor node_modules
# ------------------------------------------------------------------------
#
# Top level repos
#
# target: clone-web - Clone all general web.
.PHONY: clone-web
clone-web:
@$(call HELPTEXT,$@)
@cd web; \
for repo in $(WEB) ; do \
$(call ACTION_MESSAGE,$$repo); \
[ -d $$repo ] \
&& $(ECHO) "Repo already there, skipping cloning it." \
&& continue; \
git clone $(WEB_ORG)/$$repo.git; \
done
# target: pull-web - Pull latest for all general web.
.PHONY: pull-web
pull-web:
@$(call HELPTEXT,$@)
@cd web; \
for repo in $(WEB) ; do \
$(call ACTION_MESSAGE,$$repo); \
(cd $$repo && git pull); \
done
# target: clean-web - Remove all top general web.
.PHONY: clean-web
clean-web:
@$(call HELPTEXT,$@)
cd web && rm -rf $(WEB)
# target: status-web - Check status of each general web repo.
.PHONY: status-web
status-web:
@$(call HELPTEXT,$@)
@cd web; \
for repo in $(WEB) ; do \
$(call ACTION_MESSAGE,$$repo); \
(cd $$repo && git status); \
done
# target: check-web - Check details of each general repo.
.PHONY: check-web
check-web:
@$(call HELPTEXT,$@)
@cd web; \
for repo in $(WEB) ; do \
$(call ACTION_MESSAGE,$$repo); \
du -sk $$repo/.git; \
done
# ------------------------------------------------------------------------
#
# Top level repos
#
# target: clone-gitlabmos - Clone all general web.
.PHONY: clone-gitlabmos
clone-gitlabmos:
@$(call HELPTEXT,$@)
@cd gitlabmos; \
for repo in $(GITLABMOS) ; do \
$(call ACTION_MESSAGE,$$repo); \
[ -d $$repo ] \
&& $(ECHO) "Repo already there, skipping cloning it." \
&& continue; \
git clone $(GITLABMOS_ORG)/$$repo.git; \
done
# target: pull-gitlabmos - Pull latest for all general web.
.PHONY: pull-gitlabmos
pull-gitlabmos:
@$(call HELPTEXT,$@)
@cd gitlabmos; \
for repo in $(GITLABMOS) ; do \
$(call ACTION_MESSAGE,$$repo); \
(cd $$repo && git pull); \
done
# target: clean-gitlabmos - Remove all top general web.
.PHONY: clean-gitlabmos
clean-gitlabmos:
@$(call HELPTEXT,$@)
cd gitlabmos && rm -rf $(GITLABMOS)
# target: status-gitlabmos - Check status of each general web repo.
.PHONY: status-gitlabmos
status-gitlabmos:
@$(call HELPTEXT,$@)
@cd gitlabmos; \
for repo in $(GITLABMOS) ; do \
$(call ACTION_MESSAGE,$$repo); \
(cd $$repo && git status); \
done
# target: check-gitlabmos - Check details of each general repo.
.PHONY: check-gitlabmos
check-gitlabmos:
@$(call HELPTEXT,$@)
@cd gitlabmos; \
for repo in $(GITLABMOS) ; do \
$(call ACTION_MESSAGE,$$repo); \
du -sk $$repo/.git; \
done
# ------------------------------------------------------------------------
#
# Top level repos
#
# target: clone-repos - Clone all general repos.
.PHONY: clone-repos
clone-repos:
@$(call HELPTEXT,$@)
@cd repos; \
for repo in $(REPOS) ; do \
$(call ACTION_MESSAGE,$$repo); \
[ -d $$repo ] \
&& $(ECHO) "Repo already there, skipping cloning it." \
&& continue; \
git clone $(ORG)/$$repo.git; \
done
# target: pull-repos - Pull latest for all general repos.
.PHONY: pull-repos
pull-repos:
@$(call HELPTEXT,$@)
@cd repos; \
for repo in $(REPOS) ; do \
$(call ACTION_MESSAGE,$$repo); \
(cd $$repo && git pull); \
done
# target: clean-repos - Remove all top general repos.
.PHONY: clean-repos
clean-repos:
@$(call HELPTEXT,$@)
cd repos && rm -rf $(REPOS)
# target: status-repos - Check status of each general repo.
.PHONY: status-repos
status-repos:
@$(call HELPTEXT,$@)
@cd repos; \
for repo in $(REPOS) ; do \
$(call ACTION_MESSAGE,$$repo); \
(cd $$repo && git status); \
done
# target: check-repos - Check details of each general repo.
.PHONY: check-repos
check-repos:
@$(call HELPTEXT,$@)
@cd repos; \
for repo in $(REPOS) ; do \
$(call ACTION_MESSAGE,$$repo); \
du -sk $$repo/.git; \
done
# ------------------------------------------------------------------------
#
# Courses
#
# target: clone-courses - Clone all courses.
.PHONY: clone-courses
clone-courses:
@$(call HELPTEXT,$@)
@cd kurser; \
for repo in $(COURSES) ; do \
$(call ACTION_MESSAGE,$$repo); \
[ -d $$repo ] \
&& $(ECHO) "Repo already there, skipping cloning it." \
&& continue; \
git clone $(ORG)/$$repo.git; \
done
# target: pull-courses - Pull latest for all courses.
.PHONY: pull-courses
pull-courses:
@$(call HELPTEXT,$@)
@cd kurser; \
for repo in $(COURSES) ; do \
$(call ACTION_MESSAGE,$$repo); \
(cd $$repo && git pull); \
done
# target: clean-courses - Remove all known courses.
.PHONY: clean-courses
clean-courses:
@$(call HELPTEXT,$@)
cd kurser && rm -rf $(COURSES)
# target: status-courses - Check status of each course repo.
.PHONY: status-courses
status-courses:
@$(call HELPTEXT,$@)
@cd kurser; \
for repo in $(COURSES) ; do \
$(call ACTION_MESSAGE,$$repo); \
(cd $$repo && git status); \
done
# target: check-courses - Check details of each course repo.
.PHONY: check-courses
check-courses:
@$(call HELPTEXT,$@)
@cd kurser; \
for repo in $(COURSES) ; do \
$(call ACTION_MESSAGE,$$repo); \
du -sk $$repo/.git; \
done
# ------------------------------------------------------------------------
#
# 2025
#
#20205_BASE := [email protected]
#2025 :=
# target: clone-2025 - Clone all 2025 repos
.PHONY: clone-2025
clone-2025:
@$(call HELPTEXT,$@)
# Kursen databas organisation
@dir="2025/databas/owner"; \
repo="[email protected]:bth-databas/owner.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
@dir="2025/databas/website"; \
repo="[email protected]:bth-databas/website.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
@dir="2025/databas/forum"; \
repo="[email protected]:bth-databas/forum.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
@dir="2025/databas/template-student"; \
repo="[email protected]:bth-databas/template-student.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
@dir="2025/databas/databas-mosstud"; \
repo="[email protected]:bth-databas/databas-mosstud.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
# Kursen webtec organisation
@dir="2025/webtec/owner"; \
repo="[email protected]:bth-webtec/owner.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
@dir="2025/webtec/student"; \
repo="[email protected]:bth-webtec/student.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
@dir="2025/webtec/teacher"; \
repo="[email protected]:bth-webtec/teacher.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
@dir="2025/webtec/website"; \
repo="[email protected]:bth-webtec/website.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
@dir="2025/webtec/dbwebb-webtec"; \
repo="[email protected]:bth-webtec/dbwebb-webtec.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
# webtec mosstud
@dir="2025/webtec/mosstud/webtec-mosstud/"; \
repo="[email protected]:bth-webtec/webtec-mosstud.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
@dir="2025/webtec/mosstud/webtec-abcd25/"; \
repo="[email protected]:bth-webtec/webtec-abcd25.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
# Demo organisation
@dir="2025/webtec/teacher_"; \
repo="[email protected]:webtec-2024/teacher.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
@dir="2025/webtec/student_"; \
repo="[email protected]:webtec-2024/student.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
# New dbwebb.se website
@dir="2025/repo/website"; \
repo="[email protected]:dbwebb-se/dbwebb.bth.se.git"; \
[ -d $$dir ] || git clone $$repo $$dir;
# target: pull-2025 - Pull latest from all2025 repos
.PHONY: pull-2025
pull-2025:
@$(call HELPTEXT,$@)
@cd 2025; \
for repo in `ls` ; do \
$(call ACTION_MESSAGE,$$repo); \
cd $$repo; git pull; cd ..; \
done
for repo in `ls *` ; do \
$(call ACTION_MESSAGE,$$repo); \
cd $$repo; git pull; cd ..; \
done