On Wed, Mar 25, 2015 at 8:26 AM, Tom Lane <t...@sss.pgh.pa.us> wrote:
> Hm.  We're all agreed that there's a use case for exposing PG_VERSION_NUM
> to the makefiles, but I did not hear one for adding it to pg_config; and
> doing the former takes about two lines whereas adding a pg_config option
> entails quite a lot of overhead (documentation, translatable help text,
> yadda yadda).  So I'm not in favor of doing the latter without a much
> more solid case than has been made.

Well, I have no other cases than ones of the type mentioned upthread,
and honestly I am fine as long as we do not apply maths to a version
string. So attached is a patch that adds VERSION_NUM in
Makefile.global.
Regards,
-- 
Michael
diff --git a/configure b/configure
index 2c9b3a7..e5be6c7 100755
--- a/configure
+++ b/configure
@@ -627,6 +627,7 @@ ac_includes_default="\
 
 ac_subst_vars='LTLIBOBJS
 vpath_build
+PG_VERSION_NUM
 PROVE
 OSX
 XSLTPROC
@@ -15180,6 +15181,7 @@ PG_VERSION_NUM="`echo "$PACKAGE_VERSION" | sed 's/[A-Za-z].*$//' |
 tr '.' '	' |
 $AWK '{printf "%d%02d%02d", $1, $2, (NF >= 3) ? $3 : 0}'`"
 
+
 cat >>confdefs.h <<_ACEOF
 #define PG_VERSION_NUM $PG_VERSION_NUM
 _ACEOF
diff --git a/configure.in b/configure.in
index b2c1ce7..c27adc1 100644
--- a/configure.in
+++ b/configure.in
@@ -1984,6 +1984,7 @@ AC_DEFINE_UNQUOTED(PG_VERSION_STR,
 [PG_VERSION_NUM="`echo "$PACKAGE_VERSION" | sed 's/[A-Za-z].*$//' |
 tr '.' '	' |
 $AWK '{printf "%d%02d%02d", $1, $2, (NF >= 3) ? $3 : 0}'`"]
+AC_SUBST(PG_VERSION_NUM)
 AC_DEFINE_UNQUOTED(PG_VERSION_NUM, $PG_VERSION_NUM, [PostgreSQL version as a number])
 
 
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 7c39d82..659abc5 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -38,6 +38,7 @@ all:
 # PostgreSQL version number
 VERSION = @PACKAGE_VERSION@
 MAJORVERSION = @PG_MAJORVERSION@
+VERSION_NUM = @PG_VERSION_NUM@
 
 # Support for VPATH builds
 # (PGXS VPATH support is handled separately in pgxs.mk)
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to