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