Skip to content

Commit ac3a9af

Browse files
committed
Add PG_CFLAGS, PG_CXXFLAGS, and PG_LDFLAGS variables to PGXS
Add PG_CFLAGS, PG_CXXFLAGS, and PG_LDFLAGS variables to pgxs.mk which will be appended or prepended to the corresponding make variables. Notably, there was previously no way to pass custom CXXFLAGS to third party extension module builds, COPT and PROFILE supporting only CFLAGS and LDFLAGS. Backpatch all the way down to ease integration with existing extensions. Author: Christoph Berg Reviewed-by: Andres Freund, Tom Lane, Michael Paquier Discussion: https://postgr.es/m/20181113104005.GA32154@msg.credativ.de Backpatch-through: 9.4
1 parent 0b8bdb3 commit ac3a9af

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

doc/src/sgml/extend.sgml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,34 @@ include $(PGXS)
13531353
<term><varname>PG_CPPFLAGS</varname></term>
13541354
<listitem>
13551355
<para>
1356-
will be added to <varname>CPPFLAGS</varname>
1356+
will be prepended to <varname>CPPFLAGS</varname>
1357+
</para>
1358+
</listitem>
1359+
</varlistentry>
1360+
1361+
<varlistentry>
1362+
<term><varname>PG_CFLAGS</varname></term>
1363+
<listitem>
1364+
<para>
1365+
will be appended to <varname>CFLAGS</varname>
1366+
</para>
1367+
</listitem>
1368+
</varlistentry>
1369+
1370+
<varlistentry>
1371+
<term><varname>PG_CXXFLAGS</varname></term>
1372+
<listitem>
1373+
<para>
1374+
will be appended to <varname>CXXFLAGS</varname>
1375+
</para>
1376+
</listitem>
1377+
</varlistentry>
1378+
1379+
<varlistentry>
1380+
<term><varname>PG_LDFLAGS</varname></term>
1381+
<listitem>
1382+
<para>
1383+
will be prepended to <varname>LDFLAGS</varname>
13571384
</para>
13581385
</listitem>
13591386
</varlistentry>

src/makefiles/pgxs.mk

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@
5252
# NO_INSTALLCHECK -- don't define an installcheck target, useful e.g. if
5353
# tests require special configuration, or don't use pg_regress
5454
# EXTRA_CLEAN -- extra files to remove in 'make clean'
55-
# PG_CPPFLAGS -- will be added to CPPFLAGS
55+
# PG_CPPFLAGS -- will be prepended to CPPFLAGS
56+
# PG_CFLAGS -- will be appended to CFLAGS
57+
# PG_CXXFLAGS -- will be appended to CXXFLAGS
58+
# PG_LDFLAGS -- will be prepended to LDFLAGS
5659
# PG_LIBS -- will be added to PROGRAM link line
5760
# PG_LIBS_INTERNAL -- same, for references to libraries within build tree
5861
# SHLIB_LINK -- will be added to MODULE_big link line
@@ -119,6 +122,15 @@ endif
119122
ifdef PG_CPPFLAGS
120123
override CPPFLAGS := $(PG_CPPFLAGS) $(CPPFLAGS)
121124
endif
125+
ifdef PG_CFLAGS
126+
override CFLAGS := $(CFLAGS) $(PG_CFLAGS)
127+
endif
128+
ifdef PG_CXXFLAGS
129+
override CXXFLAGS := $(CXXFLAGS) $(PG_CXXFLAGS)
130+
endif
131+
ifdef PG_LDFLAGS
132+
override LDFLAGS := $(PG_LDFLAGS) $(LDFLAGS)
133+
endif
122134

123135
# logic for HEADERS_* stuff
124136

0 commit comments

Comments
 (0)