To make the PostgreSQL server packages build reproducibly, we need to remove
the build path from -fdebug-prefix-map and -ffile-prefix-map in CFLAGS.

* The actual server build still uses the original CFLAGS so the build path is
  correctly mapped in the object files.
* The information printed by the pg_config binary and the system view is
  filtered in src/common/Makefile.
* The build paths stored in Makefile.global are filtered in debian/rules.
  (abs_top_builddir, abs_top_srcdir, configure_args, CFLAGS)
* To make PGXS module builds reproducible, pg_buildext copies the environment
  CFLAGS to COPT where Makefile.global picks them up, using the prefix maps
  from dpkg-buildflags.

--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -27,10 +27,11 @@ include $(top_builddir)/src/Makefile.glo
 # don't include subdirectory-path-dependent -I and -L switches
 STD_CPPFLAGS := $(filter-out -I$(top_srcdir)/src/include -I$(top_builddir)/src/include,$(CPPFLAGS))
 STD_LDFLAGS := $(filter-out -L$(top_builddir)/src/common -L$(top_builddir)/src/port,$(LDFLAGS))
-override CPPFLAGS += -DVAL_CONFIGURE="\"$(configure_args)\""
+# filter build path variation from -fdebug-prefix-map and -ffile-prefix-map
+override CPPFLAGS += -DVAL_CONFIGURE="\"$(filter-out -fdebug-prefix-map=% -ffile-prefix-map=%,$(configure_args))\""
 override CPPFLAGS += -DVAL_CC="\"$(CC)\""
 override CPPFLAGS += -DVAL_CPPFLAGS="\"$(STD_CPPFLAGS)\""
-override CPPFLAGS += -DVAL_CFLAGS="\"$(CFLAGS)\""
+override CPPFLAGS += -DVAL_CFLAGS="\"$(filter-out -fdebug-prefix-map=% -ffile-prefix-map=%,$(CFLAGS))\""
 override CPPFLAGS += -DVAL_CFLAGS_SL="\"$(CFLAGS_SL)\""
 override CPPFLAGS += -DVAL_LDFLAGS="\"$(STD_LDFLAGS)\""
 override CPPFLAGS += -DVAL_LDFLAGS_EX="\"$(LDFLAGS_EX)\""
