From 49440fff08590cf1a764ab4b4c5342cd9e445991 Mon Sep 17 00:00:00 2001
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Mon, 16 Apr 2012 12:58:37 +0300
Subject: [PATCH] Install plpgsql.h to to include/server at "make install".

The header file is needed by any module that wants to use the PL/pgSQL
instrumentation plugin interface. Most notably, the pldebugger plugin needs
this. With this patch, it can be built using pgxs, without having the full
server source tree available.
---
 src/pl/plpgsql/src/Makefile | 14 +++++++++++---
 src/tools/msvc/Install.pm   |  2 ++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/pl/plpgsql/src/Makefile b/src/pl/plpgsql/src/Makefile
index 751a98dbb02..e3fef84b88c 100644
--- a/src/pl/plpgsql/src/Makefile
+++ b/src/pl/plpgsql/src/Makefile
@@ -27,20 +27,28 @@ all: all-lib
 include $(top_srcdir)/src/Makefile.shlib
 
 
-install: all install-lib install-data
+install: all install-lib install-data install-headers
 
 installdirs: installdirs-lib
 	$(MKDIR_P) '$(DESTDIR)$(datadir)/extension'
+	$(MKDIR_P) '$(DESTDIR)$(includedir_server)'
 
-uninstall: uninstall-lib uninstall-data
+uninstall: uninstall-lib uninstall-data uninstall-headers
 
 install-data: installdirs
 	$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) '$(DESTDIR)$(datadir)/extension/'
 
+# The plpgsql.h header file is needed by instrumentation plugins
+install-headers: installdirs
+	$(INSTALL_DATA) '$(srcdir)/plpgsql.h' '$(DESTDIR)$(includedir_server)'
+
 uninstall-data:
 	rm -f $(addprefix '$(DESTDIR)$(datadir)/extension'/, $(notdir $(DATA)))
 
-.PHONY: install-data uninstall-data
+uninstall-headers:
+	rm -f '$(DESTDIR)$(includedir_server)/plpgsql.h'
+
+.PHONY: install-data install-headers uninstall-data uninstall-headers
 
 
 # Force these dependencies to be known even without dependency info built:
diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm
index 6176743d8bd..7c743d17b4f 100644
--- a/src/tools/msvc/Install.pm
+++ b/src/tools/msvc/Install.pm
@@ -501,6 +501,8 @@ sub CopyIncludeFiles
     my $D;
     opendir($D, 'src/include') || croak "Could not opendir on src/include!\n";
 
+    CopyFiles('PL/pgSQL header', $target . '/include/server/','src/pl/plpgsql/src/', 'plpgsql.h');
+
     # some xcopy progs don't like mixed slash style paths
     (my $ctarget = $target) =~ s!/!\\!g;
     while (my $d = readdir($D))
-- 
GitLab