Skip site navigation (1) Skip section navigation (2)

Re: Frustrating issue with PGXS

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Eddie Stanley <eddiewould(at)paradise(dot)net(dot)nz>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>, mux(at)elvis(dot)mu(dot)org
Subject: Re: Frustrating issue with PGXS
Date: 2007-06-26 22:10:11
Message-ID: 273.1182895811@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> writes:
> Some documentation (not just code) update seems important to me.

Agreed.  I added this to xfunc.sgml's discussion of PGXS makefiles:

Index: doc/src/sgml/xfunc.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v
retrieving revision 1.128
diff -c -r1.128 xfunc.sgml
*** doc/src/sgml/xfunc.sgml	6 Jun 2007 23:00:36 -0000	1.128
--- doc/src/sgml/xfunc.sgml	26 Jun 2007 21:57:43 -0000
***************
*** 2071,2080 ****
  DATA_built = isbn_issn.sql
  DOCS = README.isbn_issn
  
! PGXS := $(shell pg_config --pgxs)
  include $(PGXS)
  </programlisting>
!     The last two lines should always be the same.  Earlier in the
      file, you assign variables or add custom
      <application>make</application> rules.
     </para>
--- 2071,2081 ----
  DATA_built = isbn_issn.sql
  DOCS = README.isbn_issn
  
! PG_CONFIG = pg_config
! PGXS := $(shell $(PG_CONFIG) --pgxs)
  include $(PGXS)
  </programlisting>
!     The last three lines should always be the same.  Earlier in the
      file, you assign variables or add custom
      <application>make</application> rules.
     </para>
***************
*** 2215,2220 ****
--- 2216,2233 ----
         </para>
        </listitem>
       </varlistentry>
+ 
+      <varlistentry>
+       <term><varname>PG_CONFIG</varname></term>
+       <listitem>
+        <para>
+         path to <application>pg_config</> program for the
+         <productname>PostgreSQL</productname> installation to build against
+         (typically just <literal>pg_config</> to use the first one in your
+         <varname>PATH</>)
+        </para>
+       </listitem>
+      </varlistentry>
      </variablelist>
     </para>
  
***************
*** 2222,2234 ****
      Put this makefile as <literal>Makefile</literal> in the directory
      which holds your extension. Then you can do
      <literal>make</literal> to compile, and later <literal>make
!     install</literal> to install your module.  The extension is
      compiled and installed for the
      <productname>PostgreSQL</productname> installation that
!     corresponds to the first <command>pg_config</command> command
!     found in your path.
     </para>
  
     <para>
      The scripts listed in the <varname>REGRESS</> variable are used for
      regression testing of your module, just like <literal>make
--- 2235,2260 ----
      Put this makefile as <literal>Makefile</literal> in the directory
      which holds your extension. Then you can do
      <literal>make</literal> to compile, and later <literal>make
!     install</literal> to install your module.  By default, the extension is
      compiled and installed for the
      <productname>PostgreSQL</productname> installation that
!     corresponds to the first <command>pg_config</command> program
!     found in your path.  You can use a different installation by
!     setting <varname>PG_CONFIG</varname> to point to its
!     <command>pg_config</command> program, either within the makefile
!     or on the <literal>make</literal> command line.
     </para>
  
+    <caution>
+     <para>
+      Changing <varname>PG_CONFIG</varname> only works when building
+      against <productname>PostgreSQL</productname> 8.3 or later.
+      With older releases it does not work to set it to anything except
+      <literal>pg_config</>; you must alter your <varname>PATH</>
+      to select the installation to build against.
+     </para>
+    </caution>
+ 
     <para>
      The scripts listed in the <varname>REGRESS</> variable are used for
      regression testing of your module, just like <literal>make


It might be worth backpatching the Makefile.global.in patch (ie, the
ifndef addition) to the 8.2 branch, which would allow us to say "8.2.5
or later" instead of "8.3 or later", and would bring correspondingly
nearer the time when people can actually use the feature without
thinking much.  Comments?

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Andrew DunstanDate: 2007-06-26 22:17:28
Subject: Re: Bugtraq: Having Fun With PostgreSQL
Previous:From: Tom LaneDate: 2007-06-26 22:05:04
Subject: pgsql: Fix PGXS conventions so that extensions can be built against

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group