Skip to content

Instantly share code, notes, and snippets.

@mcg1969
Last active January 2, 2016 13:49
Show Gist options
  • Save mcg1969/8312801 to your computer and use it in GitHub Desktop.
Save mcg1969/8312801 to your computer and use it in GitHub Desktop.
Preliminary Homebrew formula for Octave 3.8
require 'formula'
class Octave < Formula
homepage 'http://www.gnu.org/software/octave/index.html'
url 'http://ftpmirror.gnu.org/octave/octave-3.8.0.tar.bz2'
mirror 'http://ftp.gnu.org/gnu/octave/octave-3.8.0.tar.bz2'
sha1 'ebb03485b72d97fa01f105460f81016f94680f77'
# This isn't ready yet. But we're getting there.
# head 'http://hydra.nixos.org/job/gnu/octave-default/tarball/latest/download'
skip_clean 'share/info' # Keep the docs
option 'without-check', 'Skip build-time tests (not recommended)'
option 'without-docs', 'Do not build documentation'
option 'without-gui', 'Do not build the experimental GUI'
option 'with-jit', 'Use the experimental JIT support'
option 'without-openblas','Use native LAPACK/BLAS (vecLib)'
option 'without-readline','Do not use the READLINE library (not recommended)'
option 'without-arpack', 'Do not use ARPACK (large-scale eigenvalue dsolver)'
option 'without-curl', 'Do not use cURL (urlread/urlwrite/@ftp)'
option 'without-fftw', 'Do not use FFTW (fft,ifft,fft2,etc.)'
option 'without-opengl', 'Do not use OpenGL graphics'
option 'without-glpk', 'Do not use GLPK'
option 'without-gnuplot', 'Do not use gnuplot graphics'
option 'without-graphicsmagick', 'Do not use GraphicsMagick++ (imread,imwrite)'
option 'without-hdf5', 'Do not use HDF5 (hdf5 data file support)'
option 'without-qhull', 'Do not use the Qhull library (delaunay,voronoi,etc.)'
option 'without-qrupdate','Do not use the QRupdate package (qrdelete,qrinsert,qrshift,qrupdate)'
option 'without-suite-sparse','Do not use SuiteSparse (sparse matrix operations)'
option 'without-zlib', 'Do not use zlib (compressed MATLAB file formats)'
depends_on :fortran
depends_on :x11
depends_on 'pkg-config' => :build
depends_on 'gnu-sed' => :build
depends_on 'texinfo' => :build if build.with? 'docs'
depends_on 'pcre'
depends_on 'openblas' => :recommended
depends_on 'dotwrp' if MacOS.version == :snow_leopard and MacOS.prefer_64_bit and not build.with? 'openblas'
depends_on 'readline' => :recommended
depends_on 'arpack' => :recommended
depends_on 'curl' => :recommended if MacOS.version == :leopard
depends_on 'fftw' => :recommended
depends_on 'fltk' if build.with? 'gui'
depends_on 'fontconfig' if build.with? 'opengl'
depends_on 'freetype' if build.with? 'opengl'
depends_on 'glpk' => :recommended
# Someone will need to make a formula for this
# depends_on 'gp2ps' if build.with? 'opengl'
depends_on 'gnuplot' => :recommended
depends_on 'graphicsmagick' => :recommended
depends_on 'hdf5' => :recommended
depends_on 'llvm' if build.with? 'jit'
depends_on 'qhull' => :recommended
depends_on 'qrupdate' => :recommended
depends_on 'qscintilla2' if build.with? 'gui'
depends_on 'qt' if build.with? 'gui'
depends_on 'suite-sparse' => :recommended
def blas_flags
if build.with? 'openblas'
flags = "-L#{Formula.factory('openblas').lib} -lopenblas"
elsif MacOS.version == :snow_leopard and MacOS.prefer_64_bit?
flags = "-ldotwrp"
else
flags = ""
end
end
def patches
[
# Allows libtool to recognize framework paths via the -F flag
"https://gist.github.com/mcg1969/8328474/raw/octave-libtool.diff",
# Allows configure to *find* those frameworks
"https://gist.github.com/mcg1969/8328356/raw/octave-configure.diff",
# Fixes a known bug in jit-typeinfo.{cc,h} for the clang compiler
"https://gist.github.com/mcg1969/8328094/raw/jit-typeinfo.diff"
]
end unless build.head?
def install
ENV.m64 if MacOS.prefer_64_bit?
ENV.append_to_cflags "-D_REENTRANT"
args = [
'--disable-dependency-tracking',
"--prefix=#{prefix}"
]
args << '--without-framework-carbon' if MacOS.version >= :lion
# avoid spurious 'invalid assignment to cs-list' erorrs on 32 bit installs:
# args << 'CXXFLAGS=-O0' unless MacOS.prefer_64_bit?
args << "--disable-docs" if build.without? 'docs'
args << "--disable-readline" if build.without? 'readline'
# --without-arpack?
args << "--without-curl" if build.without? 'curl'
args << "--without-fftw3" if build.without? 'fftw'
args << "--disable-gui" if build.without? 'gui'
args << "--without-opengl" if build.without? 'opengl'
args << "--without-glpk" if build.without? 'glpk'
args << "--without-hdf5" if build.without? 'hdf5'
args << "--disable-jit" if build.without? 'jit'
args << "--without-qhull" if build.without? 'qhull'
args << "--without-qrupdate" if build.without? 'qrupdate'
args << "--without-amd" if build.without? 'suite-sparse'
args << "--without-camd" if build.without? 'suite-sparse'
args << "--without-colamd" if build.without? 'suite-sparse'
args << "--without-ccolamd" if build.without? 'suite-sparse'
args << "--without-cxsparse" if build.without? 'suite-sparse'
args << "--without-camd" if build.without? 'suite-sparse'
args << "--without-cholmod" if build.without? 'suite-sparse'
args << "--without-umfpack" if build.without? 'suite-sparse'
args << "--without-zlib" if build.without? 'zlib'
args << "--with-blas=#{blas_flags}" if blas_flags != ""
args << "--with-lapack=#{blas_flags}" if blas_flags != ""
args << '--disable-jit' if build.without? 'llvm'
args << '--disable-docs' if build.without? 'docs'
args << '--without-opengl' if build.without? 'fltk'
args << '--disable-gui' if build.without? 'qt'
system "./configure", *args
system "make all"
system "make check 2>&1 | tee make-check.log" if build.with? 'check'
system "make install"
prefix.install ["test/fntests.log", "make-check.log"] if build.with? 'check'
end
def caveats
gnuplot_caveats = <<-EOS.undent
When using the gnuplot plotting engine, you should set "GNUTERM=x11" before
running octave; if your are using Aquaterm, use "GNUTERM=aqua".
EOS
native_caveats = <<-EOS.undent
Octave now enables "native" plotting using OpenGL/FLTK by default. If you
prefer gnuplot, you can activate it for all future figures with the command
graphics_toolkit ("gnuplot")
or for a specific figure handle h using
graphics_toolkit (h,"gnuplot")
EOS
gui_caveats = <<-EOS.undent
The Octave GUI is experimental and not enabled by default. To use it, use the
command-line argument "--force-gui"; e.g.,
octave --force-gui
EOS
qscintilla_caveats = <<-EOS.undent
Octave was built without QScintilla2 support, which means that the GUI editor
is not operational.
EOS
s = ''
s = s + native_caveats if build.with? 'fltk'
s = s + gnuplot_caveats if build.with? 'gnuplot'
s = s + gui_caveats if build.with? 'qt'
s = s + qscintilla_caveats if build.with? 'qt' and build.without? 'qscintilla2'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment