pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Should contrib modules install .h files?
Date: Wed, 01 Aug 2018 00:33:11 +0100
Message-ID: <87d0v3atbm.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <86036c67-d76f-3dc0-a9f5-69e776b4ecc5@2ndquadrant.com>
References: <87y3euomjh.fsf@news-spur.riddles.org.uk>
	<ee05ea4c-3d5b-0ec6-8daa-3ec66f021076@2ndquadrant.com>
	<87tvpinfr4.fsf@news-spur.riddles.org.uk>
	<63444.1530537990@sss.pgh.pa.us>
	<87lgatohzp.fsf@news-spur.riddles.org.uk>
	<63655.1530540982@sss.pgh.pa.us>
	<87h8lhoevw.fsf@news-spur.riddles.org.uk>
	<63819.1530544945@sss.pgh.pa.us>
	<878t6to8j9.fsf@news-spur.riddles.org.uk>
	<874lhho071.fsf@news-spur.riddles.org.uk>
	<67427.1530738056@sss.pgh.pa.us>
	<87po02m0bh.fsf@news-spur.riddles.org.uk>
	<87in5tnafh.fsf@news-spur.riddles.org.uk>
	<87efghn7js.fsf@news-spur.riddles.org.uk>
	<87a7r5n4n2.fsf@news-spur.riddles.org.uk>
	<87o9enb4h7.fsf@news-spur.riddles.org.uk>
	<86036c67-d76f-3dc0-a9f5-69e776b4ecc5@2ndquadrant.com>

>>>>> "Peter" == Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:

 >> A review of contrib/ suggested that cube, hstore, isn, ltree and seg
 >> were the only modules that had useful headers to install, so do
 >> those.

 Peter> I'm missing some guidance what an extension using those headers
 Peter> is supposed to do. How does it get the right -I options?

All of the below assumes PGXS.

If your extension is relying on pg11+, or you have checked the pg
version when constructing the makefile, you can just do:

PG_CPPFLAGS += -I$(includedir_server)/extension/hstore

and #include "hstore.h" will work.

If you need to workaround for old versions in one makefile, as I do,
then you can do something along these lines (this goes before the
include $(PGXS) line):

# MAJORVERSION and includedir_server are not defined yet, but will be
# defined before PG_CPPFLAGS is expanded. So we use conditional
# expansions rather than 'ifeq' syntax.

# for pg11+, hstore.h will be installed here
HSTORE_INCDIR = $(includedir_server)/extension/hstore

# for pg 9.5/9.6/10, we have a local copy of hstore.h since it happens
# to be the same, barring non-semantic whitespace, between the three
# versions
HSTORE_INCDIR_OLD = old_inc

PG_CPPFLAGS += -I$(HSTORE_INCDIR$(if $(filter 9.% 10,$(MAJORVERSION)),_OLD))

If you need to distinguish more versions for whatever reason you can do
this:

HSTORE_INCDIR = $(includedir_server)/extension/hstore
HSTORE_INCDIR_10 =  whatever
HSTORE_INCDIR_9.6 = whatever
HSTORE_INCDIR_9.5 = whatever
HSTORE_INCDIR_9.4 = whatever
HSTORE_INCDIR_9.3 = whatever
PG_CPPFLAGS += -I$(HSTORE_INCDIR$(if $(filter 9.% 10,$(MAJORVERSION)),_$(MAJORVERSION)))

-- 
Andrew (irc:RhodiumToad)




view thread (81+ messages)  latest in thread

Message-ID: <87d0v3atbm.fsf@news-spur.riddles.org.uk>
Permalink:  ../87d0v3atbm.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87d0v3atbm.fsf@news-spur.riddles.org.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, peter.eisentraut@2ndquadrant.com
  Subject: Re: Should contrib modules install .h files?
  In-Reply-To: <87d0v3atbm.fsf@news-spur.riddles.org.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox