Imported Upstream version 1.0.0
[platform/upstream/nghttp2.git] / Dockerfile.android
1 # vim: ft=dockerfile:
2 # Dockerfile to build nghttp2 android binary
3 #
4 # $ sudo docker build -t nghttp2-android - < Dockerfile.android
5 #
6 # After successful build, android binaries are located under
7 # /root/build/nghttp2.  You can copy the binary using docker cp.  For
8 # example, to copy nghttpx binary to host file system location
9 # /path/to/dest, do this:
10 #
11 # $ sudo docker run -v /path/to/dest:/out nghttp2-android cp /root/build/nghttp2/src/nghttpx /out
12
13 FROM ubuntu:trusty
14
15 MAINTAINER Tatsuhiro Tsujikawa
16
17 ENV ANDROID_HOME /root/android
18 ENV PREFIX $ANDROID_HOME/usr/local
19 ENV TOOLCHAIN $ANDROID_HOME/toolchain
20 ENV PATH $TOOLCHAIN/bin:$PATH
21
22 # It would be better to use nearest ubuntu archive mirror for faster
23 # downloads.
24 # RUN sed -ie 's/archive\.ubuntu/jp.archive.ubuntu/g' /etc/apt/sources.list
25
26 RUN apt-get update
27 # genisoimage, libc6-i386 and lib32stdc++6 are required to decompress ndk.
28 RUN apt-get install -y make binutils autoconf automake autotools-dev libtool \
29     pkg-config git curl dpkg-dev libxml2-dev \
30     genisoimage libc6-i386 lib32stdc++6
31
32 WORKDIR /root/build
33 RUN curl -L -O http://dl.google.com/android/ndk/android-ndk-r10c-linux-x86_64.bin && \
34     chmod a+x android-ndk-r10c-linux-x86_64.bin && \
35     ./android-ndk-r10c-linux-x86_64.bin && \
36     rm android-ndk-r10c-linux-x86_64.bin
37
38 WORKDIR /root/build/android-ndk-r10c
39 RUN /bin/bash build/tools/make-standalone-toolchain.sh \
40     --install-dir=$ANDROID_HOME/toolchain \
41     --toolchain=arm-linux-androideabi-4.9 --llvm-version=3.5 \
42     --system=linux-x86_64
43
44 WORKDIR /root/build
45 RUN git clone https://github.com/tatsuhiro-t/spdylay
46 WORKDIR /root/build/spdylay
47 RUN autoreconf -i && \
48     ./configure \
49     --disable-shared \
50     --host=arm-linux-androideabi \
51     --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
52     --prefix=$PREFIX \
53     --without-libxml2 \
54     --disable-src \
55     --disable-examples \
56     CPPFLAGS="-I$PREFIX/include" \
57     PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" \
58     LDFLAGS="-L$PREFIX/lib" && \
59     make install
60
61 WORKDIR /root/build
62 RUN curl -L -O https://www.openssl.org/source/openssl-1.0.2a.tar.gz && \
63     tar xf openssl-1.0.2a.tar.gz && \
64     rm openssl-1.0.2a.tar.gz
65
66 WORKDIR /root/build/openssl-1.0.2a
67 RUN export CROSS_COMPILE=$TOOLCHAIN/bin/arm-linux-androideabi- && \
68     ./Configure --prefix=$PREFIX android && \
69     make && make install_sw
70
71 WORKDIR /root/build
72 RUN curl -L -O http://dist.schmorp.de/libev/libev-4.19.tar.gz && \
73     curl -L -O https://gist.github.com/tatsuhiro-t/48c45f08950f587180ed/raw/80a8f003b5d1091eae497c5995bbaa68096e739b/libev-4.19-android.patch && \
74     tar xf libev-4.19.tar.gz && \
75     rm libev-4.19.tar.gz
76
77 WORKDIR /root/build/libev-4.19
78 RUN patch -p1 < ../libev-4.19-android.patch && \
79     ./configure \
80     --host=arm-linux-androideabi \
81     --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
82     --prefix=$PREFIX \
83     --disable-shared \
84     --enable-static \
85     CPPFLAGS=-I$PREFIX/include \
86     LDFLAGS=-L$PREFIX/lib && \
87     make install
88
89 WORKDIR /root/build
90 RUN git clone https://github.com/tatsuhiro-t/nghttp2
91 WORKDIR /root/build/nghttp2
92 RUN autoreconf -i && \
93     ./configure \
94     --disable-shared \
95     --host=arm-linux-androideabi \
96     --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
97     --with-xml-prefix="$PREFIX" \
98     --without-libxml2 \
99     --disable-python-bindings \
100     --disable-examples \
101     --disable-threads \
102     LIBSPDYLAY_CFLAGS=-I$PREFIX/usr/local/include \
103     LIBSPDYLAY_LIBS="-L$PREFIX/usr/local/lib -lspdylay" \
104     CPPFLAGS="-fPIE -I$PREFIX/include" \
105     CXXFLAGS="-fno-strict-aliasing" \
106     PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" \
107     LDFLAGS="-fPIE -pie -L$PREFIX/lib" && \
108     make && \
109     arm-linux-androideabi-strip src/nghttpx src/nghttpd src/nghttp