summaryrefslogtreecommitdiff
path: root/Distrib/BuildingTheHurd.mdwn
blob: 80b8a01a5b10735f70257083866940aee239cbbf (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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<table align="center" width="75%">
  <tr>
    <td align="center" colspan="2"><nop><h2><a name="HowTo_setup_a_Hurd_cross_compile"> <nop>HowTo setup a Hurd cross-compiler in Linux </nop></a></h2></nop></td>
  </tr>
  <tr>
    <td><nop><h2><a name="Table_of_Contents"> Table of Contents </a></h2> %TOC% </nop></td>
    <td valign="top">
      <p> Created from the original by <a href="http://cvs.gentoo.org/~avenj/" target="_top">Jon Portnoy</a>, <a href="http://cvs.gentoo.org/~avenj/doc/xcompile-en.html" target="_top">http://cvs.gentoo.org/~avenj/doc/xcompile-en.html</a></p>
      <p><nop></nop></p>
      <h2><a name="Introduction"> Introduction </a></h2>
      <p> For a Linux to Hurd cross-compiler you need these versions (I tried newer versions of gcc but they won't compile) </p>
      <p>
      </p>
      <ul>
        <li><a href="http://ftp.gnu.org/gnu/binutils/" target="_top">binutils-2.13.90.0.16</a></li>
      </ul>
      <p>
      </p>
      <ul>
        <li> egcs-core-1.2.2 &amp;lt;- a very old version of gcc, but it is very stable, you will need it for compiling the gnumach headers and the mig kernel </li>
      </ul>
      <p>
      </p>
      <ul>
        <li><a href="http://ftp.gnu.org/gnu/gcc/" target="_top">gcc-core-2.95.2</a> &amp;lt;- for compiling hurd </li>
      </ul>
      <p>
      </p>
      <ul>
        <li><a href="http://ftp.gnu.org/gnu/glibc/" target="_top">glibc-2.2.5</a></li>
      </ul>
      <p>
      </p>
      <ul>
        <li><a href="http://ftp.gnu.org/gnu/gnumach/gnumach-1.3.tar.gz" target="_top">gnumach-1.3</a></li>
      </ul>
      <p>
      </p>
      <ul>
        <li><a href="http://ftp.gnu.org/gnu/mig/mig-1.3.tar.gz" target="_top">mig-1.3</a></li>
      </ul>
      <p>
      </p>
      <ul>
        <li><a href="http://www.gnu.org/software/hurd/download.html" target="_top">hurd</a></li>
      </ul>
      <p>
      </p>
    </td>
  </tr>
</table>

## <a name="Building"> Building </a>

### <a name="The_directory_structure"> The directory structure </a>

It is easier to compile the whole sources in an extra directory:

* build/binutils &lt;- the unpacked binutils sources

* build/binutils.build

* build/egcs &lt;- the unpacked egcs sources

* build/egcs.build

* build/gcc &lt;- the unpacked gcc sources

* build/gcc.build

* build/glibc &lt;- the unpacked glibc sources

* build/glibc.build

* build/gnumach &lt;- the unpacked gnumach kernel sources

* build/gnumach.build

* build/mig &lt;- the unpacked mig kernel sources

* build/mig.build

* build/hurd &lt;- the unpacked hurd kernel sources

* build/hurd.build

### <a name="Exporting_the_CFLAG_and_PATH"> </a> Exporting the CFLAG and PATH

`/usr/local` is where the sources we compile will be installed. If you want to choose another directory you have to change the path to the bin directory and too you have to change the --prefix path to the directory you want.

    export CFLAGS="-march=i686 -O2 -fomit-frame-pointer"

    export PATH=/usr/local/bin:$PATH

### <a name="Cross_binutils"> Cross binutils </a>

cd binutils.build ../binutils/configure --prefix=/usr/local --target=i686-pc-gnu make make check

make install (as root, and don't forget to export the CFLAGS and the PATH)

cd ..

### <a name="Cross_egcs"> Cross egcs </a>

When the `/usr/local/bin` directory do not exist before you will now have to export the `PATH` again because after installing binutils you will have it.

    cd egcs.build
    ../egcs/configure --prefix=/usr/local --target=i686-pc-gnu \
                      --with-gnu-as --with-gnu-ld
    make -k
    make -k install (as root, don't forget to export CFLAGS and PATH)
    ln -s /usr/local/i686-pc-gnu /usr/local/lib/gcc-lib/i686-pc-gnu/egcs-2.91.66/i686-pc-gnu
    cd ..

### <a name="GNUmach_Headers"> </a> GNUmach Headers

    cd gnumach.build
    ../gnumach/configure --build=i686-pc-linux-gnu --host=i686-pc-gnu
    make -k install-headers prefix=/usr/local/i686-pc-gnu (as root ...)
    cd ..

### <a name="Mig"> Mig </a>

Mig is the Mach Interface Generator - needed by Mach and the Hurd to create C code from their IDL files. Mig is what helps us do RPC without ever knowing much about it.

    cd mig.build
    ../mig/configure --target=i686-pc-gnu --host=i686-pc-linux-gnu \
                     --prefix=/usr/local
    make
    make install (as root ...)
    cd ..

### <a name="Gnumach_Headers_inclusive_Mig"> Gnumach Headers inclusive Mig </a>

When you first compile the GNUmach headers Mig won't be mentioned (it wasn't installed actually) and this causes some errors when compiling the GNUmach headers but you need them to compile mig. (I do nt know if you have to do this but i think it is the better way)

    cd gnumach.build
    rm -r * (deletes every file and directory in this directory)

    ../gnumach/configure --build=i686-pc-linux-gnu --host=i686-pc-gnu
    make -k install-headers prefix=/usr/local/i686-pc-gnu (as root ...)
    cd ..

### <a name="Cross_GCC"> </a> Cross GCC

For the coexistence of EGCS and GCC you have to move the `/usr/local/bin/i686-pc-gnu-gcc` to the `/usr/local/bin` directory in `i686-pc-gnu-egcs`. So you can choose wich compiler you want use: with the `CC` environment variable set to `i686-pc-gnu-egcs` you can use EGCS without this command you use GCC.

    mv /usr/local/bin/i686-pc-gnu-gcc /usr/local/bin/i686-pc-gnu-egcs

    cd gcc.build
    ../gcc/configure --prefix=/usr/local --target=i686-pc-gnu --with-gnu-as --with-gnu-ld
    make -k compile the glibc-headers)
    sudo make -k install
    cd ..
    ln -s /usr/local/i686-pc-gnu/ /usr/local/lib/gcc-lib/i686-pc-gnu/2.95.2/i686-pc-gnu

You need `make -k` because otherwise it will fail but with -k you will have everything you need.

### <a name="Hurd_Headers"> Hurd Headers </a>

    cd hurd.build

    ../hurd/configure --build=i686-pc-linux-gnu -�host=i686-pc-gnu \
                      -�prefix=/usr/local/i686-pc- gnu --disable-profile
    make install-headers no_deps=t (as root ...)
    cd ..

### <a name="Cross_GLibC"> Cross GLibC </a>

For having glibc compiled with the cross-gcc and not with your original gcc you have to export another PATH. The normal user who configures and compiles and also root has to export this PATH.

    export PATH=/usr/local/bin:/usr/local/i686-pc-gnu/bin:$PATH

    cd glibc.build
    ../glibc/configure --without-cvs --enable-add-ons=crypt --disable-profile \
                       --build=i686-pc-linux-gnu --host=i686-pc-gnu           \
                       --prefix=/usr/local/i686-pc-gnu

AS ROOT WITH EXPORTED CFLAGS:

    export PATH=/usr/local/bin:/usr/local/i686-pc-gnu/bin:$PATH

    make -k install-headers install_root=/usr/local/i686-pc-gnu

    cp ../glibc/include/features.h /usr/local/i686-pc-gnu/include/features.h
    touch /usr/local/i686-pc-gnu/include/gnu/stubs.h
    cd ..

### <a name="Building_Cross_egcs"> Building Cross egcs </a>

    mv /usr/local/bin/i686-pc-gnu-gcc /usr/local/bin/i686-pc-gnu-foo (for protecting gcc)

    mv /usr/local/bin/i686-pc-gnu-egcs /usr/local/bin/i686-pc-gnu-gcc

    cd egcs.build
    make
    make install (as root, export CFLAGS and the NEW PATH)

    cd ..

    mv /usr/local/bin/i686-pc-gnu-gcc /usr/local/bin/i686-pc-gnu-egcs

    mv /usr/local/bin/i686-pc-gnu-foo /usr/local/bin/i686-pc-gnu-gcc

### <a name="Building_Cross_GCC"> </a> Building Cross GCC

    cd gcc.build

    make

    sudo make install

    cd ..

Remember to export CFLAGS and the new PATH

### <a name="Building_Cross_GLibC"> Building Cross GLibC </a>

    cd glibc.build

    make

    sudo make install root_install=/usr/local/i686-pc-gnu

Remember to export CFLAGS and the new PATH

For solving a glibc bug you have to link the `/usr/local/i686-pc-gnu/include/libc.so.0.2` with the `/usr/local/i686-pc-gnu/lib/libc.so` ever when you (re)install glibc.

    ln -sf /usr/local/i686-pc-gnu/lib/libc.so.0.2 /usr/local/i686-pc-gnu/lib/libc.so

### <a name="Install_the_GNUmach_kernel_somew"> </a> Install the GNUmach kernel somewhere

    rm -r gnumach.build

    mkdir gnumach.build

    cd gnumach.build

You will need more than the -�target and -�host variables to build the GNUmach kernel. You have to enable some kernel features with the --enable command to have your kernel working properly. To have a quick view of what you need you can edit the gnumach/i386/README-Drivers (I do not know how old it is, so maybe there are more options available but i haven't searched for more).

My configure command:

    ../gnumach/configure --build=i686-pc-linux-gnu --host=i686-pc-gnu �-enable-lpr \
                         --enable-floppy --enable-ide --enable-aic7xxx \
                         �-enable-rtl8139

    ln -s /usr/local/i686-pc-gnu/include /where/you/want/to/install/the/kernel/include

    ln -s /usr/locali686-pc-gnu/lib /where/you/want/to/install/the/kernel/lib

    make

    make install-kernel prefix=/where/you/want/to/install/the/kernel (as root ...)

### <a name="Hurd_Servers"> Hurd Servers </a>

rm -r hurd.build

mkdir hurd.build

cd hurd.build

nano -w/vi (or what editor you ever use) ../hurd/Makeconf

You have to comment out the CFLAGS in this file or delete the -std=gnu99 and the -03.

    ../hurd/configure �build=i686-pc-linux-gnu --host=i686-pc-gnu -�prefix=/where/you/want/to/install/the/kernel --disable-profile

    make -k

    make -k install prefix=/where/you/want/to/install/the/kernel

You have to use -k because when you don't use it the compilation will brake with an error. I tried different installations of gcc and glibc and too i used different versions of hurd but i cannot solve this prob so maybe it is hurd related.

So there is no warranty that the hurd kernel you compiled will work. I will try it and then update this guide.

----

## <a name="Document_History"> Document History </a>

Created from the original, <http://cvs.gentoo.org/~avenj/doc/xcompile-en.html>, by [Jon Portnoy](http://cvs.gentoo.org/~avenj/)

I would recommend not using EGCS, but instead using the GCC cross compiler. See [[Hurd/BuildingHurd]] and [[Mach/BuildingOskitMach]] for more information on building the GNU OS components. <br />-- [[Main/JoachimNilsson]] - 13 Apr 2003