diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4920ebe8f8740c4704b691f40c409c23f3360f61..0ca088fa2f03231a79320dfdd06b70c808aeb780 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,22 @@
+Wed Aug 25 12:46:22 1999  Fred Fish  <fnf@cygnus.com>
+			  Geoffrey Keating <geoffk@cygnus.com>
+
+	* Makefile.in (PREPROCESSOR_DEFINES): New macro.
+	(protoize.o):  Use PREPROCESSOR_DEFINES and DRIVER_DEFINES.
+	(unprotoize.o): Ditto.
+	(test-protoize-simple): Don't define STD_PROTO_DIR.
+	* protoize.c: Use PARAMS rather than PROTO.  Minor whitespace
+	changes to make 'test-protoize-simple' pass.
+ 	(STD_PROTO_DIR): Remove define.
+	(STANDARD_EXEC_PREFIX): Supply default define.
+	(standard_exec_prefix): New variable, init to STANDARD_EXEC_PREFIX.
+	(target_machine): New variable, init to DEFAULT_TARGET_MACHINE.
+	(target_version): New variable, init to DEFAULT_TARGET_VERSION.
+	(GET_ENV_PATH_LIST): New macro.
+	(default_syscalls_dir): No longer initialized to STD_PROTO_DIR.
+	(do_processing): Initialize default_syscalls_dir using new
+	macros.  Use it to initialize syscalls_absolute_filename.
+
 Tue Aug 24 16:58:15 1999  Richard Henderson  <rth@cygnus.com>
 
 	* jump.c (jump_optimize_1): Do cmov opt on any single-set; force
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index a5cc9decdd145ae64e8bffe07da01dea72ff71ee..bc424b13de128b6f5271b9c122aa7d71426232ff 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1949,16 +1949,18 @@ cexp.o: $(srcdir)/cexp.c $(CONFIG_H) system.h
 $(srcdir)/cexp.c: $(srcdir)/cexp.y
 	cd $(srcdir); $(BISON) -o cexp.c cexp.y
 
+PREPROCESSOR_DEFINES = \
+  -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
+  -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
+  -DLOCAL_INCLUDE_DIR=\"$(includedir)\" \
+  -DCROSS_INCLUDE_DIR=\"$(gcc_tooldir)/sys-include\" \
+  -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\"
 # We use $(libsubdir)/$(unlibsubdir) to match the
 # -iprefix argument which gcc will pass if GCC_EXEC_PREFIX is used.
 cccp.o: cccp.c $(CONFIG_H) intl.h pcp.h version.c config.status system.h \
            mbchar.h prefix.h Makefile.in
 	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
-	  -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
-	  -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
-	  -DLOCAL_INCLUDE_DIR=\"$(includedir)\" \
-	  -DCROSS_INCLUDE_DIR=\"$(gcc_tooldir)/sys-include\" \
-	  -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
+	  $(PREPROCESSOR_DEFINES) \
 	  -c `echo $(srcdir)/cccp.c | sed 's,^\./,,'`
 
 LIBCPP_OBJS =	cpplib.o cpphash.o cppalloc.o cpperror.o cppexp.o cppfiles.o \
@@ -1988,11 +1990,7 @@ cppfiles.o: cppfiles.c $(CONFIG_H) cpplib.h intl.h system.h
 cppinit.o:  cppinit.c $(CONFIG_H) cpplib.h intl.h system.h \
 		cpphash.h prefix.h output.h Makefile
 	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
-	  -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
-	  -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
-	  -DLOCAL_INCLUDE_DIR=\"$(includedir)\" \
-	  -DCROSS_INCLUDE_DIR=\"$(gcc_tooldir)/sys-include\" \
-	  -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
+	  $(PREPROCESSOR_DEFINES) \
 	  -c `echo $(srcdir)/cppinit.c | sed 's,^\./,,'`
 
 # Note for the stamp targets, we run the program `true' instead of
@@ -2011,23 +2009,13 @@ unprotoize$(exeext): unprotoize.o $(PROTO_OBJS) $(LIBDEPS)
 protoize.o: protoize.c $(srcdir)/../include/getopt.h $(CONFIG_H) system.h \
    Makefile
 	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
-          -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
-	  -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
-	  -DCROSS_INCLUDE_DIR=\"$(gcc_tooldir)/sys-include\" \
-	  -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
-	  -DLOCAL_INCLUDE_DIR=\"$(includedir)\" \
-	  -DSTD_PROTO_DIR=\"$(libsubdir)\" \
+	  $(DRIVER_DEFINES) $(PREPROCESSOR_DEFINES) \
 	  $(srcdir)/protoize.c
 
 unprotoize.o: unprotoize.c protoize.c $(srcdir)/../include/getopt.h \
    $(CONFIG_H) system.h Makefile
 	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
-          -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
-	  -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
-	  -DCROSS_INCLUDE_DIR=\"$(gcc_tooldir)/sys-include\" \
-	  -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
-	  -DLOCAL_INCLUDE_DIR=\"$(includedir)\" \
-	  -DSTD_PROTO_DIR=\"$(libsubdir)\" \
+	  $(DRIVER_DEFINES) $(PREPROCESSOR_DEFINES) \
 	  $(srcdir)/unprotoize.c
 
 # This info describes the target machine, so compile with GCC just built.
@@ -2045,22 +2033,26 @@ test-protoize-simple: ./protoize ./unprotoize $(GCC_PASSES)
 	cp $(srcdir)/protoize.c tmp-proto.c
 	chmod u+w tmp-proto.c
 	./protoize -N -B ./ -x getopt.h -c "-B./ -Wall -Wwrite-strings \
-	  $(CFLAGS) $(INCLUDES) \
+	  $(GCC_CFLAGS) $(INCLUDES) \
 	  -DGCC_INCLUDE_DIR=0 \
 	  -DGPLUSPLUS_INCLUDE_DIR=0 \
 	  -DCROSS_INCLUDE_DIR=0 \
 	  -DTOOL_INCLUDE_DIR=0 \
-	  -DSTD_PROTO_DIR=0" tmp-proto.c
+	  -DSTANDARD_EXEC_PREFIX=0 \
+	  -DDEFAULT_TARGET_MACHINE=0 \
+	  -DDEFAULT_TARGET_VERSION=0" tmp-proto.c
 	@echo '**********' Expect 400 lines of differences.
 	-diff $(srcdir)/protoize.c tmp-proto.c > tmp-proto.diff
 	-wc -l tmp-proto.diff
 	./unprotoize -N -x getopt.h -c "-B./ -Wall -Wwrite-strings \
-	  $(CFLAGS) $(INCLUDES) \
+	  $(GCC_CFLAGS) $(INCLUDES) \
 	  -DGCC_INCLUDE_DIR=0 \
 	  -DGPLUSPLUS_INCLUDE_DIR=0 \
 	  -DCROSS_INCLUDE_DIR=0 \
 	  -DTOOL_INCLUDE_DIR=0 \
-	  -DSTD_PROTO_DIR=0" tmp-proto.c
+	  -DSTANDARD_EXEC_PREFIX=0 \
+	  -DDEFAULT_TARGET_MACHINE=0 \
+	  -DDEFAULT_TARGET_VERSION=0" tmp-proto.c
 	@echo Expect zero differences.
 	diff $(srcdir)/protoize.c tmp-proto.c | cat
 	-rm -f tmp-proto.[cs] tmp-proto$(objext)
diff --git a/gcc/protoize.c b/gcc/protoize.c
index 7e9205cb1a821c4a305e30db50ed838816f94ab3..73a573ad5d44ff81639219525d68f5e60bbc81e1 100644
--- a/gcc/protoize.c
+++ b/gcc/protoize.c
@@ -111,9 +111,9 @@ extern char *version_string;
 
 extern char *getpwd ();
 
-static void usage PROTO ((void)) ATTRIBUTE_NORETURN;
-static void aux_info_corrupted PROTO ((void)) ATTRIBUTE_NORETURN;
-static void declare_source_confusing PROTO ((const char *)) ATTRIBUTE_NORETURN;
+static void usage PARAMS ((void)) ATTRIBUTE_NORETURN;
+static void aux_info_corrupted PARAMS ((void)) ATTRIBUTE_NORETURN;
+static void declare_source_confusing PARAMS ((const char *)) ATTRIBUTE_NORETURN;
 
 /* Aliases for pointers to void.
    These were made to facilitate compilation with old brain-dead DEC C
@@ -165,9 +165,21 @@ extern size_t   strlen ()
 
 /* Define a default place to find the SYSCALLS.X file.  */
 
-#ifndef STD_PROTO_DIR
-#define STD_PROTO_DIR "/usr/local/lib"
-#endif /* !defined (STD_PROTO_DIR) */
+#ifndef UNPROTOIZE
+
+#ifndef STANDARD_EXEC_PREFIX
+#define STANDARD_EXEC_PREFIX "/usr/local/lib/gcc-lib/"
+#endif /* !defined STANDARD_EXEC_PREFIX */
+
+static char *standard_exec_prefix = STANDARD_EXEC_PREFIX;
+static char *target_machine = DEFAULT_TARGET_MACHINE;
+static char *target_version = DEFAULT_TARGET_VERSION;
+
+#ifndef GET_ENV_PATH_LIST
+#define GET_ENV_PATH_LIST(VAR,NAME)	do { (VAR) = getenv (NAME); } while (0)
+#endif
+
+#endif /* !defined (UNPROTOIZE) */
 
 /* Suffix of aux_info files.  */
 
@@ -187,7 +199,7 @@ static const char syscalls_filename[] = "SYSCALLS.c";
 
 /* Default place to find the above file.  */
 
-static const char * const default_syscalls_dir = STD_PROTO_DIR;
+static char * default_syscalls_dir;
 
 /* Variable to hold the complete absolutized filename of the SYSCALLS.c.X
    file.  */
@@ -569,10 +581,10 @@ static char * saved_repl_write_ptr;
 static const char *shortpath ();
 
 /* Translate and output an error message.  */
-static void notice			PVPROTO ((const char *, ...))
+static void notice			PARAMS ((const char *, ...))
   ATTRIBUTE_PRINTF_1;
 static void
-notice VPROTO ((const char *msgid, ...))
+notice VPARAMS ((const char *msgid, ...))
 {
 #ifndef ANSI_PROTOTYPES
   const char *msgid;
@@ -592,7 +604,7 @@ notice VPROTO ((const char *msgid, ...))
 
 char *
 xstrerror(e)
-  int e;
+     int e;
 {
 
 #ifdef HAVE_STRERROR
@@ -614,7 +626,7 @@ xstrerror(e)
 
 pointer_type
 xmalloc (byte_count)
-  size_t byte_count;
+     size_t byte_count;
 {
   register pointer_type rv = (pointer_type) malloc (byte_count);
   if (rv == NULL)
@@ -4458,16 +4470,27 @@ do_processing ()
   if (nondefault_syscalls_dir)
     {
       syscalls_absolute_filename
-        = (char *) xmalloc (strlen (nondefault_syscalls_dir)
-                            + sizeof (syscalls_filename) + 1);
+        = (char *) xmalloc (strlen (nondefault_syscalls_dir) + 1
+                            + sizeof (syscalls_filename));
       strcpy (syscalls_absolute_filename, nondefault_syscalls_dir);
     }
   else
     {
+      GET_ENV_PATH_LIST (default_syscalls_dir, "GCC_EXEC_PREFIX");
+      if (!default_syscalls_dir)
+	{
+	  default_syscalls_dir = standard_exec_prefix;
+	}
       syscalls_absolute_filename
-        = (char *) xmalloc (strlen (default_syscalls_dir)
-                            + sizeof (syscalls_filename) + 1);
+        = (char *) xmalloc (strlen (default_syscalls_dir) + 0
+			    + strlen (target_machine) + 1
+			    + strlen (target_version) + 1
+                            + sizeof (syscalls_filename));
       strcpy (syscalls_absolute_filename, default_syscalls_dir);
+      strcat (syscalls_absolute_filename, target_machine);
+      strcat (syscalls_absolute_filename, "/");
+      strcat (syscalls_absolute_filename, target_version);
+      strcat (syscalls_absolute_filename, "/");
     }
 
   syscalls_len = strlen (syscalls_absolute_filename);