Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fke8t-0005wt-Qd for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Jul 2018 23:33:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fke8o-0001Mq-GO for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Jul 2018 23:33:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fke8o-0001Mj-9Y for pgsql-hackers@lists.postgresql.org; Tue, 31 Jul 2018 23:33:22 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fke8h-0003gN-4Q for pgsql-hackers@postgresql.org; Tue, 31 Jul 2018 23:33:21 +0000 Received: from [192.168.127.1] (port=59402 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1fke8e-0001UW-Bx; Tue, 31 Jul 2018 23:33:12 +0000 Received: from [127.0.0.1] (port=38031 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1fke8d-000ILy-JE; Tue, 31 Jul 2018 23:33:11 +0000 From: Andrew Gierth To: Peter Eisentraut Cc: pgsql-hackers@postgresql.org Subject: Re: Should contrib modules install .h files? In-Reply-To: <86036c67-d76f-3dc0-a9f5-69e776b4ecc5@2ndquadrant.com> (Peter Eisentraut's message of "Wed, 1 Aug 2018 00:40:25 +0200") Message-ID: <87d0v3atbm.fsf@news-spur.riddles.org.uk> References: <87y3euomjh.fsf@news-spur.riddles.org.uk> <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> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Wed, 01 Aug 2018 00:33:11 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Peter" == Peter Eisentraut 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)