Skip to content

Instantly share code, notes, and snippets.

@cosmo0920
Created January 17, 2016 14:45
Show Gist options
  • Save cosmo0920/5e18957fccf595a514cc to your computer and use it in GitHub Desktop.
Save cosmo0920/5e18957fccf595a514cc to your computer and use it in GitHub Desktop.
class I686W64Mingw32Gcc < Formula
homepage "https://gcc.gnu.org"
url "http://ftpmirror.gnu.org/gcc/gcc-5.2.0/gcc-5.2.0.tar.bz2"
sha256 "5f835b04b5f7dd4f4d2dc96190ec1621b8d89f2dc6f638f9f8bc1b1014ba8cad"
resource "binutils" do
url "http://ftpmirror.gnu.org/binutils/binutils-2.25.1.tar.bz2"
sha256 "b5b14added7d78a8d1ca70b5cb75fef57ce2197264f4f5835326b0df22ac9f22"
end
resource "mingw-headers" do
url "https://downloads.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v4.0.4.tar.bz2"
sha256 "89356a0aa8cf9f8b9dc8d92bc8dd01a131d4750c3acb30c6350a406316c42199"
end
resource "gcc-core" do
url "http://ftpmirror.gnu.org/gcc/gcc-5.2.0/gcc-5.2.0.tar.bz2"
sha256 "5f835b04b5f7dd4f4d2dc96190ec1621b8d89f2dc6f638f9f8bc1b1014ba8cad"
end
resource "mingw-runtime" do
url "https://downloads.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v4.0.4.tar.bz2"
sha256 "89356a0aa8cf9f8b9dc8d92bc8dd01a131d4750c3acb30c6350a406316c42199"
end
resource "mingw-winpthread" do
url "https://downloads.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v4.0.4.tar.bz2"
sha256 "89356a0aa8cf9f8b9dc8d92bc8dd01a131d4750c3acb30c6350a406316c42199"
end
depends_on "gcc5" => :build
depends_on "gmp"
depends_on "mpfr"
depends_on "libmpc"
depends_on "isl014"
keg_only <<-EOS.undent
This formula is mainly used internally by other formulae.
EOS
def install
target_arch = "i686-w64-mingw32"
resource("binutils").stage do
args = %W[
CC=gcc-5
CXX=g++-5
CPP=cpp-5
LD=gcc-5
--target=#{target_arch}
--disable-werror
--disable-multilib
--prefix=#{prefix}
]
system "./configure", *args
system "make"
system "make install-strip"
end
resource("mingw-headers").stage do
args = %W[
--host=#{target_arch}
--prefix=#{prefix}/mingw
--enable-sdk=all
--enable-secure-api
]
mkdir "build-headers" do
system "../mingw-w64-headers/configure", *args
system "make"
system "make install"
end
ln_s target_arch, "mingw"
end
resource("gcc-core").stage do
ENV.prepend_path 'PATH', bin
ENV.prepend "CFLAGS", "-I#{prefix}/mingw/include"
args = %W[
CC=gcc-5
CXX=g++-5
CPP=cpp-5
LD=gcc-5
--target=#{target_arch}
--prefix=#{prefix}
--disable-multilib
--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
--enable-languages=c,c++,objc,obj-c++
--with-gmp=#{Formula["gmp"].opt_prefix}
--with-mpfr=#{Formula["mpfr"].opt_prefix}
--with-mpc=#{Formula["libmpc"].opt_prefix}
--with-isl=#{Formula["isl014"].opt_prefix}
MAKEINFO=missing
]
mkdir "build32" do
system "../configure", *args
system "make all-gcc"
system "make install-gcc"
end
# restore PATH
ENV["PATH"] = path
end
resource("mingw-runtime").stage do
path = ENV["PATH"]
ENV.prepend_path 'PATH', bin
ENV.append "CPPFLAGS", "-I#{prefix}/mingw/include"
args = %W[
CC=#{target_arch}-gcc
CXX=#{target_arch}-g++
CPP=#{target_arch}-cpp
LD=#{target_arch}-gcc
--host=#{target_arch}
--prefix=#{prefix}
--disable-lib64 --enable-lib32
]
chdir "mingw-w64-crt" do
system "./configure", *args
system "make"
system "make install"
end
# restore PATH
ENV["PATH"] = path
end
# build cross gcc
path = ENV["PATH"]
ENV.prepend_path 'PATH', bin
ENV.prepend "CFLAGS", "-I#{prefix}/mingw/include"
args = %W[
--target=#{target_arch}
--prefix=#{prefix}
--disable-multilib
--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
--enable-languages=c,c++,objc,obj-c++
--with-gmp=#{Formula["gmp"].opt_prefix}
--with-mpfr=#{Formula["mpfr"].opt_prefix}
--with-mpc=#{Formula["libmpc"].opt_prefix}
--with-isl=#{Formula["isl014"].opt_prefix}
MAKEINFO=missing
]
system "make"
system "make install"
chdir "#{prefix}/#{target_arch}/lib" do
ln_s "../../lib/gcc/#{target_arch}/lib/libgcc_s.a", "./"
end
# restore PATH
ENV["PATH"] = path
resource("mingw-winpthread").stage do
path = ENV["PATH"]
ENV.prepend_path 'PATH', bin
ENV.append "CFLAGS", "-I#{prefix}/mingw/include"
args = %W[
CC=#{target_arch}-gcc
CXX=#{target_arch}-g++
CPP=#{target_arch}-cpp
LD=#{target_arch}-gcc
--host=#{target_arch}
--prefix=#{prefix}
--disable-lib64 --enable-lib32
]
chdir "mingw-w64-libraries/winpthreads" do
system "./configure", *args
system "make"
system "make install"
end
# restore PATH
ENV["PATH"] = path
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment