forked from adestefan/homebrew-headonly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
f2c.rb
46 lines (38 loc) · 1.04 KB
/
f2c.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
require 'formula'
class F2c < Formula
homepage 'http://www.netlib.org/f2c/'
head 'http://netlib.sandia.gov/cgi-bin/netlib/netlibfiles.tar?filename=netlib/f2c'
def install
system "unzip", "libf2c.zip", "-d", "libf2c"
# f2c header and libf2c.a
cd "libf2c" do
system "make", "-f", "makefile.u", "f2c.h"
include.install "f2c.h"
system "make", "-f", "makefile.u"
lib.install "libf2c.a"
end
# f2c executable
cd "src" do
system "make", "-f", "makefile.u", "f2c"
bin.install "f2c"
end
# man pages
man1.install "f2c.1t"
end
test do
# check if executable doesn't error out
system "#{bin}/f2c", "--version"
# hello world test
(testpath/"test.f").write <<-EOS.undent
C comment line
program hello
print*, 'hello world'
stop
end
EOS
system "#{bin}/f2c", "test.f"
assert (testpath/"test.c").exist?
system "cc", "-O", "-o", "test", "test.c", "-lf2c"
assert_equal " hello world\n", `#{testpath}/test`
end
end