| Rob Landley | 451ad11 | 2007-10-16 23:31:16 -0700 | [diff] [blame] | 1 | Exporting kernel headers for use by userspace | 
|  | 2 | ============================================= | 
|  | 3 |  | 
|  | 4 | The "make headers_install" command exports the kernel's header files in a | 
|  | 5 | form suitable for use by userspace programs. | 
|  | 6 |  | 
|  | 7 | The linux kernel's exported header files describe the API for user space | 
|  | 8 | programs attempting to use kernel services.  These kernel header files are | 
|  | 9 | used by the system's C library (such as glibc or uClibc) to define available | 
|  | 10 | system calls, as well as constants and structures to be used with these | 
|  | 11 | system calls.  The C library's header files include the kernel header files | 
|  | 12 | from the "linux" subdirectory.  The system's libc headers are usually | 
|  | 13 | installed at the default location /usr/include and the kernel headers in | 
|  | 14 | subdirectories under that (most notably /usr/include/linux and | 
|  | 15 | /usr/include/asm). | 
|  | 16 |  | 
|  | 17 | Kernel headers are backwards compatible, but not forwards compatible.  This | 
|  | 18 | means that a program built against a C library using older kernel headers | 
|  | 19 | should run on a newer kernel (although it may not have access to new | 
|  | 20 | features), but a program built against newer kernel headers may not work on an | 
|  | 21 | older kernel. | 
|  | 22 |  | 
|  | 23 | The "make headers_install" command can be run in the top level directory of the | 
|  | 24 | kernel source code (or using a standard out-of-tree build).  It takes two | 
|  | 25 | optional arguments: | 
|  | 26 |  | 
|  | 27 | make headers_install ARCH=i386 INSTALL_HDR_PATH=/usr/include | 
|  | 28 |  | 
|  | 29 | ARCH indicates which architecture to produce headers for, and defaults to the | 
|  | 30 | current architecture.  The linux/asm directory of the exported kernel headers | 
|  | 31 | is platform-specific, to see a complete list of supported architectures use | 
|  | 32 | the command: | 
|  | 33 |  | 
|  | 34 | ls -d include/asm-* | sed 's/.*-//' | 
|  | 35 |  | 
|  | 36 | INSTALL_HDR_PATH indicates where to install the headers.  It defaults to | 
|  | 37 | "./usr/include". | 
|  | 38 |  | 
|  | 39 | The command "make headers_install_all" exports headers for all architectures | 
|  | 40 | simultaneously.  (This is mostly of interest to distribution maintainers, | 
|  | 41 | who create an architecture-independent tarball from the resulting include | 
|  | 42 | directory.)  Remember to provide the appropriate linux/asm directory via "mv" | 
|  | 43 | or "ln -s" before building a C library with headers exported this way. | 
|  | 44 |  | 
|  | 45 | The kernel header export infrastructure is maintained by David Woodhouse | 
|  | 46 | <dwmw2@infradead.org>. |