forked from lotia/homebrew-versions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcc49.rb
147 lines (126 loc) · 4.87 KB
/
gcc49.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
require 'formula'
class Gcc49 < Formula
def arch
if Hardware::CPU.type == :intel
if MacOS.prefer_64_bit?
'x86_64'
else
'i686'
end
elsif Hardware::CPU.type == :ppc
if MacOS.prefer_64_bit?
'ppc64'
else
'ppc'
end
end
end
def osmajor
`uname -r`.chomp
end
homepage 'http://gcc.gnu.org'
url 'ftp://gcc.gnu.org/pub/gcc/snapshots/4.9-20130505/gcc-4.9-20130505.tar.bz2'
sha1 'a16139f773d7bac650cdf88b05e1263ac0a736d6'
head 'svn://gcc.gnu.org/svn/gcc/trunk'
option 'enable-cxx', 'Build the g++ compiler'
option 'enable-fortran', 'Build the gfortran compiler'
option 'enable-java', 'Buld the gcj compiler'
option 'enable-objc', 'Enable Objective-C language support'
option 'enable-objcxx', 'Enable Objective-C++ language support'
option 'enable-all-languages', 'Enable all compilers and languages, except Ada'
option 'enable-nls', 'Build with native language support (localization)'
option 'enable-profiled-build', 'Make use of profile guided optimization when bootstrapping GCC'
option 'enable-multilib', 'Build with multilib support'
depends_on 'gmp'
depends_on 'libmpc'
depends_on 'mpfr'
depends_on 'cloog'
depends_on 'isl'
depends_on 'ecj' if build.include? 'enable-java' or build.include? 'enable-all-languages'
def install
# GCC will suffer build errors if forced to use a particular linker.
ENV.delete 'LD'
if build.include? 'enable-all-languages'
# 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++]
else
# The C compiler is always built, but additional defaults can be added
# here.
languages = %w[c]
languages << 'c++' if build.include? 'enable-cxx'
languages << 'fortran' if build.include? 'enable-fortran'
languages << 'java' if build.include? 'enable-java'
languages << 'objc' if build.include? 'enable-objc'
languages << 'obj-c++' if build.include? 'enable-objcxx'
end
# 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:
# http://gcc.gnu.org/faq.html#multiple
gcc_prefix = prefix + 'gcc'
args = [
"--build=#{arch}-apple-darwin#{osmajor}",
# Sandbox everything...
"--prefix=#{gcc_prefix}",
# ...except the stuff in share...
"--datarootdir=#{share}",
# ...and the binaries...
"--bindir=#{bin}",
# ...which are tagged with a suffix to distinguish them.
"--enable-languages=#{languages.join(',')}",
"--program-suffix=-#{version.to_s.slice(/\d\.\d/)}",
"--with-gmp=#{Formula.factory('gmp').opt_prefix}",
"--with-mpfr=#{Formula.factory('mpfr').opt_prefix}",
"--with-mpc=#{Formula.factory('libmpc').opt_prefix}",
"--with-cloog=#{Formula.factory('cloog').opt_prefix}",
"--with-isl=#{Formula.factory('isl').opt_prefix}",
"--with-system-zlib",
"--enable-libstdcxx-time=yes",
"--enable-stage1-checking",
"--enable-checking=release",
"--enable-plugin",
"--enable-lto",
# a no-op unless --HEAD is built because in head warnings will raise errs.
"--disable-werror"
]
args << '--disable-nls' unless build.include? 'enable-nls'
if build.include? 'enable-java' or build.include? 'enable-all-languages'
args << "--with-ecj-jar=#{Formula.factory('ecj').opt_prefix}/share/java/ecj.jar"
end
if build.include? 'enable-multilib'
args << '--enable-multilib'
else
args << '--disable-multilib'
end
mkdir 'build' do
unless MacOS::CLT.installed?
# For Xcode-only systems, we need to tell the sysroot path.
# 'native-system-header's will be appended
args << "--with-native-system-header-dir=/usr/include"
args << "--with-sysroot=#{MacOS.sdk_path}"
end
system '../configure', *args
if build.include? 'enable-profiled-build'
# Takes longer to build, may bug out. Provided for those who want to
# optimise all the way to 11.
system 'make profiledbootstrap'
else
system 'make bootstrap'
end
# 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'
# Remove conflicting manpages in man7
man7.rmtree
end
end
def caveats; <<-EOS.undent
This is a snapshot of GCC trunk, which is in active development and
supposed to have bugs and should not be used in production
environment.
EOS
end
end