summaryrefslogtreecommitdiffstats
path: root/recipes/gcc/gcc-4.3.3/debian/multiarch-include.dpatch
blob: 2580444e7d081980cda2b7aea68ae390bf5980c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#! /bin/sh -e

# DP: biarch-include.dpatch
# DP:
# DP: Adds biarch include directories
# DP:     /usr/local/include/<arch>-linux-gnu
# DP:     /usr/include/<arch>-linux-gnu
# DP: to the system include paths, depending on 32/64 bit mode.

dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
    pdir="-d $3"
    dir="$3/"
elif [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch)
        patch $pdir -f --no-backup-if-mismatch -p0 < $0
        ;;
    -unpatch)
        patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
        ;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1
esac
exit 0

Index: gcc/cppdefault.c
===================================================================
--- gcc/cppdefault.c	(revision 112832)
+++ gcc/cppdefault.c	(working copy)
@@ -60,6 +60,7 @@
 #endif
 #ifdef LOCAL_INCLUDE_DIR
     /* /usr/local/include comes before the fixincluded header files.  */
+    { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 },
     { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
 #endif
 #ifdef PREFIX_INCLUDE_DIR
@@ -83,6 +84,7 @@
 #endif
 #ifdef STANDARD_INCLUDE_DIR
     /* /usr/include comes dead last.  */
+    { STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0, 1, 2 },
     { STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0, 1, 0 },
 #endif
     { 0, 0, 0, 0, 0, 0 }
Index: gcc/c-incpath.c
===================================================================
--- gcc/c-incpath.c	(revision 112832)
+++ gcc/c-incpath.c	(working copy)
@@ -30,6 +30,7 @@
 #include "intl.h"
 #include "c-incpath.h"
 #include "cppdefault.h"
+#include "errors.h"
 
 /* Windows does not natively support inodes, and neither does MSDOS.
    Cygwin's emulation can generate non-unique inodes, so don't use it.
@@ -121,6 +121,31 @@
     }
 }
 
+struct multiarch_mapping
+{
+  const char *const multilib;
+  const char *const multiarch;
+};
+
+const struct multiarch_mapping multiarch_mappings[]
+= {
+#include "multiarch.inc"
+  { 0, 0 }
+};
+
+static const char*
+multilib_to_multiarch (const char *imultilib)
+{
+  const struct multiarch_mapping *p;
+
+  for (p = multiarch_mappings; p->multiarch; p++)
+    {
+      if (!strcmp(p->multilib, imultilib ? imultilib : ""))
+	return p->multiarch;
+    }
+  internal_error("no multiarch mapping for multilib (%s)\n", imultilib);
+}
+
 /* Append the standard include chain defined in cppdefault.c.  */
 static void
 add_standard_paths (const char *sysroot, const char *iprefix,
@@ -128,6 +153,7 @@
 {
   const struct default_include *p;
   size_t len;
+  const char *multiarch;
 
   if (iprefix && (len = cpp_GCC_INCLUDE_DIR_len) != 0)
     {
@@ -146,8 +172,15 @@
 	      if (!strncmp (p->fname, cpp_GCC_INCLUDE_DIR, len))
 		{
 		  char *str = concat (iprefix, p->fname + len, NULL);
-		  if (p->multilib && imultilib)
+		  if (p->multilib == 1 && imultilib)
 		    str = concat (str, dir_separator_str, imultilib, NULL);
+		  if (p->multilib == 2)
+		    {
+		      multiarch = multilib_to_multiarch (imultilib);
+		      if (!multiarch)
+			continue;
+		      str = concat (str, dir_separator_str, multiarch, NULL);
+		    }
 		  add_path (str, SYSTEM, p->cxx_aware, false);
 		}
 	    }
@@ -166,9 +199,17 @@
 	  else
 	    str = update_path (p->fname, p->component);
 
-	  if (p->multilib && imultilib)
+	  if (p->multilib == 1 && imultilib)
 	    str = concat (str, dir_separator_str, imultilib, NULL);
 
+	  if (p->multilib == 2)
+	    {
+	      multiarch = multilib_to_multiarch (imultilib);
+	      if (!multiarch)
+		continue;
+	      str = concat (str, dir_separator_str, multiarch, NULL);
+	    }
+
 	  add_path (str, SYSTEM, p->cxx_aware, false);
 	}
     }