-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
114 lines (91 loc) · 3.63 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
#!/usr/bin/make
ifneq (,$(findstring "--quiet",$(MAKEFLAGS)))
HUSH ?= @
endif
## @todo if CentOS vs Ubuntu, etc:
SUBDIRS_WITH_MAKEFILE_RAW = $(wildcard */Makefile)
SUBDIRS = $(dir $(SUBDIRS_WITH_MAKEFILE_RAW))
IAM = $(notdir ${CURDIR})
TSTAMP := $(shell date +%y%m%d.%H%M)
HUMAN_FRIENDLY = prereq prerequisites requires
TARGETS = all clean clean-state show up down unprovision provision savelogs
REQUIRES_D = requires
PREREQ_SW_D = $(REQUIRES_D)/sw
PREREQ_INGEST_D = $(REQUIRES_D)/ingest
PREREQ_STORAGE_D = $(REQUIRES_D)/storage
PREREQ_SW = $(wildcard $(PREREQ_SW_D)/*)
PREREQ_INGEST = $(wildcard $(PREREQ_INGEST_D)/*)
PREREQ_STORAGE = $(wildcard $(PREREQ_STORAGE_D)/*)
PREREQ_LIST = $(notdir $(PREREQ_SW))
PREREQ = $(PREREQ_LIST)
PREREQ_VAGRANTFILES = clusters/vc/Vagrantfile clusters/vx/Vagrantfile
PREREQ_ERROR_EXIT = 99
TAR_ADDITIONAL_FILES = Makefile README INSTALL.tarball requires bin
TAR_ARGS = --ignore-failed-read --one-file-system --checkpoint-action=dot --checkpoint=16384 -czf
TAR_EXCLUDE = --exclude=\*repos.tgz\* --exclude=\*.iso --exclude=tarballs
TAR_D = tarballs
TAR_PKG = $(IAM).$(TSTAMP).tgz
TAR_GET = $(TAR_D)/$(TAR_PKG)
TAR_CKSUM = $(IAM).$(TSTAMP).cksum
TAR_GET_CKSUM = $(TAR_D)/$(TAR_CKSUM)
.DELETE_ON_ERROR = $(TAR_GET) $(TAR_D)/$(IAM).$(TSTAMP).cksum
.PHONY: $(PREREQ) $(SUBDIRS) $(HUMAN_FRIENDLY) $(TARGETS)
$(TARGETS): $(PREREQ) $(SUBDIRS)
all: $(HUMAN_FRIENDLY) $(TARGETS) $(SUBDIRS) pkg
$(PREREQ): $(PREREQ_VAGRANTFILES)
$(PREREQ_VAGRANTFILES):
$(MAKE) -C clusters/vx Vagrantfile
$(MAKE) -C clusters/vc Vagrantfile
pkg:
$(MAKE) -C clusters pkg
tar $(TAR_EXCLUDE) $(TAR_ARGS) $(TAR_GET) $(TAR_ADDITIONAL_FILES) clusters
$(info )
cksum $(TAR_GET) > $(TAR_GET_CKSUM)
ls -l $(TAR_GET) $(TAR_GET_CKSUM)
$(PREREQ_INGEST): $(PREREQ_STORAGE)
# @todo => gmake function, also fuzzier match
# @todo move to subsidiary Makefile
$(HUMAN_FRIENDLY): $(PREREQ) $(PREREQ_LIST) $(basename $(PREREQ_LIST))
$(MAKE) -C requires/storage
$(MAKE) -C requires/memory
$(MAKE) -C requires/ingest
$(MAKE) -C requires/auth
$(HUSH)export first="Prerequisites: " ; \
for f in $(sort $^) ; \
do \
is=$$(requires/sw/$$f/cmd) ; \
requires=$$(cat requires/sw/$$f/version) ; \
if [ -z "$${is}" ] ; then \
echo "$$f version: empty" ; \
exit $(PREREQ_ERROR_EXIT) ; \
fi ; \
if [ -z "$${requires}" ] ; then \
echo "$$f requires: empty" ; \
exit $(PREREQ_ERROR_EXIT) ; \
fi ; \
is_maj=$$(echo $${is} | cut -d. -f1,1) ; \
requires_maj=$$(echo $${requires} | cut -d. -f1,1) ; \
if [ "$${is_maj}" != "$${requires_maj}" ] ; then \
warn="" ; \
if [ -f "requires/sw/$$f/warning-only" ] ; then \
warn=" (warning)" ; \
fi ; \
printf "\n$$f: mismatch: version required:$${requires} != found:$${is}$(warn)\n" ; \
if [ -z "${warn}" ] ; then \
exit $(PREREQ_ERROR_EXIT) ; \
fi ; \
else \
if [ -n "$(HUSH)" ] ; then \
echo -n "$$first$$f" ; \
first=" " ; \
fi ; \
fi ; \
done ; \
echo ''
$(SUBDIRS): $(PREREQ)
$(HUSH)$(MAKE) -s -C $@ $(MAKECMDGOALS)
help:
make -s -C clusters/vc $@
clean:
$(RM) clusters/v*/.regenerated clusters/v*/Vagrantfile
# vim: ts=2 sw=2 syntax=make background=dark