diff --git a/src/bin/initdb/Makefile b/src/bin/initdb/Makefile
index 0df36c62562fd49300ce0c146e9fbac5018f7882..0af6ae798eae57e32cbb2ba69bbe6bc5d16c26cc 100644
--- a/src/bin/initdb/Makefile
+++ b/src/bin/initdb/Makefile
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/bin/initdb/Makefile,v 1.39 2004/05/18 20:18:58 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/initdb/Makefile,v 1.40 2004/05/19 17:15:20 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -15,13 +15,17 @@ include $(top_builddir)/src/Makefile.global
 
 override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS)
 
-OBJS=	initdb.o
+OBJS=	initdb.o \
+	$(filter exec.o, $(LIBOBJS))
 
 all: submake-libpq submake-libpgport initdb
 
 initdb: $(OBJS) $(libpq_builddir)/libpq.a
 	$(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
 
+exec.c: % : $(top_srcdir)/src/port/%
+	rm -f $@ && $(LN_S) $< .
+
 install: all installdirs
 	$(INSTALL_PROGRAM) initdb$(X) $(DESTDIR)$(bindir)/initdb$(X)
 
@@ -32,7 +36,7 @@ uninstall:
 	rm -f $(DESTDIR)$(bindir)/initdb$(X)
 
 clean distclean maintainer-clean:
-	rm -f initdb$(X) $(OBJS)
+	rm -f initdb$(X) $(OBJS) exec.c
 
 
 # ensure that changes in datadir propagate into object file
diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile
index 23d1890f1ced1da583589899c861de538afe0403..51f97ac88b485d45be10063f234396cc21ecbc1f 100644
--- a/src/bin/pg_dump/Makefile
+++ b/src/bin/pg_dump/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/pg_dump/Makefile,v 1.48 2004/05/18 20:18:58 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_dump/Makefile,v 1.49 2004/05/19 17:15:20 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -18,6 +18,7 @@ override CPPFLAGS += -DFRONTEND
 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 \
 	dumputils.o
+PG_DUMPALL_OBJS =	$(filter exec.o, $(LIBOBJS))
 
 EXTRA_OBJS = $(top_builddir)/src/backend/parser/keywords.o
 
@@ -32,8 +33,11 @@ pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) $(libpq_builddir)/libpq.a
 pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
 	$(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
 
-pg_dumpall: pg_dumpall.o dumputils.o $(libpq_builddir)/libpq.a
-	$(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
+pg_dumpall: pg_dumpall.o dumputils.o $(PG_DUMPALL_OBJS) $(libpq_builddir)/libpq.a
+	$(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(PG_DUMPALL_OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
+
+exec.c: % : $(top_srcdir)/src/port/%
+	rm -f $@ && $(LN_S) $< .
 
 .PHONY: submake-backend
 submake-backend:
@@ -52,4 +56,4 @@ uninstall:
 	rm -f $(addprefix $(DESTDIR)$(bindir)/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X))
 
 clean distclean maintainer-clean:
-	rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o
+	rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o exec.c
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index 46ee47161bc82fcbebb7958a82f49fac0a9e3a1a..c61b6e0bb995cd2cf6fae4efb937d143a644b2ae 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.45 2004/05/18 20:18:58 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.46 2004/05/19 17:15:21 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -19,7 +19,8 @@ override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) -DFRONTEND
 
 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 \
-	psqlscan.o tab-complete.o mbprint.o
+	psqlscan.o tab-complete.o mbprint.o \
+	$(filter exec.o, $(LIBOBJS))
 
 FLEXFLAGS = -Cfe
 
@@ -29,6 +30,9 @@ all: submake-libpq submake-libpgport psql
 psql: $(OBJS) $(libpq_builddir)/libpq.a
 	$(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
 
+exec.c: % : $(top_srcdir)/src/port/%
+	rm -f $@ && $(LN_S) $< .
+
 help.o: $(srcdir)/sql_help.h
 
 ifdef PERL
@@ -60,7 +64,7 @@ uninstall:
 
 # psqlscan.c is in the distribution tarball, so is not cleaned here
 clean distclean:
-	rm -f psql$(X) $(OBJS)
+	rm -f psql$(X) $(OBJS) exec.c
 
 maintainer-clean: distclean
 	rm -f $(srcdir)/sql_help.h $(srcdir)/psqlscan.c
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index 05ebe74cd0ac1934ecab8dbdac8685ed9e490bc0..806a7dd925dffec70f81cc752daaa676fa86307c 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -1,4 +1,4 @@
-# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.105 2004/05/18 20:18:58 momjian Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.106 2004/05/19 17:15:21 momjian Exp $
 
 subdir = src/interfaces/ecpg/preproc
 top_builddir = ../../../..
@@ -19,13 +19,17 @@ endif
 override CFLAGS += $(PTHREAD_CFLAGS)
 
 OBJS=	preproc.o type.o ecpg.o ecpg_keywords.o output.o\
-	keywords.o c_keywords.o ../ecpglib/typename.o descriptor.o variable.o
+	keywords.o c_keywords.o ../ecpglib/typename.o descriptor.o variable.o \
+	$(filter exec.o, $(LIBOBJS))
 
 all: submake-libpgport ecpg
 
 ecpg: $(OBJS)
 	$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(PTHREAD_LIBS) -o $@$(X)
 
+exec.c: % : $(top_srcdir)/src/port/%
+	rm -f $@ && $(LN_S) $< .
+
 # pgc is compiled as part of preproc
 preproc.o: $(srcdir)/pgc.c
 
@@ -62,7 +66,7 @@ uninstall:
 	rm -f $(DESTDIR)$(bindir)/ecpg$(X)
 
 clean distclean:
-	rm -f *.o ecpg$(X)
+	rm -f *.o ecpg$(X) exec.c
 # garbage from partial builds
 	@rm -f y.tab.c y.tab.h
 # garbage from development
diff --git a/src/port/exec.c b/src/port/exec.c
index ae39c5936b3514021da4fa52144d50ac2599d6cb..eb3df771077d395eecb22a368ca860bb56a20c1e 100644
--- a/src/port/exec.c
+++ b/src/port/exec.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/port/exec.c,v 1.9 2004/05/19 04:36:33 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/port/exec.c,v 1.10 2004/05/19 17:15:21 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -48,6 +48,13 @@
 #define S_IXOTH		 ((S_IXUSR)>>6)
 #endif
 
+#ifndef FRONTEND
+/* We use only 3-parameter elog calls in this file, for simplicity */
+#define log_error(str, param)	elog(LOG, (str), (param))
+#else
+#define log_error(str, param)	fprintf(stderr, (str), (param))
+#endif
+
 static void win32_make_absolute(char *path);
 
 /*
@@ -192,7 +199,7 @@ find_my_exec(const char *argv0, char *full_path)
 	{
 		if (*++p == '\0')
 		{
-			fprintf(stderr, "argv[0] ends with a path separator \"%s\"", argv0);
+			log_error("argv[0] ends with a path separator \"%s\"", argv0);
 			return -1;
 		}
 		if (is_absolute_path(argv0) || !getcwd(buf, MAXPGPATH))
@@ -208,7 +215,7 @@ find_my_exec(const char *argv0, char *full_path)
 		}
 		else
 		{
-			fprintf(stderr, "invalid binary \"%s\"", buf);
+			log_error("invalid binary \"%s\"", buf);
 			return -1;
 		}
 	}
@@ -245,7 +252,7 @@ find_my_exec(const char *argv0, char *full_path)
 				case -1:		/* wasn't even a candidate, keep looking */
 					break;
 				case -2:		/* found but disqualified */
-					fprintf(stderr, "could not read binary \"%s\"", buf);
+					log_error("could not read binary \"%s\"", buf);
 					free(path);
 					return -1;
 			}
@@ -255,7 +262,7 @@ find_my_exec(const char *argv0, char *full_path)
 		free(path);
 	}
 
-	fprintf(stderr, "could not find a \"%s\" to execute", argv0);
+	log_error("could not find a \"%s\" to execute", argv0);
 	return -1;
 
 #if 0
@@ -337,17 +344,17 @@ pclose_check(FILE *stream)
 	}
 	else if (WIFEXITED(exitstatus))
 	{
-		fprintf(stderr, _("child process exited with exit code %d\n"),
+		log_error(_("child process exited with exit code %d\n"),
 				WEXITSTATUS(exitstatus));
 	}
 	else if (WIFSIGNALED(exitstatus))
 	{
-		fprintf(stderr, _("child process was terminated by signal %d\n"),
+		log_error(_("child process was terminated by signal %d\n"),
 				WTERMSIG(exitstatus));
 	}
 	else
 	{
-		fprintf(stderr, _("child process exited with unrecognized status %d\n"),
+		log_error(_("child process exited with unrecognized status %d\n"),
 				exitstatus);
 	}
 
@@ -369,7 +376,7 @@ win32_make_absolute(char *path)
 
 	if (_fullpath(abspath, path, MAXPGPATH) == NULL)
 	{
-		fprintf(stderr, "Win32 path expansion failed:  %s", strerror(errno));
+		log_error("Win32 path expansion failed:  %s", strerror(errno));
 		StrNCpy(abspath, path, MAXPGPATH);
 	}
 	canonicalize_path(abspath);