Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 8363396a5c
Fetching contributors…

Cannot retrieve contributors at this time

165 lines (135 sloc) 5.03 kB
require 'formula'
# NOTE: GCC 4.6.0 adds the gccgo compiler for the Go language. However,
# gccgo "is currently known to work on GNU/Linux and RTEMS. Solaris support
# is in progress. It may or may not work on other platforms."
def cxx?
ARGV.include? '--enable-cxx'
def fortran?
ARGV.include? '--enable-fortran'
def java?
ARGV.include? '--enable-java'
def objc?
ARGV.include? '--enable-objc'
def objcxx?
ARGV.include? '--enable-objcxx'
def build_everything?
ARGV.include? '--enable-all-languages'
def nls?
ARGV.include? '--enable-nls'
def profiledbuild?
ARGV.include? '--enable-profiled-build'
class Ecj < Formula
# Little Known Fact: ecj, Eclipse Java Complier, is required in order to
# produce a gcj compiler that can actually parse Java source code.
url ''
mirror ''
md5 'd7cd6a27c8801e66cbaa964a039ecfdb'
class Gcc < Formula
homepage ''
url ''
mirror ''
md5 '2a0f1d99fda235c29d40b561f81d9a77'
depends_on 'gmp'
depends_on 'libmpc'
depends_on 'mpfr'
def options
['--enable-cxx', 'Build the g++ compiler'],
['--enable-fortran', 'Build the gfortran compiler'],
['--enable-java', 'Buld the gcj compiler'],
['--enable-objc', 'Enable Objective-C language support'],
['--enable-objcxx', 'Enable Objective-C++ language support'],
['--enable-all-languages', 'Enable all compilers and languages, except Ada'],
['--enable-nls', 'Build with natural language support'],
['--enable-profiled-build', 'Make use of profile guided optimization when bootstrapping GCC']
# Dont strip compilers.
skip_clean :all
def install
# Force 64-bit on systems that use it. Build failures reported for some
# systems when this is not done.
ENV.m64 if MacOS.prefer_64_bit?
# GCC will suffer build errors if forced to use a particular linker.
ENV.delete 'LD'
# This is required on systems running a version newer than 10.6, and
# it's probably a good idea regardless.
gmp = Formula.factory 'gmp'
mpfr = Formula.factory 'mpfr'
libmpc = Formula.factory 'libmpc'
# Sandbox the GCC lib, libexec and include directories so they don't wander
# around telling small children there is no Santa Claus. This results in a
# partially keg-only brew following suggestions outlined in the "How to
# install multiple versions of GCC" section of the GCC FAQ:
gcc_prefix = prefix + 'gcc'
args = [
# Sandbox everything...
# ...except the stuff in share...
# ...and the binaries...
# ...which are tagged with a suffix to distinguish them.
args << '--disable-nls' unless nls?
if build_everything?
# Everything but Ada, which requires a pre-existing GCC Ada compiler
# (gnat) to bootstrap. GCC 4.6.0 add go as a language option, but it is
# currently only compilable on Linux.
languages = %w[c c++ fortran java objc obj-c++]
# The C compiler is always built, but additional defaults can be added
# here.
languages = %w[c]
languages << 'c++' if cxx?
languages << 'fortran' if fortran?
languages << 'java' if java?
languages << 'objc' if objc?
languages << 'obj-c++' if objcxx?
if java? or build_everything?
source_dir = Dir.pwd do |ecj|
# Copying ecj.jar into the toplevel of the GCC source tree will cause
# gcc to automagically package it into the installation. It *must* be
# named ecj.jar and not ecj-version.jar in order for this to happen.
mv "ecj-#{ecj.version}.jar", (source_dir + 'ecj.jar')
mkdir 'build' do
system '../configure', "--enable-languages=#{languages.join(',')}", *args
if profiledbuild?
# Takes longer to build, may bug out. Provided for those who want to
# optimise all the way to 11.
system 'make profiledbootstrap'
system 'make bootstrap'
# At this point `make check` could be invoked to run the testsuite. The
# deja-gnu and autogen formulae must be installed in order to do this.
system 'make install'
Jump to Line
Something went wrong with that request. Please try again.