Some fixes for karmic
[mapsector.git] / Makefile
index eee1a41..4582d31 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,30 @@
+# -*- makefile -*-
+
+default: mapsectorsh
+
+####################
+# debian package generation
+
+include gitdeb/Makefile.gitdeb
+
+prepare:: lib/00_version.sh
+
+####################
+# Place version into lib/00_version.sh
+# Marked as phony so it is regenerated on each call to make
 
 lib/00_version.sh:
-       echo "version='`git describe --tag`'" >$@
+       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 $@"
        @(                                                      \
@@ -13,68 +32,19 @@ mapsectorsh: mapsector lib/00_version.sh $(wildcard lib/[0-9][0-9]_*.sh)
            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;                                   \
                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 $@
-
-NAME       := mapsector
-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)"
-       @(                                                                                      \
-            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*)   version="$${version#v}";                                                     \
-                  release="unstable" ;;                                                                \
-           esac;                                                                               \
-           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;                                                                               \
-           echo;                                                                               \
-           date="`git log --format='%cD' $$to'^!'`";                                           \
-           author="`git log --format='%an <%ae>' $$to'^!'`";                                   \
-           echo " -- $$author  $$date";                                                        \
-           echo;                                                                               \
-       ) >$@
-.PHONY: $(word 1,$(CHANGELOGS))
-
-debian/changelog: $(CHANGELOGS)
-       cat $^ > $@
-
-prepare: lib/00_version.sh debian/changelog
-.PHONY: prepare
-
-clean:
-       fakeroot debian/rules clean
+       chmod ugo+rx $@
+ clean::
        rm -f mapsectorsh
-       rm -f debian/changelog
-       rm -f lib/00_version.sh
-       rm -rf .git/changelogs
-
-.PHONY: clean