scripts/build/kernel/linux.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Jan 13 20:46:01 2010 +0100 (2010-01-13)
changeset 1732 6b2ae7804c6f
parent 1337 7f742f73c2d1
child 1746 5851a36db763
permissions -rw-r--r--
debug/gdb: staticaly link to ncurses for the native gdb

Staticaly link the native gdb (the one that runs on the target,
not the cross one that runs on the host) to ncurses.
yann@1345
     1
# This file declares functions to install the kernel headers for linux
yann@1345
     2
# Copyright 2007 Yann E. MORIN
yann@1345
     3
# Licensed under the GPL v2. See COPYING in the root of this package
yann@1345
     4
yann@1345
     5
CT_DoKernelTupleValues() {
yann@1345
     6
    if [ "${CT_ARCH_USE_MMU}" = "y" ]; then
yann@1345
     7
        CT_TARGET_KERNEL="linux"
yann@1345
     8
    else
yann@1345
     9
        CT_TARGET_KERNEL="uclinux"
yann@1345
    10
    fi
yann@1345
    11
}
yann@1345
    12
yann@1345
    13
# Download the kernel
yann@1345
    14
do_kernel_get() {
yann@1345
    15
    if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" != "y" ]; then
yann@1345
    16
        CT_GetFile "linux-${CT_KERNEL_VERSION}" \
yann@1345
    17
                   {ftp,http}://ftp.{de.,eu.,}kernel.org/pub/linux/kernel/v2.{6{,/testing},4,2}
yann@1345
    18
    fi
yann@1345
    19
    return 0
yann@1345
    20
}
yann@1345
    21
yann@1345
    22
# Extract kernel
yann@1345
    23
do_kernel_extract() {
yann@1345
    24
    if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" != "y" ]; then
yann@1345
    25
        CT_Extract "linux-${CT_KERNEL_VERSION}"
yann@1345
    26
        CT_Patch "linux-${CT_KERNEL_VERSION}"
yann@1345
    27
    fi
yann@1345
    28
    return 0
yann@1345
    29
}
yann@1345
    30
yann@1345
    31
# Wrapper to the actual headers install method
yann@1345
    32
do_kernel_headers() {
yann@1345
    33
    CT_DoStep INFO "Installing kernel headers"
yann@1345
    34
yann@1345
    35
    if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" = "y" ]; then
yann@1345
    36
        do_kernel_custom
yann@1345
    37
    else
yann@1345
    38
        do_kernel_install
yann@1345
    39
    fi
yann@1345
    40
yann@1345
    41
    CT_EndStep
yann@1345
    42
}
yann@1345
    43
yann@1345
    44
# Install kernel headers using headers_install from kernel sources.
yann@1345
    45
do_kernel_install() {
yann@1345
    46
    CT_DoLog DEBUG "Using kernel's headers_install"
yann@1345
    47
yann@1345
    48
    mkdir -p "${CT_BUILD_DIR}/build-kernel-headers"
yann@1345
    49
    cd "${CT_BUILD_DIR}/build-kernel-headers"
yann@1345
    50
yann@1345
    51
    # Only starting with 2.6.18 does headers_install is usable. We only
yann@1345
    52
    # have 2.6 version available, so only test for sublevel.
yann@1345
    53
    k_sublevel=$(awk '/^SUBLEVEL =/ { print $3 }' "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}/Makefile")
yann@1345
    54
    [ ${k_sublevel} -ge 18 ] || CT_Abort "Kernel version >= 2.6.18 is needed to install kernel headers."
yann@1345
    55
yann@1345
    56
    V_OPT="V=${CT_KERNEL_LINUX_VERBOSE_LEVEL}"
yann@1345
    57
yann@1345
    58
    CT_DoLog EXTRA "Installing kernel headers"
yann@1345
    59
    CT_DoExecLog ALL                                    \
yann@1345
    60
    make -C "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"  \
yann@1345
    61
         O=$(pwd)                                       \
yann@1345
    62
         ARCH=${CT_KERNEL_ARCH}                         \
yann@1345
    63
         INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr"       \
yann@1345
    64
         ${V_OPT}                                       \
yann@1345
    65
         headers_install
yann@1345
    66
yann@1345
    67
    if [ "${CT_KERNEL_LINUX_INSTALL_CHECK}" = "y" ]; then
yann@1345
    68
        CT_DoLog EXTRA "Checking installed headers"
yann@1345
    69
        CT_DoExecLog ALL                                    \
yann@1345
    70
        make -C "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"  \
yann@1345
    71
             O=$(pwd)                                       \
yann@1345
    72
             ARCH=${CT_KERNEL_ARCH}                         \
yann@1345
    73
             INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr"       \
yann@1345
    74
             ${V_OPT}                                       \
yann@1345
    75
             headers_check
yann@1345
    76
        find "${CT_SYSROOT_DIR}" -type f -name '.check*' -exec rm {} \;
yann@1345
    77
    fi
yann@1345
    78
}
yann@1345
    79
yann@1345
    80
# Use custom headers (most probably by using make headers_install in a
yann@1345
    81
# modified (read: customised) kernel tree, or using pre-2.6.18 headers, such
yann@1345
    82
# as 2.4). In this case, simply copy the headers in place
yann@1345
    83
do_kernel_custom() {
yann@1345
    84
    local tar_opt
yann@1345
    85
yann@1345
    86
    CT_DoLog EXTRA "Installing custom kernel headers"
yann@1345
    87
yann@1345
    88
    mkdir -p "${CT_SYSROOT_DIR}/usr"
yann@1345
    89
    cd "${CT_SYSROOT_DIR}/usr"
yann@1345
    90
    if [ "${CT_KERNEL_LINUX_CUSTOM_IS_TARBALL}" = "y" ]; then
yann@1345
    91
        case "${CT_KERNEL_LINUX_CUSTOM_PATH}" in
yann@1345
    92
            *.tar)      ;;
yann@1345
    93
            *.tgz)      tar_opt=--gzip;;
yann@1345
    94
            *.tar.gz)   tar_opt=--gzip;;
yann@1345
    95
            *.tar.bz2)  tar_opt=--bzip2;;
yann@1345
    96
            *.tar.lzma) tar_opt=--lzma;;
yann@1345
    97
        esac
yann@1345
    98
        CT_DoExecLog ALL tar x ${tar_opt} -vf ${CT_KERNEL_LINUX_CUSTOM_PATH}
yann@1345
    99
    else
yann@1345
   100
        CT_DoExecLog ALL cp -rv "${CT_KERNEL_LINUX_CUSTOM_PATH}/include" .
yann@1345
   101
    fi
yann@1345
   102
}