-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild_bash.sh
More file actions
executable file
·140 lines (133 loc) · 3.36 KB
/
build_bash.sh
File metadata and controls
executable file
·140 lines (133 loc) · 3.36 KB
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
134
135
136
137
138
139
#!/bin/bash
#
# build_bash.sh
#
#
# 2011 nubecoder
# http://www.nubecoder.com/
#
# defines
CROSS_COMPILE="/home/nubecoder/android/toolchains/arm-none-linux-gnueabi-2011.03-41/bin/arm-none-linux-gnueabi-"
# exports
export CC="${CROSS_COMPILE}gcc"
export CFLAGS="-g -O2 -static"
# variables
CC_STRIP="${CROSS_COMPILE}strip -s"
# defaults
THREADS=$(expr 1 + $(grep processor /proc/cpuinfo | wc -l))
VERBOSE="n"
ERROR_MSG=
#functions
SPACER()
{
echo "*"
}
START_SCRIPT()
{
TIME_START=$(date +%s)
echo "=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]"
}
SHOW_COMPLETED()
{
echo "Script completed."
TIME_END=$(date +%s)
echo "Total time: $(($TIME_END - $TIME_START)) seconds."
SPACER
echo "=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]"
exit
}
FATAL_ERROR()
{
if [ -n "$ERROR_MSG" ] ; then
echo "=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]"
echo "$ERROR_MSG"
SHOW_COMPLETED
fi
}
MAKE_DISTCLEAN()
{
echo "=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]"
local T1=$(date +%s)
echo "Begin make distclean for $1..." && echo ""
rm -f arm_"$1"_stripped
pushd $1 > /dev/null
if [ "$VERBOSE" = "y" ] ; then
make V=1 distclean 2>&1 | tee bash.distclean.out
else
make distclean 2>&1 >bash.distclean.out
fi
# rm -f Makefile
popd > /dev/null
local T2=$(date +%s)
echo "" && echo "make distclean for $1 took $(($T2 - $T1)) seconds."
echo "=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]"
SPACER
}
RUN_CONFIGURE()
{
echo "=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]"
local T1=$(date +%s)
echo "Begin configure for $1..." && echo ""
pushd $1 > /dev/null
if [ "$VERBOSE" = "y" ] ; then
sh configure --build=i686-pc-linux-gnu --host=arm-none-linux-gnueabi --target=arm-none-linux-gnueabi --enable-static-link --without-bash-malloc 2>&1 | tee bash.configure.out
else
sh configure --build=i686-pc-linux-gnu --host=arm-none-linux-gnueabi --target=arm-none-linux-gnueabi --enable-static-link --without-bash-malloc 2>&1 >bash.configure.out
fi
popd > /dev/null
local T2=$(date +%s)
echo "" && echo "Configure for $1 took $(($T2 - $T1)) seconds."
echo "=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]"
SPACER
}
STRIP_BASH()
{
if [ -f bash ] ; then
echo "Bash found, stripping for size..."
VERSION=$(strings bash | egrep -Ei '^.+Bash\sversion\s.+' | egrep -oEi '[0-9]+\.[0-9]+\.[0-9]+\([0-9]+\)')
cp -f bash android_bash-"$VERSION"
$CC_STRIP android_bash-"$VERSION"
mv -f android_bash-"$VERSION" ../android_bash-"$VERSION"
else
ERR_MSG="ERROR:: Bash was not found!"
FATAL_ERROR
fi
}
BUILD_BASH()
{
echo "=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]"
local T1=$(date +%s)
echo "Begin building $1..." && echo ""
pushd $1 > /dev/null
if [ "$VERBOSE" = "y" ] ; then
make V=1 -j"$THREADS" 2>&1 | tee bash.make.out
else
make -j"$THREADS" 2>&1 >bash.make.out
fi
STRIP_BASH
popd > /dev/null
local T2=$(date +%s)
echo "" && echo "Building $1 took $(($T2 - $T1)) seconds."
echo "=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]=]"
SPACER
}
NOTIFY_COMPLETED()
{
aplay notify.wav >/dev/null 2>&1
}
DO_ALL()
{
echo "building $1"
SPACER
MAKE_DISTCLEAN "$1"
RUN_CONFIGURE "$1"
BUILD_BASH "$1"
SPACER
}
# main
START_SCRIPT
DO_ALL "bash-3.2"
DO_ALL "bash-4.0"
DO_ALL "bash-4.1"
NOTIFY_COMPLETED
SHOW_COMPLETED