source: scripts/scripts/target-scripts/target-kernel.sh @ 3a4ffbb1

clfs-1.2clfs-2.1clfs-3.0.0-systemdclfs-3.0.0-sysvinitsystemdsysvinit
Last change on this file since 3a4ffbb1 was c7ec163, checked in by Jim Gifford <clfs@…>, 18 years ago

r2473@server (orig r1230): ryan | 2006-03-06 23:56:13 -0800

r1232@rei: lfs | 2006-03-07 18:03:13 +1100
Gah, push in long forgotten changes (must sync more often)


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