Add an OSX specific patch to make the kernel be compiled
[openwrt-10.03/.git] / target / linux / generic-2.6 / patches / 902-darwin_scripts_include.patch
1 diff -urN linux-2.6.19.1/scripts/mod/file2alias.c linux-2.6.19.1.new/scripts/mod/file2alias.c
2 --- linux-2.6.19.1/scripts/mod/file2alias.c     2006-12-11 20:32:53.000000000 +0100
3 +++ linux-2.6.19.1.new/scripts/mod/file2alias.c 2007-01-02 15:28:47.000000000 +0100
4 @@ -37,7 +37,21 @@
5   * even potentially has different endianness and word sizes, since
6   * we handle those differences explicitly below */
7  #include "../../include/linux/mod_devicetable.h"
8 +#ifndef __APPLE__
9  #include "../../include/linux/input.h"
10 +#else
11 +#define EV_MAX                  0x1f
12 +#define KEY_MUTE                113
13 +#define KEY_MIN_INTERESTING     KEY_MUTE
14 +#define KEY_MAX                 0x1ff
15 +#define REL_MAX                 0x0f
16 +#define ABS_MAX                 0x3f
17 +#define MSC_MAX                 0x07
18 +#define LED_MAX                 0x0f
19 +#define SND_MAX                 0x07
20 +#define FF_MAX                 0x7f
21 +#define SW_MAX                  0x0f
22 +#endif
23  
24  #define ADD(str, sep, cond, field)                              \
25  do {                                                            \
26 diff -urN linux-2.6.19.1/scripts/mod/mk_elfconfig.c linux-2.6.19.1.new/scripts/mod/mk_elfconfig.c
27 --- linux-2.6.19.1/scripts/mod/mk_elfconfig.c   2006-12-11 20:32:53.000000000 +0100
28 +++ linux-2.6.19.1.new/scripts/mod/mk_elfconfig.c       2007-01-02 15:43:57.000000000 +0100
29 @@ -1,7 +1,9 @@
30  #include <stdio.h>
31  #include <stdlib.h>
32  #include <string.h>
33 -#include <elf.h>
34 +#ifdef __APPLE__
35 +#include "../../../../../tools/sstrip/include/elf.h"
36 +#endif
37  
38  int
39  main(int argc, char **argv)
40 diff -urN linux-2.6.19.1/scripts/mod/modpost.h linux-2.6.19.1.new/scripts/mod/modpost.h
41 --- linux-2.6.19.1/scripts/mod/modpost.h        2006-12-11 20:32:53.000000000 +0100
42 +++ linux-2.6.19.1.new/scripts/mod/modpost.h    2007-01-02 15:40:55.000000000 +0100
43 @@ -7,7 +7,9 @@
44  #include <sys/mman.h>
45  #include <fcntl.h>
46  #include <unistd.h>
47 -#include <elf.h>
48 +#ifdef __APPLE__
49 +#include "../../../../../tools/sstrip/include/elf.h"
50 +#endif
51  
52  #include "elfconfig.h"
53  
54 diff -urN linux-2.6.19.1/scripts/mod/sumversion.c linux-2.6.19.1.new/scripts/mod/sumversion.c
55 --- linux-2.6.19.1/scripts/mod/sumversion.c     2006-12-11 20:32:53.000000000 +0100
56 +++ linux-2.6.19.1.new/scripts/mod/sumversion.c 2007-01-02 15:30:23.000000000 +0100
57 @@ -8,6 +8,9 @@
58  #include <errno.h>
59  #include <string.h>
60  #include "modpost.h"
61 +#ifdef __APPLE__
62 +#include <limits.h>
63 +#endif
64  
65  /*
66   * Stolen form Cryptographic API.
67 diff -urN linux-2.6.19.1/scripts/kconfig linux-2.6.19.1.new/scripts/kconfig/Makefile
68 --- linux-2.6.19.1/scripts/kconfig/Makefile    2007-01-04 17:49:35.000000000 +0100
69 +++ linux-2.6.19.1.new/scripts/kconfig/Makefile        2007-01-04 17:50:37.000000000 +0100
70 @@ -86,7 +86,10 @@
71  # Use reursively expanded variables so we do not call gcc unless
72  # we really need to do so. (Do not call gcc as part of make mrproper)
73  HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
74 -HOST_LOADLIBES   = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
75 +HOST_LOADLIBES   = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) -lncurses
76 +ifeq ($(shell uname -s),Darwin)
77 +HOST_LOADLIBES  += -lncurses
78 +endif
79  
80  HOST_EXTRACFLAGS += -DLOCALE
81
82 diff -urN linux-2.6.19.1/scripts/genksyms/parse.y linux-2.6.19.1.new/scripts/genksyms/parse.y 
83 --- linux-2.6.19.1/scripts/genksyms/parse.y     2006-12-11 20:32:53.000000000 +0100
84 +++ linux-2.6.19.1.new/scripts/genksyms/parse.y 2007-01-04 19:20:55.000000000 +0100
85 @@ -24,7 +24,9 @@
86  %{
87  
88  #include <assert.h>
89 +#ifndef __APPLE__
90  #include <malloc.h>
91 +#endif
92  #include "genksyms.h"
93  
94  static int is_typedef;
95 diff -urN linux-2.6.19.1/scripts/genksyms/parse.c_shipped linux-2.6.19.1.new/scripts/genksyms/parse.c_shipped
96 --- linux-2.6.19.1/scripts/genksyms/parse.c_shipped     2007-01-04 19:34:09.000000000 +0100
97 +++ linux-2.6.19.1.new/scripts/genksyms/parse.c_shipped 2007-01-04 19:34:02.000000000 +0100
98 @@ -144,7 +144,9 @@
99  
100  
101  #include <assert.h>
102 +#ifndef __APPLE__
103  #include <malloc.h>
104 +#endif
105  #include "genksyms.h"
106  
107  static int is_typedef;
108 --- linux-2.6.19.1/scripts/kallsyms.c   2006-12-11 20:32:53.000000000 +0100
109 +++ linux-2.6.19.1.new/scripts/kallsyms.c       2007-01-04 19:46:38.000000000 +0100
110 @@ -30,6 +30,35 @@
111  #include <stdlib.h>
112  #include <string.h>
113  #include <ctype.h>
114 +#ifdef __APPLE__
115 +/* Darwin has no memmem implementation, this one is ripped of the uClibc-0.9.28 source */
116 +void *memmem (const void *haystack, size_t haystack_len,
117 +                          const void *needle,  size_t needle_len)
118 +{
119 +  const char *begin;
120 +  const char *const last_possible
121 +    = (const char *) haystack + haystack_len - needle_len;
122 +
123 +  if (needle_len == 0)
124 +    /* The first occurrence of the empty string is deemed to occur at
125 +       the beginning of the string.  */
126 +    return (void *) haystack;
127 +
128 +  /* Sanity check, otherwise the loop might search through the whole
129 +     memory.  */
130 +  if (__builtin_expect (haystack_len < needle_len, 0))
131 +    return NULL;
132 +
133 +  for (begin = (const char *) haystack; begin <= last_possible; ++begin)
134 +    if (begin[0] == ((const char *) needle)[0] &&
135 +        !memcmp ((const void *) &begin[1],
136 +                 (const void *) ((const char *) needle + 1),
137 +                 needle_len - 1))
138 +      return (void *) begin;
139 +
140 +  return NULL;
141 +}
142 +#endif
143  
144  #define KSYM_NAME_LEN          127
145