From 9d3085bffe74a0c2f4de1d8d27d383eba20523bf Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Tue, 10 Mar 2015 21:10:50 -0700
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
 src/tools/msvc/Mkvcbuild.pm              | 32 ++++++++++++++++----------------
 14 files changed, 28 insertions(+), 32 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 @@ pages.
   </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 @@ Complete list of usable sgml source files in this directory.
 <!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 @@
    &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
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index de4c194..0a0469a 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -32,40 +32,40 @@ my $libpq;
 # Set of variables for contrib modules
 my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' };
 my @contrib_uselibpq =
-  ('dblink', 'oid2name', 'pgbench', 'pg_upgrade', 'postgres_fdw', 'vacuumlo');
+  ('dblink', 'oid2name', 'pg_upgrade', 'postgres_fdw', 'vacuumlo');
 my @contrib_uselibpgport = (
-	'oid2name',       'pgbench',
-	'pg_standby',     'pg_test_fsync',
-	'pg_test_timing', 'pg_upgrade',
-	'vacuumlo');
+	'oid2name',      'pg_standby',
+	'pg_test_fsync', 'pg_test_timing',
+	'pg_upgrade',    'vacuumlo');
 my @contrib_uselibpgcommon = (
-	'oid2name',       'pgbench',
-	'pg_standby',     'pg_test_fsync',
-	'pg_test_timing', 'pg_upgrade',
-	'vacuumlo');
-my $contrib_extralibs = { 'pgbench' => ['ws2_32.lib'] };
+	'oid2name',      'pg_standby',
+	'pg_test_fsync', 'pg_test_timing',
+	'pg_upgrade',    'vacuumlo');
+my $contrib_extralibs = undef;
 my $contrib_extraincludes =
   { 'tsearch2' => ['contrib/tsearch2'], 'dblink' => ['src/backend'] };
 my $contrib_extrasource = {
 	'cube' => [ 'contrib\cube\cubescan.l', 'contrib\cube\cubeparse.y' ],
-	'pgbench' =>
-	  [ 'contrib\pgbench\exprscan.l', 'contrib\pgbench\exprparse.y' ],
 	'seg' => [ 'contrib\seg\segscan.l', 'contrib\seg\segparse.y' ], };
 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_uselibpq = ('pg_ctl', 'pgbench', 'psql');
+my @frontend_uselibpgport = ( 'pg_archivecleanup', 'pgbench' );
+my @frontend_uselibpgcommon = ( 'pg_archivecleanup', 'pgbench' );
 my $frontend_extralibs = {
 	'initdb'     => ['ws2_32.lib'],
 	'pg_restore' => ['ws2_32.lib'],
+	'pgbench'    => ['ws2_32.lib'],
 	'psql'       => ['ws2_32.lib'] };
 my $frontend_extraincludes = {
 	'initdb' => ['src\timezone'],
 	'psql'   => [ 'src\bin\pg_dump', 'src\backend' ] };
-my $frontend_extrasource = { 'psql' => ['src\bin\psql\psqlscan.l'] };
+my $frontend_extrasource = {
+	'pgbench' => [ 'src\bin\pgbench\exprscan.l',
+				   'src\bin\pgbench\exprparse.y' ],
+	'psql'    => [ 'src\bin\psql\psqlscan.l' ]};
 my @frontend_excludes = ('pgevent', 'pg_basebackup', 'pg_dump',
 						 'pg_xlogdump','scripts');
 
-- 
2.3.1

