Skip to content

Commit 42b204d

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 fba0a82 commit 42b204d

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
@@ -1146,7 +1146,34 @@ include $(PGXS)
11461146
<term><varname>PG_CPPFLAGS</varname></term>
11471147
<listitem>
11481148
<para>
1149-
will be added to <varname>CPPFLAGS</varname>
1149+
will be prepended to <varname>CPPFLAGS</varname>
1150+
</para>
1151+
</listitem>
1152+
</varlistentry>
1153+
1154+
<varlistentry>
1155+
<term><varname>PG_CFLAGS</varname></term>
1156+
<listitem>
1157+
<para>
1158+
will be appended to <varname>CFLAGS</varname>
1159+
</para>
1160+
</listitem>
1161+
</varlistentry>
1162+
1163+
<varlistentry>
1164+
<term><varname>PG_CXXFLAGS</varname></term>
1165+
<listitem>
1166+
<para>
1167+
will be appended to <varname>CXXFLAGS</varname>
1168+
</para>
1169+
</listitem>
1170+
</varlistentry>
1171+
1172+
<varlistentry>
1173+
<term><varname>PG_LDFLAGS</varname></term>
1174+
<listitem>
1175+
<para>
1176+
will be prepended to <varname>LDFLAGS</varname>
11501177
</para>
11511178
</listitem>
11521179
</varlistentry>

src/makefiles/pgxs.mk

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
# REGRESS -- list of regression test cases (without suffix)
4141
# REGRESS_OPTS -- additional switches to pass to pg_regress
4242
# EXTRA_CLEAN -- extra files to remove in 'make clean'
43-
# PG_CPPFLAGS -- will be added to CPPFLAGS
43+
# PG_CPPFLAGS -- will be prepended to CPPFLAGS
44+
# PG_CFLAGS -- will be appended to CFLAGS
45+
# PG_CXXFLAGS -- will be appended to CXXFLAGS
46+
# PG_LDFLAGS -- will be prepended to LDFLAGS
4447
# PG_LIBS -- will be added to PROGRAM link line
4548
# PG_LIBS_INTERNAL -- same, for references to libraries within build tree
4649
# SHLIB_LINK -- will be added to MODULE_big link line
@@ -97,6 +100,15 @@ endif
97100
ifdef PG_CPPFLAGS
98101
override CPPFLAGS := $(PG_CPPFLAGS) $(CPPFLAGS)
99102
endif
103+
ifdef PG_CFLAGS
104+
override CFLAGS := $(CFLAGS) $(PG_CFLAGS)
105+
endif
106+
ifdef PG_CXXFLAGS
107+
override CXXFLAGS := $(CXXFLAGS) $(PG_CXXFLAGS)
108+
endif
109+
ifdef PG_LDFLAGS
110+
override LDFLAGS := $(PG_LDFLAGS) $(LDFLAGS)
111+
endif
100112

101113
all: $(PROGRAM) $(DATA_built) $(SCRIPTS_built) $(addsuffix $(DLSUFFIX), $(MODULES)) $(addsuffix .control, $(EXTENSION))
102114

0 commit comments

Comments
 (0)