From 8c2ff9e47b8047351b503ff82c908199eb31ad6c Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Tue, 10 Mar 2015 20:42:28 -0700
Subject: [PATCH 1/7] Move pg_archivecleanup from contrib/ to src/bin/

---
 contrib/Makefile                                   |  1 -
 contrib/pg_archivecleanup/Makefile                 | 18 ---------------
 doc/src/sgml/contrib.sgml                          |  1 -
 doc/src/sgml/filelist.sgml                         |  1 -
 doc/src/sgml/ref/allfiles.sgml                     |  1 +
 doc/src/sgml/{ => ref}/pgarchivecleanup.sgml       | 10 +--------
 doc/src/sgml/reference.sgml                        |  1 +
 src/bin/Makefile                                   |  1 +
 {contrib => src/bin}/pg_archivecleanup/.gitignore  |  0
 src/bin/pg_archivecleanup/Makefile                 | 14 ++++++++++++
 .../bin}/pg_archivecleanup/pg_archivecleanup.c     |  2 +-
 src/tools/msvc/Mkvcbuild.pm                        | 26 +++++++++++-----------
 12 files changed, 32 insertions(+), 44 deletions(-)
 delete mode 100644 contrib/pg_archivecleanup/Makefile
 rename doc/src/sgml/{ => ref}/pgarchivecleanup.sgml (97%)
 rename {contrib => src/bin}/pg_archivecleanup/.gitignore (100%)
 create mode 100644 src/bin/pg_archivecleanup/Makefile
 rename {contrib => src/bin}/pg_archivecleanup/pg_archivecleanup.c (99%)

diff --git a/contrib/Makefile b/contrib/Makefile
index 195d447..c56050e 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -28,7 +28,6 @@ SUBDIRS = \
 		oid2name	\
 		pageinspect	\
 		passwordcheck	\
-		pg_archivecleanup \
 		pg_buffercache	\
 		pg_freespacemap \
 		pg_prewarm	\
diff --git a/contrib/pg_archivecleanup/Makefile b/contrib/pg_archivecleanup/Makefile
deleted file mode 100644
index ab52390..0000000
diff --git a/doc/src/sgml/contrib.sgml b/doc/src/sgml/contrib.sgml
index a698d0f..f21fa14 100644
--- a/doc/src/sgml/contrib.sgml
+++ b/doc/src/sgml/contrib.sgml
@@ -202,7 +202,6 @@ pages.
    part of the core <productname>PostgreSQL</productname> distribution.
   </para>
 
- &pgarchivecleanup;
  &pgstandby;
  &pgtestfsync;
  &pgtesttiming;
diff --git a/doc/src/sgml/filelist.sgml b/doc/src/sgml/filelist.sgml
index f03b72a..5e3c34b 100644
--- a/doc/src/sgml/filelist.sgml
+++ b/doc/src/sgml/filelist.sgml
@@ -125,7 +125,6 @@
 <!ENTITY pageinspect     SYSTEM "pageinspect.sgml">
 <!ENTITY passwordcheck   SYSTEM "passwordcheck.sgml">
 <!ENTITY pgbench         SYSTEM "pgbench.sgml">
-<!ENTITY pgarchivecleanup SYSTEM "pgarchivecleanup.sgml">
 <!ENTITY pgbuffercache   SYSTEM "pgbuffercache.sgml">
 <!ENTITY pgcrypto        SYSTEM "pgcrypto.sgml">
 <!ENTITY pgfreespacemap  SYSTEM "pgfreespacemap.sgml">
diff --git a/doc/src/sgml/ref/allfiles.sgml b/doc/src/sgml/ref/allfiles.sgml
index 7aa3128..cbe4611 100644
--- a/doc/src/sgml/ref/allfiles.sgml
+++ b/doc/src/sgml/ref/allfiles.sgml
@@ -179,6 +179,7 @@ Complete list of usable sgml source files in this directory.
 <!ENTITY dropuser           SYSTEM "dropuser.sgml">
 <!ENTITY ecpgRef            SYSTEM "ecpg-ref.sgml">
 <!ENTITY initdb             SYSTEM "initdb.sgml">
+<!ENTITY pgarchivecleanup   SYSTEM "pgarchivecleanup.sgml">
 <!ENTITY pgBasebackup       SYSTEM "pg_basebackup.sgml">
 <!ENTITY pgConfig           SYSTEM "pg_config-ref.sgml">
 <!ENTITY pgControldata      SYSTEM "pg_controldata.sgml">
diff --git a/doc/src/sgml/pgarchivecleanup.sgml b/doc/src/sgml/ref/pgarchivecleanup.sgml
similarity index 97%
rename from doc/src/sgml/pgarchivecleanup.sgml
rename to doc/src/sgml/ref/pgarchivecleanup.sgml
index fdf0cbb..779159d 100644
--- a/doc/src/sgml/pgarchivecleanup.sgml
+++ b/doc/src/sgml/ref/pgarchivecleanup.sgml
@@ -1,4 +1,4 @@
-<!-- doc/src/sgml/pgarchivecleanup.sgml -->
+<!-- doc/src/sgml/ref/pgarchivecleanup.sgml -->
 
 <refentry id="pgarchivecleanup">
  <indexterm zone="pgarchivecleanup">
@@ -194,14 +194,6 @@ archive_cleanup_command = 'pg_archivecleanup -d /mnt/standby/archive %r 2>>clean
  </refsect1>
 
  <refsect1>
-  <title>Author</title>
-
-  <para>
-   Simon Riggs <email>simon@2ndquadrant.com</email>
-  </para>
- </refsect1>
-
- <refsect1>
   <title>See Also</title>
 
   <simplelist type="inline">
diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml
index 10c9a6d..62267db 100644
--- a/doc/src/sgml/reference.sgml
+++ b/doc/src/sgml/reference.sgml
@@ -257,6 +257,7 @@
   </partintro>
 
    &initdb;
+   &pgarchivecleanup;
    &pgControldata;
    &pgCtl;
    &pgResetxlog;
diff --git a/src/bin/Makefile b/src/bin/Makefile
index 90ca1a8..2347076 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -15,6 +15,7 @@ include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
 	initdb \
+	pg_archivecleanup \
 	pg_basebackup \
 	pg_config \
 	pg_controldata \
diff --git a/contrib/pg_archivecleanup/.gitignore b/src/bin/pg_archivecleanup/.gitignore
similarity index 100%
rename from contrib/pg_archivecleanup/.gitignore
rename to src/bin/pg_archivecleanup/.gitignore
diff --git a/src/bin/pg_archivecleanup/Makefile b/src/bin/pg_archivecleanup/Makefile
new file mode 100644
index 0000000..5df86eb
--- /dev/null
+++ b/src/bin/pg_archivecleanup/Makefile
@@ -0,0 +1,14 @@
+# src/bin/pg_archivecleanup/Makefile
+
+PGFILEDESC = "pg_archivecleanup - cleans archive when used with streaming replication"
+PGAPPICON = win32
+
+subdir = src/bin/pg_archivecleanup
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PROGRAM = pg_archivecleanup
+OBJS	= pg_archivecleanup.o $(WIN32RES)
+
+NO_PGXS = 1
+include $(top_srcdir)/src/makefiles/pgxs.mk
diff --git a/contrib/pg_archivecleanup/pg_archivecleanup.c b/src/bin/pg_archivecleanup/pg_archivecleanup.c
similarity index 99%
rename from contrib/pg_archivecleanup/pg_archivecleanup.c
rename to src/bin/pg_archivecleanup/pg_archivecleanup.c
index 97225a8..2ff2a27 100644
--- a/contrib/pg_archivecleanup/pg_archivecleanup.c
+++ b/src/bin/pg_archivecleanup/pg_archivecleanup.c
@@ -1,5 +1,5 @@
 /*
- * contrib/pg_archivecleanup/pg_archivecleanup.c
+ * src/bin/pg_archivecleanup/pg_archivecleanup.c
  *
  * pg_archivecleanup.c
  *
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 989a2ec..b00f335 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -34,17 +34,15 @@ my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' };
 my @contrib_uselibpq =
   ('dblink', 'oid2name', 'pgbench', 'pg_upgrade', 'postgres_fdw', 'vacuumlo');
 my @contrib_uselibpgport = (
-	'oid2name',      'pgbench',
-	'pg_standby',    'pg_archivecleanup',
-	'pg_test_fsync', 'pg_test_timing',
-	'pg_upgrade',    'pg_xlogdump',
-	'vacuumlo');
+	'oid2name',       'pgbench',
+	'pg_standby',     'pg_test_fsync',
+	'pg_test_timing', 'pg_upgrade',
+	'pg_xlogdump',    'vacuumlo');
 my @contrib_uselibpgcommon = (
-	'oid2name',      'pgbench',
-	'pg_standby',    'pg_archivecleanup',
-	'pg_test_fsync', 'pg_test_timing',
-	'pg_upgrade',    'pg_xlogdump',
-	'vacuumlo');
+	'oid2name',       'pgbench',
+	'pg_standby',     'pg_test_fsync',
+	'pg_test_timing', 'pg_upgrade',
+	'pg_xlogdump',    'vacuumlo');
 my $contrib_extralibs = { 'pgbench' => ['ws2_32.lib'] };
 my $contrib_extraincludes =
   { 'tsearch2' => ['contrib/tsearch2'], 'dblink' => ['src/backend'] };
@@ -58,6 +56,8 @@ my @contrib_excludes = ('pgcrypto', 'intagg', 'sepgsql');
 # Set of variables for frontend modules
 my $frontend_defines = { 'initdb' => 'FRONTEND' };
 my @frontend_uselibpq = ('pg_ctl', 'psql');
+my @frontend_uselibpgport = ( 'pg_archivecleanup' );
+my @frontend_uselibpgcommon = ( 'pg_archivecleanup' );
 my $frontend_extralibs = {
 	'initdb'     => ['ws2_32.lib'],
 	'pg_restore' => ['ws2_32.lib'],
@@ -766,9 +766,9 @@ sub AdjustContribProj
 sub AdjustFrontendProj
 {
 	my $proj = shift;
-	AdjustModule($proj, $frontend_defines, \@frontend_uselibpq, undef,
-		undef, $frontend_extralibs,
-		$frontend_extrasource, $frontend_extraincludes);
+	AdjustModule($proj, $frontend_defines, \@frontend_uselibpq,
+		\@frontend_uselibpgport, \@frontend_uselibpgcommon,
+		$frontend_extralibs, $frontend_extrasource, $frontend_extraincludes);
 }
 
 sub AdjustModule
-- 
2.3.1

