From: Stefan Bund Date: Thu, 12 Nov 2009 12:03:04 +0000 (+0100) Subject: Makefile reorganization X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=8f1390b5ddb120c7983bc6fdf1e7e6c7754d48a9;p=mapsector.git Makefile reorganization --- diff --git a/Makefile b/Makefile index 99f283b..ad1a9fe 100644 --- a/Makefile +++ b/Makefile @@ -1,34 +1,21 @@ +########################################################################### +# Standard debian rules -lib/00_version.sh: - echo "version='`git describe --tag`'" >$@ -.PHONY: lib/00_version.sh +clean:: + fakeroot debian/rules clean +.PHONY: clean -# The $(wildcard ...) return value is sorted and duplicates are -# removed from the list of dependencies. I need to mention -# lib/00_version.sh explicitly since it might not yet exist -mapsectorsh: mapsector lib/00_version.sh $(wildcard lib/[0-9][0-9]_*.sh) - @echo "generating $@" - @( \ - sed -n -e '1p' $<; \ - echo "#"; \ - echo "# $@ automatically generated from"; \ - for script in $^; do \ - echo "# $$script"; \ - done; \ - sed -n -e '2,/^load$$/p' $<; \ - for script in $^; do \ - if [ "$$script" == "$<" ]; then continue; fi; \ - echo "#### $$script"; \ - echo; \ - cat $$script; \ - echo; \ - done; \ - sed -n -e '/^load$$/,$$p' $<; \ - ) >$@ - @sed -i -e 's/^load$$/####/' -eT -eh -eG -eH -eG -eH -eG -e'y/\n/#/' $@ - @chmod ugo+rx $@ +prepare:: +.PHONY: prepare + +deb: prepare + dpkg-buildpackage -us -uc -rfakeroot -I.git -I.gitignore -I.gitmodules +.PHONY: deb -NAME := mapsector +########################################################################### +# Generate debian/changelog from git log + +NAME := $(shell awk '/^Source:/{print $$2}' debian/control) CLOGDIR := .git/changelogs CHANGELOGS := $(shell lasttag=HEAD; \ (git tag -l 'v*'; echo) \ @@ -41,14 +28,15 @@ $(CHANGELOGS): %: @echo "generating $@" @mkdir -p "$(CLOGDIR)" @( \ + set -e; \ version="$@"; version="$${version#$(CLOGDIR)/}"; \ from="$${version%-*}"; version="$${version#*-}"; to="$$version"; \ if [ "$$from" == "$$to" ]; then from=""; fi; \ - case "$$version" in \ - HEAD) version="`git describe --tag --match='v*' | sed -e 's/-/~/' -e 's/-/./g'`"; \ - release="UNRELEASED" ;; \ - v*) release="unstable" ;; \ - esac; \ + release="unstable"; \ + if [ "$$version" == "HEAD" ]; then \ + version="`git describe --tag --match='v*' | sed -e 's/-/~/' -e 's/-/./g'`"; \ + release="UNRELEASED"; \ + fi; \ version="$${version#v}"; \ echo "$(NAME) ($$version) $$release; urgency=low"; \ echo; \ @@ -56,25 +44,52 @@ $(CHANGELOGS): %: | while read commit description; do \ echo " * [$$commit] $$description"; \ done; \ - echo; \ - date="`git log --format='%cD' $$to'^!'`"; \ - author="`git log --format='%an <%ae>' $$to'^!'`"; \ - echo " -- $$author $$date"; \ - echo; \ - ) >$@ -.PHONY: $(word 1,$(CHANGELOGS)) + git log --format='%n -- %an <%ae> %cD%n' $$to'^!'; \ + ) >$@ || (rm -f $@; false) +.PHONY: $(word 1,$(CHANGELOGS)) # The first changelog entry must be recreated on each call debian/changelog: $(CHANGELOGS) - cat $^ > $@ - -prepare: lib/00_version.sh debian/changelog -.PHONY: prepare + cat $^ > $@ || (rm -f $@; false) -clean: - fakeroot debian/rules clean - rm -f mapsectorsh +clean:: rm -f debian/changelog + rm -rf $(CLOGDIR) + +prepare:: debian/changelog + +########################################################################### +########################################################################### + +prepare:: + echo "version='`git describe --tag`'" >lib/00_version.sh +clean:: rm -f lib/00_version.sh - rm -rf .git/changelogs -.PHONY: clean + +# The $(wildcard ...) return value is sorted and duplicates are +# removed from the list of dependencies. I need to mention +# lib/00_version.sh explicitly since it might not yet exist +mapsectorsh: mapsector lib/00_version.sh $(wildcard lib/[0-9][0-9]_*.sh) + @echo "generating $@" + @( \ + set -e; \ + sed -n -e '1p' $<; \ + echo "#"; \ + echo "# $@ automatically generated from"; \ + for script in $^; do \ + echo "# $$script"; \ + done; \ + sed -n -e '2,/^load$$/p' $<; \ + for script in $^; do \ + if [ "$$script" == "$<" ]; then continue; fi; \ + echo "#### $$script"; \ + echo; \ + cat $$script; \ + echo; \ + done; \ + sed -n -e '/^load$$/,$$p' $<; \ + ) >$@ || (rm -f $@; false) + @sed -i -e 's/^load$$/####/' -eT -eh -eG -eH -eG -eH -eG -e'y/\n/#/' $@ + chmod ugo+rx $@ +clean:: + rm -f mapsectorsh