Merge "ARM: Support KFENCE for ARM" into tizen
[platform/kernel/linux-rpi.git] / build-rpi4.sh
1 #!/bin/bash
2
3 NCPUS=`cat /proc/cpuinfo | grep processor | wc -l`
4 NCPUS=$(($NCPUS * 2))
5
6 if [ $# == 0 ]; then
7         echo "Usage : $0 <architecture> [rt]"
8         echo "  architecture : arm or arm64"
9         echo "  e.g) $0 arm"
10         echo "  e.g) $0 arm64 rt"
11         exit
12 fi
13
14 # Check this system has ccache
15 check_ccache()
16 {
17         type ccache
18         if [ "$?" -eq "0" ]; then
19                 CCACHE=ccache
20         fi
21 }
22
23 check_ccache
24
25 cleanup_localversion()
26 {
27         rm -f localversion-rt
28 }
29
30 DEFCONFIG=tizen_bcm2711_defconfig
31 touch .kernel_buildenv
32 if [ "$2" = "rt" ]; then
33         echo "Build RT-Kernel"
34         BUILD_VERSION=`cat .kernel_buildenv`
35         if [ "$BUILD_VERSION" != "RT" ]; then
36                 echo "Previous .config is for Normal Kernel, so remove"
37                 rm -f .config
38         fi
39         DEFCONFIG=tizen_bcm2711_rt_defconfig
40         cp _localversion-rt localversion-rt
41         trap cleanup_localversion EXIT
42         echo "RT" > ./.kernel_buildenv
43 else
44         echo "Build Normal-Kernel"
45         BUILD_VERSION=`cat .kernel_buildenv`
46         if [ "$BUILD_VERSION" == "RT" ]; then
47                 echo "Previous .config is for RT Kernel, so remove"
48                 rm -f .config
49         fi
50         echo "NORMAL" > ./.kernel_buildenv
51 fi
52
53 if [ $1 = "arm" ]; then
54         echo "ARM"
55
56         rm -f arch/arm/boot/zImage
57         rm -f arch/arm/boot/dts/*.dtb
58
59         if ! [ -e .config ] ; then
60                 make ARCH=arm CROSS_COMPILE="${CCACHE} arm-linux-gnueabi-" ${DEFCONFIG}
61         fi
62
63         make ARCH=arm CROSS_COMPILE="${CCACHE} arm-linux-gnueabi-" -j $NCPUS
64
65         if [ ! -f "./arch/arm/boot/zImage" ]; then
66                 echo "Build fail"
67                 exit 1
68         fi
69 elif [ $1 = "arm64" ]; then
70         echo "ARM64"
71
72         rm -f arch/arm64/boot/Image
73         rm -f arch/arm64/boot/dts/broadcom/*.dtb
74
75         if ! [ -e .config ] ; then
76                 make ARCH=arm64 CROSS_COMPILE="${CCACHE} aarch64-linux-gnu-" ${DEFCONFIG}
77         fi
78         make ARCH=arm64 CROSS_COMPILE="${CCACHE} aarch64-linux-gnu-" -j $NCPUS
79         if [ ! -f "./arch/arm64/boot/Image" ]; then
80                 echo "Build fail"
81                 exit 1
82         fi
83 fi
84
85 scripts/mkbootimg_rpi4.sh