1 # This file declares functions to install the kernel headers for linux
2 # Copyright 2007 Yann E. MORIN
3 # Licensed under the GPL v2. See COPYING in the root of this package
5 CT_DoKernelTupleValues() {
6 if [ "${CT_ARCH_USE_MMU}" = "y" ]; then
7 CT_TARGET_KERNEL="linux"
9 # Sometime, noMMU linux targets have a -uclinux tuple, while
10 # sometime it's -linux. We currently have only one noMMU linux
11 # target, and it uses -linux, so let's just use that. Time
12 # to fix that later...
13 # CT_TARGET_KERNEL="uclinux"
14 CT_TARGET_KERNEL="linux"
20 if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" \
21 -a "${CT_KERNEL_LINUX_CUSTOM}" != "y" \
23 CT_GetFile "linux-${CT_KERNEL_VERSION}" \
24 {ftp,http}://ftp.{de.,eu.,}kernel.org/pub/linux/kernel/v2.{6{,/testing},4,2}
31 if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
32 if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
33 # We extract the custom linux tree into a directory with a
34 # well-known name, and strip the leading directory component
35 # of the extracted pathes. This is needed because we do not
36 # know the value for this first component, because it is a
38 # Also, we have to protect from partial extraction using the
39 # .extracting and .extracted locks (not using .patching and
40 # .patched as we are *not* patching that kernel).
42 if [ -e "${CT_SRC_DIR}/.linux-custom.extracted" ]; then
43 CT_DoLog DEBUG "Custom linux kernel tree already extracted"
47 CT_TestAndAbort "Custom kernel tree partially extracted. Remove before resuming" -f "${CT_SRC_DIR}/.linux-custom.extracting"
48 CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.linux-custom.extracting"
49 CT_DoExecLog DEBUG mkdir "${CT_SRC_DIR}/linux-custom"
51 case "${CT_KERNEL_LINUX_CUSTOM_TARBALL}" in
52 *.tar.bz2) tar_opt=-j;;
53 *.tar.gz|*.tgz) tar_opt=-z;;
55 *) CT_Abort "Don't know how to handle '${CT_KERNEL_LINUX_CUSTOM_TARBALL}': unknown extension";;
57 CT_DoLog EXTRA "Extracting custom linux kernel"
58 CT_DoExecLog ALL tar x -C "${CT_SRC_DIR}/linux-custom" \
59 --strip-components 1 -v ${tar_opt} \
60 -f "${CT_KERNEL_LINUX_CUSTOM_TARBALL}"
62 CT_DoExecLog ALL mv -v "${CT_SRC_DIR}/.linux-custom.extracting" "${CT_SRC_DIR}/.linux-custom.extracted"
64 CT_Extract "linux-${CT_KERNEL_VERSION}"
65 CT_Patch "linux" "${CT_KERNEL_VERSION}"
70 # Wrapper to the actual headers install method
72 CT_DoStep INFO "Installing kernel headers"
74 if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
83 # Install kernel headers using headers_install from kernel sources.
87 CT_DoLog DEBUG "Using kernel's headers_install"
89 mkdir -p "${CT_BUILD_DIR}/build-kernel-headers"
91 kernel_path="${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"
92 if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
93 kernel_path="${CT_SRC_DIR}/linux-custom"
95 V_OPT="V=${CT_KERNEL_LINUX_VERBOSE_LEVEL}"
97 CT_DoLog EXTRA "Installing kernel headers"
99 make -C "${kernel_path}" \
100 O="${CT_BUILD_DIR}/build-kernel-headers" \
102 INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
106 if [ "${CT_KERNEL_LINUX_INSTALL_CHECK}" = "y" ]; then
107 CT_DoLog EXTRA "Checking installed headers"
109 make -C "${kernel_path}" \
110 O="${CT_BUILD_DIR}/build-kernel-headers" \
112 INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
115 find "${CT_SYSROOT_DIR}" -type f -name '.check*' -exec rm {} \;
119 # Use custom headers (most probably by using make headers_install in a
120 # modified (read: customised) kernel tree, or using pre-2.6.18 headers, such
121 # as 2.4). In this case, simply copy the headers in place
125 CT_DoLog EXTRA "Installing custom kernel headers"
127 mkdir -p "${CT_SYSROOT_DIR}/usr"
128 cd "${CT_SYSROOT_DIR}/usr"
129 if [ "${CT_KERNEL_LINUX_CUSTOM_IS_TARBALL}" = "y" ]; then
130 case "${CT_KERNEL_LINUX_CUSTOM_PATH}" in
132 *.tgz) tar_opt=--gzip;;
133 *.tar.gz) tar_opt=--gzip;;
134 *.tar.bz2) tar_opt=--bzip2;;
135 *.tar.lzma) tar_opt=--lzma;;
137 CT_DoExecLog ALL tar x ${tar_opt} -vf ${CT_KERNEL_LINUX_CUSTOM_PATH}
139 CT_DoExecLog ALL cp -rv "${CT_KERNEL_LINUX_CUSTOM_PATH}/include" .