+diff -urpa postgresql-9.5.14.orig/src/bin/pg_config/pg_config.c postgresql-9.5.14/src/bin/pg_config/pg_config.c
+--- postgresql-9.5.14.orig/src/bin/pg_config/pg_config.c 2018-08-23 13:41:50.944654284 +0000
++++ postgresql-9.5.14/src/bin/pg_config/pg_config.c 2018-08-23 13:42:31.233653830 +0000
+@@ -26,6 +26,8 @@
+
+ #include "port.h"
+
++#include "../port/pg_config_paths.h"
++
+ static const char *progname;
+ static char mypath[MAXPGPATH];
+
+@@ -481,7 +483,6 @@ main(int argc, char **argv)
+ {
+ int i;
+ int j;
+- int ret;
+
+ set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_config"));
+
+@@ -497,13 +498,7 @@ main(int argc, char **argv)
+ }
+ }
+
+- ret = find_my_exec(argv[0], mypath);
+-
+- if (ret)
+- {
+- fprintf(stderr, _("%s: could not find own program executable\n"), progname);
+- exit(1);
+- }
++ snprintf(mypath, sizeof(mypath), "%s/%s", PGBINDIR, progname);
+
+ /* no arguments -> print everything */
+ if (argc < 2)
+diff -urpa postgresql-9.5.14.orig/src/Makefile.global.in postgresql-9.5.14/src/Makefile.global.in
+--- postgresql-9.5.14.orig/src/Makefile.global.in 2018-08-23 13:41:50.825654285 +0000
++++ postgresql-9.5.14/src/Makefile.global.in 2018-08-23 13:42:31.233653830 +0000
+@@ -120,7 +120,7 @@ libdir := @libdir@
+ pkglibdir = $(libdir)
+ ifeq "$(findstring pgsql, $(pkglibdir))" ""
+ ifeq "$(findstring postgres, $(pkglibdir))" ""
+-override pkglibdir := $(pkglibdir)/postgresql
++override pkglibdir := $(pkglibdir)/postgresql/@PG_MAJORVERSION@/lib
+ endif
+ endif
+
+@@ -168,7 +168,7 @@ endif # PGXS
+
+ # These derived path variables aren't separately configurable.
+
+-includedir_server = $(pkgincludedir)/server
++includedir_server = $(pkgincludedir)/@PG_MAJORVERSION@/server
+ includedir_internal = $(pkgincludedir)/internal
+ pgxsdir = $(pkglibdir)/pgxs
+