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 {ftp,http}://ftp.{de.,eu.,}kernel.org/pub/linux/kernel/v2.{6{,/testing,/longterm/v${k_ver}},4,2}
41 if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
42 if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
43 # We extract the custom linux tree into a directory with a
44 # well-known name, and strip the leading directory component
45 # of the extracted pathes. This is needed because we do not
46 # know the value for this first component, because it is a
48 # Also, we have to protect from partial extraction using the
49 # .extracting and .extracted locks (not using .patching and
50 # .patched as we are *not* patching that kernel).
52 if [ -e "${CT_SRC_DIR}/.linux-custom.extracted" ]; then
53 CT_DoLog DEBUG "Custom linux kernel tree already extracted"
57 CT_TestAndAbort "Custom kernel tree partially extracted. Remove before resuming" -f "${CT_SRC_DIR}/.linux-custom.extracting"
58 CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.linux-custom.extracting"
59 CT_DoExecLog DEBUG mkdir "${CT_SRC_DIR}/linux-custom"
61 case "${CT_KERNEL_LINUX_CUSTOM_TARBALL}" in
62 *.tar.bz2) tar_opt=-j;;
63 *.tar.gz|*.tgz) tar_opt=-z;;
65 *) CT_Abort "Don't know how to handle '${CT_KERNEL_LINUX_CUSTOM_TARBALL}': unknown extension";;
67 CT_DoLog EXTRA "Extracting custom linux kernel"
68 CT_DoExecLog ALL tar x -C "${CT_SRC_DIR}/linux-custom" \
69 --strip-components 1 -v ${tar_opt} \
70 -f "${CT_KERNEL_LINUX_CUSTOM_TARBALL}"
72 CT_DoExecLog ALL mv -v "${CT_SRC_DIR}/.linux-custom.extracting" "${CT_SRC_DIR}/.linux-custom.extracted"
74 CT_Extract "linux-${CT_KERNEL_VERSION}"
75 CT_Patch "linux" "${CT_KERNEL_VERSION}"
80 # Wrapper to the actual headers install method
82 CT_DoStep INFO "Installing kernel headers"
84 if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
93 # Install kernel headers using headers_install from kernel sources.
97 CT_DoLog DEBUG "Using kernel's headers_install"
99 mkdir -p "${CT_BUILD_DIR}/build-kernel-headers"
101 kernel_path="${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"
102 if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
103 kernel_path="${CT_SRC_DIR}/linux-custom"
105 V_OPT="V=${CT_KERNEL_LINUX_VERBOSE_LEVEL}"
107 CT_DoLog EXTRA "Installing kernel headers"
109 make -C "${kernel_path}" \
110 O="${CT_BUILD_DIR}/build-kernel-headers" \
112 INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
116 if [ "${CT_KERNEL_LINUX_INSTALL_CHECK}" = "y" ]; then
117 CT_DoLog EXTRA "Checking installed headers"
119 make -C "${kernel_path}" \
120 O="${CT_BUILD_DIR}/build-kernel-headers" \
122 INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
128 find "${CT_SYSROOT_DIR}" -type f \
129 \( -name '.install' \
130 -o -name '..install.cmd' \
132 -o -name '..check.cmd' \
137 # Use custom headers (most probably by using make headers_install in a
138 # modified (read: customised) kernel tree, or using pre-2.6.18 headers, such
139 # as 2.4). In this case, simply copy the headers in place
143 CT_DoLog EXTRA "Installing custom kernel headers"
145 mkdir -p "${CT_SYSROOT_DIR}/usr"
146 cd "${CT_SYSROOT_DIR}/usr"
147 if [ "${CT_KERNEL_LINUX_CUSTOM_IS_TARBALL}" = "y" ]; then
148 case "${CT_KERNEL_LINUX_CUSTOM_PATH}" in
150 *.tgz) tar_opt=--gzip;;
151 *.tar.gz) tar_opt=--gzip;;
152 *.tar.bz2) tar_opt=--bzip2;;
153 *.tar.lzma) tar_opt=--lzma;;
155 CT_DoExecLog ALL tar x ${tar_opt} -vf ${CT_KERNEL_LINUX_CUSTOM_PATH}
157 CT_DoExecLog ALL cp -rv "${CT_KERNEL_LINUX_CUSTOM_PATH}/include" .