Add PG_CFLAGS, PG_CXXFLAGS, and PG_LDFLAGS variables to PGXS
authorMichael Paquier
Sun, 3 Feb 2019 08:49:04 +0000 (17:49 +0900)
committerMichael Paquier
Sun, 3 Feb 2019 08:49:04 +0000 (17:49 +0900)
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[email protected]
Backpatch-through: 9.4

doc/src/sgml/extend.sgml
src/makefiles/pgxs.mk

index 8ee3fa0766b4c635dea1a50fbc0ad7309c3034cb..feb7a92c17f7d187bdb1aee534c5db528df60f2a 100644 (file)
@@ -1146,7 +1146,34 @@ include $(PGXS)
       PG_CPPFLAGS
       
        
-        will be added to CPPFLAGS
+        will be prepended to CPPFLAGS
+       
+      
+     
+
+     
+      PG_CFLAGS
+      
+       
+        will be appended to CFLAGS
+       
+      
+     
+
+     
+      PG_CXXFLAGS
+      
+       
+        will be appended to CXXFLAGS
+       
+      
+     
+
+     
+      PG_LDFLAGS
+      
+       
+        will be prepended to LDFLAGS
        
       
      
index a6e70ce0d101ccee1e1832fb18359d76976363f4..faa7dd9b987ed0a60fd79cf4d39168fae5ed4225 100644 (file)
 #   REGRESS -- list of regression test cases (without suffix)
 #   REGRESS_OPTS -- additional switches to pass to pg_regress
 #   EXTRA_CLEAN -- extra files to remove in 'make clean'
-#   PG_CPPFLAGS -- will be added to CPPFLAGS
+#   PG_CPPFLAGS -- will be prepended to CPPFLAGS
+#   PG_CFLAGS -- will be appended to CFLAGS
+#   PG_CXXFLAGS -- will be appended to CXXFLAGS
+#   PG_LDFLAGS -- will be prepended 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
@@ -97,6 +100,15 @@ endif
 ifdef PG_CPPFLAGS
 override CPPFLAGS := $(PG_CPPFLAGS) $(CPPFLAGS)
 endif
+ifdef PG_CFLAGS
+override CFLAGS := $(CFLAGS) $(PG_CFLAGS)
+endif
+ifdef PG_CXXFLAGS
+override CXXFLAGS := $(CXXFLAGS) $(PG_CXXFLAGS)
+endif
+ifdef PG_LDFLAGS
+override LDFLAGS := $(PG_LDFLAGS) $(LDFLAGS)
+endif
 
 all: $(PROGRAM) $(DATA_built) $(SCRIPTS_built) $(addsuffix $(DLSUFFIX), $(MODULES)) $(addsuffix .control, $(EXTENSION))