Last active
January 9, 2020 11:49
-
-
Save Drakulix/9881160 to your computer and use it in GitHub Desktop.
Script to install a Mingw-w64 Cross-Compiler Suite on Mac OS X 10.9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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="/usr/local/mingw" | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
cd $DIR | |
mkdir source | |
mkdir $PREFIX | |
echo "Downloading binutils\n" | |
cd ./source | |
curl -O http://ftp.gnu.org/gnu/binutils/binutils-2.24.tar.bz2 | |
tar xjf binutils-2.24.tar.bz2 | |
echo "Building binutils\n" | |
echo "1/2 32-bit\n" | |
cd binutils-2.24 | |
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 .. | |
rm -rf build | |
mkdir build | |
cd build | |
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" | |
wget -O mingw-w64-v3.1.0.tar.bz2 "http://downloads.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v3.1.0.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-v3.1.0.tar.bz2 | |
echo "Building mingw-headers\n" | |
echo "1/2 32-bit\n" | |
cd mingw-w64-v3.1.0 | |
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/source/mingw-w64-v3.1.0 | |
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/source/ | |
echo "Downloading gcc\n" | |
curl -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.8.2/gcc-4.8.2.tar.bz2 | |
tar xjf gcc-4.8.2.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.2 | |
mkdir build32 | |
cd build32 | |
CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 LD=gcc-4.8 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/source/gcc-4.8.2 | |
mkdir build64 | |
cd build64 | |
CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 LD=gcc-4.8 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/source/mingw-w64-v3.1.0 | |
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/source/mingw-w64-v3.1.0 | |
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/source/gcc-4.8.2/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/source/gcc-4.8.2/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/source/mingw-w64-v3.1.0/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\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
I am working on a homebrew version of this script.
EDIT: I just noticed that cosmo0920 (https://github.com/cosmo0920/homebrew-mingw_w64) has already begun to work on a brew version of this script.