Re: Module dependency on PostgeSQL version

From: Thomas Hallgren <thhal(at)mailblocks(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Module dependency on PostgeSQL version
Date: 2004-05-11 22:16:20
Message-ID: c7rjbh$2p2i$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Thomas Hallgren <thhal(at)mailblocks(dot)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=$(word 2,$(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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-05-11 22:19:12 Re: XLog: how to log?
Previous Message Bruce Momjian 2004-05-11 22:13:27 Re: Probably security hole in postgresql-7.4.1