From 06decfcd62d1ca9069cd4707115ecb92bea39064 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Tue, 6 Feb 2007 21:25:36 +0000 Subject: [PATCH] Detect the snapshot version number using darcs For non-release builds, we want to append a date to the version number (e.g. 6.7.20070206). Previously this was done by the nightly build script, this new method figures out the snapshot version by querying the darcs repository and finding the date of the most recent patch (actually it finds the most recent of the last 100 patches, but that should be good enough). This is done by the configure script. To handle source distributions, we create a file VERSION in the top-level directory that contains the version number, and ship this in the source distribution. The configure script picks up the version from this file if it doesn't see a _darcs directory. --- Makefile | 10 +++++++++- aclocal.m4 | 19 ++++++++++++++++++- configure.ac | 15 +++++++++++++-- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b8c1498..b03289b 100644 --- a/Makefile +++ b/Makefile @@ -66,6 +66,11 @@ endif SUBDIRS = $(SUBDIRS_NOLIB) libraries +VERSION : + echo $(ProjectVersion) >VERSION + +all :: VERSION + # Sanity check that all the core libraries are in the tree, to catch # failure to run darcs-all. check-packages : @@ -417,7 +422,7 @@ SRC_DIST_DIRS += mk docs distrib $(filter-out docs distrib,$(SUBDIRS)) SRC_DIST_FILES += \ configure.ac config.guess config.sub configure \ aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \ - ghc.spec.in + ghc.spec.in VERSION # ----------------------------------------------------------------------------- # Source distributions @@ -506,6 +511,9 @@ DIST_CLEAN_FILES += config.cache config.status mk/config.h mk/stamp-h \ # don't clean config.mk: it's needed when cleaning stuff later on LATE_DIST_CLEAN_FILES += mk/config.mk +# VERSION is shipped in a source dist +MAINTAINER_CLEAN_FILES += VERSION + extraclean:: $(RM) -rf autom4te.cache diff --git a/aclocal.m4 b/aclocal.m4 index 36c0128..87149a7 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -969,7 +969,24 @@ fi]) # FP_SETUP_PROJECT_VERSION # --------------------- AC_DEFUN([FP_SETUP_PROJECT_VERSION], -[# Some renamings +[ +if test "$RELEASE" = "NO"; then + AC_MSG_CHECKING([for GHC version date]) + if test -d _darcs; then + changequote(, )dnl + ver_date=`darcs changes --last=100 --xml | grep 'date=' | sed "s/^.*date='\([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\).*$/\1/g" | sort -n | tail -1` + changequote([, ])dnl + PACKAGE_VERSION=${PACKAGE_VERSION}.$ver_date + AC_MSG_RESULT($PACKAGE_VERSION) + elif test -f VERSION; then + PACKAGE_VERSION=`cat VERSION` + AC_MSG_RESULT($PACKAGE_VERSION) + else + AC_MSG_ERROR([no version found]) + fi +fi + +# Some renamings AC_SUBST([ProjectName], [$PACKAGE_NAME]) AC_SUBST([ProjectVersion], [$PACKAGE_VERSION]) diff --git a/configure.ac b/configure.ac index eb64f4e..a1a9861 100644 --- a/configure.ac +++ b/configure.ac @@ -3,9 +3,9 @@ dnl (run "grep '^dnl \*' configure.ac | sed -e 's/dnl / /g; s/\*\*/ +/g;'" dnl (or some such) to see the outline of this file) dnl # -# (c) The AQUA Project, Glasgow University, 1994-2004 +# (c) The University of Glasgow 1994-2004 # -# Configure script template for the Glasgow functional programming tools +# Configure script template for GHC # # Process with 'autoreconf' to get a working configure script. # @@ -15,6 +15,17 @@ dnl AC_INIT([The Glorious Glasgow Haskell Compilation System], [6.7], [glasgow-haskell-bugs@haskell.org], [ghc]) +# Set this to YES for a released version, otherwise NO +RELEASE=NO + +# The primary version (e.g. 6.7, 6.6.1) is set in the AC_INIT line +# above. If this is not a released version, then we will append the +# date to the version number (e.g. 6.7.20070204). The date is +# constructed by finding the date of the most recent patch in the +# darcs repository. If this is a source distribution (not a darcs +# checkout), then we ship a file 'VERSION' containing the full version +# when the source distribution was created. + if test ! -f mk/config.h.in; then echo "mk/config.h.in doesn't exist: perhaps you haven't run 'autoreconf'?" exit 1 -- 1.7.10.4