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 versions (for 2.6 stables and long-terms), and
27 # 3-part versions (for 3.x.y stables and long-terms),
28 # we need to trash the last digit
29 k_ver="${CT_KERNEL_VERSION%.*}"
32 # 3-part version (for 2.6.x initial releases), and 2-part
33 # versions (for 3.x initial releases), use all of it
34 k_ver="${CT_KERNEL_VERSION}"
37 CT_GetFile "linux-${CT_KERNEL_VERSION}" \
38 http://ftp.{de.,eu.,}kernel.org/pub/linux/kernel/v2.6 \
39 http://ftp.{de.,eu.,}kernel.org/pub/linux/kernel/v3.0 \
40 http://ftp.{de.,eu.,}kernel.org/pub/linux/kernel/v2.6/longterm/v${k_ver} \
41 http://ftp.{de.,eu.,}kernel.org/pub/linux/kernel/v3.0/longterm/v${k_ver}
48 if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
49 if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
50 # We extract the custom linux tree into a directory with a
51 # well-known name, and strip the leading directory component
52 # of the extracted pathes. This is needed because we do not
53 # know the value for this first component, because it is a
55 # Also, we have to protect from partial extraction using the
56 # .extracting and .extracted locks (not using .patching and
57 # .patched as we are *not* patching that kernel).
59 if [ -e "${CT_SRC_DIR}/.linux-custom.extracted" ]; then
60 CT_DoLog DEBUG "Custom linux kernel tree already extracted"
64 CT_TestAndAbort "Custom kernel tree partially extracted. Remove before resuming" -f "${CT_SRC_DIR}/.linux-custom.extracting"
65 CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.linux-custom.extracting"
66 CT_DoExecLog DEBUG mkdir "${CT_SRC_DIR}/linux-custom"
68 case "${CT_KERNEL_LINUX_CUSTOM_TARBALL}" in
69 *.tar.bz2) tar_opt=-j;;
70 *.tar.gz|*.tgz) tar_opt=-z;;
72 *) CT_Abort "Don't know how to handle '${CT_KERNEL_LINUX_CUSTOM_TARBALL}': unknown extension";;
74 CT_DoLog EXTRA "Extracting custom linux kernel"
75 CT_DoExecLog ALL tar x -C "${CT_SRC_DIR}/linux-custom" \
76 --strip-components 1 -v ${tar_opt} \
77 -f "${CT_KERNEL_LINUX_CUSTOM_TARBALL}"
79 CT_DoExecLog ALL mv -v "${CT_SRC_DIR}/.linux-custom.extracting" "${CT_SRC_DIR}/.linux-custom.extracted"
81 CT_Extract "linux-${CT_KERNEL_VERSION}"
82 CT_Patch "linux" "${CT_KERNEL_VERSION}"
87 # Wrapper to the actual headers install method
89 CT_DoStep INFO "Installing kernel headers"
91 if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
100 # Install kernel headers using headers_install from kernel sources.
101 do_kernel_install() {
104 CT_DoLog DEBUG "Using kernel's headers_install"
106 mkdir -p "${CT_BUILD_DIR}/build-kernel-headers"
108 kernel_path="${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"
109 if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
110 kernel_path="${CT_SRC_DIR}/linux-custom"
112 V_OPT="V=${CT_KERNEL_LINUX_VERBOSE_LEVEL}"
114 CT_DoLog EXTRA "Installing kernel headers"
116 make -C "${kernel_path}" \
117 O="${CT_BUILD_DIR}/build-kernel-headers" \
119 INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
123 if [ "${CT_KERNEL_LINUX_INSTALL_CHECK}" = "y" ]; then
124 CT_DoLog EXTRA "Checking installed headers"
126 make -C "${kernel_path}" \
127 O="${CT_BUILD_DIR}/build-kernel-headers" \
129 INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
135 find "${CT_SYSROOT_DIR}" -type f \
136 \( -name '.install' \
137 -o -name '..install.cmd' \
139 -o -name '..check.cmd' \
144 # Use custom headers (most probably by using make headers_install in a
145 # modified (read: customised) kernel tree, or using pre-2.6.18 headers, such
146 # as 2.4). In this case, simply copy the headers in place
150 CT_DoLog EXTRA "Installing custom kernel headers"
152 mkdir -p "${CT_SYSROOT_DIR}/usr"
153 cd "${CT_SYSROOT_DIR}/usr"
154 if [ "${CT_KERNEL_LINUX_CUSTOM_IS_TARBALL}" = "y" ]; then
155 case "${CT_KERNEL_LINUX_CUSTOM_PATH}" in
157 *.tgz) tar_opt=--gzip;;
158 *.tar.gz) tar_opt=--gzip;;
159 *.tar.bz2) tar_opt=--bzip2;;
160 *.tar.lzma) tar_opt=--lzma;;
162 CT_DoExecLog ALL tar x ${tar_opt} -vf ${CT_KERNEL_LINUX_CUSTOM_PATH}
164 CT_DoExecLog ALL cp -rv "${CT_KERNEL_LINUX_CUSTOM_PATH}/include" .