-
Notifications
You must be signed in to change notification settings - Fork 0
/
form@4.2.0.rb
64 lines (57 loc) · 1.83 KB
/
form@4.2.0.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
class FormAT420 < Formula
desc "Symbolic manipulation system for very big expressions"
homepage "http://www.nikhef.nl/~form/"
url "https://github.com/vermaseren/form/releases/download/v4.2.0/form-4.2.0.tar.gz"
sha256 "55fb2f69b98e4bd48e365b2245f3d0e22ef0f969d07b1a4aa81b120baf42a2a4"
option "with-debug", "Build also the debug versions"
option "without-test", "Skip build-time tests"
option "with-mpich", "Build also the MPI versions with MPICH"
option "with-open-mpi", "Build also the MPI versions with Open MPI"
depends_on "zlib" => :recommended unless OS.mac?
depends_on "gmp" => :recommended
depends_on "mpich" => :optional
depends_on "open-mpi" => :optional
def normalize_flags(flags)
# Don't use optimization flags given by Homebrew.
return flags if flags.nil?
a = flags.split(" ")
a.delete_if do |item|
item == "-Os" || item == "-w"
end
a.join(" ")
end
def install
ENV["CFLAGS"] = normalize_flags(ENV["CFLAGS"])
ENV["CXXFLAGS"] = normalize_flags(ENV["CXXFLAGS"])
args = [
"--prefix=#{prefix}",
"--program-suffix=-#{version}",
"--disable-dependency-tracking",
"--disable-silent-rules",
]
args << "--enable-debug" if build.with? "debug"
args << "--enable-parform" if build.with?("open-mpi") || build.with?("mpich")
args << "--without-gmp" if build.without? "gmp"
system "./configure", *args
system "make"
system "make", "check" if build.with? "test"
system "make", "install"
end
test do
(testpath/"test.frm").write <<~EOS
Off stats;
Off finalstats;
Off totalsize;
On highfirst;
Symbols a, b;
Local F = (a + b)^2;
Print;
.end
EOS
result = <<-EOS
F =
a^2 + 2*a*b + b^2;
EOS
assert_equal result, pipe_output("#{bin}/form-#{version} -q test.frm")
end
end