forked from jesec/android_kernel_samsung_universal8895
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build_kernel.sh
126 lines (106 loc) · 3.31 KB
/
build_kernel.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
# Kernel Build Script
BUILD_WHERE=$(pwd)
BUILD_KERNEL_DIR=$BUILD_WHERE
BUILD_ROOT_DIR=$BUILD_KERNEL_DIR/..
BUILD_KERNEL_OUT_DIR=$BUILD_ROOT_DIR/kernel_out/KERNEL_OBJ
PRODUCT_OUT=$BUILD_ROOT_DIR/kernel_out
BUILD_CROSS_COMPILE=$KERNEL_TOOLCHAIN
BUILD_JOB_NUMBER=`grep processor /proc/cpuinfo|wc -l`
KERNEL_DEFCONFIG=exynos8895-$1_eur_open_defconfig
KERNEL_IMG=$PRODUCT_OUT/Image
DTIMG=$PRODUCT_OUT/dt.img
DTBTOOL=$KERNEL_DTBTOOL
FUNC_GENERATE_DEFCONFIG()
{
echo ""
echo "=============================================="
echo "START : FUNC_GENERATE_DEFCONFIG"
echo "=============================================="
echo "build config="$KERNEL_DEFCONFIG ""
echo ""
make -C $BUILD_KERNEL_DIR O=$BUILD_KERNEL_OUT_DIR -j$BUILD_JOB_NUMBER ARCH=arm64 \
CROSS_COMPILE=$BUILD_CROSS_COMPILE \
$KERNEL_DEFCONFIG || exit -1
cp $BUILD_KERNEL_OUT_DIR/.config $BUILD_KERNEL_DIR/arch/arm64/configs/$KERNEL_DEFCONFIG
echo ""
echo "================================="
echo "END : FUNC_GENERATE_DEFCONFIG"
echo "================================="
echo ""
}
FUNC_GENERATE_DTB()
{
echo ""
echo "=============================================="
echo "START : FUNC_GENERATE_DTB"
echo "=============================================="
echo ""
rm -rf $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts
make dtbs -C $BUILD_KERNEL_DIR O=$BUILD_KERNEL_OUT_DIR -j$BUILD_JOB_NUMBER ARCH=arm64 \
CROSS_COMPILE=$BUILD_CROSS_COMPILE || exit -1
echo ""
echo "================================="
echo "END : FUNC_GENERATE_DTB"
echo "================================="
echo ""
}
FUNC_BUILD_KERNEL()
{
echo ""
echo "================================="
echo "START : FUNC_BUILD_KERNEL"
echo "================================="
echo ""
rm $KERNEL_IMG $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/Image
rm -rf $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts
if [ "$USE_CCACHE" ]
then
make -C $BUILD_KERNEL_DIR O=$BUILD_KERNEL_OUT_DIR -j$BUILD_JOB_NUMBER ARCH=arm64 \
CROSS_COMPILE=$BUILD_CROSS_COMPILE \
CC="ccache "$BUILD_CROSS_COMPILE"gcc" CPP="ccache "$BUILD_CROSS_COMPILE"gcc -E" || exit -1
else
make -C $BUILD_KERNEL_DIR O=$BUILD_KERNEL_OUT_DIR -j$BUILD_JOB_NUMBER ARCH=arm64 \
CROSS_COMPILE=$BUILD_CROSS_COMPILE || exit -1
fi
cp $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/Image $KERNEL_IMG
echo "Made Kernel image: $KERNEL_IMG"
echo "================================="
echo "END : FUNC_BUILD_KERNEL"
echo "================================="
echo ""
}
FUNC_GENERATE_DTIMG()
{
echo ""
echo "================================="
echo "START : FUNC_GENERATE_DTIMG"
echo "================================="
rm $DTIMG
$DTBTOOL -o $DTIMG -s 2048 -p $BUILD_KERNEL_OUT_DIR/scripts/dtc/ $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts/exynos
if [ -f "$DTIMG" ]; then
echo "Made DT image: $DTIMG"
fi
echo "================================="
echo "END : FUNC_GENERATE_DTIMG"
echo "================================="
echo ""
}
# MAIN FUNCTION
(
START_TIME=`date +%s`
FUNC_GENERATE_DEFCONFIG
if [ "$2" = "--dt-only" ]
then
FUNC_GENERATE_DTB
else
FUNC_BUILD_KERNEL
fi
FUNC_GENERATE_DTIMG
END_TIME=`date +%s`
let "ELAPSED_TIME=$END_TIME-$START_TIME"
echo "Total compile time is $ELAPSED_TIME seconds"
) 2>&1
if [ ! -f "$KERNEL_IMG" ]; then
exit -1
fi