Skip to content

Instantly share code, notes, and snippets.

@Yasushi
Forked from Drakulix/mingw-w64-3.10-osx10.9.sh
Last active March 27, 2016 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yasushi/0645068f6dcdc107300c to your computer and use it in GitHub Desktop.
Save Yasushi/0645068f6dcdc107300c to your computer and use it in GitHub Desktop.
Script to install a Mingw-w64 Cross-Compiler Suite on Mac OS X 10.11
#!/bin/sh
# dependencies
#echo "Installing dependencies via Homebrew (http://brew.sh)"
#ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
#brew update
#brew install gcc48
#brew install wget
# mingw
PREFIX=$HOME/root/mingw-w64
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
mkdir source
mkdir $PREFIX
echo "Downloading binutils\n"
cd ./source
curl -O http://ftp.t.ring.gr.jp/pub/GNU/binutils/binutils-2.26.tar.bz2
tar xjf binutils-2.26.tar.bz2
echo "Building binutils\n"
echo "1/2 32-bit\n"
cd binutils-2.26
mkdir build
cd build
CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 LD=gcc-4.8 ../configure --target=i686-w64-mingw32 --disable-werror --disable-multilib --prefix=$PREFIX --with-sysroot=$PREFIX
make -j4
make install-strip
echo "2/2 64-bit\n"
cd ..
mkdir build64
cd build64
CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 LD=gcc-4.8 ../configure --target=x86_64-w64-mingw32 --disable-werror --disable-multilib --prefix=$PREFIX --with-sysroot=$PREFIX --enable-64-bit-bfd
make -j4
make install-strip
cd ..
cd ..
echo "Downloading mingw-w64\n"
aria2c 'http://downloads.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v4.0.5.tar.bz2?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fmingw-w64%2Ffiles%2Fmingw-w64%2Fmingw-w64-release%2F&ts=1458910797&use_mirror=heanet'
tar xjf mingw-w64-v4.0.5.tar.bz2
echo "Building mingw-headers\n"
echo "1/2 32-bit\n"
cd mingw-w64-v4.0.5
mkdir build-headers
cd build-headers
../mingw-w64-headers/configure --host=i686-w64-mingw32 --prefix=$PREFIX/i686-w64-mingw32 --enable-secure-api
make -j4
make install-strip
cd $PREFIX/i686-w64-mingw32
ln -s lib lib32
cd $DIR/source/mingw-w64-v4.0.5
echo "2/2 64-bit\n"
mkdir build-headers64
cd build-headers64
../mingw-w64-headers/configure --host=x86_64-w64-mingw32 --prefix=$PREFIX/x86_64-w64-mingw32 --enable-secure-api
make -j4
make install-strip
cd $PREFIX/x86_64-w64-mingw32
ln -s lib lib64
cd $DIR/source/
echo "Downloading gcc\n"
wget http://ftp.t.ring.gr.jp/pub/GNU/gcc/gcc-4.8.5/gcc-4.8.5.tar.bz2
tar xf gcc-4.8.5.tar.bz2
echo "Building core gcc\n"
echo "1/2 32-bit\n"
cd $PREFIX
ln -s i686-w64-mingw32 mingw
cd $DIR/source/gcc-4.8.5
mkdir build32
cd build32
CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 LD=gcc-4.8 PATH=$PREFIX/bin/:$PATH ../configure --target=i686-w64-mingw32 --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/Cellar/gmp4/4.3.2/ --with-mpfr=/usr/local/Cellar/mpfr2/2.4.2/ --with-mpc=/usr/local/Cellar/libmpc08/0.8.1/ --with-cloog=/usr/local/Cellar/cloog018/0.18.0/ --with-isl=/usr/local/Cellar/isl011/0.11.1/ --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --enable-threads=win32 --disable-sjlj-exceptions --prefix=$PREFIX --with-sysroot=$PREFIX
PATH=$PREFIX/bin/:$PATH make all-gcc -j4
PATH=$PREFIX/bin/:$PATH make install-gcc
echo "2/2 64-bit\n"
cd $PREFIX
rm mingw
ln -s x86_64-w64-mingw32 mingw
cd $DIR/source/gcc-4.8.5
mkdir build64
cd build64
CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 LD=gcc-4.8 PATH=$PREFIX/bin/:$PATH ../configure --target=x86_64-w64-mingw32 --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/Cellar/gmp4/4.3.2/ --with-mpfr=/usr/local/Cellar/mpfr2/2.4.2/ --with-mpc=/usr/local/Cellar/libmpc08/0.8.1/ --with-cloog=/usr/local/Cellar/cloog018/0.18.0/ --with-isl=/usr/local/Cellar/isl011/0.11.1/ --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --enable-threads=win32 --prefix=$PREFIX --with-sysroot=$PREFIX
PATH=$PREFIX/bin/:$PATH make all-gcc -j4
PATH=$PREFIX/bin/:$PATH make install-gcc
echo "Building mingw runtime\n"
cd $PREFIX
rm mingw
ln -s i686-w64-mingw32 mingw
cd $DIR/source/mingw-w64-v4.0.5
mkdir build-crt
cd build-crt
echo "1/2 32-Bit\n"
PATH=$PREFIX/bin/:$PATH ../mingw-w64-crt/configure --host=i686-w64-mingw32 --prefix=$PREFIX/i686-w64-mingw32 --with-sysroot=$PREFIX
PATH=$PREFIX/bin/:$PATH make
PATH=$PREFIX/bin/:$PATH make install-strip
echo "2/2 64-Bit\n"
cd $PREFIX
rm mingw
ln -s x86_64-w64-mingw32 mingw
cd $DIR/source/mingw-w64-v4.0.5
mkdir build-crt64
cd build-crt64
PATH=$PREFIX/bin/:$PATH ../mingw-w64-crt/configure --host=x86_64-w64-mingw32 --prefix=$PREFIX/x86_64-w64-mingw32 --with-sysroot=$PREFIX
PATH=$PREFIX/bin/:$PATH make
PATH=$PREFIX/bin/:$PATH make install-strip
echo "Building all gcc\n"
echo "1/2 32-Bit\n"
cd $PREFIX
rm mingw
ln -s i686-w64-mingw32 mingw
cd $DIR/source/gcc-4.8.5/build32
PATH=$PREFIX/bin/:$PATH make
PATH=$PREFIX/bin/:$PATH make install-strip
echo "2/2 64-Bit\n"
cd $PREFIX
rm mingw
ln -s x86_64-w64-mingw32 mingw
cd $DIR/source/gcc-4.8.5/build64
PATH=$PREFIX/bin/:$PATH make
PATH=$PREFIX/bin/:$PATH make install-strip
echo "Linking libgcc\n"
cd $PREFIX/i686-w64-mingw32/lib
ln -s ../../lib/gcc/i686-w64-mingw32/lib/libgcc_s.a ./
cd $PREFIX/x86_64-w64-mingw32/lib
ln -s ../../lib/gcc/x86_64-w64-mingw32/lib/libgcc_s.a ./
echo "Building winpthreads\n"
cd $DIR/source/mingw-w64-v4.0.5/mingw-w64-libraries/winpthreads
echo "1/2 32-Bit\n"
mkdir build
cd build
PATH=$PREFIX/bin/:$PATH ../configure --host=i686-w64-mingw32 --prefix=$PREFIX/i686-w64-mingw32
PATH=$PREFIX/bin/:$PATH make
PATH=$PREFIX/bin/:$PATH make install-strip
cd ..
echo "2/2 64-Bit\n"
mkdir build64
cd build64
PATH=$PREFIX/bin/:$PATH ../configure --host=x86_64-w64-mingw32 --prefix=$PREFIX/x86_64-w64-mingw32
PATH=$PREFIX/bin/:$PATH make
PATH=$PREFIX/bin/:$PATH make install-strip
echo "Cleaning up\n"
cd $DIR
rm -rf source
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment