doc: Flesh out extension docs for the "prefix" make variable master github/master
authorPeter Eisentraut <peter@eisentraut.org>
Thu, 1 May 2025 20:10:36 +0000 (22:10 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Thu, 1 May 2025 20:23:52 +0000 (22:23 +0200)
The variable is a bit magical in how it requires "postgresql" or
"pgsql" to be part of the path, and files end up in its "share" and
"lib" subdirectories.  So mention all that and show an example of
setting "extension_control_path" and "dynamic_library_path" to use
those locations.

Author: David E. Wheeler <david@justatheory.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Christoph Berg <myon@debian.org>
Discussion: https://www.postgresql.org/message-id/6B5BF07B-8A21-48E3-858C-1DC22F3A28B4@justatheory.com

doc/src/sgml/extend.sgml

index 64f8e133caeb3a39e711794a085be2571bc71574..4915c1985e0b73957d31596ed5f55ab18d4409ef 100644 (file)
@@ -1809,10 +1809,36 @@ include $(PGXS)
     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.
-    You can also select a separate installation directory for your extension
-    by setting the <literal>make</literal> variable <varname>prefix</varname>
-    on the <literal>make</literal> command line.  (But this will then require
-    additional setup to get the server to find the extension there.)
+   </para>
+
+   <para>
+    You can select a separate directory prefix in which to install your
+    extension's files, by setting the <command>make</command> variable
+    <varname>prefix</varname> when executing <literal>make install</literal>
+    like so:
+<programlisting>
+make install prefix=/usr/local/postgresql
+</programlisting>
+    This will install the extension control and SQL files into
+    <filename>/usr/local/postgresql/share</filename> and the shared modules into
+    <filename>/usr/local/postgresql/lib</filename>.  If the prefix does not
+    include the strings <literal>postgres</literal> or
+    <literal>pgsql</literal>, such as
+<programlisting>
+make install prefix=/usr/local/extras
+</programlisting>
+    then <literal>postgresql</literal> will be appended to the directory
+    names, installing the control and SQL files into
+    <filename>/usr/local/extras/share/postgresql/extension</filename> and the
+    shared modules into <filename>/usr/local/extras/lib/postgresql</filename>.
+    Either way, you'll need to set <xref
+    linkend="guc-extension-control-path"/> and <xref
+    linkend="guc-dynamic-library-path"/> to enable the
+    <productname>PostgreSQL</productname> server to find the files:
+<programlisting>
+extension_control_path = '/usr/local/extras/share/postgresql/extension:$system'
+dynamic_library_path = '/usr/local/extras/lib/postgresql:$libdir'
+</programlisting>
    </para>
 
    <para>