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 # Some no-mmu linux targets requires a -uclinux tuple (like m68k/cf),
10 # while others must have a -linux tuple (like bfin). Other targets
11 # should be added here when someone starts to care about them.
13 blackfin) CT_TARGET_KERNEL="linux" ;;
14 m68k) CT_TARGET_KERNEL="uclinux" ;;
15 *) CT_Abort "Unsupported no-mmu arch '${CT_ARCH}'"
25 local korg_base mirror_base
27 if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" = "y" ]; then
31 if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
32 if [ ! -d "${CT_KERNEL_LINUX_CUSTOM_LOCATION}" ]; then
33 # Wee need to know the custom tarball extension,
34 # so we can create a properly-named symlink, which
35 # we use later on in 'extract'
36 case "${CT_KERNEL_LINUX_CUSTOM_LOCATION}" in
37 *.tar.bz2) custom_name="linux-custom.tar.bz2";;
38 *.tar.gz|*.tgz) custom_name="linux-custom.tar.gz";;
39 *.tar) custom_name="linux-custom.tar";;
40 *) CT_Abort "Unknown extension for custom linux tarball '${CT_KERNEL_LINUX_CUSTOM_LOCATION}'";;
42 CT_DoExecLog DEBUG ln -sf "${CT_KERNEL_LINUX_CUSTOM_LOCATION}" \
43 "${CT_TARBALLS_DIR}/${custom_name}"
45 custom_name="linux-custom"
46 CT_DoExecLog DEBUG ln -sf "${CT_KERNEL_LINUX_CUSTOM_LOCATION}" \
47 "${CT_SRC_DIR}/${custom_name}"
49 else # Not a custom tarball
50 case "${CT_KERNEL_VERSION}" in
52 # 4-part versions (for 2.6 stables and long-terms), and
53 # 3-part versions (for 3.x.y stables and long-terms),
54 # we need to trash the last digit
55 k_ver="${CT_KERNEL_VERSION%.*}"
58 # 3-part version (for 2.6.x initial releases), and 2-part
59 # versions (for 3.x initial releases), use all of it
60 k_ver="${CT_KERNEL_VERSION}"
63 case "${CT_KERNEL_VERSION}" in
67 korg_base="http://ftp.kernel.org/pub/linux/kernel/${rel_dir}"
68 CT_GetFile "linux-${CT_KERNEL_VERSION}" \
70 "${korg_base}/longterm/v${k_ver}" \
71 "${korg_base}/longterm"
77 if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" = "y" \
78 -o -d "${CT_KERNEL_LINUX_CUSTOM_LOCATION}" ]; then
82 # This also handles the custom tarball
83 CT_Extract "linux-${CT_KERNEL_VERSION}"
84 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_USE_CUSTOM_HEADERS}" = "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;;
161 CT_DoExecLog ALL tar x ${tar_opt} -vf ${CT_KERNEL_LINUX_CUSTOM_PATH}
163 CT_DoExecLog ALL cp -rv "${CT_KERNEL_LINUX_CUSTOM_PATH}/include" .