Dockerfile which builds CURL FOR ANDROID using x86 ARCH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# THIS DOCKERFILE TRIES TO COMPILE CURL FOR ANDROID x86 ARCH | |
# Description - http://vitiy.info/dockerfile-example-to-compile-libcurl-for-android-inside-docker-container/ | |
FROM ubuntu | |
MAINTAINER Victor Laskin "victor.laskin@gmail.com" | |
# Install compilation tools | |
RUN apt-get update && apt-get install -y \ | |
automake \ | |
build-essential \ | |
wget \ | |
p7zip-full \ | |
bash \ | |
curl | |
# Download SDK / NDK | |
RUN mkdir /Android && cd Android && mkdir output | |
WORKDIR /Android | |
RUN wget http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz | |
RUN wget http://dl.google.com/android/ndk/android-ndk-r10c-linux-x86_64.bin | |
# Extracting ndk/sdk | |
RUN tar -xvzf android-sdk_r23.0.2-linux.tgz && \ | |
chmod a+x android-ndk-r10c-linux-x86_64.bin && \ | |
7z x android-ndk-r10c-linux-x86_64.bin | |
# Set ENV variables | |
ENV ANDROID_HOME /Android/android-sdk-linux | |
ENV NDK_ROOT /Android/android-ndk-r10c | |
ENV PATH $PATH:$ANDROID_HOME/tools | |
ENV PATH $PATH:$ANDROID_HOME/platform-tools | |
# Make stand alone toolchain (Modify platform / arch here) | |
RUN mkdir=toolchain-x86 && bash $NDK_ROOT/build/tools/make-standalone-toolchain.sh --verbose --platform=android-21 --install-dir=toolchain-x86 --arch=x86 --toolchain=x86-4.9 --system=linux-x86_64 | |
ENV TOOLCHAIN /Android/toolchain-x86 | |
RUN ls /Android/toolchain-x86/bin | |
ENV SYSROOT $TOOLCHAIN/sysroot | |
ENV PATH $PATH:$TOOLCHAIN/bin:$SYSROOT/usr/local/bin | |
# Configure toolchain path | |
ENV ARCH i686 | |
ENV CROSS_COMPILE i686-linux-android | |
ENV CC i686-linux-android-gcc | |
ENV CXX i686-linux-android-g++ | |
ENV AR i686-linux-android-ar | |
ENV AS i686-linux-android-as | |
ENV LD i686-linux-android-ld | |
ENV RANLIB i686-linux-android-ranlib | |
ENV NM i686-linux-android-nm | |
ENV STRIP i686-linux-android-strip | |
ENV CHOST i686-linux-android | |
ENV CPPFLAGS -std=c++11 -DANDROID | |
# download, configure and make Zlib | |
RUN curl -O http://zlib.net/zlib-1.2.8.tar.gz && \ | |
tar -xzf zlib-1.2.8.tar.gz && \ | |
mv zlib-1.2.8 zlib | |
RUN cd zlib && ./configure --static && \ | |
make && \ | |
ls -hs . && \ | |
cp libz.a /Android/output | |
# Download and extract curl | |
ENV CFLAGS -v --sysroot=$SYSROOT -mandroid -march=$ARCH | |
ENV CPPFLAGS $CPPFLAGS $CFLAGS | |
ENV LDFLAGS -L${TOOLCHAIN}/include | |
RUN curl -O http://curl.haxx.se/download/curl-7.38.0.tar.gz && \ | |
tar -xzf curl-7.38.0.tar.gz | |
RUN cd curl-7.38.0 && ./configure --host=i686-linux-android --disable-shared --enable-static --disable-dependency-tracking --with-zlib=/Android/zlib --without-ca-bundle --without-ca-path --enable-ipv6 --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-sspi --disable-manual --target=i686-linux-android --build=x86_64-unknown-linux-gnu || cat config.log | |
# Make curl | |
RUN cd curl-7.38.0 && \ | |
make && \ | |
ls lib/.libs/ && \ | |
cp lib/.libs/libcurl.a /Android/output && \ | |
ls -hs /Android/output && \ | |
mkdir /output | |
# ziplib | |
RUN curl -O http://www.nih.at/libzip/libzip-0.11.2.tar.gz && \ | |
tar -xzf libzip-0.11.2.tar.gz && \ | |
mv libzip-0.11.2 libzip && \ | |
cd libzip && \ | |
./configure --help && \ | |
./configure --enable-static --host=i686-linux-android --target=i686-linux-android && \ | |
make && \ | |
ls -hs lib && \ | |
cp lib/.libs/libzip.a /Android/output && \ | |
mkdir /Android/output/ziplib && \ | |
cp lib/*.c /Android/output/ziplib && \ | |
cp lib/*.h /Android/output/ziplib && \ | |
cp config.h /Android/output/ziplib | |
# To get the results run container with output folder | |
# Example: docker run -v HOSTFOLDER:/output --rm=true IMAGENAME | |
ENTRYPOINT cp -r /Android/output/* /output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment