scripts/build/kernel/linux.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Jun 15 20:04:01 2010 +0200 (2010-06-15)
changeset 1989 f357bc3abfa6
parent 1910 207ad430c254
child 1990 c12158f27395
permissions -rw-r--r--
kernel/linux: reorder upstream/custom-tree handling
     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
     4 
     5 CT_DoKernelTupleValues() {
     6     if [ "${CT_ARCH_USE_MMU}" = "y" ]; then
     7         CT_TARGET_KERNEL="linux"
     8     else
     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"
    15     fi
    16 }
    17 
    18 # Download the kernel
    19 do_kernel_get() {
    20     if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
    21         CT_GetFile "linux-${CT_KERNEL_VERSION}" \
    22                    {ftp,http}://ftp.{de.,eu.,}kernel.org/pub/linux/kernel/v2.{6{,/testing},4,2}
    23     fi
    24 }
    25 
    26 # Extract kernel
    27 do_kernel_extract() {
    28     if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
    29         CT_Extract "linux-${CT_KERNEL_VERSION}"
    30         CT_Patch "linux" "${CT_KERNEL_VERSION}"
    31     fi
    32 }
    33 
    34 # Wrapper to the actual headers install method
    35 do_kernel_headers() {
    36     CT_DoStep INFO "Installing kernel headers"
    37 
    38     if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
    39         do_kernel_install
    40     else
    41         do_kernel_custom
    42     fi
    43 
    44     CT_EndStep
    45 }
    46 
    47 # Install kernel headers using headers_install from kernel sources.
    48 do_kernel_install() {
    49     CT_DoLog DEBUG "Using kernel's headers_install"
    50 
    51     mkdir -p "${CT_BUILD_DIR}/build-kernel-headers"
    52     cd "${CT_BUILD_DIR}/build-kernel-headers"
    53 
    54     V_OPT="V=${CT_KERNEL_LINUX_VERBOSE_LEVEL}"
    55 
    56     CT_DoLog EXTRA "Installing kernel headers"
    57     CT_DoExecLog ALL                                    \
    58     make -C "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"  \
    59          O=$(pwd)                                       \
    60          ARCH=${CT_ARCH}                                \
    61          INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr"       \
    62          ${V_OPT}                                       \
    63          headers_install
    64 
    65     if [ "${CT_KERNEL_LINUX_INSTALL_CHECK}" = "y" ]; then
    66         CT_DoLog EXTRA "Checking installed headers"
    67         CT_DoExecLog ALL                                    \
    68         make -C "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"  \
    69              O=$(pwd)                                       \
    70              ARCH=${CT_ARCH}                                \
    71              INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr"       \
    72              ${V_OPT}                                       \
    73              headers_check
    74         find "${CT_SYSROOT_DIR}" -type f -name '.check*' -exec rm {} \;
    75     fi
    76 }
    77 
    78 # Use custom headers (most probably by using make headers_install in a
    79 # modified (read: customised) kernel tree, or using pre-2.6.18 headers, such
    80 # as 2.4). In this case, simply copy the headers in place
    81 do_kernel_custom() {
    82     local tar_opt
    83 
    84     CT_DoLog EXTRA "Installing custom kernel headers"
    85 
    86     mkdir -p "${CT_SYSROOT_DIR}/usr"
    87     cd "${CT_SYSROOT_DIR}/usr"
    88     if [ "${CT_KERNEL_LINUX_CUSTOM_IS_TARBALL}" = "y" ]; then
    89         case "${CT_KERNEL_LINUX_CUSTOM_PATH}" in
    90             *.tar)      ;;
    91             *.tgz)      tar_opt=--gzip;;
    92             *.tar.gz)   tar_opt=--gzip;;
    93             *.tar.bz2)  tar_opt=--bzip2;;
    94             *.tar.lzma) tar_opt=--lzma;;
    95         esac
    96         CT_DoExecLog ALL tar x ${tar_opt} -vf ${CT_KERNEL_LINUX_CUSTOM_PATH}
    97     else
    98         CT_DoExecLog ALL cp -rv "${CT_KERNEL_LINUX_CUSTOM_PATH}/include" .
    99     fi
   100 }