From 7b55ad274aa30d43cfdabb822f72257b3cec8336 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@otacoo.com>
Date: Sun, 18 Jan 2015 21:01:02 +0900
Subject: [PATCH] Fix Makefiles and re-add author references

---
 doc/src/sgml/ref/pgarchivecleanup.sgml |  8 ++++++++
 doc/src/sgml/ref/pgstandby.sgml        |  8 ++++++++
 doc/src/sgml/ref/pgtestfsync.sgml      |  8 ++++++++
 doc/src/sgml/ref/pgtesttiming.sgml     |  8 ++++++++
 src/bin/pg_archivecleanup/Makefile     | 30 +++++++++++++++++++++++----
 src/bin/pg_standby/Makefile            | 30 +++++++++++++++++++++++----
 src/bin/pg_test_fsync/Makefile         | 28 ++++++++++++++++++++++---
 src/bin/pg_test_timing/Makefile        | 28 ++++++++++++++++++++++---
 src/bin/pg_upgrade/Makefile            | 37 ++++++++++++++++++++++++++--------
 src/bin/pg_xlogdump/Makefile           | 33 ++++++++++++++++++++++++------
 src/bin/pgbench/Makefile               | 33 ++++++++++++++++++++++++------
 11 files changed, 217 insertions(+), 34 deletions(-)

diff --git a/doc/src/sgml/ref/pgarchivecleanup.sgml b/doc/src/sgml/ref/pgarchivecleanup.sgml
index 2665c53..f9f32e9 100644
--- a/doc/src/sgml/ref/pgarchivecleanup.sgml
+++ b/doc/src/sgml/ref/pgarchivecleanup.sgml
@@ -197,6 +197,14 @@ 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/ref/pgstandby.sgml b/doc/src/sgml/ref/pgstandby.sgml
index 87d5043..698a6c2 100644
--- a/doc/src/sgml/ref/pgstandby.sgml
+++ b/doc/src/sgml/ref/pgstandby.sgml
@@ -380,6 +380,14 @@ recovery_end_command = 'del C:\pgsql.trigger.5442'
  </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/ref/pgtestfsync.sgml b/doc/src/sgml/ref/pgtestfsync.sgml
index 3f76071..f704ab5 100644
--- a/doc/src/sgml/ref/pgtestfsync.sgml
+++ b/doc/src/sgml/ref/pgtestfsync.sgml
@@ -107,6 +107,14 @@ PostgreSQL documentation
  </refsect1>
 
  <refsect1>
+  <title>Author</title>
+
+  <para>
+   Bruce Momjian <email>bruce@momjian.us</email>
+  </para>
+ </refsect1>
+
+ <refsect1>
   <title>See Also</title>
 
   <simplelist type="inline">
diff --git a/doc/src/sgml/ref/pgtesttiming.sgml b/doc/src/sgml/ref/pgtesttiming.sgml
index 9850538..d1279fc 100644
--- a/doc/src/sgml/ref/pgtesttiming.sgml
+++ b/doc/src/sgml/ref/pgtesttiming.sgml
@@ -294,6 +294,14 @@ Histogram of timing durations:
  </refsect1>
 
  <refsect1>
+  <title>Author</title>
+
+  <para>
+   Ants Aasma <email>ants.aasma@eesti.ee</email>
+  </para>
+ </refsect1>
+
+ <refsect1>
   <title>See Also</title>
 
   <simplelist type="inline">
diff --git a/src/bin/pg_archivecleanup/Makefile b/src/bin/pg_archivecleanup/Makefile
index 5df86eb..b7d792e 100644
--- a/src/bin/pg_archivecleanup/Makefile
+++ b/src/bin/pg_archivecleanup/Makefile
@@ -1,4 +1,13 @@
+#-------------------------------------------------------------------------
+#
+# Makefile for src/bin/pg_archivecleanup
+#
+# Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
+# Portions Copyright (c) 1994, Regents of the University of California
+#
 # src/bin/pg_archivecleanup/Makefile
+#
+#-------------------------------------------------------------------------
 
 PGFILEDESC = "pg_archivecleanup - cleans archive when used with streaming replication"
 PGAPPICON = win32
@@ -7,8 +16,21 @@ subdir = src/bin/pg_archivecleanup
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-PROGRAM = pg_archivecleanup
-OBJS	= pg_archivecleanup.o $(WIN32RES)
+OBJS = pg_archivecleanup.o $(WIN32RES)
 
-NO_PGXS = 1
-include $(top_srcdir)/src/makefiles/pgxs.mk
+all: pg_archivecleanup
+
+pg_archivecleanup: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+install: all installdirs
+	$(INSTALL_PROGRAM) pg_archivecleanup$(X) '$(DESTDIR)$(bindir)/pg_archivecleanup$(X)'
+
+installdirs:
+	$(MKDIR_P) '$(DESTDIR)$(bindir)'
+
+uninstall:
+	rm -f '$(DESTDIR)$(bindir)/pg_archivecleanup$(X)'
+
+clean distclean maintainer-clean:
+	rm -f pg_archivecleanup$(X) $(OBJS)
diff --git a/src/bin/pg_standby/Makefile b/src/bin/pg_standby/Makefile
index d45a47d..a975eae 100644
--- a/src/bin/pg_standby/Makefile
+++ b/src/bin/pg_standby/Makefile
@@ -1,4 +1,13 @@
+#-------------------------------------------------------------------------
+#
+# Makefile for src/bin/pg_standby
+#
+# Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
+# Portions Copyright (c) 1994, Regents of the University of California
+#
 # src/bin/pg_standby/Makefile
+#
+#-------------------------------------------------------------------------
 
 PGFILEDESC = "pg_standby - supports creation of a warm standby"
 PGAPPICON = win32
@@ -7,8 +16,21 @@ subdir = src/bin/pg_standby
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-PROGRAM = pg_standby
-OBJS	= pg_standby.o $(WIN32RES)
+OBJS = pg_standby.o $(WIN32RES)
 
-NO_PGXS = 1
-include $(top_srcdir)/src/makefiles/pgxs.mk
+all: pg_standby
+
+pg_standby: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+install: all installdirs
+	$(INSTALL_PROGRAM) pg_standby$(X) '$(DESTDIR)$(bindir)/pg_standby$(X)'
+
+installdirs:
+	$(MKDIR_P) '$(DESTDIR)$(bindir)'
+
+uninstall:
+	rm -f '$(DESTDIR)$(bindir)/pg_standby$(X)'
+
+clean distclean maintainer-clean:
+	rm -f pg_standby$(X) $(OBJS)
diff --git a/src/bin/pg_test_fsync/Makefile b/src/bin/pg_test_fsync/Makefile
index e8d1952..72cf50b 100644
--- a/src/bin/pg_test_fsync/Makefile
+++ b/src/bin/pg_test_fsync/Makefile
@@ -1,4 +1,13 @@
+#-------------------------------------------------------------------------
+#
+# Makefile for src/bin/pg_test_fsync
+#
+# Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
+# Portions Copyright (c) 1994, Regents of the University of California
+#
 # src/bin/pg_test_fsync/Makefile
+#
+#-------------------------------------------------------------------------
 
 PGFILEDESC = "pg_test_fsync - test various disk sync methods"
 PGAPPICON = win32
@@ -7,8 +16,21 @@ subdir = src/bin/pg_test_fsync
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-PROGRAM  = pg_test_fsync
 OBJS = pg_test_fsync.o $(WIN32RES)
 
-NO_PGXS = 1
-include $(top_srcdir)/src/makefiles/pgxs.mk
+all: pg_test_fsync
+
+pg_test_fsync: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+install: all installdirs
+	$(INSTALL_PROGRAM) pg_test_fsync$(X) '$(DESTDIR)$(bindir)/pg_test_fsync$(X)'
+
+installdirs:
+	$(MKDIR_P) '$(DESTDIR)$(bindir)'
+
+uninstall:
+	rm -f '$(DESTDIR)$(bindir)/pg_test_fsync$(X)'
+
+clean distclean maintainer-clean:
+	rm -f pg_test_fsync$(X) $(OBJS)
diff --git a/src/bin/pg_test_timing/Makefile b/src/bin/pg_test_timing/Makefile
index f96d2e9..61f0a04 100644
--- a/src/bin/pg_test_timing/Makefile
+++ b/src/bin/pg_test_timing/Makefile
@@ -1,4 +1,13 @@
+#-------------------------------------------------------------------------
+#
+# Makefile for src/bin/pg_test_timing
+#
+# Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
+# Portions Copyright (c) 1994, Regents of the University of California
+#
 # src/bin/pg_test_timing/Makefile
+#
+#-------------------------------------------------------------------------
 
 PGFILEDESC = "pg_test_timing - test timing overhead"
 PGAPPICON = win32
@@ -7,8 +16,21 @@ subdir = src/bin/pg_test_timing
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-PROGRAM  = pg_test_timing
 OBJS = pg_test_timing.o $(WIN32RES)
 
-NO_PGXS = 1
-include $(top_srcdir)/src/makefiles/pgxs.mk
+all: pg_test_timing
+
+pg_test_timing: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+install: all installdirs
+	$(INSTALL_PROGRAM) pg_test_timing$(X) '$(DESTDIR)$(bindir)/pg_test_timing$(X)'
+
+installdirs:
+	$(MKDIR_P) '$(DESTDIR)$(bindir)'
+
+uninstall:
+	rm -f '$(DESTDIR)$(bindir)/pg_test_timing$(X)'
+
+clean distclean maintainer-clean:
+	rm -f pg_test_timing$(X) $(OBJS)
diff --git a/src/bin/pg_upgrade/Makefile b/src/bin/pg_upgrade/Makefile
index c22daa5..0f67a76 100644
--- a/src/bin/pg_upgrade/Makefile
+++ b/src/bin/pg_upgrade/Makefile
@@ -1,4 +1,13 @@
+#-------------------------------------------------------------------------
+#
+# Makefile for src/bin/pg_upgrade
+#
+# Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
+# Portions Copyright (c) 1994, Regents of the University of California
+#
 # src/bin/pg_upgrade/Makefile
+#
+#-------------------------------------------------------------------------
 
 PGFILEDESC = "pg_upgrade - an in-place binary upgrade utility"
 PGAPPICON = win32
@@ -7,20 +16,32 @@ subdir = src/bin/pg_upgrade
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-PROGRAM  = pg_upgrade
 OBJS = check.o controldata.o dump.o exec.o file.o function.o info.o \
        option.o page.o parallel.o pg_upgrade.o relfilenode.o server.o \
        tablespace.o util.o version.o $(WIN32RES)
 
-PG_CPPFLAGS  = -DFRONTEND -DDLSUFFIX=\"$(DLSUFFIX)\" -I$(srcdir) -I$(libpq_srcdir)
-PG_LIBS = $(libpq_pgport)
+override CPPFLAGS := -DFRONTEND -DDLSUFFIX=\"$(DLSUFFIX)\" -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)
 
-EXTRA_CLEAN = analyze_new_cluster.sh delete_old_cluster.sh log/ tmp_check/ \
-              pg_upgrade_dump_globals.sql \
-              pg_upgrade_dump_*.custom pg_upgrade_*.log
+EXTRA_OBJS = analyze_new_cluster.sh delete_old_cluster.sh log/ tmp_check/ \
+	     pg_upgrade_dump_globals.sql \
+	     pg_upgrade_dump_*.custom pg_upgrade_*.log
 
-NO_PGXS = 1
-include $(top_srcdir)/src/makefiles/pgxs.mk
+all: pg_upgrade
+
+pg_upgrade: $(OBJS) | submake-libpq submake-libpgport
+	$(CC) $(CFLAGS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+install: all installdirs
+	$(INSTALL_PROGRAM) pg_upgrade$(X) '$(DESTDIR)$(bindir)/pg_upgrade$(X)'
+
+installdirs:
+	$(MKDIR_P) '$(DESTDIR)$(bindir)'
+
+uninstall:
+	rm -f '$(DESTDIR)$(bindir)/pg_upgrade$(X)'
+
+clean distclean maintainer-clean:
+	rm -rf pg_upgrade$(X) $(OBJS) $(EXTRA_OBJS)
 
 check: test.sh all
 	MAKE=$(MAKE) bindir=$(bindir) libdir=$(libdir) EXTRA_REGRESS_OPTS="$(EXTRA_REGRESS_OPTS)" $(SHELL) $< --install
diff --git a/src/bin/pg_xlogdump/Makefile b/src/bin/pg_xlogdump/Makefile
index ab8597b..067ed44 100644
--- a/src/bin/pg_xlogdump/Makefile
+++ b/src/bin/pg_xlogdump/Makefile
@@ -1,13 +1,21 @@
+#-------------------------------------------------------------------------
+#
+# Makefile for src/bin/pg_xlogdump
+#
+# Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
+# Portions Copyright (c) 1994, Regents of the University of California
+#
 # src/bin/pg_xlogdump/Makefile
+#
+#-------------------------------------------------------------------------
 
 PGFILEDESC = "pg_xlogdump - decode and display WAL"
-PGAPPICON=win32
+PGAPPICON = win32
 
 subdir = src/bin/pg_xlogdump
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-PROGRAM = pg_xlogdump
 OBJS = pg_xlogdump.o compat.o xlogreader.o rmgrdesc.o \
 	$(RMGRDESCOBJS) $(WIN32RES)
 override CPPFLAGS := -DFRONTEND $(CPPFLAGS)
@@ -15,14 +23,27 @@ override CPPFLAGS := -DFRONTEND $(CPPFLAGS)
 RMGRDESCSOURCES = $(notdir $(wildcard $(top_srcdir)/src/backend/access/rmgrdesc/*desc.c))
 RMGRDESCOBJS = $(patsubst %.c,%.o,$(RMGRDESCSOURCES))
 
-EXTRA_CLEAN = $(RMGRDESCSOURCES) xlogreader.c
-
-NO_PGXS = 1
-include $(top_srcdir)/src/makefiles/pgxs.mk
+EXTRA_OBJS = $(RMGRDESCSOURCES) xlogreader.c
 
+all: pg_xlogdump
 
 xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/%
 	rm -f $@ && $(LN_S) $< .
 
 $(RMGRDESCSOURCES): % : $(top_srcdir)/src/backend/access/rmgrdesc/%
 	rm -f $@ && $(LN_S) $< .
+
+pg_xlogdump: $(OBJS)
+	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+install: all installdirs
+	$(INSTALL_PROGRAM) pg_xlogdump$(X) '$(DESTDIR)$(bindir)/pg_xlogdump$(X)'
+
+installdirs:
+	$(MKDIR_P) '$(DESTDIR)$(bindir)'
+
+uninstall:
+	rm -f '$(DESTDIR)$(bindir)/pg_xlogdump$(X)'
+
+clean distclean maintainer-clean:
+	rm -f pg_xlogdump$(X) $(OBJS) $(EXTRA_OBJS)
diff --git a/src/bin/pgbench/Makefile b/src/bin/pgbench/Makefile
index de4863c..5ac7283 100644
--- a/src/bin/pgbench/Makefile
+++ b/src/bin/pgbench/Makefile
@@ -1,4 +1,13 @@
+#-------------------------------------------------------------------------
+#
+# Makefile for src/bin/pgbench
+#
+# Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
+# Portions Copyright (c) 1994, Regents of the University of California
+#
 # src/bin/pgbench/Makefile
+#
+#-------------------------------------------------------------------------
 
 PGFILEDESC = "pgbench - a simple program for running benchmark tests"
 PGAPPICON = win32
@@ -7,15 +16,27 @@ subdir = src/bin/pgbench
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-PROGRAM = pgbench
 OBJS	= pgbench.o $(WIN32RES)
 
-PG_CPPFLAGS = -I$(libpq_srcdir)
-PG_LIBS = $(libpq_pgport) $(PTHREAD_LIBS)
-
-NO_PGXS = 1
-include $(top_srcdir)/src/makefiles/pgxs.mk
+override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
 
 ifneq ($(PORTNAME), win32)
 override CFLAGS += $(PTHREAD_CFLAGS)
 endif
+
+all: pgbench
+
+pgbench: $(OBJS) | submake-libpq submake-libpgport
+	$(CC) $(CFLAGS) $(OBJS) $(libpq_pgport) $(PTHREAD_LIBS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+install: all installdirs
+	$(INSTALL_PROGRAM) pgbench$(X) '$(DESTDIR)$(bindir)/pgbench$(X)'
+
+installdirs:
+	$(MKDIR_P) '$(DESTDIR)$(bindir)'
+
+uninstall:
+	rm -f '$(DESTDIR)$(bindir)/pgbench$(X)'
+
+clean distclean maintainer-clean:
+	rm -f pgbench$(X) $(OBJS)
-- 
2.2.2

