wok-tiny view linux/receipt @ rev 167

linux: build pentium optimized kernel too
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Feb 18 11:46:30 2021 +0000 (2021-02-18)
parents 14cd26e5e302
children eb617e43dc08
line source
1 # SliTaz package receipt.
3 PACKAGE="linux"
4 VERSION="2.6.14"
5 CATEGORY="base-system"
6 SHORT_DESC="The Linux kernel."
7 TARGET="i486"
8 MAINTAINER="devel@slitaz.org"
9 LICENSE="GPL2"
10 TARBALL="$PACKAGE-$VERSION.tar.bz2"
11 WEB_SITE="http://www.kernel.org/"
12 WGET_URL="https://www.kernel.org/pub/linux/kernel/v${VERSION:0:3}/$TARBALL"
13 WEB_SITE2="http://elinux.org/Linux_Tiny"
14 PATCH="https://www.selenic.com/tiny/2.6.14-tiny1.patch.bz2"
15 AUTO_SELECTION="always"
17 DEPENDS=""
18 BUILD_DEPENDS="slitaz-toolchain perl git lzma wget gcc2 upx advancecomp"
19 INSTALL_DEPENDS="lz4 grep"
21 case "$TARGET" in
22 i486) SUGGESTED="memtest ipxe plop";; # bundle may install a boot menu
23 esac
25 S2bin()
26 {
27 [ -s $stuff/$1.S ] &&
28 cc -o $1.o -Wa,-algms=$1.lst -c $stuff/$1.S &&
29 objcopy -O binary $1.o $1.bin
30 }
32 # Rules to configure and make the package.
33 compile_rules()
34 {
35 [ -s $SRC/$(basename $PATCH) ] ||
36 wget --no-check-certificate -O $SRC/$(basename $PATCH) $PATCH
37 bzcat $SRC/$(basename $PATCH) | patch -p1
38 patch -p0 < $stuff/linux-2.6.14-unpack.u
39 patch -p0 < $stuff/jsclipboard.u
40 sed -i 's|\([>\.]\)val|\1u.val|;s|\([>\.]\)next|\1u.next|;s|\t};|\t} u;|' \
41 lib/inflate.c
42 sed '/DEBUG/,/* kstrdup/d' < mm/slab.c > mm/kstrdup.c
43 echo 'obj-y += kstrdup.o' >> mm/Makefile
44 sed -i 's|3.1024|11*256|' arch/i386/boot/compressed/misc.c
45 sed -i 's/O_CREAT/&|O_TRUNC/' init/initramfs.c
46 which advdef 2> /dev/null && ! which upx 2> /dev/null &&
47 sed -i 's|gzip)|&\n advdef -z4 $@|' \
48 usr/Makefile arch/i386/boot/compressed/Makefile
50 mkdir $src/slitaz
51 cp $stuff/list_modules.sh $src/slitaz
52 S2bin bootloader
53 S2bin helper
54 S2bin unpacklz4
55 cp $stuff/pack .
56 sh ./pack --build
58 sed -i '/config %config:/{NNNps/config %config:/%config:/}' Makefile
59 sed -i 's/^config %config:/config:/' Makefile
61 cp $stuff/linux-$VERSION-slitaz.config .config
62 yes '' | make ARCH=i386 HOSTCC=gcc-2 config
63 make ARCH=i386 CC=gcc-2 HOSTCC=gcc-2 -j 4 bzImage
65 grep -q "CONFIG_MODULES=y" .config &&
66 make ARCH=i386 CC=gcc-2 HOSTCC=gcc-2 -j 4 modules &&
67 make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR -j 1 modules_install || true
68 S2bin bundle
69 cp $stuff/bundle .
70 sh ./bundle
71 S2bin cmdline
72 cp arch/i386/boot/bzImage arch/i386/boot/bzImage.386
73 cp .config .config.386
74 cp System.map System.map.386
75 cp $stuff/linux-$VERSION-slitaz.config.586 .config
76 yes '' | make ARCH=i386 HOSTCC=gcc-2 config
77 make ARCH=i386 CC=gcc-2 HOSTCC=gcc-2 -j 4 bzImage
78 which upx 2> /dev/null && upx --ultra-brute arch/i386/boot/bzImage
79 }
81 # Rules to gen a SliTaz package suitable for Tazpkg.
82 genpkg_rules()
83 {
84 mkdir $fs/boot
85 cp -a $src/arch/i386/boot/bzImage* $fs/boot/
86 dd if=$src/bootloader.bin of=$fs/boot/bzImage conv=notrunc
87 dd if=$src/cmdline.bin bs=1 seek=560 of=$fs/boot/bzImage conv=notrunc
88 cp -a $src/pack $fs/boot/
89 cp -a $src/System.map* $fs/boot/
90 cp -a $src/.config $fs/boot/config
91 [ -s $src/.config.386 ] && cp -a $src/.config.386 $fs/boot/config.386
92 cp -a $src/bundle.sh $fs/boot/bundle
93 }
95 config_form()
96 {
97 cat <<EOT
98 <table>
99 <td>Tune the kernel according to the CPU type<td>
100 <td>
101 <input type="radio" name="CPU586" $([ "$CPU586" = "no" ] && echo "checked=checked ")value="no"> for any CPU starting from 386sx
102 <input type="radio" name="CPU586" $([ "$CPU586" != "no" ] && echo "checked=checked ")value="yes"> optimized for pentium or newer CPU
103 </td>
104 </tr>
105 </table>
106 EOT
107 }
109 # Pre and post install commands for Tazpkg.
110 post_install()
111 {
112 for i in $1/boot/*.386 ; do
113 [ "$CPU586" = "yes" ] && rm -f $i || mv -f $i ${i%.386}
114 done 2> /dev/null
115 rm -f $1/boot/bzImage.noupx
116 [ -s $1/boot/cmdline ] && cat $1/boot/cmdline | sed 's/^ *//' | \
117 dd of=$1/boot/bzImage conv=notrunc bs=1 seek=768 count=3072
118 $1/boot/pack $1/boot/bzImage
119 }