forked from mobile-shell/mosh
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build
executable file
·128 lines (112 loc) · 2.75 KB
/
build
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
#!/bin/bash -xe
here="$(dirname "$(readlink -f "$0")")"
source "$here"/vars
inputs="$here"/inputs
tool="$here"/tool
libs="$here"/libs
prefix="$here"/prefix
rm -rf "$tool" "$libs" "$prefix"
mkdir -p "$tool" "$libs" "$prefix"
export PATH="$tool"/bin:"$PATH"
ndk="$(readlink -f "$inputs"/ndk)"
if ! [ -d "$ndk" \
-a -f "$inputs/$ncurses_src" \
-a -f "$inputs/$protobuf_src" ]; then
set +x
echo
echo "Error: missing inputs"
echo "See android/README.md."
exit 1
fi
protoc="$(which protoc; true)"
if [ "$protoc" = "" ]; then
set +x
echo
echo "Error: need Protocol Buffers compiler (protoc)"
exit 1
fi
function make_toolchain {
"$ndk"/build/tools/make-standalone-toolchain.sh \
--arch=$arch \
--platform=android-$android_version \
--install-dir="$tool"
}
function unpack {
tar -C"$libs" -axf "$inputs/$1"
}
function config {
./configure \
--host=$platform \
CC=$platform-gcc \
CXX=$platform-g++ \
"$@"
}
function build_ncurses {
unpack $ncurses_src
cd "$libs"/${ncurses_src%.*.*}
config \
--prefix="$prefix" \
--disable-shared \
--with-termlib \
--without-ada \
--without-manpages \
--without-tests
patch -p0 <<EOF
--- include/ncurses_cfg.h.orig 2012-03-18 03:36:59.000000000 -0400
+++ include/ncurses_cfg.h 2012-03-18 03:38:27.000000000 -0400
@@ -105,7 +105,6 @@
#define HAVE_FCNTL_H 1
#define HAVE_GETOPT_H 1
#define HAVE_LIMITS_H 1
-#define HAVE_LOCALE_H 1
#define HAVE_MATH_H 1
#define HAVE_POLL_H 1
#define HAVE_SYS_IOCTL_H 1
EOF
make $MAKE_FLAGS install
cd "$here"
}
function build_protobuf {
unpack $protobuf_src
cd "$libs"/${protobuf_src%.*.*}
patch -p0 <<EOF
--- config.sub.orig 2012-03-18 03:49:52.000000000 -0400
+++ config.sub 2012-03-18 03:50:21.000000000 -0400
@@ -1269,6 +1269,7 @@
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \\
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \\
+ | -androideabi \\
| -kopensolaris* \\
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \\
| -aos* | -aros* \\
EOF
cp config.sub gtest/build-aux/
config \
--prefix="$prefix" \
--disable-shared \
--with-protoc="$protoc"
make $MAKE_FLAGS install
cd "$here"
}
function build_mosh {
dir_flags="-I$prefix/include -I$prefix/include/ncurses -L$prefix/lib"
cd "$here"/..
./autogen.sh
config \
--disable-server \
CFLAGS="$dir_flags" \
CXXFLAGS="$dir_flags" \
protobuf_LIBS="-lprotobuf -lz" # no pthread
make clean
make $MAKE_FLAGS
set +x
echo
echo 'Success!'
file src/frontend/mosh-client
cd "$here"
}
make_toolchain
build_ncurses
build_protobuf
build_mosh