Skip to content

Instantly share code, notes, and snippets.

@ch0c01d
Created June 20, 2016 15:44
Show Gist options
  • Save ch0c01d/c092eb7072f4a4cf802f598b1fd80e6a to your computer and use it in GitHub Desktop.
Save ch0c01d/c092eb7072f4a4cf802f598b1fd80e6a to your computer and use it in GitHub Desktop.
MingW Installer Mac OS
#!/bin/sh
# mingw
PREFIX="/usr/local/mingw"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
mkdir source
mkdir $PREFIX
echo "Downloading mingw-w64\n"
wget -O mingw-w64-v4.0.6.tar.bz2 "http://downloads.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v4.0.6.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmingw-w64%2Ffiles%2Fmingw-w64%2Fmingw-w64-release%2F&ts=1396199899&use_mirror=kent"
tar xjf mingw-w64-v4.0.6.tar.bz2
echo "Building mingw-headers\n"
echo "1/2 32-bit\n"
cd mingw-w64-v4.0.6
mkdir build-headers
cd build-headers
../mingw-w64-headers/configure --host=i686-w64-mingw32 --prefix=$PREFIX/i686-w64-mingw32
make -j4
make install-strip
cd $PREFIX/i686-w64-mingw32
ln -s lib lib32
cd $DIR/mingw-w64-v4.0.6
echo "2/2 64-bit\n"
rm -rf build-headers
mkdir build-headers
cd build-headers
../mingw-w64-headers/configure --host=x86_64-w64-mingw32 --prefix=$PREFIX/x86_64-w64-mingw32
make -j4
make install-strip
cd $PREFIX/x86_64-w64-mingw32
ln -s lib lib64
cd $DIR/
echo "Downloading gcc\n"
curl -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-6.1.0/gcc-6.1.0.tar.bz2
tar xjf gcc-6.1.0.tar.bz2
echo "Building core gcc\n"
echo "1/2 32-bit\n"
cd $PREFIX
ln -s i686-w64-mingw32 mingw
cd $DIR/gcc-6.1.0
mkdir build32
cd build32
CC=gcc-6.1 CXX=g++-6.1 CPP=cpp-6.1 LD=gcc-6.1 PATH=/usr/local/mingw/bin/:$PATH ../configure --target=i686-w64-mingw32 --disable-multilib --enable-languages=c,c++,objc,obj-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=/usr/local/mingw/bin/:$PATH make all-gcc -j4
PATH=/usr/local/mingw/bin/:$PATH make install-gcc
echo "2/2 64-bit\n"
cd $PREFIX
rm mingw
ln -s x86_64-w64-mingw32 mingw
cd $DIR/gcc-6.1.0
mkdir build64
cd build64
CC=gcc-6.1 CXX=g++-6.1 CPP=cpp-6.1 LD=gcc-6.1 PATH=/usr/local/mingw/bin/:$PATH ../configure --target=x86_64-w64-mingw32 --disable-multilib --enable-languages=c,c++,objc,obj-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=/usr/local/mingw/bin/:$PATH make all-gcc -j4
PATH=/usr/local/mingw/bin/:$PATH make install-gcc
echo "Building mingw runtime\n"
cd $PREFIX
rm mingw
ln -s i686-w64-mingw32 mingw
cd $DIR/mingw-w64-v4.0.6
mkdir build-crt
cd build-crt
echo "1/2 32-Bit\n"
PATH=/usr/local/mingw/bin/:$PATH ../mingw-w64-crt/configure --host=i686-w64-mingw32 --prefix=$PREFIX/i686-w64-mingw32 --with-sysroot=$PREFIX
PATH=/usr/local/mingw/bin/:$PATH make
PATH=/usr/local/mingw/bin/:$PATH make install-strip
echo "2/2 64-Bit\n"
cd $PREFIX
rm mingw
ln -s x86_64-w64-mingw32 mingw
cd $DIR/mingw-w64-v4.0.6
rm -rf build-crt
mkdir build-crt
cd build-crt
PATH=/usr/local/mingw/bin/:$PATH ../mingw-w64-crt/configure --host=x86_64-w64-mingw32 --prefix=$PREFIX/x86_64-w64-mingw32 --with-sysroot=$PREFIX
PATH=/usr/local/mingw/bin/:$PATH make
PATH=/usr/local/mingw/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/gcc-6.1.0/build32
PATH=/usr/local/mingw/bin/:$PATH make
PATH=/usr/local/mingw/bin/:$PATH make install-strip
echo "2/2 64-Bit\n"
cd $PREFIX
rm mingw
ln -s x86_64-w64-mingw32 mingw
cd $DIR/gcc-6.1.0/build64
PATH=/usr/local/mingw/bin/:$PATH make
PATH=/usr/local/mingw/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/mingw-w64-v4.0.6/mingw-w64-libraries/winpthreads
echo "1/2 32-Bit\n"
mkdir build
cd build
../configure --host=i686-w64-mingw32 --prefix=$PREFIX/i686-w64-mingw32
make
make install-strip
cd ..
rm -rf build
echo "2/2 64-Bit\n"
mkdir build
cd build
../configure --host=x86_64-w64-mingw32 --prefix=$PREFIX/x86_64-w64-mingw32
make
make install-strip
echo "Cleaning up file ..\n"
cd $DIR
echo "Process Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment