2010-06-28 21:21:19 +00:00
|
|
|
require 'formula'
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Gfortran < Formula
|
2012-11-09 15:58:31 +00:00
|
|
|
homepage 'http://gcc.gnu.org/wiki/GFortran'
|
2013-10-16 18:49:51 +00:00
|
|
|
url 'http://ftpmirror.gnu.org/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2'
|
|
|
|
mirror 'http://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2'
|
|
|
|
sha1 '810fb70bd721e1d9f446b6503afe0a9088b62986'
|
2013-06-03 21:50:40 +00:00
|
|
|
|
2013-10-16 23:03:18 +00:00
|
|
|
bottle do
|
|
|
|
sha1 '4bf29afb128791de733e10f3000bcd479a9e3808' => :mountain_lion
|
|
|
|
sha1 '9814a52f73882e801a92b8bea20ae9475d389306' => :lion
|
|
|
|
sha1 '7d7b7d79b973ff32824d442a79c22a8c2d455467' => :snow_leopard
|
|
|
|
end
|
|
|
|
|
2012-12-24 16:57:50 +00:00
|
|
|
option 'enable-profiled-build', 'Make use of profile guided optimization when bootstrapping GCC'
|
|
|
|
option 'check', 'Run the make check fortran. This is for maintainers.'
|
2013-07-01 03:48:53 +00:00
|
|
|
option 'enable-multilib', 'Build with multilib support' if MacOS.prefer_64_bit?
|
2012-12-24 16:57:50 +00:00
|
|
|
|
2012-11-09 15:58:31 +00:00
|
|
|
depends_on 'gmp'
|
|
|
|
depends_on 'libmpc'
|
|
|
|
depends_on 'mpfr'
|
2013-04-23 18:03:56 +00:00
|
|
|
depends_on 'cloog'
|
|
|
|
depends_on 'isl'
|
2010-06-28 21:21:19 +00:00
|
|
|
|
2012-12-24 16:57:50 +00:00
|
|
|
# http://gcc.gnu.org/install/test.html
|
|
|
|
depends_on 'dejagnu' if build.include? 'check'
|
2012-11-09 15:58:31 +00:00
|
|
|
|
2010-06-28 21:21:19 +00:00
|
|
|
def install
|
2012-11-09 15:58:31 +00:00
|
|
|
# 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
|
|
|
|
gfortran_prefix = prefix/'gfortran'
|
2010-08-27 00:42:43 +00:00
|
|
|
|
2012-11-09 15:58:31 +00:00
|
|
|
args = [
|
|
|
|
# Sandbox everything...
|
|
|
|
"--prefix=#{gfortran_prefix}",
|
|
|
|
# ...except the stuff in share...
|
|
|
|
"--datarootdir=#{share}",
|
|
|
|
# ...and the binaries...
|
|
|
|
"--bindir=#{bin}",
|
2013-04-23 18:03:56 +00:00
|
|
|
"--enable-languages=fortran",
|
2012-11-09 15:58:31 +00:00
|
|
|
"--with-system-zlib",
|
|
|
|
# ...opt_prefix survives upgrades and works even if `brew unlink gmp`
|
|
|
|
"--with-gmp=#{Formula.factory('gmp').opt_prefix}",
|
|
|
|
"--with-mpfr=#{Formula.factory('mpfr').opt_prefix}",
|
|
|
|
"--with-mpc=#{Formula.factory('libmpc').opt_prefix}",
|
2013-04-23 18:03:56 +00:00
|
|
|
"--with-cloog=#{Formula.factory('cloog').opt_prefix}",
|
|
|
|
"--with-isl=#{Formula.factory('isl').opt_prefix}",
|
2013-09-01 06:34:07 +00:00
|
|
|
# ...and disable isl and cloog version checks in case they upgrade
|
|
|
|
"--disable-cloog-version-check",
|
|
|
|
"--disable-isl-version-check",
|
2012-11-09 15:58:31 +00:00
|
|
|
# ...we build the stage 1 gcc with clang (which is know to fail checks)
|
|
|
|
"--enable-checking=release",
|
|
|
|
"--disable-stage1-checking",
|
2013-09-01 06:34:07 +00:00
|
|
|
# ...speed up build by stop building libstdc++-v3
|
|
|
|
"--disable-libstdcxx",
|
|
|
|
"--enable-lto",
|
2012-11-09 15:58:31 +00:00
|
|
|
# ...disable translations avoid conflict with brew install gcc --enable-nls
|
|
|
|
'--disable-nls'
|
|
|
|
]
|
2010-08-27 00:42:43 +00:00
|
|
|
|
2013-06-30 22:34:34 +00:00
|
|
|
# https://github.com/mxcl/homebrew/issues/19584#issuecomment-19661219
|
2013-07-01 03:48:53 +00:00
|
|
|
if build.include? 'enable-multilib' and MacOS.prefer_64_bit?
|
|
|
|
args << '--enable-multilib'
|
|
|
|
else
|
|
|
|
args << '--disable-multilib'
|
2013-06-30 22:34:34 +00:00
|
|
|
end
|
|
|
|
|
2012-11-09 15:58:31 +00:00
|
|
|
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
|
|
|
|
|
2013-04-23 18:03:56 +00:00
|
|
|
system '../configure', *args
|
2011-11-29 23:08:34 +00:00
|
|
|
|
2012-11-09 15:58:31 +00:00
|
|
|
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'
|
2011-11-29 23:08:34 +00:00
|
|
|
end
|
2012-11-09 15:58:31 +00:00
|
|
|
|
|
|
|
system "make"
|
|
|
|
system "make check-fortran" if build.include? 'check'
|
|
|
|
system 'make install'
|
2010-06-28 21:21:19 +00:00
|
|
|
end
|
2012-01-06 19:52:25 +00:00
|
|
|
|
2012-11-09 15:58:31 +00:00
|
|
|
# This package installs a whole GCC suite. Removing non-fortran components:
|
2013-11-04 16:33:00 +00:00
|
|
|
bin.children.reject{ |p| p.basename.to_s.match(/gfortran/) }.each(&:unlink)
|
|
|
|
info.children.reject{ |p| p.basename.to_s.match(/gfortran/) }.each(&:unlink)
|
|
|
|
man1.children.reject{ |p| p.basename.to_s.match(/gfortran/) }.each(&:unlink)
|
2013-04-23 18:03:56 +00:00
|
|
|
man7.rmtree # dupes: fsf fundraising and gpl
|
2012-11-09 15:58:31 +00:00
|
|
|
# (share/'locale').rmtree
|
2013-04-23 18:03:56 +00:00
|
|
|
(share/"gcc-#{version}").rmtree # dupes: libstdc++ pretty printer, will be added by gcc* formula
|
2012-11-09 15:58:31 +00:00
|
|
|
end
|
|
|
|
|
2013-02-02 05:12:35 +00:00
|
|
|
test do
|
|
|
|
fixture = <<-EOS.undent
|
|
|
|
integer,parameter::m=10000
|
|
|
|
real::a(m), b(m)
|
|
|
|
real::fact=0.5
|
|
|
|
|
|
|
|
do concurrent (i=1:m)
|
|
|
|
a(i) = a(i) + fact*b(i)
|
|
|
|
end do
|
|
|
|
print *, "done"
|
|
|
|
end
|
|
|
|
EOS
|
|
|
|
Pathname('in.f90').write(fixture)
|
|
|
|
system "#{bin}/gfortran -c in.f90"
|
|
|
|
system "#{bin}/gfortran -o test in.o"
|
2013-06-09 02:26:19 +00:00
|
|
|
assert_equal 'done', `./test`.strip
|
2010-06-28 21:21:19 +00:00
|
|
|
end
|
|
|
|
|
2011-03-10 19:23:42 +00:00
|
|
|
def caveats; <<-EOS.undent
|
2013-06-24 03:29:13 +00:00
|
|
|
Brews that require a Fortran compiler should use:
|
|
|
|
depends_on :fortran
|
2011-11-29 23:08:34 +00:00
|
|
|
EOS
|
2010-06-28 21:21:19 +00:00
|
|
|
end
|
|
|
|
end
|