Gitweb:
http://git.exim.org/exim.git/commitdiff/5901f0abfe16545a81e820cd9816e830287776a7
Commit: 5901f0abfe16545a81e820cd9816e830287776a7
Parent: 74fc64f2283f197ce744cc8c786f26bd8b16d323
Author: Tony Finch <dot@???>
AuthorDate: Thu Jun 30 20:03:17 2011 +0100
Committer: Tony Finch <dot@???>
CommitDate: Thu Jun 30 20:39:52 2011 +0100
Use git to automatically create version.h
Adapted from git itself via unifdef. This does not (yet) include
the equivalent automation for the doc build.
---
doc/doc-txt/ChangeLog | 3 +
release-process/scripts/mk_exim_release.pl | 49 +++++++---------------
src/OS/Makefile-Base | 23 +++++-----
src/scripts/MakeLinks | 5 --
src/scripts/reversion | 61 ++++++++++++++++++++++++++++
src/src/version.h | 15 -------
6 files changed, 91 insertions(+), 65 deletions(-)
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index cba3385..2db30fe 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -85,6 +85,9 @@ TF/05 Removed obsolete $Cambridge$ CVS revision strings.
TF/06 Removed a few PCRE remnants.
+TF/07 Automatically extract Exim's version number from tags in the git
+ repository when doing development or release builds.
+
Exim version 4.76
-----------------
diff --git a/release-process/scripts/mk_exim_release.pl b/release-process/scripts/mk_exim_release.pl
index 64fbb56..4bad07a 100755
--- a/release-process/scripts/mk_exim_release.pl
+++ b/release-process/scripts/mk_exim_release.pl
@@ -72,7 +72,7 @@ sub deal_with_working_directory {
mkpath( $context->{directory}, { verbose => ( $verbose || $debug ) } );
# set and create subdirectories
- foreach (qw(release_tree pkgs pkgdirs docbook)) {
+ foreach (qw(release_tree pkgs pkgdirs docbook tmp)) {
$context->{$_} = File::Spec->catdir( $context->{directory}, $_ );
mkpath( $context->{$_}, { verbose => ( $verbose || $debug ) } );
}
@@ -84,7 +84,7 @@ sub export_git_tree {
my $context = shift;
# build git command
- my $archive_file = sprintf( '%s/%s-%s.tar', $context->{tmp_dir}, $context->{pkgname}, $context->{release} );
+ my $archive_file = sprintf( '%s/%s-%s.tar', $context->{tmp}, $context->{pkgname}, $context->{release} );
$context->{tmp_archive_file} = $archive_file;
my @cmd = ( 'git', 'archive', '--format=tar', "--output=$archive_file", $context->{tag} );
@@ -108,7 +108,7 @@ sub unpack_tree {
# ------------------------------------------------------------------
-sub adjust_version_extension {
+sub make_version_script {
my $context = shift;
return if ($context->{release} eq $context->{trelease});
@@ -117,41 +117,22 @@ sub adjust_version_extension {
if ( $context->{release} ne $context->{trelease} . $variant ) {
die "Broken version numbering, I'm buggy";
}
-
+
my $srcdir = File::Spec->catdir( $context->{release_tree}, 'src', 'src' );
- my $version_h = File::Spec->catfile( $srcdir, 'version.h' );
-
- my $fh = new IO::File $version_h, 'r';
- die "Cannot read version.h: $!\n" unless ( defined $fh );
- my @lines = <$fh>;
- $fh->close() or die "Failed to close-read($version_h): $!\n";
-
- my $found = 0;
- my $i;
- for ( $i = 0 ; $i < @lines ; ++$i ) {
- if ( $lines[$i] =~ /EXIM_VARIANT_VERSION/ ) {
- $found = 1;
- last;
- }
- }
- die "Cannot find version.h EXIM_VARIANT_VERSION\n" unless $found;
- unless ( $lines[$i] =~ m/^\s* \# \s* define \s+ EXIM_VARIANT_VERSION \s+ "(.*)" \s* $/x ) {
- die "Broken version.h EXIM_VARIANT_VERSION line\n";
- }
- if ( length $1 ) {
- print( "WARNING: version.h has a variant tag already defined: $1\n" );
- print( " not changing that tag\n" );
+ chdir $srcdir or die "chdir $srcdir: $\n";
+
+ if ( -f "version.sh" ) {
+ print( "WARNING: version.sh already exists - leaving it in place\n" );
return;
}
- $lines[$i] = qq{#define EXIM_VARIANT_VERSION\t\t"$variant"\n};
- # deliberately not verbose constrained:
- print( "Adjusting version.h for $variant release.\n" );
+ my @cmd = ("../scripts/reversion", "release");
+ print( "Running: ", join( ' ', @cmd ), "\n" ) if ($verbose);
+ system(@cmd) == 0 || croak "reversion failed";
+
+ unlink "version.h";
- $fh = new IO::File $version_h, "w";
- die "Cannot write version.h: $!\n" unless ( defined $fh );
- $fh->print( @lines );
- $fh->close() or die "Failed to close-write($version_h): $!\n";
+ -f "version.sh" or die "failed to create version.h";
}
# ------------------------------------------------------------------
@@ -366,7 +347,7 @@ sub create_tar_files {
export_git_tree($context);
chdir( $context->{directory} ) || die;
unpack_tree($context);
- adjust_version_extension($context);
+ make_version_script($context);
build_documentation($context);
build_package_directories($context);
create_tar_files($context);
diff --git a/src/OS/Makefile-Base b/src/OS/Makefile-Base
index cb2359f..9723c60 100644
--- a/src/OS/Makefile-Base
+++ b/src/OS/Makefile-Base
@@ -32,7 +32,7 @@ FE = $(FULLECHO)
# up-to-date. Then the os-specific source files and the C configuration file
# are set up, and finally it goes to the main Exim target.
-all: $(EDITME) checklocalmake Makefile os.h os.c config.h allexim
+all: $(EDITME) checklocalmake Makefile os.h os.c config.h version.h allexim
checklocalmake:
@if $(SHELL) $(SCRIPTS)/newer $(EDITME)-$(OSTYPE) $(EDITME) || \
@@ -317,13 +317,7 @@ OBJ_EXIM = acl.o child.o crypt16.o daemon.o dbfn.o debug.o deliver.o \
exim: lookups/lookups.a auths/auths.a pdkim/pdkim.a \
routers/routers.a transports/transports.a \
- $(OBJ_EXIM) version.c
- @echo " "
- awk '{ print ($$1+1) }' cnumber.h > cnumber.temp
- rm -f cnumber.h; mv cnumber.temp cnumber.h
- @echo "$(CC) version.c"
- $(FE)$(CC) -c $(CFLAGS) $(INCLUDE) $(IPV6_INCLUDE) $(TLS_INCLUDE) version.c
- rm -f exim
+ $(OBJ_EXIM) version.o
@echo "$(LNCC) -o exim"
$(FE)$(PURIFY) $(LNCC) -o exim $(LFLAGS) $(OBJ_EXIM) version.o \
routers/routers.a transports/transports.a lookups/lookups.a \
@@ -459,6 +453,13 @@ PHDRS = ../config.h ../dbfunctions.h ../dbstuff.h ../exim.h ../functions.h ../gl
.c.o:; @echo "$(CC) $*.c"
$(FE)$(CC) -c $(CFLAGS) -I. $(INCLUDE) $(IPV6_INCLUDE) $(TLS_INCLUDE) $*.c
+# Update Exim's version information and build the version object.
+
+version.h::
+ @../scripts/reversion
+
+version.o: $(HDRS) cnumber.h version.h version.c
+
# This is the dummy module for use by test compiles of individual modules. It
# contains functions such as log_write() that may be called from bits of Exim
# in the tested code.
@@ -637,10 +638,10 @@ $(MONBIN): $(HDRS)
# The lookups library.
-buildlookups lookups/lookups.a: config.h
+buildlookups lookups/lookups.a: config.h version.h
@cd lookups; $(MAKE) SHELL=$(SHELL) AR="$(AR)" $(MFLAGS) CC="$(CC)" CFLAGS="$(CFLAGS)" \
- CFLAGS_DYNAMIC="$(CFLAGS_DYNAMIC)" \
- FE="$(FE)" RANLIB="$(RANLIB)" RM_COMMAND="$(RM_COMMAND)" HDRS="$(PHDRS)" \
+ CFLAGS_DYNAMIC="$(CFLAGS_DYNAMIC)" HDRS="../version.h $(PHDRS)" \
+ FE="$(FE)" RANLIB="$(RANLIB)" RM_COMMAND="$(RM_COMMAND)" \
INCLUDE="$(INCLUDE) $(IPV6_INCLUDE) $(TLS_INCLUDE) $(LOOKUP_INCLUDE)"; \
echo " "
diff --git a/src/scripts/MakeLinks b/src/scripts/MakeLinks
index a4ab31c..082659c 100755
--- a/src/scripts/MakeLinks
+++ b/src/scripts/MakeLinks
@@ -16,10 +16,6 @@ if [ -r pcre/Makefile ] ; then
fi
-# Initialize the file holding the compile number
-
-echo "0" > cnumber.h
-
echo ""
echo ">>> Creating links to source files..."
@@ -183,7 +179,6 @@ ln -s ../src/osfunctions.h osfunctions.h
ln -s ../src/store.h store.h
ln -s ../src/structs.h structs.h
ln -s ../src/lookupapi.h lookupapi.h
-ln -s ../src/version.h version.h
ln -s ../src/acl.c acl.c
ln -s ../src/buildconfig.c buildconfig.c
diff --git a/src/scripts/reversion b/src/scripts/reversion
new file mode 100755
index 0000000..7bc56f6
--- /dev/null
+++ b/src/scripts/reversion
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+# Update Exim's version header file.
+
+# Read version information that was generated by a previous run of
+# this script, or during the release process.
+
+if [ -f version.sh ]
+then . version.sh
+elif [ -f ../src/version.sh ]
+then . ../src/version.sh
+fi
+
+# If this tree is a git working directory, use that to get version information.
+
+if [ -e ../../.git ] || [ "$1" = "release" ]
+then
+ # Modify the output of git describe into separate parts for
+ # the name "exim" and the release and variant versions.
+ # Put a dot in the version number and remove a spurious g.
+ set $(git describe --dirty=-XX --match 'exim-4*' |
+ sed 's|-| |;s|_|.|;s|[-_]| _|;s|-g|-|')
+ # Only update if we need to
+ if [ "$2 $3" != "$EXIM_RELEASE_VERSION $EXIM_VARIANT_VERSION" ]
+ then
+ EXIM_RELEASE_VERSION="$2"
+ EXIM_VARIANT_VERSION="$3"
+ rm -f version.h
+ fi
+fi
+
+# If you are maintaining a patched version of Exim, you can either
+# create your own version.sh as part of your release process, or you
+# can modify EXIM_VARIANT_VERSION at this point in this script.
+
+case $EXIM_RELEASE_VERSION in
+'') echo "*** Your copy of Exim lacks any version information."
+ exit 1
+esac
+
+EXIM_COMPILE_NUMBER=$(expr "${EXIM_COMPILE_NUMBER:-0}" + 1)
+
+echo "$EXIM_COMPILE_NUMBER" >cnumber.h
+
+( echo '# automatically generated file - see ../scripts/reversion'
+ echo EXIM_RELEASE_VERSION='"'"$EXIM_RELEASE_VERSION"'"'
+ echo EXIM_VARIANT_VERSION='"'"$EXIM_VARIANT_VERSION"'"'
+ echo EXIM_COMPILE_NUMBER='"'"$EXIM_COMPILE_NUMBER"'"'
+) >version.sh
+
+if [ ! -f version.h ]
+then
+( echo '/* automatically generated file - see ../scripts/reversion */'
+ echo '#define EXIM_RELEASE_VERSION "'"$EXIM_RELEASE_VERSION"'"'
+ echo '#define EXIM_VARIANT_VERSION "'"$EXIM_VARIANT_VERSION"'"'
+ echo '#define EXIM_VERSION_STR EXIM_RELEASE_VERSION EXIM_VARIANT_VERSION'
+) >version.h
+fi
+
+echo ">>> version $EXIM_RELEASE_VERSION$EXIM_VARIANT_VERSION #$EXIM_COMPILE_NUMBER"
+echo
diff --git a/src/src/version.h b/src/src/version.h
deleted file mode 100644
index 6c1cc55..0000000
--- a/src/src/version.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*************************************************
-* Exim - an Internet mail transport agent *
-*************************************************/
-
-/* Copyright (c) Google, Inc. 2010 */
-/* See the file NOTICE for conditions of use and distribution. */
-
-/* This is bumped by the Exim Maintainers, the release engineer: */
-#define EXIM_RELEASE_VERSION_STR "4.76"
-/* If you apply extensive local patches, consider putting -foo into here */
-#define EXIM_VARIANT_VERSION ""
-
-#define EXIM_VERSION_STR EXIM_RELEASE_VERSION_STR EXIM_VARIANT_VERSION
-
-/* End of version.h */