forked from jason416/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·116 lines (100 loc) · 2.42 KB
/
build.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
#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
usage() {
local prog="`basename $1`"
echo "Usage: $prog [-c] [-d] [-k] [-m] [-a] [-i path] [-h] [-v]"
echo " $prog -h for help."
exit 1
}
showhelp() {
echo "Usage: `basename $1`: [-c] [-d] [-k] [-m] [-a] [-i path] [-h] [-v]"
echo " -c build .config"
echo " -d build dtbs"
echo " -k build kernel"
echo " -m build modules"
echo " -a build all needed files, default operation"
echo " -i <path> install kernel, dtbs and modules to given path"
echo " -h show this help"
echo " -v turn on verbose"
exit 1
}
build_config() {
echo "build .config..."
if [ ! -e .config ]; then
make itop4412_defconfig
if [ ! $? -eq 0 ]; then
echo 'failed to build config'
exit 1
fi
fi
}
build_kernel() {
build_config
echo "build kernel..."
make uImage LOADADDR=0x40007000 -j$(nproc)
if [ ! $? -eq 0 ]; then
echo 'failed to build kernel'
exit 1
fi
}
build_dtbs() {
echo "building dtbs..."
make dtbs
if [ ! $? -eq 0 ]; then
echo 'failed to build dtbs'
exit 1
fi
}
build_modules() {
echo "building modules..."
make modules -j$(nproc)
if [ ! $? -eq 0 ]; then
echo 'failed to build kernel'
exit 1
fi
}
build_all() {
echo "building all needed files..."
build_kernel
build_dtbs
build_modules
}
do_install() {
echo "install to $1 ..."
INSTALL_DIR=$1
KERNEL=arch/arm/boot/uImage
DTB=arch/arm/boot/dts/exynos4412-itop-elite.dtb
if [ ! -e $INSTALL_DIR ]; then
mkdir $INSTALL_DIR
fi
if [ -e $KERNEL ]; then
rm -rf $INSTALL_DIR/uImage
cp $KERNEL $INSTALL_DIR
fi
if [ -e $DTB ]; then
rm -rf $INSTALL_DIR/exynos4412-itop-elite.dtb
cp $DTB $INSTALL_DIR
fi
make modules_install INSTALL_MOD_PATH=$INSTALL_DIR
}
if [ $# -gt 0 ] ; then
while getopts "acdkmi:vh" opt
do
case $opt in
a) build_all ;;
c) build_config ;;
d) build_dtbs ;;
k) build_kernel ;;
m) build_modules ;;
i)
do_install $OPTARG
;;
v) set -x ;;
h) showhelp $0 ;;
?) usage $0 ;;
esac
done
else
usage $0
fi