kernel-headers.xml 3.3 KB

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