-
Notifications
You must be signed in to change notification settings - Fork 4
/
cutest.rb
184 lines (164 loc) · 5.9 KB
/
cutest.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
class Cutest < Formula
desc "Constrained and Unconstrained Testing Environment on steroids"
homepage "https://github.com/ralna/CUTEst/wiki"
url "https://github.com/ralna/CUTEst/archive/refs/tags/v2.1.0.tar.gz"
sha256 "83557557a8c6b174e817116ddc056f4a321bc6651719b25925fff399e44b5997"
revision 3
head "https://github.com/ralna/CUTEst.git"
bottle do
root_url "https://github.com/optimizers/homebrew-cutest/releases/download/cutest-2.1.0_3"
sha256 cellar: :any, arm64_sonoma: "75e848b0c872ce2947febaa7b973cbcec49f0150b87c980e8596b89feb7bdb8f"
sha256 cellar: :any, ventura: "02f2b5957d31ad4173717c41ef61073974829a0acb6dd1e710a3d78b9192499c"
sha256 cellar: :any_skip_relocation, x86_64_linux: "665c42d63b12a621abb8adb708a084dc117858978936744d3e879ab921013da6"
end
option "with-matlab", "Compile with Matlab support"
option "without-single", "Compile without single support"
option "without-quadruple", "Compile without quadruple support"
depends_on "gcc"
depends_on "optimizers/cutest/archdefs"
depends_on "optimizers/cutest/gsl@1"
depends_on "optimizers/cutest/sifdecode"
env :std
patch :DATA
def install
toolset = build.with?("matlab") ? "1" : "2"
single = build.with?("single") ? "y" : "n"
quadruple = build.with?("quadruple") ? "y" : "n"
precisions = ["double"]
build.with?("single") && precisions.append("single")
build.with?("quadruple") && precisions.append("quadruple")
if OS.mac?
machine, key = Hardware::CPU.is_64_bit? ? %w[mac64 2] : %w[mac 4]
arch = "osx"
fcomp = "4"
ccomp = "3"
Pathname.new("cutest.input").write <<~EOF
#{key}
n#{fcomp}
#{toolset}
#{ccomp}
nnyd#{single}#{quadruple}
EOF
else
machine = "pc64"
arch = "lnx"
fcomp = "8"
ccomp = "7"
Pathname.new("cutest.input").write <<~EOF
1
1
n#{fcomp}
#{toolset}
#{ccomp}
nnyd#{single}#{quadruple}
EOF
end
ENV["ARCHDEFS"] = Formula["archdefs"].opt_libexec
ENV["SIFDECODE"] = Formula["sifdecode"].opt_libexec
ENV.deparallelize do
system "./install_cutest < cutest.input"
end
# Build shared libraries.
if OS.mac?
so = "dylib"
all_load = ["-Wl,-all_load"]
noall_load = []
extra = ["-Wl,-undefined", "-Wl,dynamic_lookup", "-headerpad_max_install_names"]
else
so = "so"
all_load = ["-Wl,-whole-archive"]
noall_load = ["-Wl,-no-whole-archive"]
extra = []
end
compiler = "gfo"
precisions.each do |prec|
cd "objects/#{machine}.#{arch}.#{compiler}/#{prec}" do
Dir["*.a"].each do |l|
lname = File.basename(l, ".a") + "_#{prec}.#{so}"
system "gfortran", "-fPIC", "-shared", *all_load, l, *noall_load, "-o", lname, *extra
end
end
end
# We only want certain links in /usr/local/bin.
libexec.install Dir["*"]
%w[cutest2matlab_osx runcutest].each do |f|
bin.install_symlink "#{libexec}/bin/#{f}"
end
include.install_symlink Dir["#{libexec}/include/*.h"]
man1.install_symlink Dir["#{libexec}/man/man1/*.1"]
man3.install_symlink Dir["#{libexec}/man/man3/*.3"]
doc.install_symlink Dir["#{libexec}/doc/README*"], "#{libexec}/doc/pdf"
lib.install_symlink "#{libexec}/objects/#{machine}.#{arch}.#{compiler}/double/libcutest.a"
lib.install_symlink "#{libexec}/objects/#{machine}.#{arch}.#{compiler}/double/libcutest_double.#{so}"
ln_sf "#{libexec}/objects/#{machine}.#{arch}.#{compiler}/double/libcutest.a", "#{lib}/libcutest_double.a"
ln_sf "#{libexec}/objects/#{machine}.#{arch}.#{compiler}/double/libcutest_double.#{so}", "#{lib}/libcutest.#{so}"
if build.with? "single"
ln_sf "#{libexec}/objects/#{machine}.#{arch}.#{compiler}/single/libcutest.a", "#{lib}/libcutest_single.a"
ln_sf "#{libexec}/objects/#{machine}.#{arch}.#{compiler}/single/libcutest_single.#{so}",
"#{lib}/libcutest_single.#{so}"
end
if build.with? "quadruple"
ln_sf "#{libexec}/objects/#{machine}.#{arch}.#{compiler}/quadruple/libcutest.a", "#{lib}/libcutest_quadruple.a"
ln_sf "#{libexec}/objects/#{machine}.#{arch}.#{compiler}/quadruple/libcutest_quadruple.#{so}",
"#{lib}/libcutest_quadruple.#{so}"
end
s = <<~EOS
export CUTEST=#{opt_libexec}
EOS
if build.with? "matlab"
s += <<~EOS
export MYMATLABARCH=#{machine}.#{arch}.#{compiler}
export MATLABPATH=$MATLABPATH:#{opt_libexec}/src/matlab
EOS
end
(prefix/"cutest.bashrc").write(s)
(prefix/"cutest.machine").write <<~EOF
#{machine}
#{arch}
#{compiler}
EOF
end
def caveats
s = <<~EOS
In your ~/.bashrc, add
. #{prefix}/cutest.bashrc
EOS
if build.with? "matlab"
s += <<~EOS
export MYMATLAB=/path/to/your/matlab
Please also look at
#{share}/doc/README.osx
to set up your ~/.mexopts.sh.
EOS
end
s
end
test do
machine, arch, compiler = File.read(opt_prefix/"cutest.machine").split
ENV["ARCHDEFS"] = Formula["archdefs"].opt_libexec
ENV["SIFDECODE"] = Formula["sifdecode"].opt_libexec
ENV["CUTEST"] = opt_libexec
ENV["MYARCH"] = "#{machine}.#{arch}.#{compiler}"
ENV["MASTSIF"] = "#{opt_libexec}/sif"
cd testpath do
%w[gen77 gen90 genc].each do |pkg|
system "#{bin}/runcutest", "-p", pkg, "-D", "ROSENBR.SIF"
system "#{bin}/runcutest", "-p", pkg, "-sp", "-D", "ROSENBR.SIF" if build.with? "single"
end
end
end
end
__END__
diff --git a/bin/install_cutest_alone b/bin/install_cutest_alone
index a7edfde..cc8474b 100755
--- a/bin/install_cutest_alone
+++ b/bin/install_cutest_alone
@@ -372,8 +372,8 @@ if [[ -e $CUTEST/versions/$VERSION ]]; then
[[ $? == 0 ]] && exit 4
fi
-MATLABGCC="gcc-4.3"
-MATLABGFORTRAN="gfortran-4.3"
+MATLABGCC="gcc"
+MATLABGFORTRAN="gfortran"
matlab=""
#echo $CMP