forked from ClusterLabs/pacemaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
337 lines (285 loc) · 13.5 KB
/
GNUmakefile
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
#
# Copyright (C) 2008 Andrew Beekhof
#
# This program 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 2
# of the License, or (at your option) any later version.
#
# This program 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 program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
default: $(shell test ! -e configure && echo init) $(shell test -e configure && echo core)
-include Makefile
PACKAGE ?= pacemaker
# Force 'make dist' to be consistent with 'make export'
distdir = $(PACKAGE)-$(TAG)
TARFILE = $(distdir).tar.gz
DIST_ARCHIVES = $(TARFILE)
RPM_ROOT = $(shell pwd)
RPM_OPTS = --define "_sourcedir $(RPM_ROOT)" \
--define "_specdir $(RPM_ROOT)" \
--define "_srcrpmdir $(RPM_ROOT)" \
MOCK_OPTIONS ?= --resultdir=$(RPM_ROOT)/mock --no-cleanup-after
# Default to fedora compliant spec files
# SLES: /etc/SuSE-release
# openSUSE: /etc/SuSE-release
# RHEL: /etc/redhat-release
# Fedora: /etc/fedora-release, /etc/redhat-release, /etc/system-release
F ?= $(shell test ! -e /etc/fedora-release && echo 0; test -e /etc/fedora-release && rpm --eval %{fedora})
ARCH ?= $(shell test -e /etc/fedora-release && rpm --eval %{_arch})
MOCK_CFG ?= $(shell test -e /etc/fedora-release && echo fedora-$(F)-$(ARCH))
DISTRO ?= $(shell test -e /etc/SuSE-release && echo suse; echo fedora)
TAG ?= $(shell git log --pretty="format:%H" -n 1)
WITH ?= --without doc
#WITH ?= --without=doc --with=gcov
LAST_RC ?= $(shell test -e /Volumes || git tag -l | grep Pacemaker | sort -Vr | grep rc | head -n 1)
LAST_RELEASE ?= $(shell test -e /Volumes || git tag -l | grep Pacemaker | sort -Vr | grep -v rc | head -n 1)
NEXT_RELEASE ?= $(shell echo $(LAST_RELEASE) | awk -F. '/[0-9]+\./{$$3+=1;OFS=".";print $$1,$$2,$$3}')
BUILD_COUNTER ?= build.counter
LAST_COUNT = $(shell test ! -e $(BUILD_COUNTER) && echo 0; test -e $(BUILD_COUNTER) && cat $(BUILD_COUNTER))
COUNT = $(shell expr 1 + $(LAST_COUNT))
SPECVERSION ?= $(COUNT)
init:
./autogen.sh init
export:
rm -f $(PACKAGE)-dirty.tar.* $(PACKAGE)-tip.tar.* $(PACKAGE)-HEAD.tar.*
if [ ! -f $(TARFILE) ]; then \
rm -f $(PACKAGE).tar.*; \
if [ $(TAG) = dirty ]; then \
git commit -m "DO-NOT-PUSH" -a; \
git archive --prefix=$(distdir)/ HEAD | gzip > $(TARFILE); \
git reset --mixed HEAD^; \
else \
git archive --prefix=$(distdir)/ $(TAG) | gzip > $(TARFILE); \
fi; \
echo `date`: Rebuilt $(TARFILE); \
else \
echo `date`: Using existing tarball: $(TARFILE); \
fi
$(PACKAGE)-opensuse.spec: $(PACKAGE)-suse.spec
cp $^ $@
@echo Rebuilt $@
$(PACKAGE)-suse.spec: $(PACKAGE).spec.in GNUmakefile
rm -f $@
if [ x != x"`git ls-files -m | grep pacemaker.spec.in`" ]; then \
cp $(PACKAGE).spec.in $@; \
echo "Rebuilt $@ (local modifications)"; \
elif [ x = x"`git show $(TAG):pacemaker.spec.in 2>/dev/null`" ]; then \
cp $(PACKAGE).spec.in $@; \
echo "Rebuilt $@"; \
else \
git show $(TAG):$(PACKAGE).spec.in >> $@; \
echo "Rebuilt $@ from $(TAG)"; \
fi
sed -i s:%{_docdir}/%{name}:%{_docdir}/%{name}-%{version}:g $@
sed -i s:corosynclib:libcorosync:g $@
sed -i s:libexecdir}/lcrso:libdir}/lcrso:g $@
sed -i 's:%{name}-libs:lib%{name}3:g' $@
sed -i s:heartbeat-libs:heartbeat:g $@
sed -i s:cluster-glue-libs:libglue:g $@
sed -i s:libselinux-devel:automake:g $@
sed -i s:lm_sensors-devel:automake:g $@
sed -i s:bzip2-devel:libbz2-devel:g $@
sed -i s:bcond_without\ publican:bcond_with\ publican:g $@
sed -i s:docbook-style-xsl:docbook-xsl-stylesheets:g $@
sed -i s:libtool-ltdl-devel::g $@
sed -i s:dbus-devel:dbus-1-devel:g $@
sed -i s:publican::g $@
sed -i s:byacc::g $@
sed -i s:global\ cs_major.*:global\ cs_major\ 1:g $@
sed -i s:global\ cs_minor.*:global\ cs_minor\ 4:g $@
sed -i s:gnutls-devel:libgnutls-devel:g $@
sed -i s:189:90:g $@
sed -i 's@python-devel@python-devel python-curses python-xml@' $@
sed -i 's@Requires: python@Requires: python python-curses python-xml@' $@
sed -i 's@%systemd_post pacemaker.service@if [ ZZZ -eq 1 ]; then systemctl preset pacemaker.service || : ; fi@' $@
sed -i 's@%systemd_postun_with_restart pacemaker.service@systemctl daemon-reload || : ; if [ ZZZ -ge 1 ]; then systemctl try-restart pacemaker.service || : ; fi@' $@
sed -i 's@%systemd_preun pacemaker.service@if [ ZZZ -eq 0 ]; then systemctl --no-reload disable pacemaker.service || : ; systemctl stop pacemaker.service || : ; fi@' $@
sed -i 's@%systemd_post pacemaker_remote.service@if [ ZZZ -eq 1 ]; then systemctl preset pacemaker_remote.service || : ; fi@' $@
sed -i 's@%systemd_postun_with_restart pacemaker_remote.service@systemctl daemon-reload || : ; if [ ZZZ -ge 1 ]; then systemctl try-restart pacemaker_remote.service || : ; fi@' $@
sed -i 's@%systemd_preun pacemaker_remote.service@if [ ZZZ -eq 0 ]; then systemctl --no-reload disable pacemaker_remote.service || : ; systemctl stop pacemaker_remote.service || : ; fi@' $@
sed -i "s@ZZZ@\o0441@g" $@
@echo "Applied SUSE-specific modifications"
# Works for all fedora based distros
$(PACKAGE)-%.spec: $(PACKAGE).spec.in
rm -f $@
if [ x != x"`git ls-files -m | grep pacemaker.spec.in`" ]; then \
cp $(PACKAGE).spec.in $(PACKAGE)-$*.spec; \
echo "Rebuilt $@ (local modifications)"; \
elif [ x = x"`git show $(TAG):pacemaker.spec.in 2>/dev/null`" ]; then \
cp $(PACKAGE).spec.in $(PACKAGE)-$*.spec; \
echo "Rebuilt $@"; \
else \
git show $(TAG):$(PACKAGE).spec.in >> $(PACKAGE)-$*.spec; \
echo "Rebuilt $@ from $(TAG)"; \
fi
# rpmbuild apparently temporarily lost the ability to use --with arguments at some point
# Compensate by tweaking the format for pcmk_release here
srpm-%: export $(PACKAGE)-%.spec
rm -f *.src.rpm
cp $(PACKAGE)-$*.spec $(PACKAGE).spec
echo "* $(shell date +"%a %b %d %Y") Andrew Beekhof <[email protected]> $(shell git describe --tags $(TAG) | sed -e s:Pacemaker-:: -e s:-.*::)-1" >> $(PACKAGE).spec
echo " - See included ChangeLog file or https://raw.github.com/ClusterLabs/pacemaker/master/ChangeLog for full details" >> $(PACKAGE).spec
if [ -e $(BUILD_COUNTER) ]; then \
echo $(COUNT) > $(BUILD_COUNTER); \
fi
sed -i 's/global\ specversion.*/global\ specversion\ $(SPECVERSION)/' $(PACKAGE).spec
sed -i 's/global\ commit.*/global\ commit\ $(TAG)/' $(PACKAGE).spec
case "$(WITH)" in \
*pre_release*) \
sed -i 's/global\ pcmk_release.*/global\ pcmk_release\ 0.%{specversion}.%{shortcommit}.git/' $(PACKAGE).spec; \
sed -i 's/Version:.*/Version:\ $(shell echo $(NEXT_RELEASE) | sed -e s:Pacemaker-:: -e s:-.*::)/' $(PACKAGE).spec;; \
*) \
sed -i 's/Version:.*/Version:\ $(shell git describe --tags $(TAG) | sed -e s:Pacemaker-:: -e s:-.*::)/' $(PACKAGE).spec;;\
esac
rpmbuild -bs --define "dist .$*" $(RPM_OPTS) $(PACKAGE).spec
chroot: mock-$(MOCK_CFG) mock-install-$(MOCK_CFG) mock-sh-$(MOCK_CFG)
echo "Done"
mock-next:
make F=$(shell expr 1 + $(F)) mock
mock-rawhide:
make F=rawhide mock
mock-install-%:
echo "Installing packages"
mock --root=$* $(MOCK_OPTIONS) --install $(RPM_ROOT)/mock/*.rpm vi sudo valgrind lcov gdb fence-agents psmisc
mock-install: mock-install-$(MOCK_CFG)
echo "Done"
mock-sh: mock-sh-$(MOCK_CFG)
echo "Done"
mock-sh-%:
echo "Connecting"
mock --root=$* $(MOCK_OPTIONS) --shell
echo "Done"
# eg. WITH="--with cman" make rpm
mock-%:
make srpm-$(firstword $(shell echo $(@:mock-%=%) | tr '-' ' '))
-rm -rf $(RPM_ROOT)/mock
@echo "mock --root=$* --rebuild $(WITH) $(MOCK_OPTIONS) $(RPM_ROOT)/*.src.rpm"
mock --root=$* --no-cleanup-after --rebuild $(WITH) $(MOCK_OPTIONS) $(RPM_ROOT)/*.src.rpm
srpm: srpm-$(DISTRO)
echo "Done"
mock: mock-$(MOCK_CFG)
echo "Done"
rpm-dep: $(PACKAGE)-$(DISTRO).spec
if [ x != x`which yum-builddep 2>/dev/null` ]; then \
echo "Installing with yum-builddep"; \
sudo yum-builddep $(PACKAGE)-$(DISTRO).spec; \
elif [ x != x`which yum 2>/dev/null` ]; then \
echo -e "Installing: $(shell grep BuildRequires pacemaker.spec.in | sed -e s/BuildRequires:// -e s:\>.*0:: | tr '\n' ' ')\n\n"; \
sudo yum install $(shell grep BuildRequires pacemaker.spec.in | sed -e s/BuildRequires:// -e s:\>.*0:: | tr '\n' ' '); \
elif [ x != x`which zypper` ]; then \
echo -e "Installing: $(shell grep BuildRequires pacemaker.spec.in | sed -e s/BuildRequires:// -e s:\>.*0:: | tr '\n' ' ')\n\n"; \
sudo zypper install $(shell grep BuildRequires pacemaker.spec.in | sed -e s/BuildRequires:// -e s:\>.*0:: | tr '\n' ' ');\
else \
echo "I don't know how to install $(shell grep BuildRequires pacemaker.spec.in | sed -e s/BuildRequires:// -e s:\>.*0:: | tr '\n' ' ')";\
fi
rpm: srpm
@echo To create custom builds, edit the flags and options in $(PACKAGE).spec first
rpmbuild $(RPM_OPTS) $(WITH) --rebuild $(RPM_ROOT)/*.src.rpm
release:
make TAG=$(LAST_RELEASE) rpm
rc:
make TAG=$(LAST_RC) rpm
dirty:
make TAG=dirty mock
COVERITY_DIR = $(shell pwd)/coverity-$(TAG)
COVFILE = pacemaker-coverity-$(TAG).tgz
COVHOST ?= scan5.coverity.com
COVPASS ?= password
# Public coverity
coverity:
test -e configure || ./autogen.sh
test -e Makefile || ./configure
make core-clean
rm -rf $(COVERITY_DIR)
cov-build --dir $(COVERITY_DIR) make core
tar czf $(COVFILE) --transform=s@.*$(TAG)@cov-int@ $(COVERITY_DIR)
@echo "Uploading to public Coverity instance..."
curl --form file=@$(COVFILE) --form project=$(PACKAGE) --form password=$(COVPASS) --form [email protected] http://$(COVHOST)/cgi-bin/upload.py
rm -rf $(COVFILE) $(COVERITY_DIR)
coverity-corp:
test -e configure || ./autogen.sh
test -e Makefile || ./configure
make core-clean
rm -rf $(COVERITY_DIR)
cov-build --dir $(COVERITY_DIR) make core
@echo "Waiting for a corporate Coverity license..."
cov-analyze --dir $(COVERITY_DIR) --wait-for-license
cov-format-errors --dir $(COVERITY_DIR) --emacs-style > $(TAG).coverity
cov-format-errors --dir $(COVERITY_DIR)
rsync -avzxlSD --progress $(COVERITY_DIR)/c/output/errors/ [email protected]:/var/www/html/coverity/$(PACKAGE)/$(TAG)
make core-clean
# cov-commit-defects --host $(COVHOST) --dir $(COVERITY_DIR) --stream $(PACKAGE) --user auto --password $(COVPASS)
rm -rf $(COVERITY_DIR)
global: clean-generic
gtags -q
%.8.html: %.8
echo groff -mandoc `man -w ./$<` -T html > $@
groff -mandoc `man -w ./$<` -T html > $@
rsync -azxlSD --progress $@ [email protected]:/var/www/html/man/
%.7.html: %.7
echo groff -mandoc `man -w ./$<` -T html > $@
groff -mandoc `man -w ./$<` -T html > $@
rsync -azxlSD --progress $@ [email protected]:/var/www/html/man/
doxygen: Doxyfile
doxygen Doxyfile
abi:
abi-check pacemaker $(LAST_RELEASE) $(TAG)
abi-www:
abi-check -u pacemaker $(LAST_RELEASE) $(TAG)
www: all global doxygen
find . -name "[a-z]*.8" -exec make \{\}.html \;
find . -name "[a-z]*.7" -exec make \{\}.html \;
htags -sanhIT
rsync -avzxlSD --progress HTML/ [email protected]:/var/www/html/global/$(PACKAGE)/$(TAG)
rsync -avzxlSD --progress doc/api/html/ [email protected]:/var/www/html/doxygen/$(PACKAGE)/$(TAG)
make -C doc www
make coverity
summary:
@printf "\n* `date +"%a %b %d %Y"` `git config user.name` <`git config user.email`> $(NEXT_RELEASE)-1"
@printf "\n- Update source tarball to revision: `git log --pretty=format:%h -n 1`"
@printf "\n- Changesets: `git log --pretty=oneline $(LAST_RELEASE)..HEAD | wc -l`"
@printf "\n- Diff: "
@git diff -r $(LAST_RELEASE)..HEAD --stat include lib mcp pengine/*.c pengine/*.h cib crmd fencing lrmd tools xml | tail -n 1
rc-changes:
@make NEXT_RELEASE=$(shell echo $(LAST_RC) | sed s:-rc.*::) LAST_RELEASE=$(LAST_RC) changes
changes: summary
@printf "\n- Features added since $(LAST_RELEASE)\n"
@git log --pretty=format:' +%s' --abbrev-commit $(LAST_RELEASE)..HEAD | grep -e Feature: | sed -e 's@Feature:@@' | sort -uf
@printf "\n- Changes since $(LAST_RELEASE)\n"
@git log --pretty=format:' +%s' --abbrev-commit $(LAST_RELEASE)..HEAD | grep -e High: -e Fix: -e Bug | sed -e 's@Fix:@@' -e s@High:@@ -e s@Fencing:@fencing:@ -e 's@Bug@ Bug@' -e s@PE:@pengine:@ | sort -uf
changelog:
@make changes > ChangeLog
@printf "\n">> ChangeLog
git show $(LAST_RELEASE):ChangeLog >> ChangeLog
@echo -e "\033[1;35m -- Don't forget to run the bumplibs.sh script! --\033[0m"
indent:
find . -name "*.h" -exec ./p-indent \{\} \;
find . -name "*.c" -exec ./p-indent \{\} \;
git co HEAD crmd/fsa_proto.h lib/gnu
rel-tags: tags
find . -name TAGS -exec sed -i 's:\(.*\)/\(.*\)/TAGS:\2/TAGS:g' \{\} \;
CLANG_analyzer = $(shell which scan-build)
CLANG_checkers =
check: clang cppcheck
# Extra cppcheck options: --enable=all --inconclusive --std=posix
cppcheck:
for d in $(LIBLTDL_DIR) replace lib mcp attrd pengine cib crmd fencing lrmd tools; do cppcheck -q $$d; done
clang:
test -e $(CLANG_analyzer)
scan-build $(CLANG_checkers:%=-enable-checker %) make clean all
# V3 = scandir unsetenv alphasort xalloc
# V2 = setenv strerror strchrnul strndup
# http://www.gnu.org/software/gnulib/manual/html_node/Initial-import.html#Initial-import
GNU_MODS = crypto/md5
gnulib-update:
-test ! -e gnulib && git clone git://git.savannah.gnu.org/gnulib.git
cd gnulib && git pull
gnulib/gnulib-tool --source-base=lib/gnu --lgpl=2 --no-vc-files --import $(GNU_MODS)