Document usage of COPT environment variable for adjusting configure flags.
authorTom Lane <[email protected]>
Fri, 17 Feb 2017 21:11:03 +0000 (16:11 -0500)
committerTom Lane <[email protected]>
Fri, 17 Feb 2017 21:11:03 +0000 (16:11 -0500)
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
src/Makefile.global.in

index 2b81093ab9041dfe5dd6473eb46bd14c870dccf9..d8a0b08c066af95d8b111f72ca91e6a20cd3f97f 100644 (file)
@@ -1413,6 +1413,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>gmake</>.  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>gmake COPT='-Werror'</>
+</screen>
+     or
+<screen>
+<userinput>export COPT='-Werror'</>
+<userinput>gmake</>
+</screen>
+    </para>
+
     <note>
      <para>
       When developing code inside the server, it is recommended to
@@ -1433,6 +1453,14 @@ su - postgres
       <option>-O0</>.  An easy way to do this is by passing an option
       to <application>make</>: <command>gmake 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>
 
index d1e82d654043bd5fe4ef6caa69d06bb1d55783e8..5f79b7d4d2d6f15dcaafbb3e6fe07cd18aa1121a 100644 (file)
@@ -482,6 +482,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)