Home Explore Blog CI



postgresql

27th chunk of `doc/src/sgml/extend.sgml`
33555289339a2d3bc8c350eb9e875408149919c1043fd7c80000000100000b78
   </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:$system'
dynamic_library_path = '/usr/local/extras/lib/postgresql:$libdir'
</programlisting>
   </para>

   <para>
    You can also run <literal>make</literal> in a directory outside the source
    tree of your extension, if you want to keep the build directory separate.
    This procedure is also called a
    <indexterm><primary>VPATH</primary></indexterm><firstterm>VPATH</firstterm>
    build.  Here's how:
<programlisting>
mkdir build_dir
cd build_dir
make -f /path/to/extension/source/tree/Makefile
make -f /path/to/extension/source/tree/Makefile install
</programlisting>
   </para>

   <para>
    Alternatively, you can set up a directory for a VPATH build in a similar
    way to how it is done for the core code. One way to do this is using the
    core script <filename>config/prep_buildtree</filename>. Once this has been done
    you can build by setting the <literal>make</literal> variable
    <varname>VPATH</varname> like this:
<programlisting>
make VPATH=/path/to/extension/source/tree
make VPATH=/path/to/extension/source/tree install
</programlisting>
    This procedure can work with a greater variety of directory layouts.
   </para>

   <para>
    The scripts listed in the <varname>REGRESS</varname> variable are used for
    regression testing of your module, which can be invoked by <literal>make
    installcheck</literal> after doing <literal>make install</literal>.  For this to
    work you must have a running <productname>PostgreSQL</productname> server.
    The script files listed in <varname>REGRESS</varname> must appear in a
    subdirectory named <literal>sql/</literal> in your extension's directory.

Title: PostgreSQL Extension Installation and Testing
Summary
This section details how to customize the installation of PostgreSQL extensions and how to perform regression testing. It explains how to use the 'prefix' variable to specify a custom installation directory, with automatic adjustments made to subdirectory names based on the prefix. It also covers the necessary configuration of extension_control_path and dynamic_library_path to enable the PostgreSQL server to find the installed files. The text then describes two methods for performing a VPATH build, which allows building the extension in a separate directory from the source. Finally, it explains how to use the REGRESS variable for regression testing of the module using 'make installcheck', which requires a running PostgreSQL server and test scripts in a 'sql/' subdirectory.