# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../gcc/gcc-4.1.2-cross_search_paths-1.patch
# Copyright (C) 2008 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- SDE-COPYRIGHT-NOTE-END ---

Submitted by: Ryan Oliver <ryan.oliver@pha.com.au>
Date: 2007-02-14
Initial Package Version: 4.1.2
Origin: Ryan Oliver (issue reported by Erik-Jan Post)
        Rediffed against 4.1.0 by Chris Staub
	Rediffed against 4.1.2 by Jim Gifford
Upstream Status: N/A
Description:
  Removes standard_exec_prefix_2 from library search path when cross-compiling.
  Removes both standard_exec_prefix_1 and standard_exec_prefix_2 from the gcc
  executable search path when cross-compiling.

  ie: if cross_compile = 1 in the specs file, do not
      - do not add /usr/lib/gcc/${TARGET}/${GCC_VER} to the library search path
      - do not add /usr/lib/gcc/${TARGET}/${GCC_VER} or
                   /usr/libexec/gcc/${TARGET}/${GCC_VER}
        to the executable search path

  This avoids the possibility of linking in libraries from the host if they
  exist under those directories.
 
diff -Naur gcc-4.1.2.orig/gcc/gcc.c gcc-4.1.2/gcc/gcc.c
--- gcc-4.1.2.orig/gcc/gcc.c	2006-11-07 06:26:21.000000000 -0800
+++ gcc-4.1.2/gcc/gcc.c	2007-02-14 07:48:55.000000000 -0800
@@ -3821,16 +3821,22 @@
 	      PREFIX_PRIORITY_LAST, 2, 0);
   add_prefix (&exec_prefixes, standard_exec_prefix, "BINUTILS",
 	      PREFIX_PRIORITY_LAST, 2, 0);
-  add_prefix (&exec_prefixes, standard_exec_prefix_1, "BINUTILS",
+  if (*cross_compile == '0')
+    {
+      add_prefix (&exec_prefixes, standard_exec_prefix_1, "BINUTILS",
 	      PREFIX_PRIORITY_LAST, 2, 0);
-  add_prefix (&exec_prefixes, standard_exec_prefix_2, "BINUTILS",
+      add_prefix (&exec_prefixes, standard_exec_prefix_2, "BINUTILS",
 	      PREFIX_PRIORITY_LAST, 2, 0);
+    }
 #endif
 
   add_prefix (&startfile_prefixes, standard_exec_prefix, "BINUTILS",
 	      PREFIX_PRIORITY_LAST, 1, 0);
-  add_prefix (&startfile_prefixes, standard_exec_prefix_2, "BINUTILS",
+  if (*cross_compile == '0')
+    {
+      add_prefix (&startfile_prefixes, standard_exec_prefix_2, "BINUTILS",
 	      PREFIX_PRIORITY_LAST, 1, 0);
+    }
 
   tooldir_prefix = concat (tooldir_base_prefix, spec_machine,
 			   dir_separator_str, NULL);