]> granicus.if.org Git - postgis/commitdiff
Force generation of an svnrevision.h file when building in a repo and the svn executa...
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 7 Feb 2012 23:27:57 +0000 (23:27 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 7 Feb 2012 23:27:57 +0000 (23:27 +0000)
Ensure that when building a tarball with make_dist.sh the revision is read from the tag in the remote svn repository.
This should cover both development and distribution cases.

git-svn-id: http://svn.osgeo.org/postgis/trunk@9079 b70326c6-7e19-0410-871a-916f4a2858ee

GNUmakefile.in
make_dist.sh
postgis/Makefile.in
utils/svn_repo_revision.pl [new file with mode: 0644]

index e91585af9c838ff4622cf64228221e82bb973bc1..217ff0af24de82d6c16a3f69fea72cc727ac0715 100644 (file)
@@ -7,6 +7,8 @@
 # todo: add all subdirs
 SUBDIRS = liblwgeom libpgcommon postgis regress @RASTER@ @TOPOLOGY@ loader utils @EXTENSIONS@  
 
+PERL = @PERL@
+
 # todo: add more rules here, like uninstall, clean...
 all install uninstall noop clean distclean check:
        for s in $(SUBDIRS); do \
@@ -17,6 +19,8 @@ all install uninstall noop clean distclean check:
                echo "PostGIS was built successfully. Ready to install."; \
        fi
 
+all: svnrevision.h
+
 install: all
 
 uninstall: docs-uninstall comments-uninstall
@@ -174,5 +178,9 @@ authors.git: authors.svn
 svnrebase: authors.git
        git svn rebase --authors-file authors.git
 
+svnrevision.h: .FORCE
+       $(PERL) utils/svn_repo_revision.pl
 
 .PHONY: utils liblwgeom ChangeLog.svn raster
+
+.FORCE:
index 8af9f4045628a2e2d099a75a652ba9a8b8a46dc0..ea920846c483cebb4e2c91b271ffd0dd93569bf4 100644 (file)
@@ -32,8 +32,8 @@ if [ -d "$outdir" ]; then
 fi
 
 echo "Exporting tag $tag"
-#cvs export -r "$tag" -d "$outdir" postgis 
-svn export "http://svn.osgeo.org/postgis/$tag" "$outdir"
+svnurl="http://svn.osgeo.org/postgis/$tag"
+svn export $svnurl "$outdir"
 if [ $? -gt 0 ]; then
        exit 1
 fi
@@ -48,6 +48,7 @@ rm -f "$outdir"/make_dist.sh "$outdir"/HOWTO_RELEASE
 echo "Running autogen.sh; ./configure"
 owd="$PWD"
 cd "$outdir"
+perl utils/svn_repo_revision.pl $svnurl
 ./autogen.sh
 ./configure
 #make
index dc383cbb91f8407ab48fe8d14a316002e59ad2e1..723f661748b71d097f8950944565ba61cfa0d34d 100644 (file)
@@ -113,7 +113,10 @@ endif
 #
 # Also they are all dependent on postgis_config.h
 #
-$(PG_OBJS): ../liblwgeom/.libs/liblwgeom.a ../libpgcommon/libpgcommon.a ../postgis_config.h
+$(PG_OBJS): ../liblwgeom/.libs/liblwgeom.a ../libpgcommon/libpgcommon.a ../postgis_config.h ../svnrevision.h
+
+../svnrevision.h:
+       $(MAKE) -C .. svnrevision.h
 
 # Borrow the $libdir substitution from PGXS but customise by adding the version number
 %.sql: %.sql.in
diff --git a/utils/svn_repo_revision.pl b/utils/svn_repo_revision.pl
new file mode 100644 (file)
index 0000000..b574dd7
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+
+use Cwd;
+my $cwd = &Cwd::cwd();
+
+my $svn_exe = `which svn`;
+
+my $target = "local";
+
+$target = $ARGV[0] if $ARGV[0];
+
+# Don't muck with things if you can't find svn
+exit(0) if ( ! $svn_exe );
+
+# Don't muck with thinks if you aren't in an svn repository
+if ( $target eq "local" && ! -d ".svn" ) {
+  exit(0);
+}
+
+# Read the svn revision number
+my $svn_info;
+if ( $target eq "local" ) {
+  $svn_info  = `svn info`;
+} else {
+  $svn_info  = `svn info $target`;
+}
+
+if ( $svn_info =~ /Last Changed Rev: (\d+)/ ) {
+  my $rev = $1;
+  open(OUT,">$cwd/svnrevision.h");
+  print OUT "#define SVNREV $rev\n";
+  close(OUT);
+}
+else {
+  die "Unable to find revision in svn info\n";
+}