aboutsummaryrefslogtreecommitdiffstats
path: root/chapter06/kernel-headers.xml
blob: 14d73d992ac0da456620581dbcb080aaab0dcd3b (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
<sect1 id="ch-system-kernel-headers">
<title>Installing Linux-&kernel-version; headers</title>
<?dbhtml filename="kernelheaders.html" dir="chapter06"?>

<screen>&buildtime; &kernel-time-headers;
&diskspace; &kernel-compsize-headers;</screen>

<sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>

<sect2>
<title>Installation of the kernel headers</title>

<para>We won't be compiling a new kernel yet -- we'll do that when we have
finished the installation of all the packages. But the libraries installed in
the next section need to refer to the kernel header files in order to know how
to interface with the kernel. Instead of unpacking the kernel sources again,
making the version file and the symlinks and so on, we will simply copy the
headers from the temporary tools directory in one swoop:</para>

<screen><userinput>cp -a /tools/include/{asm,asm-generic,linux} /usr/include</userinput></screen>

<para>A few kernel header files refer to the <filename>autoconf.h</filename>
header file. Since we have not yet configured the kernel, we need to create
this file ourselves in order to avoid a compilation failure of Sysklogd.
Create an empty <filename>autoconf.h</filename> file with:</para>

<screen><userinput>touch /usr/include/linux/autoconf.h</userinput></screen>

</sect2>

<sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>

<sect2>
<title>Why we copy the kernel headers</title>

<para>In the past it was common practice to symlink the
<filename class="directory">/usr/include/{linux,asm}</filename> directories
to <filename class="directory">/usr/src/linux/include/{linux,asm}</filename>.
This was a <emphasis>bad</emphasis> practice, as the following extract from a
post by Linus Torvalds to the Linux Kernel Mailing List points out:</para>

<screen>I would suggest that people who compile new kernels should: 

 - not have a single symbolic link in sight (except the one that the 
   kernel build itself sets up, namely the "linux/include/asm" symlink 
   that is only used for the internal kernel compile itself) 

And yes, this is what I do. My /usr/src/linux still has the old 2.2.13 
header files, even though I haven't run a 2.2.13 kernel in a _loong_ 
time. But those headers were what Glibc was compiled against, so those 
headers are what matches the library object files. 

And this is actually what has been the suggested environment for at 
least the last five years. I don't know why the symlink business keeps 
on living on, like a bad zombie. Pretty much every distribution still 
has that broken symlink, and people still remember that the linux 
sources should go into "/usr/src/linux" even though that hasn't been 
true in a _loong_ time.</screen>

<para>The essential part is where Linus states that the header files should be
<emphasis>the ones which Glibc was compiled against</emphasis>. These are
the headers that should be used when you later compile other packages, as they
are the ones that match the object-code library files. By copying the headers,
we ensure that they remain available if later you upgrade your kernel.</para>

<para>Note, by the way, that it is perfectly all right to have the kernel sources
in <filename class="directory">/usr/src/linux</filename>, as long as you don't
have the <filename class="directory">/usr/include/{linux,asm}</filename>
symlinks.</para>

</sect2>

</sect1>