]> rtime.felk.cvut.cz Git - jailhouse.git/blob - ci/gen-kernel-build.sh
Merge remote-tracking branch 'kiszka/master'
[jailhouse.git] / ci / gen-kernel-build.sh
1 #!/bin/bash
2 #
3 # Jailhouse, a Linux-based partitioning hypervisor
4 #
5 # Copyright (c) Siemens AG, 2014-2016
6 #
7 # Authors:
8 #  Jan Kiszka <jan.kiszka@siemens.com>
9 #
10 # This work is licensed under the terms of the GNU GPL, version 2.  See
11 # the COPYING file in the top-level directory.
12 #
13
14 BASEDIR=`cd \`dirname $0\`; pwd`
15
16 if test -z $KERNEL; then
17         KERNEL=https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.4.tar.xz
18 fi
19 if test -z $PARALLEL_BUILD; then
20         PARALLEL_BUILD=-j16
21 fi
22 if test -z $OUTDIR; then
23         OUTDIR=$BASEDIR/out
24 fi
25
26 prepare_out()
27 {
28         rm -rf $OUTDIR
29         mkdir -p $OUTDIR
30         cd $OUTDIR
31 }
32
33 prepare_kernel()
34 {
35         ARCHIVE_FILE=`basename $KERNEL`
36         if ! test -f $BASEDIR/$ARCHIVE_FILE; then
37                 wget $KERNEL -O $BASEDIR/$ARCHIVE_FILE
38         fi
39         tar xJf $BASEDIR/$ARCHIVE_FILE
40         ln -s linux-* linux
41         cd linux
42 }
43
44 build_kernel()
45 {
46         mkdir build-$1
47         cp $BASEDIR/kernel-config-$1 build-$1/.config
48         make O=build-$1 vmlinux $PARALLEL_BUILD ARCH=$2 CROSS_COMPILE=$3
49         # clean up some unneeded build output
50         find build-$1 \( -name "*.o" -o -name "*.cmd" -o -name ".tmp_*" \) -exec rm -rf {} \;
51 }
52
53 package_out()
54 {
55         cd $OUTDIR
56         tar cJf kernel-build.tar.xz linux-* linux
57 }
58
59 prepare_out
60 prepare_kernel
61 build_kernel x86 x86_64
62 build_kernel banana-pi arm arm-linux-gnueabihf-
63 build_kernel vexpress arm arm-linux-gnueabihf-
64 package_out