postgres.git / summary / log / commit / refs
commit 156fbdfcef5d5dfae63bddeeaef2f1aac15f2151
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Fri Feb 17 21:11:02 2017 +0000
Document usage of COPT environment variable for adjusting configure flags.
Also add to the existing rather half-baked description of PROFILE,
which does exactly the same thing, but I think people use it differently.
Discussion: https://postgr.es/m/16461.1487361849@sss.pgh.pa.us
doc/src/sgml/installation.sgml | 28 ++++++++++++++++++++++++++++
src/Makefile.global.in | 5 +++++
2 files changed, 33 insertions(+)
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 71818f6b43f..41ec896b559 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -1465,6 +1465,26 @@ su - postgres
</variablelist>
</para>
+ <para>
+ Sometimes it is useful to add compiler flags after-the-fact to the set
+ that were chosen by <filename>configure</>. An important example is
+ that <application>gcc</>'s <option>-Werror</> option cannot be included
+ in the <envar>CFLAGS</envar> passed to <filename>configure</>, because
+ it will break many of <filename>configure</>'s built-in tests. To add
+ such flags, include them in the <envar>COPT</envar> environment variable
+ while running <filename>make</>. The contents of <envar>COPT</envar>
+ are added to both the <envar>CFLAGS</envar> and <envar>LDFLAGS</envar>
+ options set up by <filename>configure</>. For example, you could do
+<screen>
+<userinput>make COPT='-Werror'</>
+</screen>
+ or
+<screen>
+<userinput>export COPT='-Werror'</>
+<userinput>make</>
+</screen>
+ </para>
+
<note>
<para>
When developing code inside the server, it is recommended to
@@ -1485,6 +1505,14 @@ su - postgres
<option>-O0</>. An easy way to do this is by passing an option
to <application>make</>: <command>make PROFILE=-O0 file.o</>.
</para>
+
+ <para>
+ The <envar>COPT</> and <envar>PROFILE</> environment variables are
+ actually handled identically by the <productname>PostgreSQL</>
+ makefiles. Which to use is a matter of preference, but a common habit
+ among developers is to use <envar>PROFILE</> for one-time flag
+ adjustments, while <envar>COPT</> might be kept set all the time.
+ </para>
</note>
</step>
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 6facb990936..71391ad2868 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -548,6 +548,11 @@ ifneq ($(CUSTOM_COPT),)
COPT= $(CUSTOM_COPT)
endif
+#
+# These variables are meant to be set in the environment of "make"
+# to add flags to whatever configure picked. Unlike the ones above,
+# they are documented.
+#
ifdef COPT
CFLAGS += $(COPT)
LDFLAGS += $(COPT)
[parent: 4bd0f8317256]