win build
This commit is contained in:
120
rin/miner/Dockerfile.windows-build
Normal file
120
rin/miner/Dockerfile.windows-build
Normal file
@@ -0,0 +1,120 @@
|
||||
# Dockerfile for cross-compiling cpuminer-opt for Windows on Linux
|
||||
FROM ubuntu:22.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install cross-compilation tools and some dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
autotools-dev \
|
||||
automake \
|
||||
autoconf \
|
||||
pkg-config \
|
||||
libtool \
|
||||
wget \
|
||||
curl \
|
||||
git \
|
||||
unzip \
|
||||
mingw-w64 \
|
||||
mingw-w64-tools \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set up cross-compilation environment
|
||||
ENV HOST=x86_64-w64-mingw32
|
||||
ENV CC=${HOST}-gcc
|
||||
ENV CXX=${HOST}-g++
|
||||
ENV AR=${HOST}-ar
|
||||
ENV STRIP=${HOST}-strip
|
||||
ENV RANLIB=${HOST}-ranlib
|
||||
ENV PKG_CONFIG=${HOST}-pkg-config
|
||||
|
||||
# Create build directory
|
||||
WORKDIR /build
|
||||
|
||||
# Build zlib for Windows
|
||||
RUN wget https://github.com/madler/zlib/archive/refs/tags/v1.3.1.tar.gz -O zlib-1.3.1.tar.gz && \
|
||||
tar -xzf zlib-1.3.1.tar.gz && \
|
||||
cd zlib-1.3.1 && \
|
||||
CC=${HOST}-gcc AR=${HOST}-ar RANLIB=${HOST}-ranlib ./configure --prefix=/usr/${HOST} --static && \
|
||||
make && make install && \
|
||||
cd .. && rm -rf zlib-1.3.1*
|
||||
|
||||
# Build GMP for Windows
|
||||
RUN wget https://gmplib.org/download/gmp/gmp-6.3.0.tar.xz && \
|
||||
tar -xf gmp-6.3.0.tar.xz && \
|
||||
cd gmp-6.3.0 && \
|
||||
./configure --host=${HOST} --prefix=/usr/${HOST} --enable-static --disable-shared && \
|
||||
make -j$(nproc) && make install && \
|
||||
cd .. && rm -rf gmp-6.3.0*
|
||||
|
||||
# Build a minimal OpenSSL for Windows (or we could skip this and just use system curl)
|
||||
RUN wget https://www.openssl.org/source/openssl-3.0.15.tar.gz && \
|
||||
tar -xzf openssl-3.0.15.tar.gz && \
|
||||
cd openssl-3.0.15 && \
|
||||
./Configure mingw64 --cross-compile-prefix=${HOST}- --prefix=/usr/${HOST} no-shared && \
|
||||
make -j$(nproc) && make install_sw && \
|
||||
cd .. && rm -rf openssl-3.0.15*
|
||||
|
||||
# Build libcurl for Windows
|
||||
RUN wget https://curl.se/download/curl-8.8.0.tar.gz && \
|
||||
tar -xzf curl-8.8.0.tar.gz && \
|
||||
cd curl-8.8.0 && \
|
||||
./configure --host=${HOST} --prefix=/usr/${HOST} \
|
||||
--with-openssl=/usr/${HOST} \
|
||||
--with-zlib=/usr/${HOST} \
|
||||
--enable-static --disable-shared \
|
||||
--disable-ldap --disable-ldaps \
|
||||
--without-libpsl --without-nghttp2 \
|
||||
--without-brotli --without-zstd && \
|
||||
make -j$(nproc) && make install && \
|
||||
cd .. && rm -rf curl-8.8.0*
|
||||
|
||||
# Build jansson for Windows
|
||||
RUN wget https://github.com/akheron/jansson/releases/download/v2.14/jansson-2.14.tar.gz && \
|
||||
tar -xzf jansson-2.14.tar.gz && \
|
||||
cd jansson-2.14 && \
|
||||
./configure --host=${HOST} --prefix=/usr/${HOST} --enable-static --disable-shared && \
|
||||
make -j$(nproc) && make install && \
|
||||
cd .. && rm -rf jansson-2.14*
|
||||
|
||||
# Set up environment for cross-compilation
|
||||
ENV PKG_CONFIG_PATH="/usr/${HOST}/lib/pkgconfig"
|
||||
ENV LDFLAGS="-L/usr/${HOST}/lib"
|
||||
ENV CPPFLAGS="-I/usr/${HOST}/include"
|
||||
|
||||
# Copy cpuminer source
|
||||
COPY cpuminer /build/cpuminer
|
||||
|
||||
WORKDIR /build/cpuminer
|
||||
|
||||
# Build script
|
||||
RUN echo '#!/bin/bash\n\
|
||||
set -e\n\
|
||||
\n\
|
||||
echo "Cleaning previous builds..."\n\
|
||||
make clean || true\n\
|
||||
rm -f config.status\n\
|
||||
\n\
|
||||
echo "Running autogen..."\n\
|
||||
./autogen.sh\n\
|
||||
\n\
|
||||
echo "Configuring for Windows cross-compile..."\n\
|
||||
./configure \\\n\
|
||||
--host=${HOST} \\\n\
|
||||
--with-curl=/usr/${HOST} \\\n\
|
||||
CFLAGS="-O3 -march=x86-64 -mtune=generic -msse2 -static" \\\n\
|
||||
LDFLAGS="-L/usr/${HOST}/lib -static" \\\n\
|
||||
CPPFLAGS="-I/usr/${HOST}/include"\n\
|
||||
\n\
|
||||
echo "Building cpuminer..."\n\
|
||||
make -j$(nproc)\n\
|
||||
\n\
|
||||
echo "Stripping binary..."\n\
|
||||
${STRIP} cpuminer.exe\n\
|
||||
\n\
|
||||
echo "Build complete! cpuminer.exe created."\n\
|
||||
ls -la cpuminer.exe\n\
|
||||
file cpuminer.exe\n\
|
||||
' > /build/build-windows.sh && chmod +x /build/build-windows.sh
|
||||
|
||||
CMD ["/build/build-windows.sh"]
|
Reference in New Issue
Block a user