2009-05-20 20:13:13 +00:00
|
|
|
# This file declares functions to install the kernel headers for linux
|
|
|
|
# Copyright 2007 Yann E. MORIN
|
|
|
|
# Licensed under the GPL v2. See COPYING in the root of this package
|
|
|
|
|
|
|
|
CT_DoKernelTupleValues() {
|
|
|
|
if [ "${CT_ARCH_USE_MMU}" = "y" ]; then
|
|
|
|
CT_TARGET_KERNEL="linux"
|
|
|
|
else
|
2012-09-26 07:09:23 +00:00
|
|
|
# Some no-mmu linux targets requires a -uclinux tuple (like m68k/cf),
|
2015-11-10 06:30:45 +00:00
|
|
|
# while others must have a -linux tuple. Other targets
|
2012-09-26 07:09:23 +00:00
|
|
|
# should be added here when someone starts to care about them.
|
|
|
|
case "${CT_ARCH}" in
|
2016-01-13 14:03:27 +00:00
|
|
|
arm*) CT_TARGET_KERNEL="linux" ;;
|
2012-09-26 07:09:23 +00:00
|
|
|
m68k) CT_TARGET_KERNEL="uclinux" ;;
|
|
|
|
*) CT_Abort "Unsupported no-mmu arch '${CT_ARCH}'"
|
|
|
|
esac
|
2009-05-20 20:13:13 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Download the kernel
|
|
|
|
do_kernel_get() {
|
2011-01-14 17:32:38 +00:00
|
|
|
local k_ver
|
2011-08-14 17:59:02 +00:00
|
|
|
local custom_name
|
2011-09-26 20:59:14 +00:00
|
|
|
local rel_dir
|
|
|
|
local korg_base mirror_base
|
2011-08-14 17:59:02 +00:00
|
|
|
|
|
|
|
if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
|
2015-11-26 13:06:21 +00:00
|
|
|
CT_GetCustom "linux" "${CT_KERNEL_LINUX_CUSTOM_VERSION}" \
|
|
|
|
"${CT_KERNEL_LINUX_CUSTOM_LOCATION}"
|
2011-08-14 17:59:02 +00:00
|
|
|
else # Not a custom tarball
|
2011-01-14 17:32:38 +00:00
|
|
|
case "${CT_KERNEL_VERSION}" in
|
2015-04-27 00:40:35 +00:00
|
|
|
2.6.*.*|3.*.*|4.*.*)
|
2011-07-22 19:45:07 +00:00
|
|
|
# 4-part versions (for 2.6 stables and long-terms), and
|
2015-11-10 06:30:45 +00:00
|
|
|
# 3-part versions (for 3.x.y and 4.x.y stables and long-terms)
|
2011-07-22 19:45:07 +00:00
|
|
|
# we need to trash the last digit
|
2011-01-14 17:32:38 +00:00
|
|
|
k_ver="${CT_KERNEL_VERSION%.*}"
|
|
|
|
;;
|
2015-04-27 00:40:35 +00:00
|
|
|
2.6.*|3.*|4.*)
|
2011-07-22 19:45:07 +00:00
|
|
|
# 3-part version (for 2.6.x initial releases), and 2-part
|
2015-04-27 00:40:35 +00:00
|
|
|
# versions (for 3.x and 4.x initial releases), use all of it
|
2011-01-14 17:32:38 +00:00
|
|
|
k_ver="${CT_KERNEL_VERSION}"
|
|
|
|
;;
|
|
|
|
esac
|
2011-09-26 20:59:14 +00:00
|
|
|
case "${CT_KERNEL_VERSION}" in
|
|
|
|
2.6.*) rel_dir=v2.6;;
|
|
|
|
3.*) rel_dir=v3.x;;
|
2015-04-27 00:40:35 +00:00
|
|
|
4.*) rel_dir=v4.x;;
|
2011-09-26 20:59:14 +00:00
|
|
|
esac
|
2014-12-08 23:03:08 +00:00
|
|
|
korg_base="http://www.kernel.org/pub/linux/kernel/${rel_dir}"
|
2011-12-11 23:01:54 +00:00
|
|
|
CT_GetFile "linux-${CT_KERNEL_VERSION}" \
|
|
|
|
"${korg_base}" \
|
|
|
|
"${korg_base}/longterm/v${k_ver}" \
|
2011-12-12 20:47:08 +00:00
|
|
|
"${korg_base}/longterm"
|
2009-05-20 20:13:13 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Extract kernel
|
|
|
|
do_kernel_extract() {
|
2012-10-16 18:57:44 +00:00
|
|
|
# If using a custom directory location, nothing to do
|
|
|
|
if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" \
|
|
|
|
-a -d "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Otherwise, we're using either a mainstream tarball, or a custom
|
|
|
|
# tarball; in either case, we need to extract
|
2011-08-14 17:59:02 +00:00
|
|
|
CT_Extract "linux-${CT_KERNEL_VERSION}"
|
2012-10-16 18:57:44 +00:00
|
|
|
|
|
|
|
# If using a custom tarball, no need to patch
|
|
|
|
if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
2011-08-14 17:59:02 +00:00
|
|
|
CT_Patch "linux" "${CT_KERNEL_VERSION}"
|
2009-05-20 20:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Install kernel headers using headers_install from kernel sources.
|
2015-11-26 11:43:03 +00:00
|
|
|
do_kernel_headers() {
|
2010-06-17 16:30:09 +00:00
|
|
|
local kernel_path
|
2014-01-01 18:14:20 +00:00
|
|
|
local kernel_arch
|
2010-06-17 16:30:09 +00:00
|
|
|
|
2015-11-26 11:43:03 +00:00
|
|
|
CT_DoStep INFO "Installing kernel headers"
|
2009-05-20 20:13:13 +00:00
|
|
|
|
|
|
|
mkdir -p "${CT_BUILD_DIR}/build-kernel-headers"
|
|
|
|
|
2010-06-17 16:30:09 +00:00
|
|
|
kernel_path="${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"
|
2009-05-20 20:13:13 +00:00
|
|
|
V_OPT="V=${CT_KERNEL_LINUX_VERBOSE_LEVEL}"
|
|
|
|
|
2013-12-30 22:15:02 +00:00
|
|
|
kernel_arch="${CT_ARCH}"
|
2013-12-30 22:28:18 +00:00
|
|
|
case "${CT_ARCH}:${CT_ARCH_BITNESS}" in
|
|
|
|
# ARM 64 (aka AArch64) is special
|
|
|
|
arm:64) kernel_arch="arm64";;
|
|
|
|
esac
|
2013-12-30 22:15:02 +00:00
|
|
|
|
2009-05-20 20:13:13 +00:00
|
|
|
CT_DoLog EXTRA "Installing kernel headers"
|
|
|
|
CT_DoExecLog ALL \
|
2016-11-21 07:50:17 +00:00
|
|
|
make -C "${kernel_path}" \
|
2015-11-03 00:55:44 +00:00
|
|
|
CROSS_COMPILE="${CT_TARGET}-" \
|
2010-06-17 16:30:09 +00:00
|
|
|
O="${CT_BUILD_DIR}/build-kernel-headers" \
|
2014-01-01 18:14:20 +00:00
|
|
|
ARCH=${kernel_arch} \
|
2009-05-20 20:13:13 +00:00
|
|
|
INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
|
|
|
|
${V_OPT} \
|
|
|
|
headers_install
|
|
|
|
|
|
|
|
if [ "${CT_KERNEL_LINUX_INSTALL_CHECK}" = "y" ]; then
|
|
|
|
CT_DoLog EXTRA "Checking installed headers"
|
|
|
|
CT_DoExecLog ALL \
|
2016-11-21 07:50:17 +00:00
|
|
|
make -C "${kernel_path}" \
|
2015-11-03 00:55:44 +00:00
|
|
|
CROSS_COMPILE="${CT_TARGET}-" \
|
2010-06-17 16:30:09 +00:00
|
|
|
O="${CT_BUILD_DIR}/build-kernel-headers" \
|
2014-01-01 18:14:20 +00:00
|
|
|
ARCH=${kernel_arch} \
|
2009-05-20 20:13:13 +00:00
|
|
|
INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
|
|
|
|
${V_OPT} \
|
|
|
|
headers_check
|
|
|
|
fi
|
2010-12-22 21:41:51 +00:00
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
find "${CT_SYSROOT_DIR}" -type f \
|
|
|
|
\( -name '.install' \
|
|
|
|
-o -name '..install.cmd' \
|
|
|
|
-o -name '.check' \
|
|
|
|
-o -name '..check.cmd' \
|
|
|
|
\) \
|
|
|
|
-exec rm {} \;
|
2009-05-20 20:13:13 +00:00
|
|
|
|
2015-11-26 11:43:03 +00:00
|
|
|
CT_EndStep
|
2009-05-20 20:13:13 +00:00
|
|
|
}
|