echo "PostGIS was built successfully. Ready to install."; \
fi
-all:
+all: postgis_svn_revision.h
install: all
svnrebase: authors.git
git svn rebase --authors-file authors.git
+postgis_svn_revision.h: .FORCE
+ $(PERL) utils/svn_repo_revision.pl
+
.PHONY: utils liblwgeom ChangeLog.svn raster
.FORCE:
Datum postgis_scripts_released(PG_FUNCTION_ARGS);
Datum postgis_version(PG_FUNCTION_ARGS);
Datum postgis_lib_version(PG_FUNCTION_ARGS);
+Datum postgis_svn_version(PG_FUNCTION_ARGS);
Datum postgis_libxml_version(PG_FUNCTION_ARGS);
Datum postgis_lib_build_date(PG_FUNCTION_ARGS);
Datum LWGEOM_length2d_linestring(PG_FUNCTION_ARGS);
PG_RETURN_TEXT_P(result);
}
+PG_FUNCTION_INFO_V1(postgis_svn_version);
+Datum postgis_svn_version(PG_FUNCTION_ARGS)
+{
+ static int rev = POSTGIS_SVN_REVISION;
+ char ver[32];
+ if ( rev > 0 )
+ {
+ snprintf(ver, 32, "%d", rev);
+ PG_RETURN_TEXT_P(cstring2text(ver));
+ }
+ else
+ PG_RETURN_NULL();
+}
+
PG_FUNCTION_INFO_V1(postgis_lib_build_date);
Datum postgis_lib_build_date(PG_FUNCTION_ARGS)
{
AS 'MODULE_PATHNAME'\r
LANGUAGE 'C' IMMUTABLE;\r
\r
+CREATE OR REPLACE FUNCTION postgis_svn_version() RETURNS text\r
+ AS 'MODULE_PATHNAME'\r
+ LANGUAGE 'C' IMMUTABLE;\r
+\r
CREATE OR REPLACE FUNCTION postgis_libxml_version() RETURNS text\r
AS 'MODULE_PATHNAME'\r
LANGUAGE 'C' IMMUTABLE;\r
SELECT postgis_uses_stats() INTO usestats;\r
SELECT postgis_scripts_installed() INTO dbproc;\r
SELECT postgis_scripts_released() INTO relproc;\r
+ select postgis_svn_version() INTO svnver;\r
\r
fullver = 'POSTGIS="' || libver || '"';\r
\r
IF libxmlver IS NOT NULL THEN\r
fullver = fullver || ' LIBXML="' || libxmlver || '"';\r
END IF;\r
+\r
+ IF svnver IS NOT NULL THEN\r
+ fullver = fullver || ' SVN_REVISION=' || svnver;\r
+ END IF;\r
\r
IF usestats THEN\r
fullver = fullver || ' USE_STATS';\r
/* postgis_config.h.in. Generated from configure.ac by autoheader. */
+#include "postgis_svn_revision.h"
+
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
use Cwd;
my $cwd = &Cwd::cwd();
-my $svn_exe = `which svn`;
+my $svn_exe = `which svnn`;
-my $target = "local";
+my $svn_revision = 0;
+my $defn_string = $defn_string_start . $svn_revision;
+my $rev_file = "postgis_svn_revision.h";
$target = $ARGV[0] if $ARGV[0];
# Don't muck with things if you can't find svn
if ( ! $svn_exe ) {
- if ( ! -f "svnrevision.h" ) {
- die "Couldn't find svn exectable or svnrevision.h, cannot continue.\n";
+ if ( ! -f $rev_file ) {
+ &write_defn(0);
+ exit(0);
}
else {
exit(0);
}
};
-# Don't muck with thinks if you aren't in an svn repository
+# Don't muck with things if you aren't in an svn repository
if ( $target eq "local" && ! -d ".svn" ) {
- if ( ! -f "svnrevision.h" ) {
- die "Couldn't find or generate svnrevision.h, cannot continue.\n";
+ if ( ! -f $rev_file ) {
+ &write_defn(0);
+ exit(0);
}
else {
exit(0);
}
if ( $svn_info =~ /Last Changed Rev: (\d+)/ ) {
- my $rev = $1;
- open(OUT,">$cwd/svnrevision.h");
- print OUT "#define SVNREV $rev\n";
- close(OUT);
+ &write_defn($1);
}
else {
- die "Unable to find revision in svn info\n";
+ if ( ! -f $rev_file ) {
+ &write_defn(0);
+ exit(0);
+ }
+ else {
+ exit(0);
+ }
+}
+
+sub write_defn {
+ my $rev = shift;
+ my $string = "#define POSTGIS_SVN_REVISION $rev\n";
+ open(OUT,">$rev_file");
+ print OUT $string;
+ close(OUT);
}