From 0bc642a31600bbfaac15779b8d932a409283ae3f Mon Sep 17 00:00:00 2001
From: Matthias Vogelgesang <matthias.vogelgesang@gmail.com>
Date: Wed, 26 Sep 2012 14:51:14 +0200
Subject: Generalized log generation

---
 docs/Makefile         |  8 ++++++--
 docs/gen-changelog    | 20 ++++++++++++++++++++
 docs/manual.md        |  2 +-
 docs/update-changelog | 22 ----------------------
 docs/z-changes-1.0.md |  5 -----
 5 files changed, 27 insertions(+), 30 deletions(-)
 create mode 100755 docs/gen-changelog
 delete mode 100755 docs/update-changelog
 delete mode 100644 docs/z-changes-1.0.md

diff --git a/docs/Makefile b/docs/Makefile
index 83c1d01..ff7113d 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -10,11 +10,15 @@ html: manual.html
 clean:
 	rm -f manual.pdf manual.html
 
-manual.pdf: manual.md
+manual.pdf: manual.md gen-changelog
+	./gen-changelog
 	$(PANDOC) $(OPTS) manual.md z-changes-*.md -o manual.pdf
+	rm z-changes-*.md
 
-manual.html: manual.md style.css
+manual.html: manual.md style.css gen-changelog
+	./gen-changelog
 	$(PANDOC) $(OPTS) manual.md z-changes-*.md -H webfonts.html -c style.css -o manual.html
+	rm z-changes-*.md
 
 ifeq ($(PANDOC),)
 	$(warning Pandoc not found!)
diff --git a/docs/gen-changelog b/docs/gen-changelog
new file mode 100755
index 0000000..51650f1
--- /dev/null
+++ b/docs/gen-changelog
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+FROM=$1
+TO=$2
+OUTPUT=$3
+series=('v1.0' 'v1.0.1')
+
+logname="z-changes-${series[0]}.md"
+
+echo "## Changes for stable branch ${series[0]}
+" >> $logname
+
+for ((i = 1; i < ${#series[@]}; i++)) do
+    curr=${series[i]}
+    prev=${series[i-1]}
+
+    echo "### Changes from $prev to $curr
+" >> $logname
+    git log --pretty=format:'* [%h](http://ufo.kit.edu/repos/libuca.git/commit/?id=%h): %s' $prev..$curr >> $logname
+done
diff --git a/docs/manual.md b/docs/manual.md
index 19eacca..91935cc 100644
--- a/docs/manual.md
+++ b/docs/manual.md
@@ -444,4 +444,4 @@ grabbing time:
 [TODO: Get more information from Volker Kaiser and/or Mihael Koep]
 
 
-# Changes
+# ChangeLog
diff --git a/docs/update-changelog b/docs/update-changelog
deleted file mode 100755
index 57fe7a6..0000000
--- a/docs/update-changelog
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/bash
-
-FROM=$1
-TO=$2
-OUTPUT=$3
-
-echo "## Changes from $FROM to $TO
-" >> tmp
-git log --pretty=format:'* [%h](http://ufo.kit.edu/repos/libuca.git/commit/?id=%h): %s' $FROM..$TO >> tmp
-
-echo "
-" >> tmp
-
-if [ -f "$OUTPUT" ]
-then
-    cat tmp $OUTPUT > tmp_md
-    rm $OUTPUT
-    mv tmp_md $OUTPUT
-    rm tmp
-else
-    mv tmp $OUTPUT
-fi
diff --git a/docs/z-changes-1.0.md b/docs/z-changes-1.0.md
deleted file mode 100644
index 4628b37..0000000
--- a/docs/z-changes-1.0.md
+++ /dev/null
@@ -1,5 +0,0 @@
-## Changes from v1.0 to v1.0.1
-
-* [5d99f27](http://ufo.kit.edu/repos/libuca.git/commit/?id=5d99f27): Bump version to prepare for SO fix
-* [178298f](http://ufo.kit.edu/repos/libuca.git/commit/?id=178298f): Set SO version to major not minor version
-
-- 
cgit v1.2.3