Index: src/bin/initdb/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/initdb/Makefile,v
retrieving revision 1.39
diff -c -c -r1.39 Makefile
*** src/bin/initdb/Makefile	18 May 2004 20:18:58 -0000	1.39
--- src/bin/initdb/Makefile	19 May 2004 17:12:59 -0000
***************
*** 15,27 ****
  
  override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS)
  
! OBJS=	initdb.o
  
  all: submake-libpq submake-libpgport initdb
  
  initdb: $(OBJS) $(libpq_builddir)/libpq.a
  	$(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
  
  install: all installdirs
  	$(INSTALL_PROGRAM) initdb$(X) $(DESTDIR)$(bindir)/initdb$(X)
  
--- 15,31 ----
  
  override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS)
  
! 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,38 ****
  	rm -f $(DESTDIR)$(bindir)/initdb$(X)
  
  clean distclean maintainer-clean:
! 	rm -f initdb$(X) $(OBJS)
  
  
  # ensure that changes in datadir propagate into object file
--- 36,42 ----
  	rm -f $(DESTDIR)$(bindir)/initdb$(X)
  
  clean distclean maintainer-clean:
! 	rm -f initdb$(X) $(OBJS) exec.c
  
  
  # ensure that changes in datadir propagate into object file
Index: src/bin/pg_dump/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_dump/Makefile,v
retrieving revision 1.48
diff -c -c -r1.48 Makefile
*** src/bin/pg_dump/Makefile	18 May 2004 20:18:58 -0000	1.48
--- src/bin/pg_dump/Makefile	19 May 2004 17:12:59 -0000
***************
*** 18,23 ****
--- 18,24 ----
  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,39 ****
  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)
  
  .PHONY: submake-backend
  submake-backend:
--- 33,43 ----
  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 $(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,55 ****
  	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
--- 56,59 ----
  	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 exec.c
Index: src/bin/psql/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/psql/Makefile,v
retrieving revision 1.45
diff -c -c -r1.45 Makefile
*** src/bin/psql/Makefile	18 May 2004 20:18:58 -0000	1.45
--- src/bin/psql/Makefile	19 May 2004 17:12:59 -0000
***************
*** 19,25 ****
  
  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
  
  FLEXFLAGS = -Cfe
  
--- 19,26 ----
  
  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 \
! 	$(filter exec.o, $(LIBOBJS))
  
  FLEXFLAGS = -Cfe
  
***************
*** 29,34 ****
--- 30,38 ----
  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,66 ****
  
  # psqlscan.c is in the distribution tarball, so is not cleaned here
  clean distclean:
! 	rm -f psql$(X) $(OBJS)
  
  maintainer-clean: distclean
  	rm -f $(srcdir)/sql_help.h $(srcdir)/psqlscan.c
--- 64,70 ----
  
  # psqlscan.c is in the distribution tarball, so is not cleaned here
  clean distclean:
! 	rm -f psql$(X) $(OBJS) exec.c
  
  maintainer-clean: distclean
  	rm -f $(srcdir)/sql_help.h $(srcdir)/psqlscan.c
Index: src/interfaces/ecpg/preproc/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/preproc/Makefile,v
retrieving revision 1.105
diff -c -c -r1.105 Makefile
*** src/interfaces/ecpg/preproc/Makefile	18 May 2004 20:18:58 -0000	1.105
--- src/interfaces/ecpg/preproc/Makefile	19 May 2004 17:13:00 -0000
***************
*** 19,31 ****
  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
  
  all: submake-libpgport ecpg
  
  ecpg: $(OBJS)
  	$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(PTHREAD_LIBS) -o $@$(X)
  
  # pgc is compiled as part of preproc
  preproc.o: $(srcdir)/pgc.c
  
--- 19,35 ----
  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 \
! 	$(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,68 ****
  	rm -f $(DESTDIR)$(bindir)/ecpg$(X)
  
  clean distclean:
! 	rm -f *.o ecpg$(X)
  # garbage from partial builds
  	@rm -f y.tab.c y.tab.h
  # garbage from development
--- 66,72 ----
  	rm -f $(DESTDIR)$(bindir)/ecpg$(X)
  
  clean distclean:
! 	rm -f *.o ecpg$(X) exec.c
  # garbage from partial builds
  	@rm -f y.tab.c y.tab.h
  # garbage from development
Index: src/port/exec.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/port/exec.c,v
retrieving revision 1.9
diff -c -c -r1.9 exec.c
*** src/port/exec.c	19 May 2004 04:36:33 -0000	1.9
--- src/port/exec.c	19 May 2004 17:13:00 -0000
***************
*** 48,53 ****
--- 48,60 ----
  #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,198 ****
  	{
  		if (*++p == '\0')
  		{
! 			fprintf(stderr, "argv[0] ends with a path separator \"%s\"", argv0);
  			return -1;
  		}
  		if (is_absolute_path(argv0) || !getcwd(buf, MAXPGPATH))
--- 199,205 ----
  	{
  		if (*++p == '\0')
  		{
! 			log_error("argv[0] ends with a path separator \"%s\"", argv0);
  			return -1;
  		}
  		if (is_absolute_path(argv0) || !getcwd(buf, MAXPGPATH))
***************
*** 208,214 ****
  		}
  		else
  		{
! 			fprintf(stderr, "invalid binary \"%s\"", buf);
  			return -1;
  		}
  	}
--- 215,221 ----
  		}
  		else
  		{
! 			log_error("invalid binary \"%s\"", buf);
  			return -1;
  		}
  	}
***************
*** 245,251 ****
  				case -1:		/* wasn't even a candidate, keep looking */
  					break;
  				case -2:		/* found but disqualified */
! 					fprintf(stderr, "could not read binary \"%s\"", buf);
  					free(path);
  					return -1;
  			}
--- 252,258 ----
  				case -1:		/* wasn't even a candidate, keep looking */
  					break;
  				case -2:		/* found but disqualified */
! 					log_error("could not read binary \"%s\"", buf);
  					free(path);
  					return -1;
  			}
***************
*** 255,261 ****
  		free(path);
  	}
  
! 	fprintf(stderr, "could not find a \"%s\" to execute", argv0);
  	return -1;
  
  #if 0
--- 262,268 ----
  		free(path);
  	}
  
! 	log_error("could not find a \"%s\" to execute", argv0);
  	return -1;
  
  #if 0
***************
*** 337,353 ****
  	}
  	else if (WIFEXITED(exitstatus))
  	{
! 		fprintf(stderr, _("child process exited with exit code %d\n"),
  				WEXITSTATUS(exitstatus));
  	}
  	else if (WIFSIGNALED(exitstatus))
  	{
! 		fprintf(stderr, _("child process was terminated by signal %d\n"),
  				WTERMSIG(exitstatus));
  	}
  	else
  	{
! 		fprintf(stderr, _("child process exited with unrecognized status %d\n"),
  				exitstatus);
  	}
  
--- 344,360 ----
  	}
  	else if (WIFEXITED(exitstatus))
  	{
! 		log_error(_("child process exited with exit code %d\n"),
  				WEXITSTATUS(exitstatus));
  	}
  	else if (WIFSIGNALED(exitstatus))
  	{
! 		log_error(_("child process was terminated by signal %d\n"),
  				WTERMSIG(exitstatus));
  	}
  	else
  	{
! 		log_error(_("child process exited with unrecognized status %d\n"),
  				exitstatus);
  	}
  
***************
*** 369,375 ****
  
  	if (_fullpath(abspath, path, MAXPGPATH) == NULL)
  	{
! 		fprintf(stderr, "Win32 path expansion failed:  %s", strerror(errno));
  		StrNCpy(abspath, path, MAXPGPATH);
  	}
  	canonicalize_path(abspath);
--- 376,382 ----
  
  	if (_fullpath(abspath, path, MAXPGPATH) == NULL)
  	{
! 		log_error("Win32 path expansion failed:  %s", strerror(errno));
  		StrNCpy(abspath, path, MAXPGPATH);
  	}
  	canonicalize_path(abspath);
