Commit f6820308e025d645d9d766c97586badd4ddb8754

Authored by Kirill A. Shutemov
Committed by Michal Marek
1 parent 8990c1bc4b

kbuild: introduce HDR_ARCH_LIST for headers_install_all

Using HDR_ARCH_LIST you can specify subset of architectures you want to get
headers for.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Michal Marek <mmarek@suse.cz>

Showing 2 changed files with 4 additions and 3 deletions Inline Diff

Documentation/make/headers_install.txt
1 Exporting kernel headers for use by userspace 1 Exporting kernel headers for use by userspace
2 ============================================= 2 =============================================
3 3
4 The "make headers_install" command exports the kernel's header files in a 4 The "make headers_install" command exports the kernel's header files in a
5 form suitable for use by userspace programs. 5 form suitable for use by userspace programs.
6 6
7 The linux kernel's exported header files describe the API for user space 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 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 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 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 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 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 13 installed at the default location /usr/include and the kernel headers in
14 subdirectories under that (most notably /usr/include/linux and 14 subdirectories under that (most notably /usr/include/linux and
15 /usr/include/asm). 15 /usr/include/asm).
16 16
17 Kernel headers are backwards compatible, but not forwards compatible. This 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 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 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 20 features), but a program built against newer kernel headers may not work on an
21 older kernel. 21 older kernel.
22 22
23 The "make headers_install" command can be run in the top level directory of the 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 24 kernel source code (or using a standard out-of-tree build). It takes two
25 optional arguments: 25 optional arguments:
26 26
27 make headers_install ARCH=i386 INSTALL_HDR_PATH=/usr/include 27 make headers_install ARCH=i386 INSTALL_HDR_PATH=/usr/include
28 28
29 ARCH indicates which architecture to produce headers for, and defaults to the 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 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 31 is platform-specific, to see a complete list of supported architectures use
32 the command: 32 the command:
33 33
34 ls -d include/asm-* | sed 's/.*-//' 34 ls -d include/asm-* | sed 's/.*-//'
35 35
36 INSTALL_HDR_PATH indicates where to install the headers. It defaults to 36 INSTALL_HDR_PATH indicates where to install the headers. It defaults to
37 "./usr/include". 37 "./usr/include".
38 38
39 The command "make headers_install_all" exports headers for all architectures 39 The command "make headers_install_all" exports headers for all architectures
40 simultaneously. (This is mostly of interest to distribution maintainers, 40 simultaneously. (This is mostly of interest to distribution maintainers,
41 who create an architecture-independent tarball from the resulting include 41 who create an architecture-independent tarball from the resulting include
42 directory.) Remember to provide the appropriate linux/asm directory via "mv" 42 directory.) You also can use HDR_ARCH_LIST to specify list of architectures.
43 or "ln -s" before building a C library with headers exported this way. 43 Remember to provide the appropriate linux/asm directory via "mv" or "ln -s"
44 before building a C library with headers exported this way.
44 45
45 The kernel header export infrastructure is maintained by David Woodhouse 46 The kernel header export infrastructure is maintained by David Woodhouse
46 <dwmw2@infradead.org>. 47 <dwmw2@infradead.org>.
47 48
1 #!/bin/sh 1 #!/bin/sh
2 # Run headers_$1 command for all suitable architectures 2 # Run headers_$1 command for all suitable architectures
3 3
4 # Stop on error 4 # Stop on error
5 set -e 5 set -e
6 6
7 do_command() 7 do_command()
8 { 8 {
9 if [ -f ${srctree}/arch/$2/include/asm/Kbuild ]; then 9 if [ -f ${srctree}/arch/$2/include/asm/Kbuild ]; then
10 make ARCH=$2 KBUILD_HEADERS=$1 headers_$1 10 make ARCH=$2 KBUILD_HEADERS=$1 headers_$1
11 else 11 else
12 printf "Ignoring arch: %s\n" ${arch} 12 printf "Ignoring arch: %s\n" ${arch}
13 fi 13 fi
14 } 14 }
15 15
16 archs=$(ls ${srctree}/arch) 16 archs=${HDR_ARCH_LIST:-$(ls ${srctree}/arch)}
17 17
18 for arch in ${archs}; do 18 for arch in ${archs}; do
19 case ${arch} in 19 case ${arch} in
20 um) # no userspace export 20 um) # no userspace export
21 ;; 21 ;;
22 cris) # headers export are known broken 22 cris) # headers export are known broken
23 ;; 23 ;;
24 *) 24 *)
25 if [ -d ${srctree}/arch/${arch} ]; then 25 if [ -d ${srctree}/arch/${arch} ]; then
26 do_command $1 ${arch} 26 do_command $1 ${arch}
27 fi 27 fi
28 ;; 28 ;;
29 esac 29 esac
30 done 30 done
31 31
32 32
33 33