scripts/build/kernel/linux-common.sh
changeset 1337 7f742f73c2d1
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/scripts/build/kernel/linux-common.sh	Wed May 13 20:55:15 2009 +0000
     1.3 @@ -0,0 +1,99 @@
     1.4 +# This file declares functions to install the kernel headers for linux
     1.5 +# Copyright 2007 Yann E. MORIN
     1.6 +# Licensed under the GPL v2. See COPYING in the root of this package
     1.7 +
     1.8 +CT_DoKernelTupleValues() {
     1.9 +    # Nothing to do, keep the default value
    1.10 +    :
    1.11 +}
    1.12 +
    1.13 +# Download the kernel
    1.14 +do_kernel_get() {
    1.15 +    if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" != "y" ]; then
    1.16 +        CT_GetFile "linux-${CT_KERNEL_VERSION}" \
    1.17 +                   {ftp,http}://ftp.{de.,eu.,}kernel.org/pub/linux/kernel/v2.{6{,/testing},4,2}
    1.18 +    fi
    1.19 +    return 0
    1.20 +}
    1.21 +
    1.22 +# Extract kernel
    1.23 +do_kernel_extract() {
    1.24 +    if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" != "y" ]; then
    1.25 +        CT_Extract "linux-${CT_KERNEL_VERSION}"
    1.26 +        CT_Patch "linux-${CT_KERNEL_VERSION}"
    1.27 +    fi
    1.28 +    return 0
    1.29 +}
    1.30 +
    1.31 +# Wrapper to the actual headers install method
    1.32 +do_kernel_headers() {
    1.33 +    CT_DoStep INFO "Installing kernel headers"
    1.34 +
    1.35 +    if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" = "y" ]; then
    1.36 +        do_kernel_custom
    1.37 +    else
    1.38 +        do_kernel_install
    1.39 +    fi
    1.40 +
    1.41 +    CT_EndStep
    1.42 +}
    1.43 +
    1.44 +# Install kernel headers using headers_install from kernel sources.
    1.45 +do_kernel_install() {
    1.46 +    CT_DoLog DEBUG "Using kernel's headers_install"
    1.47 +
    1.48 +    mkdir -p "${CT_BUILD_DIR}/build-kernel-headers"
    1.49 +    cd "${CT_BUILD_DIR}/build-kernel-headers"
    1.50 +
    1.51 +    # Only starting with 2.6.18 does headers_install is usable. We only
    1.52 +    # have 2.6 version available, so only test for sublevel.
    1.53 +    k_sublevel=$(awk '/^SUBLEVEL =/ { print $3 }' "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}/Makefile")
    1.54 +    [ ${k_sublevel} -ge 18 ] || CT_Abort "Kernel version >= 2.6.18 is needed to install kernel headers."
    1.55 +
    1.56 +    V_OPT="V=${CT_KERNEL_LINUX_VERBOSE_LEVEL}"
    1.57 +
    1.58 +    CT_DoLog EXTRA "Installing kernel headers"
    1.59 +    CT_DoExecLog ALL                                    \
    1.60 +    make -C "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"  \
    1.61 +         O=$(pwd)                                       \
    1.62 +         ARCH=${CT_KERNEL_ARCH}                         \
    1.63 +         INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr"       \
    1.64 +         ${V_OPT}                                       \
    1.65 +         headers_install
    1.66 +
    1.67 +    if [ "${CT_KERNEL_LINUX_INSTALL_CHECK}" = "y" ]; then
    1.68 +        CT_DoLog EXTRA "Checking installed headers"
    1.69 +        CT_DoExecLog ALL                                    \
    1.70 +        make -C "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"  \
    1.71 +             O=$(pwd)                                       \
    1.72 +             ARCH=${CT_KERNEL_ARCH}                         \
    1.73 +             INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr"       \
    1.74 +             ${V_OPT}                                       \
    1.75 +             headers_check
    1.76 +        find "${CT_SYSROOT_DIR}" -type f -name '.check*' -exec rm {} \;
    1.77 +    fi
    1.78 +}
    1.79 +
    1.80 +# Use custom headers (most probably by using make headers_install in a
    1.81 +# modified (read: customised) kernel tree, or using pre-2.6.18 headers, such
    1.82 +# as 2.4). In this case, simply copy the headers in place
    1.83 +do_kernel_custom() {
    1.84 +    local tar_opt
    1.85 +
    1.86 +    CT_DoLog EXTRA "Installing custom kernel headers"
    1.87 +
    1.88 +    mkdir -p "${CT_SYSROOT_DIR}/usr"
    1.89 +    cd "${CT_SYSROOT_DIR}/usr"
    1.90 +    if [ "${CT_KERNEL_LINUX_CUSTOM_IS_TARBALL}" = "y" ]; then
    1.91 +        case "${CT_KERNEL_LINUX_CUSTOM_PATH}" in
    1.92 +            *.tar)      ;;
    1.93 +            *.tgz)      tar_opt=--gzip;;
    1.94 +            *.tar.gz)   tar_opt=--gzip;;
    1.95 +            *.tar.bz2)  tar_opt=--bzip2;;
    1.96 +            *.tar.lzma) tar_opt=--lzma;;
    1.97 +        esac
    1.98 +        CT_DoExecLog ALL tar x ${tar_opt} -vf ${CT_KERNEL_LINUX_CUSTOM_PATH}
    1.99 +    else
   1.100 +        CT_DoExecLog ALL cp -rv "${CT_KERNEL_LINUX_CUSTOM_PATH}/include" .
   1.101 +    fi
   1.102 +}