Skip to content

Instantly share code, notes, and snippets.

@niXman
Created September 13, 2022 08:12
Show Gist options
  • Save niXman/83f4c9a2e1a7bdf19f0c53dcb42043bf to your computer and use it in GitHub Desktop.
Save niXman/83f4c9a2e1a7bdf19f0c53dcb42043bf to your computer and use it in GitHub Desktop.
linux-hosted-mingw-w64
#!/bin/bash
THREADS=12
CURRENT_DIR="$(pwd)"
CROSS_MINGW_PREFIX="$CURRENT_DIR/../mingw-w64-cross"
ORIGINAL_PATH="$PATH"
rm -rf "$CROSS_MINGW_PREFIX"
echo "GMP /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd gmp && rm -rf * && ../gmp-6.2.1/configure --disable-shared --enable-cxx --prefix="$CURRENT_DIR/deps" && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
echo "MPFR ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd mpfr && rm -rf * && ../mpfr-4.1.0/configure --disable-shared --with-gmp="$CURRENT_DIR/deps" --prefix="$CURRENT_DIR/deps" && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
echo "MPC /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd mpc && rm -rf * && ../mpc-1.2.1/configure --disable-shared --with-gmp="$CURRENT_DIR/deps" --with-mpfr="$CURRENT_DIR/deps" --prefix="$CURRENT_DIR/deps" && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
echo "ISL /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd isl && rm -rf * && ../isl-0.19/configure --disable-shared --with-gmp-prefix="$CURRENT_DIR/deps" --prefix="$CURRENT_DIR/deps" && make install-strip -j$THREADS)
[[ $? != 0 ]] && exit 1
echo "ICONV ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd libiconv && rm -rf * && ../libiconv-1.17/configure --enable-relocatable --disable-rpath --disable-silent-rules --enable-nls --disable-shared --prefix="$CURRENT_DIR/deps" && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
echo "BINUTILS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd binutils && rm -rf * && ../binutils-2.38/configure --target=x86_64-w64-mingw32 --disable-multilib --disable-shared --enable-static --with-sysroot="$CROSS_MINGW_PREFIX" --prefix="$CROSS_MINGW_PREFIX" && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
export PATH="$CROSS_MINGW_PREFIX/bin:$PATH"
echo "API /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd m64-api && rm -rf * && ../mingw-w64-v10.0.0/mingw-w64-headers/configure --build=x86_64-linux-gnu --host=x86_64-w64-mingw32 --prefix="$CROSS_MINGW_PREFIX/x86_64-w64-mingw32" && make -j$THREADS && make install-strip)
[[ $? != 0 ]] && exit 1
(cd "$CROSS_MINGW_PREFIX" && ln -s x86_64-w64-mingw32 mingw)
[[ $? != 0 ]] && exit 1
echo "GCC-C ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd gcc && rm -rf * && ../gcc-12.2.0/configure --build=x86_64-linux-gnu --target=x86_64-w64-mingw32 --disable-multilib --prefix="$CROSS_MINGW_PREFIX" --with-sysroot="$CROSS_MINGW_PREFIX" --disable-shared --enable-static --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}="$CURRENT_DIR/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 --build=x86_64-linux-gnu --host=x86_64-w64-mingw32 --disable-lib32 --enable-lib64 --with-sysroot="$CROSS_MINGW_PREFIX" --prefix="$CROSS_MINGW_PREFIX/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 --build=x86_64-linux-gnu --host=x86_64-w64-mingw32 --disable-lib32 --enable-lib64 --with-sysroot="$CROSS_MINGW_PREFIX" --prefix="$CROSS_MINGW_PREFIX/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 "RM LINK /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
(cd $CROSS_MINGW_PREFIX && rm mingw)
[[ $? != 0 ]] && exit 1
#echo "POST ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
#(cd $CROSS_MINGW_PREFIX/lib/gcc/x86_64-w64-mingw32/lib && cp libgcc_s.a $CROSS_MINGW_PREFIX/x86_64-w64-mingw32/lib)
#[[ $? != 0 ]] && exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment