1 | <sect1 id="ch-system-kernel-headers">
|
---|
2 | <title>Installing Linux-&kernel-version; headers</title>
|
---|
3 | <?dbhtml filename="kernelheaders.html" dir="chapter06"?>
|
---|
4 |
|
---|
5 | <screen>&buildtime; &kernel-time-headers;
|
---|
6 | &diskspace; &kernel-compsize-headers;</screen>
|
---|
7 |
|
---|
8 | <sect2><title> </title><para> </para></sect2>
|
---|
9 |
|
---|
10 | <sect2>
|
---|
11 | <title>Installation of the kernel headers</title>
|
---|
12 |
|
---|
13 | <para>We won't be compiling a new kernel yet -- we'll do that when we have
|
---|
14 | finished the installation of all the packages. But the libraries installed in
|
---|
15 | the next section need to refer to the kernel header files in order to know how
|
---|
16 | to interface with the kernel. Instead of unpacking the kernel sources again,
|
---|
17 | making the version file and the symlinks and so on, we will simply copy the
|
---|
18 | headers from the temporary tools directory in one swoop:</para>
|
---|
19 |
|
---|
20 | <screen><userinput>cp -a /tools/include/{asm,asm-generic,linux} /usr/include</userinput></screen>
|
---|
21 |
|
---|
22 | <para>A few kernel header files refer to the <filename>autoconf.h</filename>
|
---|
23 | header file. Since we have not yet configured the kernel, we need to create
|
---|
24 | this file ourselves in order to avoid a compilation failure of Sysklogd.
|
---|
25 | Create an empty <filename>autoconf.h</filename> file with:</para>
|
---|
26 |
|
---|
27 | <screen><userinput>touch /usr/include/linux/autoconf.h</userinput></screen>
|
---|
28 |
|
---|
29 | </sect2>
|
---|
30 |
|
---|
31 | <sect2><title> </title><para> </para></sect2>
|
---|
32 |
|
---|
33 | <sect2>
|
---|
34 | <title>Why we copy the kernel headers</title>
|
---|
35 |
|
---|
36 | <para>In the past it was common practice to symlink the
|
---|
37 | <filename class="directory">/usr/include/{linux,asm}</filename> directories
|
---|
38 | to <filename class="directory">/usr/src/linux/include/{linux,asm}</filename>.
|
---|
39 | This was a <emphasis>bad</emphasis> practice, as the following extract from a
|
---|
40 | post by Linus Torvalds to the Linux Kernel Mailing List points out:</para>
|
---|
41 |
|
---|
42 | <screen>I would suggest that people who compile new kernels should:
|
---|
43 |
|
---|
44 | - not have a single symbolic link in sight (except the one that the
|
---|
45 | kernel build itself sets up, namely the "linux/include/asm" symlink
|
---|
46 | that is only used for the internal kernel compile itself)
|
---|
47 |
|
---|
48 | And yes, this is what I do. My /usr/src/linux still has the old 2.2.13
|
---|
49 | header files, even though I haven't run a 2.2.13 kernel in a _loong_
|
---|
50 | time. But those headers were what Glibc was compiled against, so those
|
---|
51 | headers are what matches the library object files.
|
---|
52 |
|
---|
53 | And this is actually what has been the suggested environment for at
|
---|
54 | least the last five years. I don't know why the symlink business keeps
|
---|
55 | on living on, like a bad zombie. Pretty much every distribution still
|
---|
56 | has that broken symlink, and people still remember that the linux
|
---|
57 | sources should go into "/usr/src/linux" even though that hasn't been
|
---|
58 | true in a _loong_ time.</screen>
|
---|
59 |
|
---|
60 | <para>The essential part is where Linus states that the header files should be
|
---|
61 | <emphasis>the ones which Glibc was compiled against</emphasis>. These are
|
---|
62 | the headers that should be used when you later compile other packages, as they
|
---|
63 | are the ones that match the object-code library files. By copying the headers,
|
---|
64 | we ensure that they remain available if later you upgrade your kernel.</para>
|
---|
65 |
|
---|
66 | <para>Note, by the way, that it is perfectly all right to have the kernel sources
|
---|
67 | in <filename class="directory">/usr/src/linux</filename>, as long as you don't
|
---|
68 | have the <filename class="directory">/usr/include/{linux,asm}</filename>
|
---|
69 | symlinks.</para>
|
---|
70 |
|
---|
71 | </sect2>
|
---|
72 |
|
---|
73 | </sect1>
|
---|
74 |
|
---|