-
Notifications
You must be signed in to change notification settings - Fork 9
/
build_openwrt.sh
executable file
·89 lines (76 loc) · 1.43 KB
/
build_openwrt.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
#!/bin/bash
SCRIPTDIR=$PWD
source $SCRIPTDIR/build_prepare.sh
config_get CUSTOMER
config_get GIT_SERVER_URL
config_get SDK_BRANCH
config_get USE_RTK_REPO
config_get BUILDTYPE_ANDROID
config_get IMAGE_DRAM_SIZE
config_get OPENWRT_CONFIG
config_get USE_RTK1295_EMMC_SWAP
config_get IMAGE_TARGET_BOARD
ERR=0
VERBOSE=
NCPU=`grep processor /proc/cpuinfo | wc -l`
MULTI=`expr $NCPU + 2`
build_openwrt()
{
pushd $OPENWRTDIR > /dev/null
if [ ! -e .config ]; then
cat ${IMAGE_TARGET_BOARD}-${OPENWRT_CONFIG}_defconfig > .config
make defconfig
fi
if [ "${BUILDTYPE_ANDROID}" = "kylin32_tv" ]; then
sed -i 's/kylin32"/kylin32_tv"/' .config
fi
make -j8 V=s
ERR=$?
popd
return $ERR
}
function build_cmd()
{
$@
ERR=$?
printf "$* "
if [ "$ERR" != "0" ]; then
echo -e "\033[47;31m [ERROR] $ERR \033[0m"
exit 1
else
echo "[OK]"
fi
}
clean_openwrt()
{
pushd $OPENWRTDIR > /dev/null
make clean V=99 -j8;rm .config .config.old
popd > /dev/null
pushd $OPENWRTKERNELDIR > /dev/null
make distclean;rm .config*
popd > /dev/null
return $ERR
}
if [ "$1" = "" ]; then
echo "$0 commands are:"
echo " build "
echo " clean "
else
while [ "$1" != "" ]
do
case "$1" in
clean)
build_cmd clean_openwrt
;;
build)
build_cmd build_openwrt
;;
*)
echo -e "$0 \033[47;31mUnknown CMD: $1\033[0m"
exit 1
;;
esac
shift 1
done
fi
exit $ERR