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
|
Building Android binary
=======================
In this article, we briefly describe how to build Android binary using
`Android NDK <https://developer.android.com/ndk>`_ cross-compiler on
Debian Linux.
The easiest way to build android binary is use Dockerfile.android.
See Dockerfile.android for more details. If you cannot use
Dockerfile.android for whatever reason, continue to read the rest of
this article.
We offer ``android-config`` script to make the build easier. To make
the script work, NDK directory must be set to ``NDK`` environment
variable. NDK directory is the directory where NDK is unpacked:
.. code-block:: text
$ unzip android-ndk-$NDK_VERSION-linux.zip
$ cd android-ndk-$NDK_VERSION
$ export NDK=$PWD
The dependent libraries, such as OpenSSL, libev, and c-ares should be
built with the same NDK toolchain and installed under
``$NDK/usr/local``. We recommend to build these libraries as static
library to make the deployment easier. libxml2 support is currently
disabled.
Although zlib comes with Android NDK, it seems not to be a part of
public API, so we have to built it for our own. That also provides us
proper .pc file as a bonus.
Before running ``android-config``, ``NDK`` environment variable must
be set to point to the correct path.
You need to set ``NGHTTP2`` environment variable to the absolute path
to the source directory of nghttp2.
To configure OpenSSL, use the following script:
.. code-block:: sh
#!/bin/sh
. $NGHTTP2/android-env
export ANDROID_NDK_HOME=$NDK
export PATH=$TOOLCHAIN/bin:$PATH
./Configure no-shared --prefix=$PREFIX android-arm64
And run the following script to build and install without
documentation:
.. code-block:: sh
#!/bin/sh
. $NGHTTP2/android-env
export PATH=$TOOLCHAIN/bin:$PATH
make install_sw
To configure libev, use the following script:
.. code-block:: sh
#!/bin/sh
. $NGHTTP2/android-env
./configure \
--host=$TARGET \
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
--prefix=$PREFIX \
--disable-shared \
--enable-static \
CPPFLAGS=-I$PREFIX/include \
LDFLAGS=-L$PREFIX/lib
And run ``make install`` to build and install.
To configure c-ares, use the following script:
.. code-block:: sh
#!/bin/sh -e
. $NGHTTP2/android-env
./configure \
--host=$TARGET \
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
--prefix=$PREFIX \
--disable-shared
And run ``make install`` to build and install.
To configure zlib, use the following script:
.. code-block:: sh
#!/bin/sh -e
. $NGHTTP2/android-env
export HOST=$TARGET
./configure \
--prefix=$PREFIX \
--libdir=$PREFIX/lib \
--includedir=$PREFIX/include \
--static
And run ``make install`` to build and install.
After prerequisite libraries are prepared, run ``android-config`` and
then ``make`` to compile nghttp2 source files.
If all went well, application binaries, such as nghttpx, are created
under src directory. Strip debugging information from the binary
using the following command:
.. code-block:: text
$ $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip src/nghttpx
|