diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index 09e8bc6425ed8989d67b7dd521c64729ac74d098..9f7a09c6fc11419853dbc3d3b61c76c3031d148d 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.49 2004/10/04 18:05:55 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.50 2004/10/04 20:36:10 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -15,7 +15,7 @@ include $(top_builddir)/src/Makefile.global
 
 REFDOCDIR= $(top_srcdir)/doc/src/sgml/ref
 
-override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS) -DFRONTEND
+override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(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/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile
index 004bca7f7425173562b50e374e0340d506022aa0..e8bb4d983db90204fc8f02acaaaf4a40b5d7e90b 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.25 2004/07/13 00:06:41 tgl Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.26 2004/10/04 20:36:11 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -21,6 +21,9 @@ override CPPFLAGS := -DFRONTEND -I$(top_srcdir)/src/interfaces/ecpg/include \
 	-I$(libpq_srcdir) -I$(top_builddir)/src/port $(CPPFLAGS)
 override CFLAGS += $(PTHREAD_CFLAGS)
 
+# Need to recomple any libpgport object files
+LIBS := $(patsubst -lpgport,, $(LIBS))
+
 OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
 	connect.o misc.o path.o exec.o
 
diff --git a/src/interfaces/ecpg/pgtypeslib/Makefile b/src/interfaces/ecpg/pgtypeslib/Makefile
index 165b0346f7b391ee19a06964ad9f967096c9fe18..545bbc4949c021127be48618889a90562f5745dd 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.22 2004/07/13 00:06:43 tgl Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.23 2004/10/04 20:36:12 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -21,6 +21,9 @@ override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include \
 	-I$(top_srcdir)/src/include/utils -I$(libpq_srcdir) $(CPPFLAGS) \
 	$(PTHREAD_CFLAGS) -DFRONTEND
 
+# Need to recomple any libpgport object files
+LIBS := $(patsubst -lpgport,, $(LIBS))
+
 SHLIB_LINK += -lm
 
 OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o \
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index d65b4775a0d1d15520b53b36ed1b049f812bed8c..b0a90b010c7c9ae999a27e0df46809d442989ff0 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.113 2004/09/26 02:14:47 momjian Exp $
+# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.114 2004/10/04 20:36:12 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -19,9 +19,12 @@ SO_MAJOR_VERSION= 3
 SO_MINOR_VERSION= 2
 DLTYPE= library
 
-override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port -DFRONTEND
+override CPPFLAGS :=  -DFRONTEND -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port
 override CFLAGS += $(PTHREAD_CFLAGS)
 
+# Need to recomple any libpgport object files
+LIBS := $(patsubst -lpgport,, $(LIBS))
+
 OBJS=	fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
 	fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
 	dllist.o md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o \