From: Paul Ramsey Date: Tue, 7 Feb 2012 23:27:57 +0000 (+0000) Subject: Force generation of an svnrevision.h file when building in a repo and the svn executa... X-Git-Tag: 2.0.0alpha4~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1de0d3d8ae55b3ccf1b73151ed4b8e668d17ce12;p=postgis Force generation of an svnrevision.h file when building in a repo and the svn executable is available. 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 --- diff --git a/GNUmakefile.in b/GNUmakefile.in index e91585af9..217ff0af2 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -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: diff --git a/make_dist.sh b/make_dist.sh index 8af9f4045..ea920846c 100644 --- a/make_dist.sh +++ b/make_dist.sh @@ -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 diff --git a/postgis/Makefile.in b/postgis/Makefile.in index dc383cbb9..723f66174 100644 --- a/postgis/Makefile.in +++ b/postgis/Makefile.in @@ -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 index 000000000..b574dd7a5 --- /dev/null +++ b/utils/svn_repo_revision.pl @@ -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"; +}