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"
21 if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" \
22 -a "${CT_KERNEL_LINUX_CUSTOM}" != "y" \
24 case "${CT_KERNEL_VERSION}" in
26 # 4-part version, we need only first three digits
27 k_ver="${CT_KERNEL_VERSION%.*}"
29 *) # 3-part version, use all of it
30 k_ver="${CT_KERNEL_VERSION}"
33 CT_GetFile "linux-${CT_KERNEL_VERSION}" \
34 http://ftp.{de.,eu.,}kernel.org/pub/linux/kernel/v2.6 \
35 http://ftp.{de.,eu.,}kernel.org/pub/linux/kernel/v2.6/longterm/v${k_ver}
42 if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
43 if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
44 # We extract the custom linux tree into a directory with a
45 # well-known name, and strip the leading directory component
46 # of the extracted pathes. This is needed because we do not
47 # know the value for this first component, because it is a
49 # Also, we have to protect from partial extraction using the
50 # .extracting and .extracted locks (not using .patching and
51 # .patched as we are *not* patching that kernel).
53 if [ -e "${CT_SRC_DIR}/.linux-custom.extracted" ]; then
54 CT_DoLog DEBUG "Custom linux kernel tree already extracted"
58 CT_TestAndAbort "Custom kernel tree partially extracted. Remove before resuming" -f "${CT_SRC_DIR}/.linux-custom.extracting"
59 CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.linux-custom.extracting"
60 CT_DoExecLog DEBUG mkdir "${CT_SRC_DIR}/linux-custom"
62 case "${CT_KERNEL_LINUX_CUSTOM_TARBALL}" in
63 *.tar.bz2) tar_opt=-j;;
64 *.tar.gz|*.tgz) tar_opt=-z;;
66 *) CT_Abort "Don't know how to handle '${CT_KERNEL_LINUX_CUSTOM_TARBALL}': unknown extension";;
68 CT_DoLog EXTRA "Extracting custom linux kernel"
69 CT_DoExecLog ALL tar x -C "${CT_SRC_DIR}/linux-custom" \
70 --strip-components 1 -v ${tar_opt} \
71 -f "${CT_KERNEL_LINUX_CUSTOM_TARBALL}"
73 CT_DoExecLog ALL mv -v "${CT_SRC_DIR}/.linux-custom.extracting" "${CT_SRC_DIR}/.linux-custom.extracted"
75 CT_Extract "linux-${CT_KERNEL_VERSION}"
76 CT_Patch "linux" "${CT_KERNEL_VERSION}"
81 # Wrapper to the actual headers install method
83 CT_DoStep INFO "Installing kernel headers"
85 if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
94 # Install kernel headers using headers_install from kernel sources.
98 CT_DoLog DEBUG "Using kernel's headers_install"
100 mkdir -p "${CT_BUILD_DIR}/build-kernel-headers"
102 kernel_path="${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"
103 if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
104 kernel_path="${CT_SRC_DIR}/linux-custom"
106 V_OPT="V=${CT_KERNEL_LINUX_VERBOSE_LEVEL}"
108 CT_DoLog EXTRA "Installing kernel headers"
110 make -C "${kernel_path}" \
111 O="${CT_BUILD_DIR}/build-kernel-headers" \
113 INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
117 if [ "${CT_KERNEL_LINUX_INSTALL_CHECK}" = "y" ]; then
118 CT_DoLog EXTRA "Checking installed headers"
120 make -C "${kernel_path}" \
121 O="${CT_BUILD_DIR}/build-kernel-headers" \
123 INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
129 find "${CT_SYSROOT_DIR}" -type f \
130 \( -name '.install' \
131 -o -name '..install.cmd' \
133 -o -name '..check.cmd' \
138 # Use custom headers (most probably by using make headers_install in a
139 # modified (read: customised) kernel tree, or using pre-2.6.18 headers, such
140 # as 2.4). In this case, simply copy the headers in place
144 CT_DoLog EXTRA "Installing custom kernel headers"
146 mkdir -p "${CT_SYSROOT_DIR}/usr"
147 cd "${CT_SYSROOT_DIR}/usr"
148 if [ "${CT_KERNEL_LINUX_CUSTOM_IS_TARBALL}" = "y" ]; then
149 case "${CT_KERNEL_LINUX_CUSTOM_PATH}" in
151 *.tgz) tar_opt=--gzip;;
152 *.tar.gz) tar_opt=--gzip;;
153 *.tar.bz2) tar_opt=--bzip2;;
154 *.tar.lzma) tar_opt=--lzma;;
156 CT_DoExecLog ALL tar x ${tar_opt} -vf ${CT_KERNEL_LINUX_CUSTOM_PATH}
158 CT_DoExecLog ALL cp -rv "${CT_KERNEL_LINUX_CUSTOM_PATH}/include" .