Skip to content

Instantly share code, notes, and snippets.

@niXman
Created September 13, 2022 08:13
Show Gist options
  • Save niXman/27f339aa3f96de52db22efa66ab0c56f to your computer and use it in GitHub Desktop.
Save niXman/27f339aa3f96de52db22efa66ab0c56f to your computer and use it in GitHub Desktop.
windows-hosted-mingw-w64
#!/bin/bash
THREADS=12
CROSS_MINGW_PREFIX="/home/nixman/mingw-w64-cross"
NATIVE_MINGW_PREFIX="/home/nixman/mingw-w64"
ORIGINAL_PATH="$PATH"
export PATH="$CROSS_MINGW_PREFIX/bin:$PATH"
rm -rf "$NATIVE_MINGW_PREFIX"
echo "GMP /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd gmp && rm -rf * && ../gmp-6.2.1/configure --host=x86_64-w64-mingw32 --disable-shared --enable-cxx --prefix=/home/nixman/mingw-w64-build/deps && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
echo "MPFR ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd mpfr && rm -rf * && ../mpfr-4.1.0/configure --host=x86_64-w64-mingw32 --disable-shared --with-gmp=/home/nixman/mingw-w64-build/deps --prefix=/home/nixman/mingw-w64-build/deps && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
echo "MPC /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd mpc && rm -rf * && ../mpc-1.2.1/configure --host=x86_64-w64-mingw32 --disable-shared --with-gmp=/home/nixman/mingw-w64-build/deps --with-mpfr=/home/nixman/mingw-w64-build/deps --prefix=/home/nixman/mingw-w64-build/deps && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
echo "ISL /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd isl && rm -rf * && ../isl-0.19/configure --host=x86_64-w64-mingw32 --disable-shared --with-gmp-prefix=/home/nixman/mingw-w64-build/deps --prefix=/home/nixman/mingw-w64-build/deps && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
echo "ICONV ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd libiconv && rm -rf * && ../libiconv-1.17/configure --host=x86_64-w64-mingw32 --enable-relocatable --disable-rpath --disable-silent-rules --enable-nls --disable-shared --prefix=/home/nixman/mingw-w64-build/deps && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
echo "BINUTILS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd binutils && rm -rf * && ../binutils-2.38/configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-multilib --with-sysroot=/home/nixman/mingw-w64 --prefix=/home/nixman/mingw-w64 && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
echo "API /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd m64-api && rm -rf * && ../mingw-w64-v10.0.0/mingw-w64-headers/configure --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --prefix=/home/nixman/mingw-w64/x86_64-w64-mingw32 && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
(cd $NATIVE_MINGW_PREFIX && ln -s x86_64-w64-mingw32 mingw)
[[ $? != 0 ]] && exit 1
echo "GCC-C ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd gcc && rm -rf * && ../gcc-12.2.0/configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-multilib --prefix=/home/nixman/mingw-w64 --with-sysroot=/home/nixman/mingw-w64 --enable-languages=c,c++ --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-{gmp,mpfr,mpc,isl}=/home/nixman/mingw-w64-build/deps && make all-gcc -j$THREADS && make install-strip-gcc)
[[ $? != 0 ]] && exit 1
echo "CRT /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd m64-crt && rm -rf * && ../mingw-w64-v10.0.0/mingw-w64-crt/configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-lib32 --enable-lib64 --with-sysroot=/home/nixman/mingw-w64 --prefix=/home/nixman/mingw-w64/x86_64-w64-mingw32 && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
echo "THRD ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd m64-thrd && rm -rf * && ../mingw-w64-v10.0.0/mingw-w64-libraries/winpthreads/configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-sysroot=/home/nixman/mingw-w64 --prefix=/home/nixman/mingw-w64/x86_64-w64-mingw32 && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
echo "GCC-C++ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd gcc && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
echo "POST ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd $NATIVE_MINGW_PREFIX && rm mingw)
(cd $NATIVE_MINGW_PREFIX && cd x86_64-w64-mingw32/bin && mv libwinpthread-1.dll $NATIVE_MINGW_PREFIX/bin/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment