-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathMakefile
194 lines (155 loc) · 5.75 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
SHELL = /bin/ksh
COMMON = ../install/common
QACOMMENT = -comment cmrs=qa
PYTHON_DEFAULT = /usr/bin/env python
PYTHON_CLIENT_PROD = /ms/dist/python/PROJ/core/3.10.11-0/bin/python -E
PYTHON_SERVER_PROD = /ms/dist/python/PROJ/core/3.10.11-0/bin/python -E
MPR := $(shell echo $(PWD) | awk -F/ '{print $$(NF-3), $$(NF-2), $$(NF-1)}')
META = $(word 1,$(MPR))
PROJ = $(word 2,$(MPR))
REL = $(word 3,$(MPR))
NON_AQ6_HOST := $(findstring 6., $(shell egrep '\s6\.[0-9]+' /etc/redhat-release))
ifneq (aquilon,$(META))
META = aquilon
PROJ = aqd
REL := $(shell git describe | awk -F- '{print $$1}')
endif
# determine if we're in /ms/dev or our shadow
# keep them owner writeable in shadow install
PERMS = 755
LIB_PERMS = 644
IN_AFS = $(findstring /ms/dev/aquilon/aqd, $(PWD))
ifneq (,$(IN_AFS))
COMMON = /ms/dev/aquilon/aqd/$(REL)/install/common
PERMS = 555
LIB_PERMS = 444
endif
#try make print-LIB_DIRS for an example
#IF YOU WANT THE FILE DEFINED FROM, ADD (from $(origin $*))
print-%: ; @$(error $* is $($*) ($(value $*)))
# Here, we make some very easy to parse, and perhaps not very subtle,
# The goal is to be readable by someone who doesn't know make very well,
# to make it maintainable, not to impress you with how well I know the tool
BIN_FILES := $(shell find bin sbin -type f | sed -e 's/.py$$//')
LIB_FILES := $(shell find lib -type f)
ETC_FILES := $(shell find etc -type f | grep -v templates)
PYC_FILES := $(shell find lib -name '*.py' | sed -e 's,\.py,\.pyc,')
FILES = $(BIN_FILES) $(LIB_FILES) $(MAN_FILES) $(ETC_FILES) $(PYC_FILES)
INSTALLFILES = $(addprefix $(COMMON)/,$(FILES))
$(COMMON)/bin/aq: bin/aq.py
@mkdir -p `dirname $@`
sed -e '1s,^#!$(PYTHON_DEFAULT)\(.*\),#!$(PYTHON_CLIENT_PROD)\1,' <$< >$@
chmod $(PERMS) $@
$(COMMON)/bin/aq_compile: bin/aq_compile.py
@mkdir -p `dirname $@`
sed -e '1s,^#!$(PYTHON_DEFAULT)\(.*\),#!$(PYTHON_CLIENT_PROD)\1,' <$< >$@
chmod $(PERMS) $@
$(COMMON)/bin/aqd_config: bin/aqd_config.py
@mkdir -p `dirname $@`
sed -e '1s,^#!$(PYTHON_DEFAULT)\(.*\),#!$(PYTHON_CLIENT_PROD)\1,' <$< >$@
chmod $(PERMS) $@
$(COMMON)/sbin/aqd: sbin/aqd.py
@mkdir -p `dirname $@`
sed -e '1s,^#!$(PYTHON_DEFAULT)\(.*\),#!$(PYTHON_SERVER_PROD)\1,' <$< >$@
chmod $(PERMS) $@
$(COMMON)/sbin/aq_notifyd: sbin/aq_notifyd.py
@mkdir -p `dirname $@`
sed -e '1s,^#!$(PYTHON_DEFAULT)\(.*\),#!$(PYTHON_SERVER_PROD)\1,' <$< >$@
chmod $(PERMS) $@
$(COMMON)/sbin/aqdb_shell: sbin/aqdb_shell.py
@mkdir -p `dirname $@`
sed -e '1s,^#!$(PYTHON_DEFAULT)\(.*\),#!$(PYTHON_SERVER_PROD)\1,' <$< >$@
chmod $(PERMS) $@
$(COMMON)/sbin/aqdb_migrate: sbin/aqdb_migrate.py
@mkdir -p `dirname $@`
sed -e '1s,^#!$(PYTHON_DEFAULT)\(.*\),#!$(PYTHON_SERVER_PROD)\1,' <$< >$@
chmod $(PERMS) $@
$(COMMON)/sbin/aqdb_set_role: sbin/aqdb_set_role.py
@mkdir -p `dirname $@`
sed -e '1s,^#!$(PYTHON_DEFAULT)\(.*\),#!$(PYTHON_SERVER_PROD)\1,' <$< >$@
chmod $(PERMS) $@
$(COMMON)/sbin/aqd_consistency_check: sbin/aqd_consistency_check.py
@mkdir -p `dirname $@`
sed -e '1s,^#!$(PYTHON_DEFAULT)\(.*\),#!$(PYTHON_SERVER_PROD)\1,' <$< >$@
chmod $(PERMS) $@
$(COMMON)/%.pyc: $(COMMON)/%.py
@echo "compiling $@"
@rm -f $@
$(PYTHON_CLIENT_PROD) ./tools/compile_for_dist.py $<
$(COMMON)/lib/%: lib/%
@mkdir -p `dirname $@`
install -m $(LIB_PERMS) $< $@
$(COMMON)/etc/%: etc/%
@mkdir -p `dirname $@`
install -m $(LIB_PERMS) $< $@
$(COMMON)/etc/rc.d/init.d/aqd: etc/rc.d/init.d/aqd
@mkdir -p `dirname $@`
install -m 0555 $< $@
# Running aqd after all the files have been installed generates a
# dropin.cache file that would otherwise be missing (and that missing
# file causes the server to complain loudly on startup).
# The file will only be generated as needed. The remove_stale script
# skips dropin.cache.
#
# For gen_completion.py, there's no point in doing something make-like
# and sophisticated for this, since remove_stale is dumb and will always
# remove the generated files anyway.
.PHONY: install
install: remove_stale $(INSTALLFILES) install-doc
ln -sf aqd "$(COMMON)/sbin/aqd_readonly"
$(PYTHON_CLIENT_PROD) $(COMMON)/sbin/aqd --help >/dev/null
$(PYTHON_CLIENT_PROD) ./tools/gen_completion.py --outputdir="$(COMMON)/etc" --templatedir="./etc/templates" --all
$(PYTHON_CLIENT_PROD) ./tools/graph_schema.py --outputdir="$(COMMON)/doc"
$(PYTHON_CLIENT_PROD) ./tools/build_schema_htdocs.py --outputdir="$(COMMON)/doc/schema"
.PHONY: install-doc
install-doc:
$(MAKE) -C doc install DESTDIR="$(abspath $(COMMON)/doc)"
.PHONY: remove_stale
remove_stale:
$(PYTHON_CLIENT_PROD) ./tools/remove_stale.py "$(COMMON)"
.PHONY: default
default:
@echo "Use 'gmake install' to install ${META}/${PROJ}/${REL}"
# The second find needs to ignore the .git directory... just doing a
# find on * is an easy/legit way to do that in this case.
.PHONY: clean
clean:
$(MAKE) -C doc clean
find . -name '*.pyc' -exec rm -rf {} \;
# This needs to be fixed
# find * -type d -empty -exec rmdir {} \;
.PHONY: prodlink
prodlink:
vms turnover releaselink ${META} ${PROJ} ${REL} prod
.PHONY: betalink
betalink:
vms turnover releaselink ${META} ${PROJ} ${REL} beta
.PHONY: to
to:
vms turnover release ${META} ${PROJ} ${REL}
.PHONY: to_nolock
to_nolock:
vms turnover release ${META} ${PROJ} ${REL} -- -nolock
.PHONY: distqa
distqa: to_nolock
vms dist ${META} ${PROJ} ${REL} -- -qacells ${QACOMMENT}
.PHONY: distworld
distworld: to_nolock
vms dist ${META} ${PROJ} ${REL} -- -gl ${QACOMMENT}
.PHONY: distfinal
distfinal: to
vms dist ${META} ${PROJ} ${REL} -- -gl ${QACOMMENT}
.PHONY: unlock
unlock:
vms unlock release ${META} ${PROJ} ${REL}
.PHONY: freeze
freeze:
vms freezedist ${META} ${PROJ}
.PHONY: thaw
thaw:
vms thawdist ${META} ${PROJ}
# Handled by SCM/GNUmakefile
.PHONY: create
create:
vms create release ${META} ${PROJ} ${REL} -- -nobuildvolume
vms create install ${META} ${PROJ} ${REL} common