From 963bcab5fcb16e5525885275ebaee55a682636bd Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Tue, 10 Mar 2015 22:33:24 -0400
Subject: [PATCH 3/7] Move pgbench from contrib/ to src/bin/

---
 contrib/Makefile                         |  1 -
 doc/src/sgml/contrib.sgml                |  1 -
 doc/src/sgml/filelist.sgml               |  1 -
 doc/src/sgml/ref/allfiles.sgml           |  1 +
 doc/src/sgml/{ => ref}/pgbench.sgml      |  2 +-
 doc/src/sgml/reference.sgml              |  1 +
 src/bin/Makefile                         |  1 +
 {contrib => src/bin}/pgbench/.gitignore  |  0
 {contrib => src/bin}/pgbench/Makefile    | 18 +++++++-----------
 {contrib => src/bin}/pgbench/exprparse.y |  0
 {contrib => src/bin}/pgbench/exprscan.l  |  0
 {contrib => src/bin}/pgbench/pgbench.c   |  2 +-
 {contrib => src/bin}/pgbench/pgbench.h   |  0
 13 files changed, 12 insertions(+), 16 deletions(-)
 rename doc/src/sgml/{ => ref}/pgbench.sgml (99%)
 rename {contrib => src/bin}/pgbench/.gitignore (100%)
 rename {contrib => src/bin}/pgbench/Makefile (68%)
 rename {contrib => src/bin}/pgbench/exprparse.y (100%)
 rename {contrib => src/bin}/pgbench/exprscan.l (100%)
 rename {contrib => src/bin}/pgbench/pgbench.c (99%)
 rename {contrib => src/bin}/pgbench/pgbench.h (100%)

diff --git a/contrib/Makefile b/contrib/Makefile
index d9557b8..bd677d1 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -38,7 +38,6 @@ SUBDIRS = \
 		pg_trgm		\
 		pg_upgrade	\
 		pg_upgrade_support \
-		pgbench		\
 		pgcrypto	\
 		pgrowlocks	\
 		pgstattuple	\
diff --git a/doc/src/sgml/contrib.sgml b/doc/src/sgml/contrib.sgml
index d0e1446..577791b 100644
--- a/doc/src/sgml/contrib.sgml
+++ b/doc/src/sgml/contrib.sgml
@@ -187,7 +187,6 @@ <title>Client Applications</title>
   </para>
 
  &oid2name;
- &pgbench;
  &vacuumlo;
  </sect1>
 
diff --git a/doc/src/sgml/filelist.sgml b/doc/src/sgml/filelist.sgml
index 3b26a70..5bdde7b 100644
--- a/doc/src/sgml/filelist.sgml
+++ b/doc/src/sgml/filelist.sgml
@@ -124,7 +124,6 @@
 <!ENTITY oid2name        SYSTEM "oid2name.sgml">
 <!ENTITY pageinspect     SYSTEM "pageinspect.sgml">
 <!ENTITY passwordcheck   SYSTEM "passwordcheck.sgml">
-<!ENTITY pgbench         SYSTEM "pgbench.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 17260b9..61462da 100644
--- a/doc/src/sgml/ref/allfiles.sgml
+++ b/doc/src/sgml/ref/allfiles.sgml
@@ -181,6 +181,7 @@
 <!ENTITY initdb             SYSTEM "initdb.sgml">
 <!ENTITY pgarchivecleanup   SYSTEM "pgarchivecleanup.sgml">
 <!ENTITY pgBasebackup       SYSTEM "pg_basebackup.sgml">
+<!ENTITY pgbench            SYSTEM "pgbench.sgml">
 <!ENTITY pgConfig           SYSTEM "pg_config-ref.sgml">
 <!ENTITY pgControldata      SYSTEM "pg_controldata.sgml">
 <!ENTITY pgCtl              SYSTEM "pg_ctl-ref.sgml">
diff --git a/doc/src/sgml/pgbench.sgml b/doc/src/sgml/ref/pgbench.sgml
similarity index 99%
rename from doc/src/sgml/pgbench.sgml
rename to doc/src/sgml/ref/pgbench.sgml
index ed12e27..a808546 100644
--- a/doc/src/sgml/pgbench.sgml
+++ b/doc/src/sgml/ref/pgbench.sgml
@@ -1,4 +1,4 @@
-<!-- doc/src/sgml/pgbench.sgml -->
+<!-- doc/src/sgml/ref/pgbench.sgml -->
 
 <refentry id="pgbench">
  <indexterm zone="pgbench">
diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml
index 07c923b..d939d01 100644
--- a/doc/src/sgml/reference.sgml
+++ b/doc/src/sgml/reference.sgml
@@ -230,6 +230,7 @@ <title>PostgreSQL Client Applications</title>
    &dropuser;
    &ecpgRef;
    &pgBasebackup;
+   &pgbench;
    &pgConfig;
    &pgDump;
    &pgDumpall;
diff --git a/src/bin/Makefile b/src/bin/Makefile
index 469798e..3ce7707 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -23,6 +23,7 @@ SUBDIRS = \
 	pg_dump \
 	pg_resetxlog \
 	pg_xlogdump \
+	pgbench \
 	psql \
 	scripts
 
diff --git a/contrib/pgbench/.gitignore b/src/bin/pgbench/.gitignore
similarity index 100%
rename from contrib/pgbench/.gitignore
rename to src/bin/pgbench/.gitignore
diff --git a/contrib/pgbench/Makefile b/src/bin/pgbench/Makefile
similarity index 68%
rename from contrib/pgbench/Makefile
rename to src/bin/pgbench/Makefile
index a18130b..86fd757 100644
--- a/contrib/pgbench/Makefile
+++ b/src/bin/pgbench/Makefile
@@ -1,26 +1,22 @@
-# contrib/pgbench/Makefile
+# src/bin/pgbench/Makefile
 
 PGFILEDESC = "pgbench - a simple program for running benchmark tests"
 PGAPPICON = win32
 
+subdir = src/bin/pgbench
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
 PROGRAM = pgbench
 OBJS	= pgbench.o exprparse.o $(WIN32RES)
 
 PG_CPPFLAGS = -I$(libpq_srcdir)
 PG_LIBS = $(libpq_pgport) $(PTHREAD_LIBS)
 
-ifdef USE_PGXS
-PG_CONFIG = pg_config
-PGXS := $(shell $(PG_CONFIG) --pgxs)
-include $(PGXS)
-else
-subdir = contrib/pgbench
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-include $(top_srcdir)/contrib/contrib-global.mk
+NO_PGXS = 1
+include $(top_srcdir)/src/makefiles/pgxs.mk
 
 distprep: exprparse.c exprscan.c
-endif
 
 ifneq ($(PORTNAME), win32)
 override CFLAGS += $(PTHREAD_CFLAGS)
diff --git a/contrib/pgbench/exprparse.y b/src/bin/pgbench/exprparse.y
similarity index 100%
rename from contrib/pgbench/exprparse.y
rename to src/bin/pgbench/exprparse.y
diff --git a/contrib/pgbench/exprscan.l b/src/bin/pgbench/exprscan.l
similarity index 100%
rename from contrib/pgbench/exprscan.l
rename to src/bin/pgbench/exprscan.l
diff --git a/contrib/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
similarity index 99%
rename from contrib/pgbench/pgbench.c
rename to src/bin/pgbench/pgbench.c
index 706fdf5..43df747 100644
--- a/contrib/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -4,7 +4,7 @@
  * A simple benchmark program for PostgreSQL
  * Originally written by Tatsuo Ishii and enhanced by many contributors.
  *
- * contrib/pgbench/pgbench.c
+ * src/bin/pgbench/pgbench.c
  * Copyright (c) 2000-2015, PostgreSQL Global Development Group
  * ALL RIGHTS RESERVED;
  *
diff --git a/contrib/pgbench/pgbench.h b/src/bin/pgbench/pgbench.h
similarity index 100%
rename from contrib/pgbench/pgbench.h
rename to src/bin/pgbench/pgbench.h
-- 
2.3.2

