[617118d] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | # cross-lfs target linux kernel build
|
---|
| 4 | # -----------------------------------
|
---|
| 5 | # $LastChangedBy$
|
---|
| 6 | # $LastChangedDate$
|
---|
| 7 | # $LastChangedRevision$
|
---|
| 8 | # $HeadURL$
|
---|
| 9 | #
|
---|
| 10 |
|
---|
| 11 | cd ${HST_TOOLS}/bin &&
|
---|
| 12 | gzip -dc ${TARBALLS}/depmod.pl.gz > depmod.pl &&
|
---|
| 13 | patch < ${PATCHES}/depmod-pl-lfh-cross-compile.patch &&
|
---|
| 14 | chmod 755 depmod.pl || barf
|
---|
| 15 |
|
---|
| 16 | ### KERNEL ###
|
---|
| 17 | set -x
|
---|
| 18 |
|
---|
| 19 | cd ${SRC}
|
---|
| 20 | LOG=kernel.log
|
---|
| 21 | unpack_tarball linux-${KERNEL_VER} &&
|
---|
| 22 |
|
---|
| 23 | cd ${SRC}/${PKGDIR}
|
---|
| 24 |
|
---|
| 25 | case ${TGT_ARCH} in
|
---|
| 26 | i?86 ) ARCH=i386 ;;
|
---|
| 27 | sparc64* | ultrasparc* ) ARCH=sparc64 ;;
|
---|
| 28 | sparc* ) ARCH=sparc ;;
|
---|
| 29 | powerpc64 | ppc64 ) ARCH=ppc64 ;;
|
---|
| 30 | powerpc | ppc ) ARCH=ppc ;;
|
---|
| 31 | s390* ) ARCH=s390 ;;
|
---|
| 32 | mips* ) ARCH=mips ;;
|
---|
| 33 | * ) ARCH=${TGT_ARCH} ;;
|
---|
| 34 | esac
|
---|
| 35 | echo $PATH
|
---|
| 36 |
|
---|
| 37 | # get gas version
|
---|
| 38 | target_gas_ver=`${TARGET}-as --version | head -n 1 | \
|
---|
| 39 | sed 's@.* \([0-9.]*\) .*@\1@g'`
|
---|
| 40 |
|
---|
| 41 | # get gcc version
|
---|
| 42 | target_gcc_ver=`${TARGET}-gcc -v 2>&1 | grep " version " | \
|
---|
| 43 | sed 's@.*version \([0-9.]*\).*@\1@g'`
|
---|
| 44 |
|
---|
| 45 | case ${KERNEL_VER} in
|
---|
| 46 | 2.4.* )
|
---|
| 47 | apply_patch linux-2.4-lfh-Makefile &&
|
---|
| 48 | if [ "${ARCH}" = "m68k" ] ; then
|
---|
| 49 | test -f ${PATCHES}/linux-${KERNEL_VER}-m68k-lfh.patch && \
|
---|
| 50 | apply_patch linux-${KERNEL_VER}-m68k-lfh
|
---|
| 51 | fi
|
---|
| 52 | ;;
|
---|
| 53 | 2.6.* )
|
---|
| 54 | # TODO: need to handle kernel patching a whole lot better
|
---|
| 55 | # than this...
|
---|
| 56 | # What might be better is to have a separate dir for kernel patches
|
---|
| 57 | # and apply conditionally all patches in said directory.
|
---|
| 58 | # Maybe something like
|
---|
| 59 | # patches/kernel/2.6
|
---|
| 60 | # /2.6.x <- version specific
|
---|
| 61 | # /binutils-2.16 <- binutils ver specific for kern
|
---|
| 62 | # /gcc-4 <- gcc ver specific
|
---|
| 63 |
|
---|
| 64 | # fix issues with kernel concerning 2.16 binutils
|
---|
| 65 | # checked against 2.6.11, need to check against 2.6.12
|
---|
| 66 | case ${target_gas_ver} in
|
---|
| 67 | 2.16* ) apply_patch linux-2.6-seg-5 ;;
|
---|
| 68 | esac
|
---|
| 69 |
|
---|
| 70 | # fix gcc4 compilation issues
|
---|
| 71 | # Note: you cannot compile kernel < 2.6.9 with gcc4
|
---|
| 72 | case ${target_gcc_ver} in
|
---|
| 73 | 4.* ) apply_patch linux-2.6.11-gcc4_fixes -Np0 ;;
|
---|
| 74 | esac
|
---|
| 75 |
|
---|
| 76 | # update cx88 driver (applies 2.6.10 + 2.6.11, need to check 2.6.12+ )
|
---|
| 77 | case ${KERNEL_VER} in
|
---|
| 78 | 2.6.10* ) apply_patch linux-2.6.10-cx88-update ;;
|
---|
| 79 | 2.6.11* ) apply_patch linux-2.6.11-rc4-enable_dvico_dvb ;;
|
---|
| 80 | esac
|
---|
| 81 |
|
---|
| 82 | # This is to remove some gnu-specific expr syntax and invoke depmod.pl
|
---|
| 83 | # instead of depmod since we need a depmod that is not a target-native
|
---|
| 84 | # binary.
|
---|
| 85 | apply_patch linux-2.6-lfh-Makefile
|
---|
| 86 | ;;
|
---|
| 87 | esac
|
---|
| 88 |
|
---|
| 89 | max_log_init kernel ${KERNEL_VER} '' ${CONFLOGS} ${LOG}
|
---|
| 90 |
|
---|
| 91 | # TODO: Fix this up again... won't stop on error now...
|
---|
| 92 | #-----------------------------------------------------------
|
---|
| 93 | make mrproper >> ${LOGFILE} 2>&1
|
---|
| 94 |
|
---|
| 95 | test -f ${CONFIGS}/kernel/linux-${KERNEL_VER}-${TGT_ARCH}.config &&
|
---|
| 96 | {
|
---|
| 97 | cp ${CONFIGS}/kernel/linux-${KERNEL_VER}-${TGT_ARCH}.config .config || barf
|
---|
| 98 | echo "got kernel config"
|
---|
| 99 | yes "" | make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- oldconfig
|
---|
| 100 | } || {
|
---|
| 101 | echo "generating kernel config"
|
---|
| 102 | case ${KERNEL_VER} in
|
---|
| 103 | 2.4.* )
|
---|
| 104 | yes "" | env -i PATH=${PATH} make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- config ;;
|
---|
| 105 | 2.6.* )
|
---|
| 106 | yes "" | env -i PATH=${PATH} make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- defconfig ;;
|
---|
| 107 | esac
|
---|
| 108 | }
|
---|
| 109 | echo " o Configure OK" &&
|
---|
| 110 | #-----------------------------------------------------------
|
---|
| 111 |
|
---|
| 112 | min_log_init ${BUILDLOGS}
|
---|
| 113 |
|
---|
| 114 | case ${KERNEL_VER} in
|
---|
| 115 | 2.4.* )
|
---|
| 116 | env -i PATH=${PATH} make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- dep &&
|
---|
| 117 | env -i PATH=${PATH} make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- vmlinux &&
|
---|
| 118 | env -i PATH=${PATH} make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- modules
|
---|
| 119 | ;;
|
---|
| 120 | 2.6.* )
|
---|
| 121 | env -i PATH=${PATH} make V=1 ARCH=${ARCH} CROSS_COMPILE=${TARGET}-
|
---|
| 122 | ;;
|
---|
| 123 | esac >> ${LOGFILE} 2>&1 &&
|
---|
| 124 | echo " o Build OK" || barf
|
---|
| 125 |
|
---|
| 126 | min_log_init ${INSTLOGS}
|
---|
| 127 |
|
---|
| 128 | if grep -q ^CONFIG_MODULES .config ; then
|
---|
| 129 | mkdir -p ${LFS}/lib/modules &&
|
---|
| 130 | env -i PATH=${PATH} make INSTALL_MOD_PATH=${LFS} ARCH=${ARCH} CROSS_COMPILE=${TARGET}- modules_install \
|
---|
| 131 | >> ${LOGFILE} 2>&1 || barf
|
---|
| 132 | fi
|
---|
| 133 |
|
---|
| 134 | mkdir -p ${LFS}/boot
|
---|
| 135 |
|
---|
| 136 | case ${ARCH} in
|
---|
| 137 | alpha )
|
---|
| 138 | if [ -e arch/${ARCH}/boot/vmlinux.gz ]; then
|
---|
| 139 | cp arch/${ARCH}/boot/vmlinux.gz ${LFS}/boot/vmlinux-${KERNEL_VER}.gz
|
---|
| 140 | else
|
---|
| 141 | gzip -c vmlinux > ${LFS}/boot/vmlinux-${KERNEL_VER}.gz
|
---|
| 142 | fi
|
---|
| 143 | ;;
|
---|
| 144 | ppc* )
|
---|
| 145 | cp vmlinux ${LFS}/boot/vmlinux-${KERNEL_VER}
|
---|
| 146 | ;;
|
---|
| 147 | * )
|
---|
| 148 | if [ -e arch/${ARCH}/boot/bzImage ]; then
|
---|
| 149 | cp arch/${ARCH}/boot/bzImage ${LFS}/boot/bzImage-${KERNEL_VER}
|
---|
| 150 | else
|
---|
| 151 | cp vmlinux ${LFS}/boot/vmlinux-${KERNEL_VER}
|
---|
| 152 | fi
|
---|
| 153 | ;;
|
---|
| 154 | esac &&
|
---|
| 155 |
|
---|
| 156 | cp System.map ${LFS}/boot/System.map-${KERNEL_VER} &&
|
---|
| 157 | cp .config ${LFS}/boot/config-${KERNEL_VER} &&
|
---|
| 158 | cd ${LFS}/boot &&
|
---|
| 159 | ln -s System.map-${KERNEL_VER} System.map &&
|
---|
| 160 | cd ${LFS} &&
|
---|
| 161 | rm -f lib/modules/${KERNEL_VER}/build && # delete this link as it points to the build host filesystem
|
---|
| 162 | chmod -R g-w,o-w boot lib/modules &&
|
---|
| 163 | echo " o All OK" || barf
|
---|