home *** CD-ROM | disk | FTP | other *** search
/ Programming Win32 Under the API / ProgrammingWin32UnderTheApiPatVillani.iso / patches / gcc-2_95_2-x86-win32-patches.zi / gcc-2.95.2-patches / broken-down / gcc-2.95.2-relative-path.diff < prev    next >
Encoding:
Text File  |  1999-11-08  |  14.0 KB  |  403 lines

  1. Wed Jun  9 16:57:11 1999  Mumit Khan  <khan@xraylith.wisc.edu>
  2.  
  3.     * gcc.c (STANDARD_BINDIR_PREFIX): Provide default.
  4.  
  5. Fri Feb  5 14:22:01 1999  Mumit Khan  <khan@xraylith.wisc.edu>
  6.         
  7.     * gcc.c (make_relative_prefix): Handle the HAVE_EXECUTABLE_SUFFIX
  8.     case.
  9.  
  10. Fri Mar 13 17:54:04 1998  Michael Meissner  <meissner@cygnus.com>
  11.  
  12.         * gcc.c (DIR_UP): If not defined, define as "..".
  13.         (standard_bindir_prefix): New static, holds target location to
  14.         install binaries.
  15.         (split_directories): New function to split a filename into
  16.         component directories.
  17.         (free_split_directories): New function, release memory allocated
  18.         by split_directories.
  19.         (make_relative_prefix): New function, make a relative pathname if
  20.         the compiler is not in the expected location.
  21.         (process_command): Use GET_ENVIRONMENT to read GCC_EXEC_PREFIX.
  22.         If GCC_EXEC_PREFIX was not specified, see if we can figure out an
  23.         appropriate prefix from argv[0].
  24.  
  25.         * Makefile.in (gcc.o): Define STANDARD_BINDIR_PREFIX.
  26.  
  27. Mon May 10 09:11:23 1993  Ian Lance Taylor  (ian@cygnus.com)
  28.  
  29.     * Makefile.in (cccp.o): Use $(libsubdir)/$(unlibsubdir) for
  30.     LOCAL_INCLUDE_DIR, so that a native compiler can find assert.h via
  31.     GCC_EXEC_PREFIX.
  32.  
  33. Fri May  7 09:16:10 1993  Ian Lance Taylor  (ian@cygnus.com)
  34.  
  35.     * Makefile.in (gcc.o): Pass STANDARD_STARTFILE_PREFIX as
  36.     $(unlibsubdir) rather than $(libdir) so that native compilations can
  37.     find $(libdir).
  38.  
  39. Index: gcc-2.95.2/gcc/Makefile.in
  40. ===================================================================
  41. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/Makefile.in,v
  42. retrieving revision 1.1.1.1
  43. diff -u -3 -p -r1.1.1.1 Makefile.in
  44. --- gcc-2.95.2/gcc/Makefile.in    1999/11/05 01:09:41    1.1.1.1
  45. +++ gcc-2.95.2/gcc/Makefile.in    1999/11/05 05:34:35
  46. @@ -1407,11 +1407,12 @@ c-common.o : c-common.c $(CONFIG_H) syst
  47.  # Language-independent files.
  48.  
  49.  DRIVER_DEFINES = \
  50. -  -DSTANDARD_STARTFILE_PREFIX=\"$(libdir)/\" \
  51. +  -DSTANDARD_STARTFILE_PREFIX=\"$(unlibsubdir)/\" \
  52.    -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc-lib/\" \
  53.    -DDEFAULT_TARGET_VERSION=\"$(version)\" \
  54.    -DDEFAULT_TARGET_MACHINE=\"$(target_alias)\" \
  55. -  -DTOOLDIR_BASE_PREFIX=\"$(exec_prefix)/\"
  56. +  -DSTANDARD_BINDIR_PREFIX=\"$(bindir)/\" \
  57. +  -DTOOLDIR_BASE_PREFIX=\"$(unlibsubdir)/../\"
  58.  gcc.o: gcc.c $(CONFIG_H) system.h intl.h multilib.h \
  59.      Makefile $(lang_specs_files) prefix.h
  60.      $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
  61. @@ -1971,7 +1972,7 @@ cccp.o: cccp.c $(CONFIG_H) intl.h pcp.h 
  62.      $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
  63.        -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
  64.        -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
  65. -      -DLOCAL_INCLUDE_DIR=\"$(includedir)\" \
  66. +       -DLOCAL_INCLUDE_DIR=\"$(libsubdir)/$(unlibsubdir)/..`echo $(exec_prefix) | sed -e 's|^$(prefix)||' -e 's|/[^/]*|/..|g'`/include\" \
  67.        -DCROSS_INCLUDE_DIR=\"$(gcc_tooldir)/sys-include\" \
  68.        -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
  69.        -c `echo $(srcdir)/cccp.c | sed 's,^\./,,'`
  70. @@ -2005,7 +2006,7 @@ cppinit.o:  cppinit.c $(CONFIG_H) cpplib
  71.      $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
  72.        -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
  73.        -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
  74. -      -DLOCAL_INCLUDE_DIR=\"$(includedir)\" \
  75. +       -DLOCAL_INCLUDE_DIR=\"$(libsubdir)/$(unlibsubdir)/..`echo $(exec_prefix) | sed -e 's|^$(prefix)||' -e 's|/[^/]*|/..|g'`/include\" \
  76.        -DCROSS_INCLUDE_DIR=\"$(gcc_tooldir)/sys-include\" \
  77.        -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
  78.        -c `echo $(srcdir)/cppinit.c | sed 's,^\./,,'`
  79. @@ -2030,7 +2031,7 @@ protoize.o: protoize.c $(srcdir)/../incl
  80.        -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
  81.        -DCROSS_INCLUDE_DIR=\"$(gcc_tooldir)/sys-include\" \
  82.        -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
  83. -      -DLOCAL_INCLUDE_DIR=\"$(includedir)\" \
  84. +       -DLOCAL_INCLUDE_DIR=\"$(libsubdir)/$(unlibsubdir)/..`echo $(exec_prefix) | sed -e 's|^$(prefix)||' -e 's|/[^/]*|/..|g'`/include\" \
  85.        -DSTD_PROTO_DIR=\"$(libsubdir)\" \
  86.        $(srcdir)/protoize.c
  87.  
  88. @@ -2041,7 +2042,7 @@ unprotoize.o: unprotoize.c protoize.c $(
  89.        -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
  90.        -DCROSS_INCLUDE_DIR=\"$(gcc_tooldir)/sys-include\" \
  91.        -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
  92. -      -DLOCAL_INCLUDE_DIR=\"$(includedir)\" \
  93. +       -DLOCAL_INCLUDE_DIR=\"$(libsubdir)/$(unlibsubdir)/..`echo $(exec_prefix) | sed -e 's|^$(prefix)||' -e 's|/[^/]*|/..|g'`/include\" \
  94.        -DSTD_PROTO_DIR=\"$(libsubdir)\" \
  95.        $(srcdir)/unprotoize.c
  96.  
  97. Index: gcc-2.95.2/gcc/gcc.c
  98. ===================================================================
  99. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/gcc.c,v
  100. retrieving revision 1.1.1.1
  101. diff -u -3 -p -r1.1.1.1 gcc.c
  102. --- gcc-2.95.2/gcc/gcc.c    1999/11/05 01:09:43    1.1.1.1
  103. +++ gcc-2.95.2/gcc/gcc.c    1999/11/05 05:34:35
  104. @@ -76,6 +76,12 @@ compilation is specified by a string cal
  105.  
  106.  static char dir_separator_str[] = {DIR_SEPARATOR, 0};
  107.  
  108. +/* CYGNUS LOCAL -- meissner/relative pathnames */
  109. +#ifndef DIR_UP
  110. +#define DIR_UP ".."
  111. +#endif
  112. +/* END CYGNUS LOCAL -- meissner/relative pathnames */
  113. +
  114.  #define obstack_chunk_alloc xmalloc
  115.  #define obstack_chunk_free free
  116.  
  117. @@ -177,6 +183,11 @@ static void set_spec        PROTO((const char 
  118.  static struct compiler *lookup_compiler PROTO((const char *, size_t, const char *));
  119.  static char *build_search_list    PROTO((struct path_prefix *, const char *, int));
  120.  static void putenv_from_prefixes PROTO((struct path_prefix *, const char *));
  121. +/* CYGNUS LOCAL -- meissner/relative pathnames */
  122. +static char **split_directories PROTO((char *, int *));
  123. +static void free_split_directories PROTO((char **));
  124. +static char *make_relative_prefix PROTO((char *, char *, char *));
  125. +/* END CYGNUS LOCAL -- meissner/relative pathnames */
  126.  static char *find_a_file    PROTO((struct path_prefix *, const char *, int));
  127.  static void add_prefix        PROTO((struct path_prefix *, const char *,
  128.                         const char *, int, int, int *));
  129. @@ -1398,6 +1409,13 @@ static const char *standard_startfile_pr
  130.  static const char *tooldir_base_prefix = TOOLDIR_BASE_PREFIX;
  131.  static const char *tooldir_prefix;
  132.  
  133. +/* CYGNUS LOCAL -- meissner/relative pathnames */
  134. +#ifndef STANDARD_BINDIR_PREFIX
  135. +#define STANDARD_BINDIR_PREFIX "/usr/local/bin"
  136. +#endif /* !defined STANDARD_BINDIR_PREFIX */
  137. +static char *standard_bindir_prefix = STANDARD_BINDIR_PREFIX;
  138. +/* END CYGNUS LOCAL -- meissner/relative pathnames */
  139. +
  140.  /* Subdirectory to use for locating libraries.  Set by
  141.     set_multilib_dir based on the compilation options.  */
  142.  
  143. @@ -1954,6 +1972,238 @@ putenv_from_prefixes (paths, env_var)
  144.    putenv (build_search_list (paths, env_var, 1));
  145.  }
  146.  
  147. +/* CYGNUS LOCAL -- meissner/relative pathnames */
  148. +/* Split a filename into component directories.  */
  149. +
  150. +static char **
  151. +split_directories (name, ptr_num_dirs)
  152. +     char *name;
  153. +     int *ptr_num_dirs;
  154. +{
  155. +  int num_dirs = 0;
  156. +  char **dirs;
  157. +  char *p, *q;
  158. +  int ch;
  159. +
  160. +  /* Count the number of directories.  Special case MSDOS disk names as part
  161. +     of the initial directory.  */
  162. +  p = name;
  163. +  if (DIR_SEPARATOR == '\\' && name[1] == ':'
  164. +      && (name[2] == DIR_SEPARATOR || name[2] == '/'))
  165. +    {
  166. +      p += 3;
  167. +      num_dirs++;
  168. +    }
  169. +
  170. +  while ((ch = *p++) != '\0')
  171. +    {
  172. +      if (ch == '/' || ch == DIR_SEPARATOR)
  173. +        {
  174. +          num_dirs++;
  175. +          while ((ch = *p) == '/' || ch == DIR_SEPARATOR)
  176. +            p++;
  177. +        }
  178. +    }
  179. +
  180. +  dirs = (char **) xmalloc (sizeof (char *) * (num_dirs + 2));
  181. +
  182. +  /* Now copy the directory parts.  */
  183. +  num_dirs = 0;
  184. +  p = name;
  185. +  if (DIR_SEPARATOR == '\\' && name[1] == ':'
  186. +      && (name[2] == DIR_SEPARATOR || name[2] == '/'))
  187. +    {
  188. +      dirs[num_dirs++] = save_string (p, 3);
  189. +      p += 3;
  190. +    }
  191. +
  192. +  q = p;
  193. +  while ((ch = *p++) != '\0')
  194. +    {
  195. +      if (ch == '/' || ch == DIR_SEPARATOR)
  196. +        {
  197. +          while ((ch = *p) == '/' || ch == DIR_SEPARATOR)
  198. +            p++;
  199. +
  200. +          dirs[num_dirs++] = save_string (q, p - q);
  201. +          q = p;
  202. +        }
  203. +    }
  204. +
  205. +  if (p - 1 - q > 0)
  206. +    dirs[num_dirs++] = save_string (q, p - 1 - q);
  207. +
  208. +  dirs[num_dirs] = NULL_PTR;
  209. +  if (ptr_num_dirs)
  210. +    *ptr_num_dirs = num_dirs;
  211. +
  212. +  return dirs;
  213. +}
  214. +
  215. +/* Release storage held by split directories.  */
  216. +
  217. +static void
  218. +free_split_directories (dirs)
  219. +     char **dirs;
  220. +{
  221. +  int i = 0;
  222. +
  223. +  while (dirs[i] != NULL_PTR)
  224. +    free (dirs[i++]);
  225. +
  226. +  free ((char *)dirs);
  227. +}
  228. +
  229. +/* Given three strings PROGNAME, BIN_PREFIX, PREFIX, return a string that gets
  230. +   to PREFIX starting with the directory portion of PROGNAME and a relative
  231. +   pathname of the difference between BIN_PREFIX and PREFIX.
  232. +
  233. +   For example, if BIN_PREFIX is /alpha/beta/gamma/gcc/delta, PREFIX is
  234. +   /alpha/beta/gamma/omega/, and PROGNAME is /red/green/blue/gcc, then this
  235. +   function will return /reg/green/blue/../omega.
  236. +
  237. +   If no relative prefix can be found, return NULL.  */
  238. +
  239. +static char *
  240. +make_relative_prefix (progname, bin_prefix, prefix)
  241. +     char *progname;
  242. +     char *bin_prefix;
  243. +     char *prefix;
  244. +{
  245. +  char **prog_dirs, **bin_dirs, **prefix_dirs;
  246. +  int prog_num, bin_num, prefix_num, std_loc_p;
  247. +  int i, n, common;
  248. +
  249. +  prog_dirs = split_directories (progname, &prog_num);
  250. +  bin_dirs = split_directories (bin_prefix, &bin_num);
  251. +
  252. +  /* If there is no full pathname, try to find the program by checking in each
  253. +     of the directories specified in the PATH environment variable.  */
  254. +  if (prog_num == 1)
  255. +    {
  256. +      char *temp;
  257. +
  258. +      GET_ENV_PATH_LIST (temp, "PATH");
  259. +      if (temp)
  260. +        {
  261. +          char *startp, *endp;
  262. +          char *nstore = (char *) alloca (strlen (temp) + strlen (progname) 
  263. +                                          + strlen (EXECUTABLE_SUFFIX) + 1);
  264. +
  265. +          startp = endp = temp;
  266. +          while (1)
  267. +            {
  268. +              if (*endp == PATH_SEPARATOR || *endp == 0)
  269. +                {
  270. +                  if (endp == startp)
  271. +                    {
  272. +                      nstore[0] = '.';
  273. +                      nstore[1] = DIR_SEPARATOR;
  274. +                      nstore[2] = '\0';
  275. +                    }
  276. +                  else
  277. +                    {
  278. +                      strncpy (nstore, startp, endp-startp);
  279. +                      if (endp[-1] != '/' && endp[-1] != DIR_SEPARATOR)
  280. +                        {
  281. +                          nstore[endp-startp] = DIR_SEPARATOR;
  282. +                          nstore[endp-startp+1] = 0;
  283. +                        }
  284. +                      else
  285. +                        nstore[endp-startp] = 0;
  286. +                    }
  287. +                  strcat (nstore, progname);
  288. +                  if (! access (nstore, X_OK)
  289. +#ifdef HAVE_EXECUTABLE_SUFFIX
  290. +                      || ! access (strcat (nstore, EXECUTABLE_SUFFIX), X_OK)
  291. +#endif
  292. +                      )
  293. +                    {
  294. +                      free_split_directories (prog_dirs);
  295. +                      progname = nstore;
  296. +                      prog_dirs = split_directories (progname, &prog_num);
  297. +                      break;
  298. +                    }
  299. +
  300. +                  if (*endp == 0)
  301. +                    break;
  302. +                  endp = startp = endp + 1;
  303. +                }
  304. +              else
  305. +                endp++;
  306. +            }
  307. +        }
  308. +    }
  309. +
  310. +  /* Remove the program name from comparison of directory names.  */
  311. +  prog_num--;
  312. +
  313. +  /* Determine if the compiler is installed in the standard location, and if
  314. +     so, we don't need to specify relative directories.  Also, if argv[0]
  315. +     doesn't contain any directory specifiers, there is not much we can do.  */
  316. +  std_loc_p = 0;
  317. +  if (prog_num == bin_num)
  318. +    {
  319. +      for (i = 0; i < bin_num; i++)
  320. +        {
  321. +          if (strcmp (prog_dirs[i], bin_dirs[i]) != 0)
  322. +            break;
  323. +        }
  324. +
  325. +      if (prog_num <= 0 || i == bin_num)
  326. +        {
  327. +          std_loc_p = 1;
  328. +          free_split_directories (prog_dirs);
  329. +          free_split_directories (bin_dirs);
  330. +          prog_dirs = bin_dirs = (char **)0;
  331. +          return NULL_PTR;
  332. +        }
  333. +    }
  334. +
  335. +  prefix_dirs = split_directories (prefix, &prefix_num);
  336. +
  337. +  /* Find how many directories are in common between bin_prefix & prefix */
  338. +  n = (prefix_num < bin_num) ? prefix_num : bin_num;
  339. +  for (common = 0; common < n; common++)
  340. +    {
  341. +      if (strcmp (bin_dirs[common], prefix_dirs[common]) != 0)
  342. +        break;
  343. +    }
  344. +
  345. +  /* If there are no common directories, there can be no relative prefix.  */
  346. +  if (common == 0)
  347. +    {
  348. +      free_split_directories (prog_dirs);
  349. +      free_split_directories (bin_dirs);
  350. +      free_split_directories (prefix_dirs);
  351. +      return NULL_PTR;
  352. +    }
  353. +
  354. +  /* Build up the pathnames in argv[0].  */
  355. +  for (i = 0; i < prog_num; i++)
  356. +    obstack_grow (&obstack, prog_dirs[i], strlen (prog_dirs[i]));
  357. +
  358. +  /* Now build up the ..'s.  */
  359. +  for (i = common; i < n; i++)
  360. +    {
  361. +      obstack_grow (&obstack, DIR_UP, sizeof (DIR_UP)-1);
  362. +      obstack_1grow (&obstack, DIR_SEPARATOR);
  363. +    }
  364. +
  365. +  /* Put in directories to move over to prefix.  */
  366. +  for (i = common; i < prefix_num; i++)
  367. +    obstack_grow (&obstack, prefix_dirs[i], strlen (prefix_dirs[i]));
  368. +
  369. +  free_split_directories (prog_dirs);
  370. +  free_split_directories (bin_dirs);
  371. +  free_split_directories (prefix_dirs);
  372. +
  373. +  obstack_1grow (&obstack, '\0');
  374. +  return obstack_finish (&obstack);
  375. +}
  376. +/* END CYGNUS LOCAL -- meissner/relative pathnames */
  377. +
  378. +
  379.  /* Search for NAME using the prefix list PREFIXES.  MODE is passed to
  380.     access to check permissions.
  381.     Return 0 if not found, otherwise return its name, allocated with malloc.  */
  382. @@ -2597,8 +2847,19 @@ process_command (argc, argv)
  383.        break;
  384.      }
  385.      }
  386. +
  387. +  /* CYGNUS LOCAL meissner/relative pathnames */
  388. +  /* Set up the default search paths.  If there is no GCC_EXEC_PREFIX, see if we
  389. +     can create it from the pathname specified in argv[0].  */
  390.  
  391. -  /* Set up the default search paths.  */
  392. +  if (!gcc_exec_prefix)
  393. +    {
  394. +      gcc_exec_prefix = make_relative_prefix (argv[0], standard_bindir_prefix,
  395. +                                              standard_exec_prefix);
  396. +      if (gcc_exec_prefix)
  397. +        putenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL_PTR));
  398. +    }
  399. +  /* END CYGNUS LOCAL -- meissner/relative pathnames */
  400.  
  401.    if (gcc_exec_prefix)
  402.      {
  403.