Re: Michael Paquier 2019-01-04 <20190104133305.gg2...@paquier.xyz> > On Fri, Jan 04, 2019 at 11:41:15AM +0100, Peter Eisentraut wrote: > > Note that pgxs supports PG_CPPFLAGS for adding custom pieces to CPPFLAGS > > in a safe way. Maybe we should add an equivalent for CFLAGS? It's just > > that it hasn't been needed so far. > > +1. Wouldn't it make sense to also have PG_LDFLAGS? In some stuff I > maintain, I have been abusing of PG_CPPFLAGS to pass some flags, which > is not really right. We also have contrib/passwordcheck/Makefile > abuse of it to set -DUSE_CRACKLIB..
I'll buy whatever version that works. I'm using CFLAGS at the moment, but could easily switch to other variables. Note that the missing bit here is the CXX part, adding PG_CFLAGS alone wouldn't help. Updated patch attached. Christoph -- Senior Berater, Tel.: +49 2166 9901 187 credativ GmbH, HRB Mönchengladbach 12080, USt-ID-Nummer: DE204566209 Trompeterallee 108, 41189 Mönchengladbach Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer Unser Umgang mit personenbezogenen Daten unterliegt folgenden Bestimmungen: https://www.credativ.de/datenschutz
>From 51226dc97039b42e7fc8670a895ec51b8d715b12 Mon Sep 17 00:00:00 2001 From: Christoph Berg <christoph.b...@credativ.de> Date: Tue, 13 Nov 2018 11:35:26 +0100 Subject: [PATCH] Add more flexibility for passing custom compiler flags The existing machinery for extending CFLAGS and LDFLAGS via COPT and PROFILE neglected to extend CXXFLAGS as well, causing third party extensions written in C++ not to get the extra flags. Also add PG_CFLAGS, PG_CXXFLAGS, and PG_LDFLAGS variables to pgxs.mk which will append to the corresponding make variables. --- src/Makefile.global.in | 6 ++++++ src/makefiles/pgxs.mk | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/Makefile.global.in b/src/Makefile.global.in index 41c131412e..8ac511756c 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -679,8 +679,14 @@ ifdef COPT LDFLAGS += $(COPT) endif +ifdef CXXOPT + CXXFLAGS += $(CXXOPT) + LDFLAGS += $(CXXOPT) +endif + ifdef PROFILE CFLAGS += $(PROFILE) + CXXFLAGS += $(PROFILE) LDFLAGS += $(PROFILE) endif diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk index d214cb9cf2..56a8b26183 100644 --- a/src/makefiles/pgxs.mk +++ b/src/makefiles/pgxs.mk @@ -53,6 +53,9 @@ # tests require special configuration, or don't use pg_regress # EXTRA_CLEAN -- extra files to remove in 'make clean' # PG_CPPFLAGS -- will be added to CPPFLAGS +# PG_CFLAGS -- will be added to CFLAGS +# PG_CXXFLAGS -- will be added to CXXFLAGS +# PG_LDFLAGS -- will be added to LDFLAGS # PG_LIBS -- will be added to PROGRAM link line # PG_LIBS_INTERNAL -- same, for references to libraries within build tree # SHLIB_LINK -- will be added to MODULE_big link line @@ -119,6 +122,15 @@ endif ifdef PG_CPPFLAGS override CPPFLAGS := $(PG_CPPFLAGS) $(CPPFLAGS) endif +ifdef PG_CFLAGS +override CFLAGS := $(PG_CFLAGS) $(CFLAGS) +endif +ifdef PG_CXXFLAGS +override CXXFLAGS := $(PG_CXXFLAGS) $(CXXFLAGS) +endif +ifdef PG_LDFLAGS +override LDFLAGS := $(PG_LDFLAGS) $(LDFLAGS) +endif # logic for HEADERS_* stuff -- 2.19.2