[617118d] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | # cross-lfs kernel header creation
|
---|
| 4 | # --------------------------------
|
---|
| 5 | # $LastChangedBy$
|
---|
| 6 | # $LastChangedDate$
|
---|
| 7 | # $LastChangedRevision$
|
---|
| 8 | # $HeadURL$
|
---|
| 9 | #
|
---|
| 10 |
|
---|
| 11 | # install kernel headers
|
---|
| 12 |
|
---|
| 13 | cd ${SRC}
|
---|
| 14 | LOG=kernel-headers.log
|
---|
| 15 | unpack_tarball linux-${KERNEL_VER} &&
|
---|
| 16 | cd ${PKGDIR}
|
---|
| 17 |
|
---|
| 18 | # 20030510
|
---|
| 19 | # If we are building for x86_64, and the kernel is greater than 2.6.4,
|
---|
| 20 | # we need to fix unistd.h so glibc doesn't barf during assembly.
|
---|
| 21 | # TODO: track this issue, still exists as of 2.6.6 ...
|
---|
| 22 | case ${KERNEL_VER} in
|
---|
| 23 | 2.6.[4-6] )
|
---|
| 24 | apply_patch linux-2.6.6-x86_64-unistd_h-fix
|
---|
| 25 | ;;
|
---|
| 26 | esac
|
---|
| 27 |
|
---|
| 28 | max_log_init kernel-headers ${KERNEL_VER} '' ${INSTLOGS} ${LOG}
|
---|
| 29 |
|
---|
| 30 | #
|
---|
| 31 | case ${TGT_ARCH} in
|
---|
| 32 | i?86 ) ARCH=i386 ;;
|
---|
| 33 | x86_64 | x86-64 ) ARCH=i386 ;;
|
---|
| 34 | sparc64* | ultrasparc* ) ARCH=sparc64 ;;
|
---|
| 35 | sparc* ) ARCH=sparc ;;
|
---|
| 36 | powerpc64 | ppc64 ) ARCH=ppc64 ;;
|
---|
| 37 | powerpc | ppc ) ARCH=ppc ;;
|
---|
| 38 | s390* ) ARCH=s390 ;;
|
---|
| 39 | mips* ) ARCH=mips ;;
|
---|
| 40 | arm* ) ARCH=arm ;;
|
---|
| 41 | * ) ARCH=${TGT_ARCH} ;;
|
---|
| 42 | esac
|
---|
| 43 |
|
---|
| 44 | set -x
|
---|
| 45 | ARCH=${ARCH} CROSS_COMPILE=${TARGET}- make mrproper \
|
---|
| 46 | >> ${LOGFILE} 2>&1 &&
|
---|
| 47 | set +x
|
---|
| 48 | # Pre-configure kernel
|
---|
| 49 | # TODO: for want of somewhere better, put kernel .config files
|
---|
| 50 | # in ${SCRIPTS}. Should really let user supply filename
|
---|
| 51 | # via plfs-config
|
---|
| 52 | # Kernel .config files should reside under ${CONFIGS}/kernel
|
---|
| 53 | test -f ${CONFIGS}/kernel/linux-${KERNEL_VER}-${TGT_ARCH}.config &&
|
---|
| 54 | {
|
---|
| 55 | echo "got kernel config"
|
---|
| 56 | cp ${CONFIGS}/kernel/linux-${KERNEL_VER}-${TGT_ARCH}.config .config
|
---|
| 57 | yes "" | make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- oldconfig
|
---|
| 58 | } >> ${LOGFILE} 2>&1
|
---|
| 59 |
|
---|
| 60 | # 2.5/2.6 series kernels dont have "make symlinks" target but use
|
---|
| 61 | # "make include/asm"
|
---|
| 62 | # Check for the include/asm target and use it if its available
|
---|
| 63 | make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- include/linux/version.h &&
|
---|
| 64 | grep "^include/asm:" Makefile > /dev/null 2>&1 &&
|
---|
| 65 | {
|
---|
| 66 | case ${ARCH} in
|
---|
| 67 | arm | cris ) make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- \
|
---|
| 68 | include/asm include/asm-${ARCH}/.arch ;;
|
---|
| 69 | * ) make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- include/asm ;;
|
---|
| 70 | esac
|
---|
| 71 | } || {
|
---|
| 72 | make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- symlinks
|
---|
| 73 | } >> ${LOGFILE} 2>&1 &&
|
---|
| 74 |
|
---|
| 75 | # Install the headers.
|
---|
| 76 |
|
---|
| 77 | # If we are using sanitised headers, and we are installing the
|
---|
| 78 | # raw kernel headers, install raw headers into
|
---|
| 79 | # ${TGT_TOOLS}/kernel-hdrs and the sanitised ones into
|
---|
| 80 | # ${TGT_TOOLS}/include
|
---|
| 81 |
|
---|
| 82 | if [ "${USE_SYSROOT}" = "Y" ]; then
|
---|
| 83 | INSTALL_PREFIX="${LFS}/usr"
|
---|
| 84 | else
|
---|
| 85 | INSTALL_PREFIX="${TGT_TOOLS}"
|
---|
| 86 | fi
|
---|
| 87 |
|
---|
| 88 | if [ "${USE_SANITISED_HEADERS}" = "Y" ]; then
|
---|
| 89 | KERN_HDR_DIR="${INSTALL_PREFIX}/kernel-hdrs"
|
---|
| 90 | else
|
---|
| 91 | KERN_HDR_DIR="${INSTALL_PREFIX}/include"
|
---|
| 92 | fi
|
---|
| 93 |
|
---|
| 94 | # If we are doing a multiarch build we will need the kernel headers for
|
---|
| 95 | # both architectures and will have to create stub headers in include/asm
|
---|
| 96 |
|
---|
| 97 | test "Y" = "${MULTIARCH}" &&
|
---|
| 98 | {
|
---|
| 99 | case ${TGT_ARCH} in
|
---|
| 100 | x86_64 | x86-64 )
|
---|
| 101 | ARCH1_SWITCH=__x86_64__
|
---|
| 102 | ARCH1=x86_64
|
---|
| 103 | ARCH2=i386
|
---|
| 104 | ;;
|
---|
| 105 | sparc* | ultrasparc* )
|
---|
| 106 | ARCH1_SWITCH=__arch64__
|
---|
| 107 | ARCH1=sparc64
|
---|
| 108 | ARCH2=sparc
|
---|
| 109 | ;;
|
---|
| 110 | ppc* | powerpc* )
|
---|
| 111 | ARCH1_SWITCH=__powerpc64__
|
---|
| 112 | ARCH1=ppc64
|
---|
| 113 | ARCH2=ppc
|
---|
| 114 | ;;
|
---|
| 115 | s390* )
|
---|
| 116 | ARCH1_SWITCH=__s390x__
|
---|
| 117 | ARCH1=s390x
|
---|
| 118 | ARCH2=s390
|
---|
| 119 | ;;
|
---|
| 120 | esac
|
---|
| 121 |
|
---|
| 122 | # TODO: This needs to be done better
|
---|
| 123 | # Here we are handling the case of mips, where only the one set of
|
---|
| 124 | # asm headers are provided (and needed) for multi-arch.
|
---|
| 125 | if [ -z "${ARCH1_SWITCH}" ]; then
|
---|
| 126 | mkdir -p ${KERN_HDR_DIR}/asm
|
---|
| 127 | yes | cp -Rp include/asm/* ${KERN_HDR_DIR}/asm
|
---|
| 128 | else
|
---|
| 129 | mkdir -p ${KERN_HDR_DIR}/asm
|
---|
| 130 | yes | cp -Rp include/asm-${ARCH1} ${KERN_HDR_DIR}
|
---|
| 131 | yes | cp -Rp include/asm-${ARCH2} ${KERN_HDR_DIR}
|
---|
| 132 |
|
---|
| 133 | # Create stubs ( see build-init.x.x.x.sh )
|
---|
| 134 | create_kernel_stubs ${ARCH1} ${ARCH1_SWITCH} ${ARCH2} ${KERN_HDR_DIR}
|
---|
| 135 | fi
|
---|
| 136 |
|
---|
| 137 | } || {
|
---|
| 138 | # Install kernel headers in
|
---|
| 139 | # ${TGT_TOOLS}/include
|
---|
| 140 | mkdir -p ${KERN_HDR_DIR}/asm
|
---|
| 141 | yes | cp -Rp include/asm/* ${KERN_HDR_DIR}/asm
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | yes | cp -Rp include/asm-generic ${KERN_HDR_DIR}
|
---|
| 145 | yes | cp -Rp include/linux ${KERN_HDR_DIR}
|
---|
| 146 |
|
---|
| 147 | # Don't need this if we pre-configured the kernel
|
---|
| 148 | touch ${KERN_HDR_DIR}/linux/autoconf.h
|
---|
| 149 |
|
---|