Re: Module dependency on PostgeSQL version - Mailing list pgsql-hackers

From Thomas Hallgren
Subject Re: Module dependency on PostgeSQL version
Date
Msg-id c7rjbh$2p2i$1@news.hub.org
Whole thread Raw
In response to Re: Module dependency on PostgeSQL version  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
> Thomas Hallgren <thhal@mailblocks.com> writes:
> 
>>The PGSQL_MAJOR_VER and PGSQL_MINOR_VER does not exist today. Ideally, 
>>I'd like to find them in src/Makefile.global. Only thing present seems 
>>to be the VERSION. I'd like to see something like:
> 
> 
>>PGSQL_MAJOR_VER := 7
>>PGSQL_MINOR_VER := 5
>>PGSQL_PATCH_VER := devel
>>VERSION := $(PGSQL_MAJOR_VER).$(PGSQL_MINOR_VER).$(PGSQL_PATCH_VER)
> 
> 
>>To be used in CPPFLAGS as: -DPGSQL_MAJOR_VER=$(PGSQL_MAJOR_VER) etc.
> 
> 
> Wouldn't it be better to just put those #defines in to begin with,
> rather than requiring people to hack on their CPPFLAGS?  I don't offhand
> see much need for knowing the PG version at the Makefile level, but I
> do see the usefulness at the C-code level.
> 
> I think Joe Conway is already doing something like this for pl/r ...
> leastwise he's shown bits of #ifdef'd code in past email.  It would
> be interesting to see the details of his solution.
> 
>             regards, tom lane
> 
If the PostgreSQL source distribution had #defines residing in 
postgres.h or similar, that would certanly do the trick for me. Until 
they arrive I'll use the following (somewhat backward) solution to the 
problem. My makefile now contains the following and it seems to do the job:

include $(PGSQLDIR)/src/Makefile.global

# Substitute dot for whitespace so that we can pick
# the individual parts later on with the $(word,...)
#
SS_VERSION := $(subst ., ,$(subst devel,.devel,$(VERSION)))

# Pass major, minor, and patch to the preprocessor
#
override CPPFLAGS := \-DPKGLIBDIR=\"$(pkglibdir)\" -I$(INCLDIR) \-DPGSQL_MAJOR_VER=$(word 1,$(SS_VERSION))
\-DPGSQL_MINOR_VER=$(word2,$(SS_VERSION)) \-DPGSQL_PATCH_VER=$(word 3,$(SS_VERSION)) \$(CPPFLAGS)
 

The PGSQLDIR points to the PostgreSQL source distribution. The reason 
for the two level €(subst...) command is that you currently use 7.5devel 
as the VERSION, i.e. no '.' between minor and patch. IMHO, 7.5.devel 
would be more consistent.

Regards,

Thomas Hallgren



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Probably security hole in postgresql-7.4.1
Next
From: Tom Lane
Date:
Subject: Re: XLog: how to log?