Some fixes for karmic
[mapsector.git] / Makefile
index ad1a9fe..4582d31 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,87 +1,42 @@
-###########################################################################
-# Standard debian rules
+# -*- makefile -*-
 
-clean::
-       fakeroot debian/rules clean
-.PHONY: clean
-
-prepare::
-.PHONY: prepare
-
-deb: prepare
-       dpkg-buildpackage -us -uc -rfakeroot -I.git -I.gitignore -I.gitmodules
-.PHONY: deb
-
-###########################################################################
-# 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)                                  \
-                          | while read tag; do                                 \
-                             echo $(CLOGDIR)/$${tag}$${tag:+-}$$lasttag;       \
-                              lasttag=$$tag;                                   \
-                          done)
-
-$(CHANGELOGS): %:
-       @echo "generating $@"
-       @mkdir -p "$(CLOGDIR)"
-       @(                                                                                      \
-           set -e;                                                                             \
-            version="$@"; version="$${version#$(CLOGDIR)/}";                                   \
-           from="$${version%-*}"; version="$${version#*-}"; to="$$version";                    \
-           if [ "$$from" == "$$to" ]; then from=""; fi;                                        \
-           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;                                                                               \
-           git log --pretty=oneline --abbrev-commit $$from$${from:+..}$$to                     \
-               | while read commit description; do                                             \
-                   echo "  * [$$commit] $$description";                                        \
-           done;                                                                               \
-           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
+default: mapsectorsh
 
-debian/changelog: $(CHANGELOGS)
-       cat $^ > $@ || (rm -f $@; false)
+####################
+# debian package generation
 
-clean::
-       rm -f debian/changelog
-       rm -rf $(CLOGDIR)
+include gitdeb/Makefile.gitdeb
 
-prepare:: debian/changelog
+prepare:: lib/00_version.sh
 
-###########################################################################
-###########################################################################
+####################
+# Place version into lib/00_version.sh
+# Marked as phony so it is regenerated on each call to make
 
-prepare::
+lib/00_version.sh:
        echo "version='`git describe --tag`'" >lib/00_version.sh
 clean::
        rm -f lib/00_version.sh
+.PHONY: lib/00_version.sh
 
-
+####################
+# Build combined 'mapsectorsh' script
 # 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";                      \
+               echo "#         $$script";                      \
            done;                                               \
            sed -n -e '2,/^load$$/p' $<;                        \
            for script in $^; do                                \
-               if [ "$$script" == "$<" ]; then continue; fi;   \
+               if [ "$$script" = "$<" ]; then continue; fi;    \
                echo "#### $$script";                           \
                echo;                                           \
                cat $$script;                                   \
@@ -91,5 +46,5 @@ mapsectorsh: mapsector lib/00_version.sh $(wildcard lib/[0-9][0-9]_*.sh)
        ) >$@ || (rm -f $@; false)
        @sed -i -e 's/^load$$/####/' -eT -eh -eG -eH -eG -eH -eG -e'y/\n/#/' $@
        chmod ugo+rx $@
-clean::
+ clean::
        rm -f mapsectorsh