Added automatic determination of the SVN revision number if a build
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 15 May 2005 10:52:23 +0000 (10:52 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 15 May 2005 10:52:23 +0000 (10:52 +0000)
takes place in a checked-out copy. Also added mkunxarc.sh which does
the same version determination before building its archive.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5782 cda61777-01e9-0310-a592-d414129be87e

Recipe
mkunxarc.sh [new file with mode: 0755]

diff --git a/Recipe b/Recipe
index 4c508c1..c79f9a9 100644 (file)
--- a/Recipe
+++ b/Recipe
@@ -102,8 +102,10 @@ FORCE:
 !begin gtk
 version.o: FORCE;
 FORCE:
-       if test -z "$(VER)" && md5sum -c manifest; then \
+       if test -z "$(VER)" && test -f manifest && md5sum -c manifest; then \
                $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) `cat version.def` -c version.c; \
+       elif test -z "$(VER)" && svnversion . >&/dev/null; then \
+               $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) "-DREVISION=`svnversion .`" -c version.c; \
        else \
                $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) $(VER) -c version.c; \
        fi
@@ -117,6 +119,8 @@ version.o: FORCE;
 FORCE:
        if test -z "$(VER)" && test -f manifest && (md5 -r `awk '{print $$2}' manifest` | diff -w manifest -); then \
                $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) `cat version.def` -c version.c; \
+       elif test -z "$(VER)" && svnversion . >&/dev/null; then \
+               $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) "-DREVISION=`svnversion .`" -c version.c; \
        else \
                $(CC) $(COMPAT) $(XFLAGS) $(CFLAGS) $(VER) -c version.c; \
        fi
diff --git a/mkunxarc.sh b/mkunxarc.sh
new file mode 100755 (executable)
index 0000000..8b6265b
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh 
+
+# Build a Unix source distribution from the Puzzles SVN area.
+#
+# Pass a numeric argument to have the archive tagged as that SVN
+# revision. Otherwise, the script will work it out itself by
+# calling `svnversion', or failing that it will not version-tag the
+# archive at all.
+
+case "$#" in
+  0)
+    # Ignore errors; if we can't get a version, we'll have a blank
+    # string.
+    rev=`svnversion . 2>/dev/null`
+    ;;
+  *)
+    case "$1" in *[!0-9]*) echo "Malformed revision number '$1'">&2;exit 1;;esac
+    rev="$1"
+    ;;
+esac
+
+if test "x$rev" != "x"; then
+  arcsuffix="-r$rev"
+  ver="-DREVISION=$rev"
+else
+  arcsuffix=
+  ver=
+fi
+
+perl mkfiles.pl
+make -s -f Makefile.doc
+
+arcname="puzzles$arcsuffix"
+mkdir uxarc
+mkdir uxarc/$arcname
+find . -name uxarc -prune -o \
+       -name CVS -prune -o \
+       -name '*.app' -prune -o \
+       -name '.[^.]*' -prune -o \
+       -name . -o \
+       -type d -exec mkdir uxarc/$arcname/{} \;
+find . -name uxarc -prune -o \
+       -name CVS -prune -o \
+       -name '.[^.]*' -prune -o \
+       -name '*.app' -prune -o \
+       -name '*.zip' -prune -o \
+       -name '*.tar.gz' -prune -o \
+       -type f -exec ln -s $PWD/{} uxarc/$arcname/{} \;
+if test "x$ver" != "x"; then
+  (cd uxarc/$arcname;
+   md5sum `find . -name '*.[ch]' -print` > manifest;
+   echo "$ver" > version.def)
+fi
+tar -C uxarc -chzof $arcname.tar.gz $arcname
+rm -rf uxarc