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