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.* )
|
---|
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 | ;;
|
---|
99 | esac
|
---|
100 |
|
---|
101 | max_log_init kernel ${KERNEL_VER} '' ${CONFLOGS} ${LOG}
|
---|
102 |
|
---|
103 | # TODO: Fix this up again... won't stop on error now...
|
---|
104 | #-----------------------------------------------------------
|
---|
105 | make mrproper >> ${LOGFILE} 2>&1
|
---|
106 |
|
---|
107 | test -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 | }
|
---|
121 | echo " o Configure OK" &&
|
---|
122 | #-----------------------------------------------------------
|
---|
123 |
|
---|
124 | min_log_init ${BUILDLOGS}
|
---|
125 |
|
---|
126 | case ${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 | ;;
|
---|
135 | esac >> ${LOGFILE} 2>&1 &&
|
---|
136 | echo " o Build OK" || barf
|
---|
137 |
|
---|
138 | min_log_init ${INSTLOGS}
|
---|
139 |
|
---|
140 | if 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
|
---|
144 | fi
|
---|
145 |
|
---|
146 | mkdir -p ${LFS}/boot
|
---|
147 |
|
---|
148 | case ${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 | ;;
|
---|
166 | esac &&
|
---|
167 |
|
---|
168 | cp System.map ${LFS}/boot/System.map-${KERNEL_VER} &&
|
---|
169 | cp .config ${LFS}/boot/config-${KERNEL_VER} &&
|
---|
170 |
|
---|
171 | # Create /usr/share/hwdata dir and populate with pci.ids (for hald)
|
---|
172 | mkdir -p ${LFS}/usr/share/hwdata &
|
---|
173 | cp -p drivers/pci/pci.ids ${LFS}/usr/share/hwdata &
|
---|
174 |
|
---|
175 | cd ${LFS}/boot &&
|
---|
176 | ln -s System.map-${KERNEL_VER} System.map &&
|
---|
177 | cd ${LFS} &&
|
---|
178 | rm -f lib/modules/${KERNEL_VER}/build && # delete this link as it points to the build host filesystem
|
---|
179 | chmod -R g-w,o-w boot lib/modules &&
|
---|
180 | echo " o All OK" || barf
|
---|