source: scripts/scripts/target-scripts/target-kernel.sh@ bfbc4f6

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

r1048@server (orig r1046): ryan | 2006-01-12 00:57:42 -0800

r1082@rei: lfs | 2006-01-12 19:19:16 +1100
Update for kernel 2.6.14


  • Property mode set to 100755
File size: 5.5 KB
Line 
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.* )
74 case ${KERNEL_VER} in
75 2.6.9* | 2.6.1[01]* ) apply_patch linux-2.6.11-gcc4_fixes -Np0 ;;
76 esac
77 ;;
78 esac
79
80 # update cx88 driver (applies 2.6.10 + 2.6.11, need to check 2.6.12+ )
81 case ${KERNEL_VER} in
82 2.6.10* ) apply_patch linux-2.6.10-cx88-update ;;
83 2.6.11* ) apply_patch linux-2.6.11-rc4-enable_dvico_dvb ;;
84 esac
85
86 # This is to remove some gnu-specific expr syntax and invoke depmod.pl
87 # instead of depmod since we need a depmod that is not a target-native
88 # binary.
89 case ${KERNEL_VER} in
90 2.6.[4-9]* | 2.6.1[01]* ) apply_patch linux-2.6-lfh-Makefile ;;
91 2.6.14* )
92 apply_patch linux-2.6-lfh-Makefile-2
93 # TODO: interim fix only - see http://lkml.org/lkml/2005/11/10/146
94 apply_patch linux-2.6.14-fix_generic_get_unaligned
95 ;;
96 2.6.1[2-9]* ) apply_patch linux-2.6-lfh-Makefile-2 ;;
97 esac
98 ;;
99esac
100
101max_log_init kernel ${KERNEL_VER} '' ${CONFLOGS} ${LOG}
102
103# TODO: Fix this up again... won't stop on error now...
104#-----------------------------------------------------------
105make mrproper >> ${LOGFILE} 2>&1
106
107test -f ${CONFIGS}/kernel/linux-${KERNEL_VER}-${TGT_ARCH}.config &&
108{
109 cp ${CONFIGS}/kernel/linux-${KERNEL_VER}-${TGT_ARCH}.config .config || barf
110 echo "got kernel config"
111 yes "" | make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- oldconfig
112} || {
113 echo "generating kernel config"
114 case ${KERNEL_VER} in
115 2.4.* )
116 yes "" | env -i PATH=${PATH} make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- config ;;
117 2.6.* )
118 yes "" | env -i PATH=${PATH} make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- defconfig ;;
119 esac
120}
121echo " o Configure OK" &&
122#-----------------------------------------------------------
123
124min_log_init ${BUILDLOGS}
125
126case ${KERNEL_VER} in
127 2.4.* )
128 env -i PATH=${PATH} make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- dep &&
129 env -i PATH=${PATH} make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- vmlinux &&
130 env -i PATH=${PATH} make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- modules
131 ;;
132 2.6.* )
133 env -i PATH=${PATH} make V=1 ARCH=${ARCH} CROSS_COMPILE=${TARGET}-
134 ;;
135esac >> ${LOGFILE} 2>&1 &&
136echo " o Build OK" || barf
137
138min_log_init ${INSTLOGS}
139
140if grep -q ^CONFIG_MODULES .config ; then
141 mkdir -p ${LFS}/lib/modules &&
142 env -i PATH=${PATH} make INSTALL_MOD_PATH=${LFS} ARCH=${ARCH} CROSS_COMPILE=${TARGET}- modules_install \
143 >> ${LOGFILE} 2>&1 || barf
144fi
145
146mkdir -p ${LFS}/boot
147
148case ${ARCH} in
149 alpha )
150 if [ -e arch/${ARCH}/boot/vmlinux.gz ]; then
151 cp arch/${ARCH}/boot/vmlinux.gz ${LFS}/boot/vmlinux-${KERNEL_VER}.gz
152 else
153 gzip -c vmlinux > ${LFS}/boot/vmlinux-${KERNEL_VER}.gz
154 fi
155 ;;
156 ppc* )
157 cp vmlinux ${LFS}/boot/vmlinux-${KERNEL_VER}
158 ;;
159 * )
160 if [ -e arch/${ARCH}/boot/bzImage ]; then
161 cp arch/${ARCH}/boot/bzImage ${LFS}/boot/bzImage-${KERNEL_VER}
162 else
163 cp vmlinux ${LFS}/boot/vmlinux-${KERNEL_VER}
164 fi
165 ;;
166esac &&
167
168cp System.map ${LFS}/boot/System.map-${KERNEL_VER} &&
169cp .config ${LFS}/boot/config-${KERNEL_VER} &&
170
171# Create /usr/share/hwdata dir and populate with pci.ids (for hald)
172mkdir -p ${LFS}/usr/share/hwdata &
173cp -p drivers/pci/pci.ids ${LFS}/usr/share/hwdata &
174
175cd ${LFS}/boot &&
176ln -s System.map-${KERNEL_VER} System.map &&
177cd ${LFS} &&
178rm -f lib/modules/${KERNEL_VER}/build && # delete this link as it points to the build host filesystem
179chmod -R g-w,o-w boot lib/modules &&
180echo " o All OK" || barf
Note: See TracBrowser for help on using the repository browser.