Skip to content

Instantly share code, notes, and snippets.

@Lovesan
Last active February 9, 2022 23:08
Show Gist options
  • Save Lovesan/22f1cb3c55fc26cafecf07b50521e5a3 to your computer and use it in GitHub Desktop.
Save Lovesan/22f1cb3c55fc26cafecf07b50521e5a3 to your computer and use it in GitHub Desktop.
#overall:
#gmp
#mpfr
#mpc
#isl
#binutils
#mingw-w64
#gcc
#zlib (optional, only native)
cd ~/
mkdir -p xmingw
sudo ln -s /opt/xmingw ~/xmingw
mkdir -m mingw-build
cd mingw-build
mkdir -p src
cd src
wget ftp://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz
wget ftp://ftp.gnu.org/gnu/mpfr/mpfr-4.1.0.tar.xz
wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.2.1.tar.gz
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.24.tar.bz2
wget ftp://ftp.gnu.org/gnu/binutils/binutils-2.38.tar.xz
wget ftp://ftp.gnu.org/gnu/gcc/gcc-11.2.0/gcc-11.2.0.tar.xz
wget https://zlib.net/zlib-1.2.11.tar.xz
# BEFORE ALL OF THIS: download mingw-w64-v9.0.0.zip from SF and copy into src
tar xavf gmp-6.2.1.*
tar xavf mpfr-4.1.0.*
tar xavf mpc-1.2.1.*
tar xavf isl-0.24.*
tar xavf binutils-2.38.*
tar xavf zlib-1.2.11.*
unzip -o mingw-w64-v9.0.0.*
tar xaf gcc-11.2.0.*
cd ../
mkdir -p xbuild
cd xbuild
mkdir -p binutils
mkdir -p gmp
mkdir -p mpfr
mkdir -p mpc
mkdir -p isl
mkdir -p binutils-host
mkdir -p gcc
mkdir -p mingw-w64-crt
mkdir -p mingw-w64-headers
mkdir -p winpthreads
unset TARGET
export PREFIX=/opt/xmingw
cd gmp
../../src/gmp-6.2.1/configure --prefix=$PREFIX \
--enable-static \
--disable-shared \
--enable-cxx
make -j16 && make install-strip
cd ../mpfr
../../src/mpfr-4.1.0/configure --prefix=$PREFIX \
--enable-static \
--disable-shared \
--with-gmp=$PREFIX
make -j16 && make install-strip
cd ../mpc
../../src/mpc-1.2.1/configure --prefix=$PREFIX \
--enable-static \
--disable-shared \
--with-mpfr=$PREFIX \
--with-mpc=$PREFIX
make -j16 && make install-strip
cd ../isl
../../src/isl-0.24/configure --prefix=$PREFIX \
--enable-static \
--disable-shared \
--with-gmp-prefix=$PREFIX \
--with-sysroot=$PREFIX
make -j16 && make install-strip
cd ../binutils-host
../../src/binutils-2.38/configure --prefix=$PREFIX \
--disable-nls \
--enable-lto \
--enable-static \
--disable-shared \
--with-sysroot=$PREFIX \
--with-gmp=$PREFIX \
--with-mpfr=$PREFIX \
--with-mpc=$PREFIX \
--with-isl=$PREFIX
make -j16 && make install-strip
cd ../binutils
TARGET=x86_64-w64-mingw32
../../src/binutils-2.38/configure --prefix=$PREFIX \
--target=$TARGET \
--disable-nls \
--enable-lto \
--enable-static \
--disable-shared \
--with-sysroot=$PREFIX \
--with-gmp=$PREFIX \
--with-mpfr=$PREFIX \
--with-mpc=$PREFIX \
--with-isl=$PREFIX
make -j16 && make install-strip
export PATH=${PATH#/opt/xmingw/bin:}
export PATH=${PATH%:/opt/xmingw/bin}
pathappend() {
for ARG in "$@"
do
if [ -d "$ARG" ] && [[ ":$PATH:" != *":$ARG:"* ]]; then
PATH="${PATH:+"$PATH:"}$ARG"
fi
done
}
pathprepend() {
for ((i=$#; i>0; i--));
do
ARG=${!i}
if [ -d "$ARG" ] && [[ ":$PATH:" != *":$ARG:"* ]]; then
PATH="$ARG${PATH:+":$PATH"}"
fi
done
}
pathprepend '/opt/xmingw/bin'
export PATH
../../src/mingw-w64-v9.0.0/mingw-w64-headers/configure --prefix="$PREFIX/$TARGET" \
--host=$TARGET \
--target=$TARGET \
--enable-idl
make && make install
cat > /opt/xmingw/bin/$TARGET-pkg-config << EOF
#!/bin/bash
export PKG_CONFIG_PATH='/opt/xmingw/$TARGET/lib/pkgconfig'
export PKG_CONFIG_LIBDIR=\$PKG_CONFIG_PATH
pkg-config \$@
EOF
chmod 755 /opt/xmingw/bin/$TARGET-pkg-config
ln -s /opt/xmingw/$TARGET /opt/xmingw/mingw
cd ../gcc
../../src/gcc-11.2.0/configure --prefix=$PREFIX \
--target=$TARGET \
--disable-nls \
--enable-lto \
--enable-languages=c,c++ \
--disable-multilib \
--enable-static \
--disable-shared \
--with-gmp=$PREFIX \
--with-mpfr=$PREFIX \
--with-mpc=$PREFIX \
--with-isl=$PREFIX \
--with-sysroot=$PREFIX
make -j16 all-gcc
cd ../mingw-64-crt
../../src/mingw-w64-v9.0.0/mingw-w64-crt/configure --prefix="$PREFIX/$TARGET" \
--host=$TARGET \
--disable-lib32 \
--enable-lib64
make -j16 && make install
cd ../winpthreads
../../src/mingw-w64-v9.0.0/mingw-w64-libraries/winpthreads/configure --prefix="$PREFIX/$TARGET" \
--host=$TARGET \
--enable-static \
--disable-shared
make && make install
cd ../gcc
make -j16 && make install-strip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment