Make GCC_EXEC_PREFIX work again
authorMichael Meissner <meissner@cygnus.com>
Fri, 27 Mar 1998 14:20:40 +0000 (14:20 +0000)
committerMichael Meissner <meissner@gcc.gnu.org>
Fri, 27 Mar 1998 14:20:40 +0000 (14:20 +0000)
From-SVN: r18856

gcc/ChangeLog
gcc/gcc.c
gcc/prefix.c

index 2615a60ced2088fed59df6587d873f265cd822b4..e5059598bd757f49eec15e10fc45b317cae247b1 100644 (file)
@@ -1,3 +1,16 @@
+Fri Mar 27 16:04:49 1998  Michael Meissner  <meissner@cygnus.com>
+
+       * gcc.c (set_std_prefix): Add declaration.
+       (process_command): If GCC_EXEC_PREFIX is set, remove /lib/gcc-lib/
+       suffix, and update the standard prefix prefix.c uses.
+
+       * prefix.c (std_prefix): New global to hold default prefix value.
+       (get_key_value): Change to use std_prefix instead of PREFIX.
+       (translate_name): Ditto.
+       (update_path): Ditto.
+       (get_key_value): Release allocated scratch storage.
+       (set_std_prefix): New function to reset the standard prefix.
+
 Fri Mar 27 18:08:21 1998  J"orn Rennecke <amylaar@cygnus.co.uk>
 
        * sh.c (find_barrier): Fix calculations for alignment increase.
index ab376553a6e49d4e36cd41dd69fe5a5edb651525..d68f404b273fd735f738fb265bf7a6fc188bd3dc 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -51,6 +51,7 @@ extern int pexecute PROTO ((const char *, char * const *, const char *,
                            const char *, char **, char **, int));
 extern int pwait PROTO ((int, int *, int));
 extern char *update_path PROTO((char *, char *));
+extern void set_std_prefix PROTO((char *, int));
 /* Flag arguments to pexecute.  */
 #define PEXECUTE_FIRST   1
 #define PEXECUTE_LAST    2
@@ -2378,6 +2379,20 @@ process_command (argc, argv)
 
   if (gcc_exec_prefix)
     {
+      int len = strlen (gcc_exec_prefix);
+      if (len > sizeof ("/lib/gcc-lib/")-1
+         && (gcc_exec_prefix[len-1] == '/'
+             || gcc_exec_prefix[len-1] == DIR_SEPARATOR))
+       {
+         temp = gcc_exec_prefix + len - sizeof ("/lib/gcc-lib/") + 1;
+         if ((*temp == '/' || *temp == DIR_SEPARATOR)
+             && strncmp (temp+1, "lib", 3) == 0
+             && (temp[4] == '/' || temp[4] == DIR_SEPARATOR)
+             && strncmp (temp+5, "gcc-lib", 7) == 0)
+           len -= sizeof ("/lib/gcc-lib/") - 1;
+       }
+
+      set_std_prefix (gcc_exec_prefix, len);
       add_prefix (&exec_prefixes, gcc_exec_prefix, "GCC", 0, 0, NULL_PTR);
       add_prefix (&startfile_prefixes, gcc_exec_prefix, "GCC", 0, 0, NULL_PTR);
     }
index f270172e5fa4ab9b3e2b6ee9d361be1d9726340f..c07944764d42fa790200cfe95a7dfbd98cef5f76 100644 (file)
@@ -1,5 +1,5 @@
 /* Utility to update paths from internal to external forms.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -76,6 +76,8 @@ Boston, MA 02111-1307, USA.  */
 
 #include "gansidecl.h"
 
+static char *std_prefix = PREFIX;
+
 static char *get_key_value     PROTO((char *));
 static char *translate_name    PROTO((char *));
 static char *concat            PVPROTO((char *, ...));
@@ -93,16 +95,20 @@ get_key_value (key)
      char *key;
 {
   char *prefix = 0;
+  char *temp = 0;
 
 #ifdef _WIN32
   prefix = lookup_key (key);
 #endif
 
   if (prefix == 0)
-    prefix = getenv (concat (key, "_ROOT", NULL_PTR));
+    prefix = getenv (temp = concat (key, "_ROOT", NULL_PTR));
 
   if (prefix == 0)
-    prefix = PREFIX;
+    prefix = std_prefix;
+
+  if (temp)
+    free (temp);
 
   return prefix;
 }
@@ -259,7 +265,7 @@ translate_name (name)
     {
       prefix = get_key_value (key);
       if (prefix == 0)
-       prefix = PREFIX;
+       prefix = std_prefix;
     }
   else
     {
@@ -289,12 +295,12 @@ update_path (path, key)
      char *path;
      char *key;
 {
-  if (! strncmp (path, PREFIX, strlen (PREFIX)) && key != 0)
+  if (! strncmp (path, std_prefix, strlen (std_prefix)) && key != 0)
     {
       if (key[0] != '$')
        key = concat ("@", key, NULL_PTR);
 
-      path = concat (key, &path[strlen (PREFIX)], NULL_PTR);
+      path = concat (key, &path[strlen (std_prefix)], NULL_PTR);
 
       while (path[0] == '@' || path[0] == '$')
        path = translate_name (path);
@@ -315,3 +321,12 @@ update_path (path, key)
 
   return path;
 }
+
+/* Reset the standard prefix */
+void
+set_std_prefix (prefix, len)
+     char *prefix;
+     int len;
+{
+  std_prefix = save_string (prefix, len);
+}