Last active
June 21, 2021 17:29
-
-
Save CoelacanthusHex/175e56f9103b750dc8f978722475806c to your computer and use it in GitHub Desktop.
Cross-Build Aria2
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
# Dockerfile to build aria2 Windows binary using ubuntu mingw-w64 | |
# cross compiler chain. | |
# | |
# $ sudo docker build -t aria2-mingw - < Dockerfile.mingw | |
# | |
# After successful build, windows binary is located at | |
# /aria2/src/aria2c.exe. You can copy the binary using following | |
# commands: | |
# | |
# $ id=$(sudo docker create aria2-mingw) | |
# $ sudo docker cp $id:/aria2/src/aria2c.exe <dest> | |
# $ sudo docker rm -v $id | |
FROM ubuntu:21.04 | |
MAINTAINER Coelacanthus | |
# Change HOST to x86_64-w64-mingw32 to build 64-bit binary | |
ENV HOST x86_64-w64-mingw32 | |
ENV MAKEFLAGS -j10 | |
# It would be better to use nearest ubuntu archive mirror for faster | |
# downloads. | |
# RUN sed -ie 's/archive\.ubuntu/jp.archive.ubuntu/g' /etc/apt/sources.list | |
RUN sed -i 's/archive.ubuntu.com/mirrors.bfsu.edu.cn/g' /etc/apt/sources.list | |
RUN apt-get update && \ | |
apt-get install -y \ | |
make binutils autoconf automake autotools-dev libtool \ | |
pkg-config git curl dpkg-dev gcc-mingw-w64 g++-mingw-w64 \ | |
autopoint libcppunit-dev libxml2-dev libgcrypt-dev lzip | |
RUN curl -L -O https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz | |
RUN curl -L -O https://github.com/libexpat/libexpat/releases/download/R_2_4_1/expat-2.4.1.tar.bz2 | |
RUN curl -L -O https://www.sqlite.org/2021/sqlite-autoconf-3360000.tar.gz | |
RUN curl -L -O https://zlib.net/zlib-1.2.11.tar.gz | |
RUN curl -L -O https://c-ares.haxx.se/download/c-ares-1.17.1.tar.gz | |
RUN curl -L -O https://www.libssh2.org/download/libssh2-1.9.0.tar.gz | |
RUN tar xf gmp-6.2.1.tar.lz && \ | |
cd gmp-6.2.1 && \ | |
./configure \ | |
--disable-shared \ | |
--enable-static \ | |
--prefix=/usr/local/$HOST \ | |
--host=$HOST \ | |
--disable-cxx \ | |
--enable-fat \ | |
CFLAGS="-mtune=generic -O2 -g0" && \ | |
make install | |
RUN tar xf expat-2.4.1.tar.bz2 && \ | |
cd expat-2.4.1 && \ | |
./configure \ | |
--disable-shared \ | |
--enable-static \ | |
--prefix=/usr/local/$HOST \ | |
--host=$HOST \ | |
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` && \ | |
make install | |
RUN tar xf sqlite-autoconf-3360000.tar.gz && \ | |
cd sqlite-autoconf-3360000 && \ | |
./configure \ | |
--disable-shared \ | |
--enable-static \ | |
--prefix=/usr/local/$HOST \ | |
--host=$HOST \ | |
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` && \ | |
make install | |
RUN tar xf zlib-1.2.11.tar.gz && \ | |
cd zlib-1.2.11 && \ | |
CC=$HOST-gcc \ | |
AR=$HOST-ar \ | |
LD=$HOST-ld \ | |
RANLIB=$HOST-ranlib \ | |
STRIP=$HOST-strip \ | |
./configure \ | |
--prefix=/usr/local/$HOST \ | |
--libdir=/usr/local/$HOST/lib \ | |
--includedir=/usr/local/$HOST/include \ | |
--static && \ | |
make install | |
RUN tar xf c-ares-1.17.1.tar.gz && \ | |
cd c-ares-1.17.1 && \ | |
curl -O https://github.com/c-ares/c-ares/commit/c35f8ff50710cd38776e9560389504dbd96307fa.patch && \ | |
patch -Np1 < c35f8ff50710cd38776e9560389504dbd96307fa.patch && \ | |
autoreconf -fi && \ | |
./configure \ | |
--disable-shared \ | |
--enable-static \ | |
--without-random \ | |
--prefix=/usr/local/$HOST \ | |
--host=$HOST \ | |
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \ | |
LIBS="-lws2_32" && \ | |
make install | |
RUN curl -L -O https://github.com/libssh2/libssh2/archive/a88a727c2a1840f979b34f12bcce3d55dcd7ea6e.tar.gz | |
RUN tar xf a88a727c2a1840f979b34f12bcce3d55dcd7ea6e.tar.gz && \ | |
cd libssh2-a88a727c2a1840f979b34f12bcce3d55dcd7ea6e && \ | |
autoreconf -fi && \ | |
./configure \ | |
--disable-shared \ | |
--enable-static \ | |
--prefix=/usr/local/$HOST \ | |
--host=$HOST \ | |
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \ | |
--without-openssl \ | |
--with-wincng \ | |
LIBS="-lws2_32" && \ | |
make install | |
ADD https://api.github.com/repos/aria2/aria2/git/refs/heads/master version.json | |
RUN curl -L -O https://github.com/aria2/aria2/archive/refs/heads/master.tar.gz | |
RUN tar xf master.tar.gz && \ | |
cd aria2-master && \ | |
curl -O https://aur.archlinux.org/cgit/aur.git/plain/aria2-fast.patch?h=aria2-fast && mv 'aria2-fast.patch?h=aria2-fast' aria2-fast.patch && patch -Np1 < aria2-fast.patch && autoreconf -i && ./mingw-config && make && \ | |
$HOST-strip src/aria2c.exe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment