Skip to content

Commit 156fbdf

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 4bd0f83 commit 156fbdf

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
@@ -1465,6 +1465,26 @@ su - postgres
14651465
</variablelist>
14661466
</para>
14671467

1468+
<para>
1469+
Sometimes it is useful to add compiler flags after-the-fact to the set
1470+
that were chosen by <filename>configure</>. An important example is
1471+
that <application>gcc</>'s <option>-Werror</> option cannot be included
1472+
in the <envar>CFLAGS</envar> passed to <filename>configure</>, because
1473+
it will break many of <filename>configure</>'s built-in tests. To add
1474+
such flags, include them in the <envar>COPT</envar> environment variable
1475+
while running <filename>make</>. The contents of <envar>COPT</envar>
1476+
are added to both the <envar>CFLAGS</envar> and <envar>LDFLAGS</envar>
1477+
options set up by <filename>configure</>. For example, you could do
1478+
<screen>
1479+
<userinput>make COPT='-Werror'</>
1480+
</screen>
1481+
or
1482+
<screen>
1483+
<userinput>export COPT='-Werror'</>
1484+
<userinput>make</>
1485+
</screen>
1486+
</para>
1487+
14681488
<note>
14691489
<para>
14701490
When developing code inside the server, it is recommended to
@@ -1485,6 +1505,14 @@ su - postgres
14851505
<option>-O0</>. An easy way to do this is by passing an option
14861506
to <application>make</>: <command>make PROFILE=-O0 file.o</>.
14871507
</para>
1508+
1509+
<para>
1510+
The <envar>COPT</> and <envar>PROFILE</> environment variables are
1511+
actually handled identically by the <productname>PostgreSQL</>
1512+
makefiles. Which to use is a matter of preference, but a common habit
1513+
among developers is to use <envar>PROFILE</> for one-time flag
1514+
adjustments, while <envar>COPT</> might be kept set all the time.
1515+
</para>
14881516
</note>
14891517
</step>
14901518

src/Makefile.global.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,11 @@ ifneq ($(CUSTOM_COPT),)
548548
COPT= $(CUSTOM_COPT)
549549
endif
550550

551+
#
552+
# These variables are meant to be set in the environment of "make"
553+
# to add flags to whatever configure picked. Unlike the ones above,
554+
# they are documented.
555+
#
551556
ifdef COPT
552557
CFLAGS += $(COPT)
553558
LDFLAGS += $(COPT)

0 commit comments

Comments
 (0)