-
Notifications
You must be signed in to change notification settings - Fork 20
/
compile.sh
executable file
·137 lines (113 loc) · 2.54 KB
/
compile.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
127
128
129
130
131
132
133
#!/bin/bash
#Put Openwrt config for new board to './openwrt-configs' directory with '.config' suffix
# so this script can work with it.
name="$0";
boardsdir="./openwrt-configs";
FINAL_PATH="/home/build/bin/"$(date '+%Y_%m_%d_%H_%M_%S/');
show_boards() {
echo -n "Available board names:";
local itr=0;
for l in $(ls -1 $boardsdir/*.config|sed -e 's/\.config//g'|sed -e 's/.*\///g');do
if [ $itr == "0" ];then
echo ; echo " ";
itr=5;
fi;
echo -n "$l ";
itr=$(expr $itr - 1);
done
echo;echo;
};
show_usage() {
echo;
echo "USAGE:";
echo " $name [command or boardname]";
echo ;
echo "Where [command] can be one of:";
echo " list to list available boards configs to compile.";
echo " help to show this help.";
echo " usage to show this help.";
echo ;
echo "Example:";
echo " $name list";
echo " or";
echo " $name zbt-we1326";
echo;
};
compiled_successful_flag=0;
compilei() {
compiled_successful_flag=0;
if make -j $(nproc); then
compiled_successful_flag=1;
return
else
return
fi
}
compile_board() {
compiled_successful_flag=0;
local boardname="$1";
local configfile="$boardsdir/$boardname.config";
if [ -d "build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-imx6ull_cortexa7" ];then
echo "-- removing all built packages.";
rm -rf ./build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-imx6ull_cortexa7;
fi
if [ ! -f "$configfile" ];then
echo;
echo " No such config file found. Use 'list' argument to see available configs.";
echo;
return;
fi
if [ ! -d "./feeds" ];then
./scripts/feeds update -a
./scripts/feeds install -a
fi
cp "$configfile" ./.config;
yes "" | make -j $(nproc) oldconfig;
while [ $compiled_successful_flag -eq 0 ];
do
compilei;
sleep 1;
done
if [ $? -eq 0 ] && [ -n "$FINAL_PATH" ]; then
cp -R ./bin/targets/imx6ull/cortexa7/ "$FINAL_PATH"
fi
compiled_successful_flag=1;
echo " Done.";
};
compile_all()
{
local board
for l in $boardsdir/*.config;do
compiled_successful_flag=0;
board="$(echo $l | sed -e 's:.*/::g' -e 's:\..*::')"
# Rebuild linux kernel to prevent incompatibility list between targets.
echo "------------------ Compile $board configuration";
compile_board "$board";
done
}
compile()
{
local boardname=$1
echo "$FINAL_PATH"
mkdir -p "$FINAL_PATH"
if [ "$boardname" == "all" ]; then
compile_all
else
compile_board "$boardname"
fi
}
if [ X"$1" = X"" ]; then
show_usage;
exit 0;
fi
case "$1" in
list)
show_boards;
;;
help|usage)
show_usage;
;;
*)
compile "$1";
;;
esac