Skip to content

Commit da14c9b

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 1ca33fc commit da14c9b

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
@@ -1250,7 +1250,34 @@ include $(PGXS)
12501250
<term><varname>PG_CPPFLAGS</varname></term>
12511251
<listitem>
12521252
<para>
1253-
will be added to <varname>CPPFLAGS</varname>
1253+
will be prepended to <varname>CPPFLAGS</varname>
1254+
</para>
1255+
</listitem>
1256+
</varlistentry>
1257+
1258+
<varlistentry>
1259+
<term><varname>PG_CFLAGS</varname></term>
1260+
<listitem>
1261+
<para>
1262+
will be appended to <varname>CFLAGS</varname>
1263+
</para>
1264+
</listitem>
1265+
</varlistentry>
1266+
1267+
<varlistentry>
1268+
<term><varname>PG_CXXFLAGS</varname></term>
1269+
<listitem>
1270+
<para>
1271+
will be appended to <varname>CXXFLAGS</varname>
1272+
</para>
1273+
</listitem>
1274+
</varlistentry>
1275+
1276+
<varlistentry>
1277+
<term><varname>PG_LDFLAGS</varname></term>
1278+
<listitem>
1279+
<para>
1280+
will be prepended to <varname>LDFLAGS</varname>
12541281
</para>
12551282
</listitem>
12561283
</varlistentry>

src/makefiles/pgxs.mk

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@
4343
# NO_INSTALLCHECK -- don't define an installcheck target, useful e.g. if
4444
# tests require special configuration, or don't use pg_regress
4545
# EXTRA_CLEAN -- extra files to remove in 'make clean'
46-
# PG_CPPFLAGS -- will be added to CPPFLAGS
46+
# PG_CPPFLAGS -- will be prepended to CPPFLAGS
47+
# PG_CFLAGS -- will be appended to CFLAGS
48+
# PG_CXXFLAGS -- will be appended to CXXFLAGS
49+
# PG_LDFLAGS -- will be prepended to LDFLAGS
4750
# PG_LIBS -- will be added to PROGRAM link line
4851
# PG_LIBS_INTERNAL -- same, for references to libraries within build tree
4952
# SHLIB_LINK -- will be added to MODULE_big link line
@@ -100,6 +103,15 @@ endif
100103
ifdef PG_CPPFLAGS
101104
override CPPFLAGS := $(PG_CPPFLAGS) $(CPPFLAGS)
102105
endif
106+
ifdef PG_CFLAGS
107+
override CFLAGS := $(CFLAGS) $(PG_CFLAGS)
108+
endif
109+
ifdef PG_CXXFLAGS
110+
override CXXFLAGS := $(CXXFLAGS) $(PG_CXXFLAGS)
111+
endif
112+
ifdef PG_LDFLAGS
113+
override LDFLAGS := $(PG_LDFLAGS) $(LDFLAGS)
114+
endif
103115

104116
all: $(PROGRAM) $(DATA_built) $(SCRIPTS_built) $(addsuffix $(DLSUFFIX), $(MODULES)) $(addsuffix .control, $(EXTENSION))
105117

0 commit comments

Comments
 (0)