1# Copyright (C) 2010 Red Hat, Inc. 2# 3# Authors: Andrew Beekhof <abeekhof@redhat.com> 4# Steven Dake <sdake@redhat.com> 5# Angus Salkeld <asalkeld@redhat.com> 6# 7# This file is part of libqb. 8# 9# libqb is free software: you can redistribute it and/or modify 10# it under the terms of the GNU Lesser General Public License as published by 11# the Free Software Foundation, either version 2.1 of the License, or 12# (at your option) any later version. 13# 14# libqb is distributed in the hope that it will be useful, 15# but WITHOUT ANY WARRANTY; without even the implied warranty of 16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17# GNU Lesser General Public License for more details. 18# 19# You should have received a copy of the GNU Lesser General Public License 20# along with libqb. If not, see <http://www.gnu.org/licenses/>. 21 22SPEC = $(PACKAGE_NAME).spec 23 24EXTRA_DIST = autogen.sh $(SPEC).in \ 25 build-aux/git-version-gen \ 26 build-aux/gitlog-to-changelog \ 27 build-aux/release.mk \ 28 .version 29 30AUTOMAKE_OPTIONS = foreign 31 32MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure depcomp \ 33 config.guess config.sub missing install-sh \ 34 autoheader automake autoconf libtool libtoolize \ 35 ltmain.sh compile build-aux/test-driver 36 37 38ACLOCAL_AMFLAGS = -I m4 39 40dist_doc_DATA = COPYING INSTALL README.markdown 41 42SUBDIRS = include lib docs tools tests examples 43 44dist-clean-local: 45 rm -f .snapshot-version autoconf automake autoheader 46 47# this will also get rid of "libtoolized" m4 files 48maintainer-clean-local: 49 rm -f .version .tarball-version 50 rm -f $(patsubst $(top_srcdir)/m4/ax_%,,$(wildcard $(top_srcdir)/m4/*.m4)) 51 52clean-local: 53 rm -rf $(SPEC) $(DIST_ARCHIVES) 54 55## make rpm/srpm section. 56 57$(SPEC): $(SPEC).in 58 @rm -f $@-t $@ 59 @date="$(shell LC_ALL=C date "+%a %b %d %Y")" && \ 60 if [ -s .tarball-version ] || [ -n "$$(echo '${VERSION}' | grep -v UNKNOWN)" ]; then \ 61 ver="$$({ cat .tarball-version 2>/dev/null; echo '${VERSION}'; } | head -n1)" && \ 62 gitver=$$(echo $$ver | sed \ 63 -e 's|^\(v[0-9][0-9]*\.[0-9][0-9]*\)\([^.].*\)\?$$|\1.0\2|') && \ 64 rpmver=$$(echo $$gitver | sed 's/-.*//') && \ 65 alphatag="" && \ 66 dirty=$$(echo $$gitver | sed -n 's/[^-][^-]*-//p') && \ 67 numcomm="0"; \ 68 else \ 69 ver="$(shell git describe --abbrev=4 --match='v*' --tags HEAD 2>/dev/null)" && \ 70 gitver=$$(echo $$ver | sed \ 71 -e 's|^\(v[0-9][0-9]*\.[0-9][0-9]*\)\([^.].*\)\?$$|\1.0\2|') && \ 72 rpmver=$$(echo $$gitver | sed -e "s/^v//" -e "s/-.*//g") && \ 73 alphatag=$$(echo $$gitver | sed -e "s/.*-//" -e "s/^g//") && \ 74 vtag=$$(echo $$ver | sed -e "s/-.*//g") && \ 75 numcomm=$$(git rev-list $$vtag..HEAD | wc -l) && \ 76 git update-index --refresh > /dev/null 2>&1 || true && \ 77 dirty=$$(git diff-index --name-only HEAD 2>/dev/null | sed 's/..*/dirty/'); \ 78 fi && \ 79 if [ "$$numcomm" = "0" ]; then \ 80 sed \ 81 -e "s#@version@#$$rpmver#g" \ 82 -e "s#%glo.*alpha.*##g" \ 83 -e "s#%glo.*numcomm.*##g" \ 84 -e "s#@dirty@#$$dirty#g" \ 85 -e "s#@date@#$$date#g" \ 86 $< > $@-t; \ 87 else \ 88 sed \ 89 -e "s#@version@#$$rpmver#g" \ 90 -e "s#@alphatag@#$$alphatag#g" \ 91 -e "s#@numcomm@#$$numcomm#g" \ 92 -e "s#@dirty@#$$dirty#g" \ 93 -e "s#@date@#$$date#g" \ 94 $< > $@-t; \ 95 fi; \ 96 if [ -z "$$dirty" ]; then sed -i -e "s#%glo.*dirty.*##g" $@-t; fi 97 @chmod a-w $@-t 98 $(AM_V_GEN)mv $@-t $@ 99 100RPMBUILDOPTS = --define "_sourcedir $(abs_builddir)" \ 101 --define "_specdir $(abs_builddir)" \ 102 --define "_builddir $(abs_builddir)" \ 103 --define "_srcrpmdir $(abs_builddir)" \ 104 --define "_rpmdir $(abs_builddir)" 105 106# generates both .tar.[gx]z (backward compatibility) 107tarball: dist 108 109srpm: clean 110 autoreconf -if 111 $(MAKE) $(SPEC) dist-xz 112 rpmbuild $(RPMBUILDOPTS) --nodeps -bs $(SPEC) 113 114rpm: clean 115 autoreconf -if 116 $(MAKE) $(SPEC) dist-xz 117 rpmbuild $(RPMBUILDOPTS) -ba $(SPEC) 118 119# release/versioning 120BUILT_SOURCES = .version 121.version: 122 echo $(VERSION) > $@-t && mv $@-t $@ 123 124# untaint configure.ac when modified upon obtaining the "yanked" snapshot form 125dist-hook: gen-ChangeLog 126 echo $(SOURCE_EPOCH) > $(distdir)/source_epoch 127 echo $(VERSION) | tee $(distdir)/.tarball-version | grep -Eqv '\-yank' \ 128 || sed "s/\(.*git-version-gen[^']*[']\)[^']*/\1\$$Format:%h??%D\$$/" \ 129 $(distdir)/configure.ac > $(builddir)/configure.ac-t 130 if [ -f $(builddir)/configure.ac-t ]; then \ 131 touch -r $(distdir)/configure.ac $(builddir)/configure.ac-t; \ 132 chmod u+w $(builddir)/configure.ac-t; \ 133 mv $(builddir)/configure.ac-t $(distdir)/configure.ac; \ 134 fi 135 136gen_start_date = 2000-01-01 137.PHONY: gen-ChangeLog 138gen-ChangeLog: 139 if test -d .git; then \ 140 $(top_srcdir)/build-aux/gitlog-to-changelog \ 141 --since=$(gen_start_date) > $(distdir)/cl-t; \ 142 rm -f $(distdir)/ChangeLog; \ 143 mv $(distdir)/cl-t $(distdir)/ChangeLog; \ 144 fi 145