-
-
Notifications
You must be signed in to change notification settings - Fork 12.5k
/
octave.rb
169 lines (148 loc) · 5.62 KB
/
octave.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
class Octave < Formula
desc "High-level interpreted language for numerical computing"
homepage "https://octave.org/index.html"
url "https://ftp.gnu.org/gnu/octave/octave-9.2.0.tar.xz"
mirror "https://ftpmirror.gnu.org/octave/octave-9.2.0.tar.xz"
sha256 "21417afb579105b035cac0bea09201522e384893ae90a781b8727efa32765807"
license "GPL-3.0-or-later"
revision 2
# New tarballs appear on https://ftp.gnu.org/gnu/octave/ before a release is
# announced, so we check the octave.org download page instead.
livecheck do
url "https://octave.org/download"
regex(%r{Octave\s+v?(\d+(?:\.\d+)+)(?:\s*</[^>]+?>)?\s+is\s+the\s+latest\s+stable\s+release}im)
end
bottle do
sha256 arm64_sonoma: "6db0a9b4e3effce4a3f10f50a0b6b4fb721693ca517d409ffa0bf28e4aa5132e"
sha256 arm64_ventura: "ff75d2805a738e47e7624fec50d4fe25f78c17b35a62a21cc22de00d96b8120e"
sha256 sonoma: "dd39ccca52e34d7acf3b6a9c377f475efbd5b6c6a3ae739bf81627c76bb0363e"
sha256 ventura: "aeb0606c1ce997c84736fb63eaec9cff8f7ac29819b76db50f0d228fa436529c"
sha256 x86_64_linux: "752410d834abe564286d7fcfe6f6915d27866d56b760c0869d1c61b44c1bf8fa"
end
head do
url "https://hg.savannah.gnu.org/hgweb/octave", branch: "default", using: :hg
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "bison" => :build
depends_on "icoutils" => :build
depends_on "librsvg" => :build
end
# Complete list of dependencies at https://wiki.octave.org/Building
depends_on "gnu-sed" => :build # https://lists.gnu.org/archive/html/octave-maintainers/2016-09/msg00193.html
depends_on "openjdk" => :build
depends_on "pkgconf" => :build
depends_on "arpack"
depends_on "epstool"
depends_on "fftw"
depends_on "fig2dev"
depends_on "fltk"
depends_on "fontconfig"
depends_on "freetype"
depends_on "gcc" # for gfortran
depends_on "ghostscript"
depends_on "gl2ps"
depends_on "glpk"
depends_on "graphicsmagick"
depends_on "hdf5"
depends_on "libsndfile"
depends_on "libtool"
depends_on "openblas"
depends_on "pcre2"
depends_on "portaudio"
depends_on "pstoedit"
depends_on "qhull"
depends_on "qrupdate"
depends_on "qscintilla2"
depends_on "qt"
depends_on "rapidjson"
depends_on "readline"
depends_on "suite-sparse"
depends_on "sundials"
depends_on "texinfo"
uses_from_macos "bzip2"
uses_from_macos "curl"
uses_from_macos "zlib"
on_macos do
depends_on "little-cms2"
end
on_linux do
depends_on "autoconf"
depends_on "automake"
depends_on "mesa"
depends_on "mesa-glu"
end
# Dependencies use Fortran, leading to spurious messages about GCC
cxxstdlib_check :skip
def install
# Default configuration passes all linker flags to mkoctfile, to be
# inserted into every oct/mex build. This is unnecessary and can cause
# cause linking problems.
inreplace "src/mkoctfile.in.cc",
/%OCTAVE_CONF_OCT(AVE)?_LINK_(DEPS|OPTS)%/,
'""'
ENV.prepend_path "PKG_CONFIG_PATH", Formula["qt"].opt_libexec/"lib/pkgconfig" if OS.mac?
system "./bootstrap" if build.head?
args = [
"--disable-silent-rules",
"--enable-shared",
"--disable-static",
"--with-hdf5-includedir=#{Formula["hdf5"].opt_include}",
"--with-hdf5-libdir=#{Formula["hdf5"].opt_lib}",
"--with-java-homedir=#{Formula["openjdk"].opt_prefix}",
"--with-x=no",
"--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas",
"--with-portaudio",
"--with-sndfile",
]
if OS.linux?
# Explicitly specify aclocal and automake without versions
args << "ACLOCAL=aclocal"
args << "AUTOMAKE=automake"
# Mesa OpenGL location must be supplied by LDFLAGS on Linux
args << "LDFLAGS=-L#{Formula["mesa"].opt_lib} -L#{Formula["mesa-glu"].opt_lib}"
# Docs building is broken on Linux
args << "--disable-docs"
# Need to regenerate aclocal.m4 so that it will work with brewed automake
system "aclocal"
end
system "./configure", *args, *std_configure_args
# https://github.com/Homebrew/homebrew-core/pull/170959#issuecomment-2351023470
ENV.deparallelize do
system "make", "all"
end
# Avoid revision bumps whenever fftw's, gcc's or OpenBLAS' Cellar paths change
inreplace "src/mkoctfile.cc" do |s|
s.gsub! Formula["fftw"].prefix.realpath, Formula["fftw"].opt_prefix
s.gsub! Formula["gcc"].prefix.realpath, Formula["gcc"].opt_prefix
end
# Make sure that Octave uses the modern texinfo at run time
rcfile = buildpath/"scripts/startup/site-rcfile"
rcfile.append_lines "makeinfo_program(\"#{Formula["texinfo"].opt_bin}/makeinfo\");"
system "make", "install"
end
test do
ENV["LC_ALL"] = "en_US.UTF-8"
system bin/"octave", "--eval", "(22/7 - pi)/pi"
# This is supposed to crash octave if there is a problem with BLAS
system bin/"octave", "--eval", "single ([1+i 2+i 3+i]) * single ([ 4+i ; 5+i ; 6+i])"
# Test basic compilation
(testpath/"oct_demo.cc").write <<~EOS
#include <octave/oct.h>
DEFUN_DLD (oct_demo, args, /*nargout*/, "doc str")
{ return ovl (42); }
EOS
system bin/"octave", "--eval", <<~EOS
mkoctfile ('-v', '-std=c++11', '-L#{lib}/octave/#{version}', 'oct_demo.cc');
assert(oct_demo, 42)
EOS
# Test FLIBS environment variable
system bin/"octave", "--eval", <<~EOS
args = strsplit (mkoctfile ('-p', 'FLIBS'));
args = args(~cellfun('isempty', args));
mkoctfile ('-v', '-std=c++11', '-L#{lib}/octave/#{version}', args{:}, 'oct_demo.cc');
assert(oct_demo, 42)
EOS
ENV["QT_QPA_PLATFORM"] = "minimal"
system bin/"octave", "--gui"
end
end