From 314ed5de6db214600595ddf46eacffb23d0a72e1 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Thu, 27 Sep 2007 19:53:44 +0000
Subject: [PATCH] Define the FRONTEND symbol in postgres_fe.h, which allows us
 to eliminate duplicative -DFRONTEND flags from many Makefiles.  We still need
 Makefile control of the symbol in a few places that compile
 frontend-or-backend src/port/ files, but it's a lot cleaner than before.

Hiroshi Saito
---
 src/bin/initdb/Makefile                 | 4 ++--
 src/bin/pg_config/Makefile              | 3 +--
 src/bin/pg_controldata/Makefile         | 4 +---
 src/bin/pg_ctl/Makefile                 | 4 ++--
 src/bin/pg_dump/Makefile                | 4 ++--
 src/bin/pg_resetxlog/Makefile           | 4 +---
 src/bin/psql/Makefile                   | 4 ++--
 src/bin/scripts/Makefile                | 4 ++--
 src/include/postgres_fe.h               | 6 +++++-
 src/interfaces/ecpg/ecpglib/Makefile    | 5 ++---
 src/interfaces/ecpg/include/Makefile    | 3 +--
 src/interfaces/ecpg/pgtypeslib/Makefile | 5 ++---
 src/tools/findoidjoins/Makefile         | 4 ++--
 src/tools/fsync/Makefile                | 4 ++--
 src/tools/msvc/Mkvcbuild.pm             | 4 +---
 15 files changed, 28 insertions(+), 34 deletions(-)

diff --git a/src/bin/initdb/Makefile b/src/bin/initdb/Makefile
index c81378787c1..138d5ec7a3a 100644
--- a/src/bin/initdb/Makefile
+++ b/src/bin/initdb/Makefile
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/bin/initdb/Makefile,v 1.52 2007/01/05 22:19:47 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/initdb/Makefile,v 1.53 2007/09/27 19:53:43 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -14,7 +14,7 @@ subdir = src/bin/initdb
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS)
+override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
 
 OBJS=	initdb.o $(WIN32RES)
 
diff --git a/src/bin/pg_config/Makefile b/src/bin/pg_config/Makefile
index ebfb0fec1a0..07c41adcedc 100644
--- a/src/bin/pg_config/Makefile
+++ b/src/bin/pg_config/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1998-2007, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/bin/pg_config/Makefile,v 1.18 2007/01/05 22:19:48 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_config/Makefile,v 1.19 2007/09/27 19:53:43 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -19,7 +19,6 @@ OBJS=   pg_config.o $(WIN32RES)
 STD_CPPFLAGS := $(filter-out -I$(top_srcdir)/src/include -I$(top_builddir)/src/include,$(CPPFLAGS))
 STD_LDFLAGS := $(filter-out -L$(top_builddir)/src/port,$(LDFLAGS))
 
-override CPPFLAGS += -DFRONTEND
 override CPPFLAGS += -DVAL_CONFIGURE="\"$(configure_args)\""
 override CPPFLAGS += -DVAL_CC="\"$(CC)\""
 override CPPFLAGS += -DVAL_CPPFLAGS="\"$(STD_CPPFLAGS)\""
diff --git a/src/bin/pg_controldata/Makefile b/src/bin/pg_controldata/Makefile
index bf5ea029052..ae88707cbbf 100644
--- a/src/bin/pg_controldata/Makefile
+++ b/src/bin/pg_controldata/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1998-2007, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/bin/pg_controldata/Makefile,v 1.15 2007/01/05 22:19:48 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_controldata/Makefile,v 1.16 2007/09/27 19:53:43 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -13,8 +13,6 @@ subdir = src/bin/pg_controldata
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-override CPPFLAGS += -DFRONTEND
-
 OBJS= pg_controldata.o pg_crc.o $(WIN32RES)
 
 all: submake-libpgport pg_controldata
diff --git a/src/bin/pg_ctl/Makefile b/src/bin/pg_ctl/Makefile
index 460786fd15b..53c9c1b70ad 100644
--- a/src/bin/pg_ctl/Makefile
+++ b/src/bin/pg_ctl/Makefile
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/bin/pg_ctl/Makefile,v 1.23 2007/01/05 22:19:48 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_ctl/Makefile,v 1.24 2007/09/27 19:53:43 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -14,7 +14,7 @@ subdir = src/bin/pg_ctl
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-override CPPFLAGS := -DFRONTEND -DDEF_PGPORT=$(DEF_PGPORT) -I$(libpq_srcdir) $(CPPFLAGS)
+override CPPFLAGS := -DDEF_PGPORT=$(DEF_PGPORT) -I$(libpq_srcdir) $(CPPFLAGS)
 
 OBJS=	pg_ctl.o $(WIN32RES)
 
diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile
index a21bcc1e953..8f912d381ae 100644
--- a/src/bin/pg_dump/Makefile
+++ b/src/bin/pg_dump/Makefile
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/bin/pg_dump/Makefile,v 1.63 2007/01/05 22:19:48 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_dump/Makefile,v 1.64 2007/09/27 19:53:43 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -14,7 +14,7 @@ subdir = src/bin/pg_dump
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS)
+override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
 
 OBJS=	pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \
 	pg_backup_files.o pg_backup_null.o pg_backup_tar.o \
diff --git a/src/bin/pg_resetxlog/Makefile b/src/bin/pg_resetxlog/Makefile
index a3a27e8b934..2aa38792dd6 100644
--- a/src/bin/pg_resetxlog/Makefile
+++ b/src/bin/pg_resetxlog/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1998-2007, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/bin/pg_resetxlog/Makefile,v 1.17 2007/01/05 22:19:48 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_resetxlog/Makefile,v 1.18 2007/09/27 19:53:43 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -13,8 +13,6 @@ subdir = src/bin/pg_resetxlog
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-override CPPFLAGS += -DFRONTEND
-
 OBJS= pg_resetxlog.o pg_crc.o $(WIN32RES)
 
 all: submake-libpgport pg_resetxlog
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index 08d523820ff..c387e79c54c 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.58 2007/01/05 22:19:48 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.59 2007/09/27 19:53:43 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -17,7 +17,7 @@ include $(top_builddir)/src/Makefile.global
 
 REFDOCDIR= $(top_srcdir)/doc/src/sgml/ref
 
-override CPPFLAGS := -DFRONTEND -I$(srcdir) -I$(libpq_srcdir) -I$(top_srcdir)/src/bin/pg_dump $(CPPFLAGS)
+override CPPFLAGS := -I$(srcdir) -I$(libpq_srcdir) -I$(top_srcdir)/src/bin/pg_dump $(CPPFLAGS)
 
 OBJS=	command.o common.o help.o input.o stringutils.o mainloop.o copy.o \
 	startup.o prompt.o variables.o large_obj.o print.o describe.o \
diff --git a/src/bin/scripts/Makefile b/src/bin/scripts/Makefile
index 96d53e9a513..0132cec6e74 100644
--- a/src/bin/scripts/Makefile
+++ b/src/bin/scripts/Makefile
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/bin/scripts/Makefile,v 1.37 2007/01/05 22:19:50 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/scripts/Makefile,v 1.38 2007/09/27 19:53:44 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -16,7 +16,7 @@ include $(top_builddir)/src/Makefile.global
 
 PROGRAMS = createdb createlang createuser dropdb droplang dropuser clusterdb vacuumdb reindexdb
 
-override CPPFLAGS := -DFRONTEND -I$(top_srcdir)/src/bin/pg_dump -I$(top_srcdir)/src/bin/psql -I$(libpq_srcdir) $(CPPFLAGS)
+override CPPFLAGS := -I$(top_srcdir)/src/bin/pg_dump -I$(top_srcdir)/src/bin/psql -I$(libpq_srcdir) $(CPPFLAGS)
 
 all: submake-libpq submake-backend $(PROGRAMS)
 
diff --git a/src/include/postgres_fe.h b/src/include/postgres_fe.h
index 1b09c639a09..f9744aab6b5 100644
--- a/src/include/postgres_fe.h
+++ b/src/include/postgres_fe.h
@@ -11,13 +11,17 @@
  * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
  * Portions Copyright (c) 1995, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/postgres_fe.h,v 1.12 2007/01/05 22:19:50 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/postgres_fe.h,v 1.13 2007/09/27 19:53:44 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 #ifndef POSTGRES_FE_H
 #define POSTGRES_FE_H
 
+#ifndef FRONTEND
+#define FRONTEND 1
+#endif
+
 #include "c.h"
 
 #endif   /* POSTGRES_FE_H */
diff --git a/src/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile
index f60207e23c0..d95054fb324 100644
--- a/src/interfaces/ecpg/ecpglib/Makefile
+++ b/src/interfaces/ecpg/ecpglib/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.47 2007/08/14 10:01:52 meskes Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.48 2007/09/27 19:53:44 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -17,8 +17,7 @@ SO_MAJOR_VERSION= 6
 SO_MINOR_VERSION= 0
 DLTYPE= library
 
-override CPPFLAGS := -DFRONTEND \
-	-I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
+override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
 	-I$(libpq_srcdir) -I$(top_builddir)/src/port $(CPPFLAGS)
 override CFLAGS += $(PTHREAD_CFLAGS)
 
diff --git a/src/interfaces/ecpg/include/Makefile b/src/interfaces/ecpg/include/Makefile
index 2e587aac6b5..a77c5c7e23d 100644
--- a/src/interfaces/ecpg/include/Makefile
+++ b/src/interfaces/ecpg/include/Makefile
@@ -2,8 +2,7 @@ subdir = src/interfaces/ecpg/include
 top_builddir = ../../../..
 include $(top_builddir)/src/Makefile.global
 
-override CPPFLAGS := -DFRONTEND \
-	-I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
+override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
 	-I$(libpq_srcdir) -I$(top_builddir)/src/port $(CPPFLAGS)
 
 informix_esql_dir = $(pkgincludedir)/informix/esql
diff --git a/src/interfaces/ecpg/pgtypeslib/Makefile b/src/interfaces/ecpg/pgtypeslib/Makefile
index e136b915992..c02291d68a3 100644
--- a/src/interfaces/ecpg/pgtypeslib/Makefile
+++ b/src/interfaces/ecpg/pgtypeslib/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.32 2007/01/20 17:16:17 petere Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.33 2007/09/27 19:53:44 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -17,8 +17,7 @@ SO_MAJOR_VERSION= 2
 SO_MINOR_VERSION= 3
 DLTYPE= library
 
-override CPPFLAGS := -DFRONTEND \
-	-I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
+override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
 	-I$(top_srcdir)/src/include/utils -I$(libpq_srcdir) $(CPPFLAGS)
 override CFLAGS += $(PTHREAD_CFLAGS)
 
diff --git a/src/tools/findoidjoins/Makefile b/src/tools/findoidjoins/Makefile
index 867fadb9896..0f2cf1aa19b 100644
--- a/src/tools/findoidjoins/Makefile
+++ b/src/tools/findoidjoins/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 2003-2007, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/tools/findoidjoins/Makefile,v 1.3 2007/01/05 22:20:04 momjian Exp $
+# $PostgreSQL: pgsql/src/tools/findoidjoins/Makefile,v 1.4 2007/09/27 19:53:44 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -12,7 +12,7 @@ subdir = src/tools/findoidjoins
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS)
+override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
 
 OBJS= findoidjoins.o
 
diff --git a/src/tools/fsync/Makefile b/src/tools/fsync/Makefile
index 70684d9ec00..03169d9be77 100644
--- a/src/tools/fsync/Makefile
+++ b/src/tools/fsync/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 2003-2007, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/tools/fsync/Makefile,v 1.4 2007/01/05 22:20:05 momjian Exp $
+# $PostgreSQL: pgsql/src/tools/fsync/Makefile,v 1.5 2007/09/27 19:53:44 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -12,7 +12,7 @@ subdir = src/tools/fsync
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS)
+override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
 
 OBJS= test_fsync.o
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 54a60f72d3c..f1084151a7c 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -3,7 +3,7 @@ package Mkvcbuild;
 #
 # Package that generates build files for msvc build
 #
-# $PostgreSQL: pgsql/src/tools/msvc/Mkvcbuild.pm,v 1.16 2007/08/21 15:10:41 mha Exp $
+# $PostgreSQL: pgsql/src/tools/msvc/Mkvcbuild.pm,v 1.17 2007/09/27 19:53:44 tgl Exp $
 #
 use Carp;
 use Win32;
@@ -341,7 +341,6 @@ sub mkvcbuild
     $pgregress->AddFile('src\test\regress\pg_regress_main.c');
     $pgregress->AddIncludeDir('src\port');
     $pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
-    $pgregress->AddDefine('FRONTEND');
     $pgregress->AddReference($libpgport);
 
     $solution->Save();
@@ -359,7 +358,6 @@ sub AddSimpleFrontend
 
     my $p = $solution->AddProject($n,'exe','bin');
     $p->AddDir('src\bin\\' . $n);
-    $p->AddDefine('FRONTEND');
     $p->AddReference($libpgport);
     if ($uselibpq)
     {
-- 
GitLab