Skip to content

Commit 447591c

Browse files
committed
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
1 parent d993171 commit 447591c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

doc/src/sgml/installation.sgml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,26 @@ su - postgres
14421442
</variablelist>
14431443
</para>
14441444

1445+
<para>
1446+
Sometimes it is useful to add compiler flags after-the-fact to the set
1447+
that were chosen by <filename>configure</>. An important example is
1448+
that <application>gcc</>'s <option>-Werror</> option cannot be included
1449+
in the <envar>CFLAGS</envar> passed to <filename>configure</>, because
1450+
it will break many of <filename>configure</>'s built-in tests. To add
1451+
such flags, include them in the <envar>COPT</envar> environment variable
1452+
while running <filename>make</>. The contents of <envar>COPT</envar>
1453+
are added to both the <envar>CFLAGS</envar> and <envar>LDFLAGS</envar>
1454+
options set up by <filename>configure</>. For example, you could do
1455+
<screen>
1456+
<userinput>make COPT='-Werror'</>
1457+
</screen>
1458+
or
1459+
<screen>
1460+
<userinput>export COPT='-Werror'</>
1461+
<userinput>make</>
1462+
</screen>
1463+
</para>
1464+
14451465
<note>
14461466
<para>
14471467
When developing code inside the server, it is recommended to
@@ -1462,6 +1482,14 @@ su - postgres
14621482
<option>-O0</>. An easy way to do this is by passing an option
14631483
to <application>make</>: <command>make PROFILE=-O0 file.o</>.
14641484
</para>
1485+
1486+
<para>
1487+
The <envar>COPT</> and <envar>PROFILE</> environment variables are
1488+
actually handled identically by the <productname>PostgreSQL</>
1489+
makefiles. Which to use is a matter of preference, but a common habit
1490+
among developers is to use <envar>PROFILE</> for one-time flag
1491+
adjustments, while <envar>COPT</> might be kept set all the time.
1492+
</para>
14651493
</note>
14661494
</step>
14671495

src/Makefile.global.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,11 @@ ifneq ($(CUSTOM_COPT),)
566566
COPT= $(CUSTOM_COPT)
567567
endif
568568

569+
#
570+
# These variables are meant to be set in the environment of "make"
571+
# to add flags to whatever configure picked. Unlike the ones above,
572+
# they are documented.
573+
#
569574
ifdef COPT
570575
CFLAGS += $(COPT)
571576
LDFLAGS += $(COPT)

0 commit comments

Comments
 (0)