scripts/build/kernel/linux.sh
author Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Wed Apr 07 09:18:20 2010 +0200 (2010-04-07)
changeset 1910 207ad430c254
parent 1901 bdb3a98e064b
child 1989 f357bc3abfa6
permissions -rw-r--r--
Add basic support for the Blackfin architecture

For uClibc, the name of the Blackfin architecture is 'bfin'. Actually,
the naming of the architecture is quite messy: for toolchain tuples
and uClibc, it's bfin, but for the kernel, it's blackfin. We've
arbitraly choosen to name it "blackfin" in Crosstool-NG.

Add Blackfin-related uClibc patch to fix a build failure related to
fork() being used in unistd/daemon.c.

Yann E. MORIN:
Apply the patch to the kernel/linux build script to use 'linux'
in the noMMU tuples. See:
http://sourceware.org/ml/crossgcc/2010-04/msg00010.html
     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_USE_CUSTOM_HEADERS}" != "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     return 0
    25 }
    26 
    27 # Extract kernel
    28 do_kernel_extract() {
    29     if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" != "y" ]; then
    30         CT_Extract "linux-${CT_KERNEL_VERSION}"
    31         CT_Patch "linux" "${CT_KERNEL_VERSION}"
    32     fi
    33     return 0
    34 }
    35 
    36 # Wrapper to the actual headers install method
    37 do_kernel_headers() {
    38     CT_DoStep INFO "Installing kernel headers"
    39 
    40     if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" = "y" ]; then
    41         do_kernel_custom
    42     else
    43         do_kernel_install
    44     fi
    45 
    46     CT_EndStep
    47 }
    48 
    49 # Install kernel headers using headers_install from kernel sources.
    50 do_kernel_install() {
    51     CT_DoLog DEBUG "Using kernel's headers_install"
    52 
    53     mkdir -p "${CT_BUILD_DIR}/build-kernel-headers"
    54     cd "${CT_BUILD_DIR}/build-kernel-headers"
    55 
    56     V_OPT="V=${CT_KERNEL_LINUX_VERBOSE_LEVEL}"
    57 
    58     CT_DoLog EXTRA "Installing kernel headers"
    59     CT_DoExecLog ALL                                    \
    60     make -C "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"  \
    61          O=$(pwd)                                       \
    62          ARCH=${CT_ARCH}                                \
    63          INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr"       \
    64          ${V_OPT}                                       \
    65          headers_install
    66 
    67     if [ "${CT_KERNEL_LINUX_INSTALL_CHECK}" = "y" ]; then
    68         CT_DoLog EXTRA "Checking installed headers"
    69         CT_DoExecLog ALL                                    \
    70         make -C "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"  \
    71              O=$(pwd)                                       \
    72              ARCH=${CT_ARCH}                                \
    73              INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr"       \
    74              ${V_OPT}                                       \
    75              headers_check
    76         find "${CT_SYSROOT_DIR}" -type f -name '.check*' -exec rm {} \;
    77     fi
    78 }
    79 
    80 # Use custom headers (most probably by using make headers_install in a
    81 # modified (read: customised) kernel tree, or using pre-2.6.18 headers, such
    82 # as 2.4). In this case, simply copy the headers in place
    83 do_kernel_custom() {
    84     local tar_opt
    85 
    86     CT_DoLog EXTRA "Installing custom kernel headers"
    87 
    88     mkdir -p "${CT_SYSROOT_DIR}/usr"
    89     cd "${CT_SYSROOT_DIR}/usr"
    90     if [ "${CT_KERNEL_LINUX_CUSTOM_IS_TARBALL}" = "y" ]; then
    91         case "${CT_KERNEL_LINUX_CUSTOM_PATH}" in
    92             *.tar)      ;;
    93             *.tgz)      tar_opt=--gzip;;
    94             *.tar.gz)   tar_opt=--gzip;;
    95             *.tar.bz2)  tar_opt=--bzip2;;
    96             *.tar.lzma) tar_opt=--lzma;;
    97         esac
    98         CT_DoExecLog ALL tar x ${tar_opt} -vf ${CT_KERNEL_LINUX_CUSTOM_PATH}
    99     else
   100         CT_DoExecLog ALL cp -rv "${CT_KERNEL_LINUX_CUSTOM_PATH}/include" .
   101     fi
   102 }