source: scripts/target-scripts/target-kernel.sh@ 60454e2

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 60454e2 was 617118d, checked in by Jim Gifford <clfs@…>, 19 years ago

r561@server (orig r559): root | 2005-06-05 02:38:49 -0700
Fixed Directory Structure

  • Property mode set to 100755
File size: 4.9 KB
RevLine 
[617118d]1#!/bin/bash
2
3# cross-lfs target linux kernel build
4# -----------------------------------
5# $LastChangedBy$
6# $LastChangedDate$
7# $LastChangedRevision$
8# $HeadURL$
9#
10
11cd ${HST_TOOLS}/bin &&
12gzip -dc ${TARBALLS}/depmod.pl.gz > depmod.pl &&
13patch < ${PATCHES}/depmod-pl-lfh-cross-compile.patch &&
14chmod 755 depmod.pl || barf
15
16### KERNEL ###
17set -x
18
19cd ${SRC}
20LOG=kernel.log
21unpack_tarball linux-${KERNEL_VER} &&
22
23cd ${SRC}/${PKGDIR}
24
25case ${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} ;;
34esac
35echo $PATH
36
37# get gas version
38target_gas_ver=`${TARGET}-as --version | head -n 1 | \
39 sed 's@.* \([0-9.]*\) .*@\1@g'`
40
41# get gcc version
42target_gcc_ver=`${TARGET}-gcc -v 2>&1 | grep " version " | \
43 sed 's@.*version \([0-9.]*\).*@\1@g'`
44
45case ${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 ;;
87esac
88
89max_log_init kernel ${KERNEL_VER} '' ${CONFLOGS} ${LOG}
90
91# TODO: Fix this up again... won't stop on error now...
92#-----------------------------------------------------------
93make mrproper >> ${LOGFILE} 2>&1
94
95test -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}
109echo " o Configure OK" &&
110#-----------------------------------------------------------
111
112min_log_init ${BUILDLOGS}
113
114case ${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 ;;
123esac >> ${LOGFILE} 2>&1 &&
124echo " o Build OK" || barf
125
126min_log_init ${INSTLOGS}
127
128if 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
132fi
133
134mkdir -p ${LFS}/boot
135
136case ${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 ;;
154esac &&
155
156cp System.map ${LFS}/boot/System.map-${KERNEL_VER} &&
157cp .config ${LFS}/boot/config-${KERNEL_VER} &&
158cd ${LFS}/boot &&
159ln -s System.map-${KERNEL_VER} System.map &&
160cd ${LFS} &&
161rm -f lib/modules/${KERNEL_VER}/build && # delete this link as it points to the build host filesystem
162chmod -R g-w,o-w boot lib/modules &&
163echo " o All OK" || barf
Note: See TracBrowser for help on using the repository browser.