that <application>gcc</application>'s <option>-Werror</option> option cannot be included
in the <envar>CFLAGS</envar> passed to <filename>configure</filename>, because
it will break many of <filename>configure</filename>'s built-in tests. To add
such flags, include them in the <envar>COPT</envar> environment variable
while running <filename>make</filename>. The contents of <envar>COPT</envar>
are added to the <envar>CFLAGS</envar>, <envar>CXXFLAGS</envar>, and <envar>LDFLAGS</envar>
options set up by <filename>configure</filename>. For example, you could do
<screen>
<userinput>make COPT='-Werror'</userinput>
</screen>
or
<screen>
<userinput>export COPT='-Werror'</userinput>
<userinput>make</userinput>
</screen>
</para>
<note>
<para>
If using GCC, it is best to build with an optimization level of
at least <option>-O1</option>, because using no optimization
(<option>-O0</option>) disables some important compiler warnings (such
as the use of uninitialized variables). However, non-zero
optimization levels can complicate debugging because stepping
through compiled code will usually not match up one-to-one with
source code lines. If you get confused while trying to debug
optimized code, recompile the specific files of interest with
<option>-O0</option>. An easy way to do this is by passing an option
to <application>make</application>: <command>make PROFILE=-O0 file.o</command>.
</para>
<para>
The <envar>COPT</envar> and <envar>PROFILE</envar> environment variables are
actually handled identically by the <productname>PostgreSQL</productname>
makefiles. Which to use is a matter of preference, but a common habit
among developers is to use <envar>PROFILE</envar> for one-time flag
adjustments, while <envar>COPT</envar> might be kept set all the time.
</para>
</note>
</sect2>
</sect1>
<sect1 id="install-meson">
<title>Building and Installation with Meson</title>
<sect2 id="install-short-meson">
<title>Short Version</title>
<para>
<synopsis>
meson setup build --prefix=/usr/local/pgsql
cd build
ninja
su
ninja install
adduser postgres
mkdir -p /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test
</synopsis>
The long version is the rest of this
<phrase>section</phrase>.
</para>
</sect2>
<sect2 id="install-procedure-meson">
<title>Installation Procedure</title>
<procedure>
<step id="meson-configure">
<title>Configuration</title>
<para>
The first step of the installation procedure is to configure the
build tree for your system and choose the options you would like. To
create and configure the build directory, you can start with the
<literal>meson setup</literal> command.
<screen>
<userinput>meson setup build</userinput>
</screen>
The setup command takes a <literal>builddir</literal> and a <literal>srcdir</literal>
argument. If no <literal>srcdir</literal> is given, Meson will deduce the
<literal>srcdir</literal> based on the current directory and the location
of <literal>meson.build</literal>. The <literal>builddir</literal> is mandatory.
</para>
<para>
Running <literal>meson setup</literal> loads the build configuration file and sets up the build directory.
Additionally, you can also pass several build options to Meson. Some commonly
used options are mentioned in the subsequent sections. For example:
<screen>
# configure with a different installation prefix
meson setup build --prefix=/home/user/pg-install
# configure to generate a debug build
meson setup build --buildtype=debug
# configure to build with OpenSSL support
meson setup build -Dssl=openssl
</screen>
</para>
<para>