# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 147594 2016-04-09 13:44:38Z khindenburg@macports.org $
PortSystem 1.0
PortGroup compilers 1.0
PortGroup muniversal 1.0
PortGroup active_variants 1.1
PortGroup select 1.0
name octave-devel
categories math science
platforms darwin
license GPL-3+
maintainers mcalhoun openmaintainer
description a high-level language for numerical computations
long_description \
GNU Octave is a high-level language, primarily intended for numerical \
computations. It provides a convenient command line interface for \
solving linear and nonlinear problems numerically.
homepage http://www.gnu.org/software/octave
#fetch.type hg
#hg.url http://hg.savannah.gnu.org/hgweb/octave/
set version_release 4.0.0
set version_rc 4.0.1-rc4
set version_tip 4.1.0+
if { ${name} eq ${subport} } {
version ${version_tip}
revision 8
hg.tag 2868abbc88eb
# see http://savannah.gnu.org/bugs/?41027
patchfiles-append \
octave-bug_41027-half.patch
checksums-append \
${hg.tag}${extract.suffix} \
rmd160 0a5fd063e2587d451a1c8bde668e1c9b542d5fde \
sha256 58b725674c43ea866c87235da7e7c9a75e9629b3215908c0c8c20aa60ee818b4
livecheck.regex "\ntip"
}
subport octave-devel-rc {
version ${version_rc}
revision 4
hg.tag 2b66f30a0de7
if {${version_rc} eq ${version_release}} {
conflicts-append octave-devel-release
}
# see http://savannah.gnu.org/bugs/?func=detailitem&item_id=46592
patchfiles-append \
patch-e870a68742a6.diff
# see http://savannah.gnu.org/bugs/?41027
patchfiles-append \
octave-bug_41027.patch
checksums-append \
${hg.tag}${extract.suffix} \
rmd160 4bf919790f28f21752381e127cf55b3a5f4d7344 \
sha256 4785967cff091dddd7d82dbbd094658a39ad26d4a7219abc1f1bbc4fe696d43a
livecheck.regex "\nrc-"
}
subport octave-devel-release {
version ${version_release}
revision 7
hg.tag 3ccc2d02e64b
if {${version_release} eq ${version_rc}} {
conflicts-append octave-devel-release
}
# see http://savannah.gnu.org/bugs/?41178
patchfiles-append \
octave-clang-classdef.patch
# see http://savannah.gnu.org/bugs/?func=detailitem&item_id=46592
patchfiles-append \
patch-e870a68742a6.diff
# allow osmesa support to at least compile
patchfiles-append \
osmesa_mac_fix.patch
# force "${prefix}/bin/octave-${version} --no-gui-libs" to call octave-cli-${version} instead of octave-cli
patchfiles-append \
patch-append_version_cli.diff
# see http://savannah.gnu.org/bugs/?41027
patchfiles-append \
octave-bug_41027.patch
checksums-append \
${hg.tag}${extract.suffix} \
rmd160 4bbcc004ffdde859b0735e602aac2d01388d0b2c \
sha256 2a4017a03ca80c280b5d39cf88af8954c7bfdbf1b3b40b9f09d3bd4bd1dd6040
livecheck.regex "\nrelease-"
}
select.group octave
select.file ${filespath}/${subport}
# check http://hg.savannah.gnu.org/hgweb/octave/gnulib-hg/rev for latest version
set hg_gnu_tag 7f19e7f2afa2
checksums-append \
${hg_gnu_tag}${extract.suffix} \
rmd160 9d906212fdb4201f8592da10524606dadb3f50e3 \
sha256 85add8ce0c53e8868d903c28c407d864ca54bd42e8d472e09b1a1bb4b105b741
master_sites http://hg.savannah.gnu.org/hgweb/octave/archive:octave \
http://hg.savannah.gnu.org/hgweb/octave/gnulib-hg/archive:gnulib
distfiles \
${hg.tag}${extract.suffix}:octave \
${hg_gnu_tag}${extract.suffix}:gnulib
worksrcdir octave-${hg.tag}
#depends_extract-append port:git
post-extract {
# command from bootstrap script file
#system -W ${worksrcpath} "${prefix}/bin/git clone --depth 2 git://git.sv.gnu.org/gnulib gnulib-hg"
move ${worksrcpath}/../gnulib-hg-${hg_gnu_tag} ${worksrcpath}/gnulib-hg
}
# see http://git.savannah.gnu.org/cgit/gnulib.git/commit/lib/stdio.in.h?id=d6176702c3ffb6c56e6620397470e1b3bd540b10
patchfiles-append \
patch-stdio.in.h.diff
pre-patch {
# code located in pre-patch because variants from PortGroup compilers must
# be evaluated before it can be determined if clang is being used
# see http://trac.macports.org/ticket/45011
# see http://savannah.gnu.org/bugs/?43298
set libcxxbug no
if { ${configure.cc} eq "/usr/bin/clang" && [lindex [split ${xcodeversion} .] 0] eq 6 } {
set libcxxbug yes
} elseif { [variant_exists clang35] && [variant_isset clang35] } {
set libcxxbug yes
}
if { ${libcxxbug} } {
patchfiles-append \
clang-libcxx-fix.patch
}
}
# need for autoconf
depends_build-append \
port:autoconf \
port:automake \
port:libtool
use_autoconf yes
autoconf.cmd ./bootstrap
autoconf.args
# avoid depends_build-append port:coreutils
configure.env-append MKDIR_P="/bin/mkdir -p"
# avoid depends_build-append port:cctools
configure.env-append RANLIB=/usr/bin/ranlib
# main octave port lists as a depends_lib
# configure.ac list it among the "[p]rograms used in Makefiles"
depends_build-append port:gawk
configure.awk ${prefix}/bin/gawk
# in configure.ac, said to be "[p]rograms used to generate icons file formats
depends_build-append \
port:icoutils \
port:librsvg
configure.env-append \
ICOTOOL=${prefix}/bin/icotool \
RSVG_CONVERT=${prefix}/bin/rsvg-convert
# main octave port lists as a depends_lib
# configure.ac list it among the "[p]rograms used in Makefiles"
depends_build-append port:grep
configure.env-append GREP=${prefix}/bin/grep
configure.env-append EGREP=${prefix}/bin/egrep
configure.env-append FGREP=${prefix}/bin/fgrep
# configure.ac list it among the "[p]rograms used in Makefiles"
depends_build-append port:findutils
configure.env-append FIND=${prefix}/bin/gfind
# main octave port lists as a depends_lib
# configure.ac list it among the "[p]rograms used in Makefiles"
depends_build-append port:gsed
configure.env-append SED=${prefix}/bin/gsed
depends_build-append port:flex
configure.env-append LEX=${prefix}/bin/flex
depends_build-append port:bison
configure.env-append YACC="${prefix}/bin/bison -y"
depends_build-append port:gperf
configure.env-append GPERF=/usr/bin/gperf
# configure.ac list it among the "[p]rograms used in Makefiles"
depends_build-append port:perl5
configure.perl ${prefix}/bin/perl5
# avoid depends_build-append port:desktop-file-utils
#configure.env-append DESKTOP_FILE_INSTALL=""
configure.env-append ac_cv_prog_DESKTOP_FILE_INSTALL=""
depends_build-append \
port:pkgconfig
compilers.choose fc f77 f90 cc cxx
# for now, limit the number of variants
# some of these compilers may work fine
compilers.setup \
require_fortran \
-dragonegg \
-gcc49 \
-gcc48 \
-gcc46 \
-gcc45 \
-gcc44 \
-g95 \
-llvm \
-gcc47 \
-gcc46 \
-gcc45 \
-gcc44 \
-clang36 \
-clang35 \
-clang34 \
-clang33
# help prevent conflicts with various octave ports
configure.args-append \
--infodir=${prefix}/share/info/octave_${version}
# offscreen rendering with OpenGL via osmesa would be nice to have, but the following
# causes a segmentation fault:
# h = figure ("visible", "off"); fn = tempname (); sombrero (); __osmesa_print__ (h, fn, "svg");
#
# solution is ???
#
#depends_lib-append port:mesa
configure.args-append \
--without-OSMesa
#configure.args-append --with-shell=???
configure.args-append \
--with-framework-opengl \
--with-framework-carbon \
--without-x \
--enable-static
configure.args-append \
--disable-openmp
configure.args-append \
--disable-java \
--disable-gui \
--without-fltk \
--disable-jit \
--without-sndfile \
--without-portaudio \
--without-magick \
--disable-docs
# in configure.ac, listed as one of "[p]rograms used when running Octave"
depends_lib-append port:python27
configure.python ${prefix}/bin/python2.7
# in configure.ac, listed as one of "[p]rograms used when running Octave"
depends_lib-append port:ghostscript
configure.env-append GHOSTSCRIPT=${prefix}/bin/gs
# in configure.ac, listed as one of "[p]rograms used when running Octave"
depends_lib-append port:gnuplot
configure.env-append GNUPLOT=${prefix}/bin/gnuplot
# in configure.ac, listed as one of "[p]rograms used when running Octave"
depends_lib-append port:less
configure.env-append DEFAULT_PAGER=${prefix}/bin/less
depends_lib-append port:ncurses
depends_lib-append port:readline
depends_lib-append port:fontconfig
depends_lib-append port:pcre
#--without-amd
#--without-camd
#--without-colamd
#--without-cholmod
#--without-cxsparse
#--without-umfpack
depends_lib-append port:SuiteSparse
foreach lib {amd camd colamd cholmod cxsparse umfpack} {
configure.args-append \
--with-${lib}="-l${lib} -lsuitesparseconfig"
}
#--without-qhull
depends_lib-append port:qhull
#--without-z
depends_lib-append port:zlib
#--without-hdf5
depends_lib-append port:hdf5
#--disable-fftw-threads
#--without-fftw3
#--without-fftw3f
depends_lib-append port:fftw-3
depends_lib-append port:fftw-3-single
#--without-glpk
depends_lib-append port:glpk
#--without-curl
depends_lib-append port:curl
#--without-qrupdate
depends_lib-append port:qrupdate
#--without-arpack
depends_lib-append port:arpack
#--without-openssl
depends_lib-append port:openssl
# fortran arch flag is not set automatically
if {![variant_isset universal]} {
if {${build_arch} eq "x86_64" || ${build_arch} eq "ppc64"} {
configure.fflags-append -m64
} else {
configure.fflags-append -m32
}
}
# see etc/README.MacOS
depends_run-append \
port:epstool \
port:ghostscript \
port:transfig \
port:pstoedit
depends_run-append port:octave_select
variant accelerate description {use BLAS from Apple's Accelerate.framework} conflicts atlas openblas {
depends_lib-append port:vecLibFort
# dependents must be built with same BLAS and LAPACK
#require_active_variants port:arpack accelerate
#require_active_variants port:SuiteSparse accelerate
#require_active_variants port:qrupdate accelerate
configure.args-append \
--with-blas=-lvecLibFort \
--with-lapack=""
}
variant openblas description {use BLAS from MacPorts' openblas port} conflicts atlas accelerate {
depends_lib-append path:lib/libopenblas.dylib:OpenBLAS
# LAPACK required
require_active_variants path:lib/libopenblas.dylib:OpenBLAS lapack
# dependents must be built with same BLAS and LAPACK
#require_active_variants port:arpack openblas
#require_active_variants port:SuiteSparse openblas
#require_active_variants port:qrupdate openblas
# replicate default values if configure script finds openblas on its own
configure.args-append \
--with-blas=-lopenblas \
--with-lapack=""
}
variant atlas description {use BLAS from MacPorts' atlas port} conflicts accelerate openblas {
depends_lib-append port:atlas
# dependents must be built with same BLAS and LAPACK
#require_active_variants port:arpack atlas
#require_active_variants port:SuiteSparse atlas
#require_active_variants port:qrupdate atlas
# replicate default values if configure script finds atlas on its own
configure.args-append \
--with-blas="-lcblas -lf77blas -latlas" \
--with-lapack=-llapack
}
if {![variant_isset accelerate] && ![variant_isset openblas] && ![variant_isset atlas] } {
default_variants-append +accelerate
}
if {![variant_isset accelerate] && ![variant_isset openblas] && ![variant_isset atlas] } {
ui_error "\n\nYou must select either the +accelerate, +atlas, or +openblas variant.\n"
return -code error "Invalid variant selection"
}
variant java description {enable Java interface} {
PortGroup java 1.0
configure.args-replace --disable-java --enable-java
}
default_variants-append +java
variant qt4gui description {build the GUI using Qt4} {
PortGroup qt4 1.0
depends_lib-append port:qscintilla
configure.args-replace --disable-gui --enable-gui
}
default_variants-append +qt4gui
variant fltk description {enable fltk as a graphics toolkit for plotting} {
depends_lib-append path:lib/libfltk.dylib:fltk
# as of version 4.1.0+ revision 0:
# without fltk, configure script turns off "native_graphics," and
# does not look for either freetype or gl2ps
# it still looks for and links against fontconfig, however
depends_lib-append \
port:freetype \
port:gl2ps
configure.args-replace --without-fltk --with-fltk
}
default_variants-append +fltk
variant jit description {enable JIT compiler (EXPERIMENTAL)} {
# JIT requires LLVM, so select a version to use
set llvm_ver 3.7
# prevent multiple versions of llvm being required
# if clangXY compiler is requested, use llvm-X.Y
foreach clang ${compilers.clang_variants} {
if { [variant_exists ${clang}] && [variant_isset ${clang}] } {
set llvm_ver [string index ${clang} end-1].[string index ${clang} end]
}
}
depends_lib-append port:llvm-${llvm_ver}
configure.args-replace --disable-jit --enable-jit
configure.env-append LLVM_CONFIG=${prefix}/bin/llvm-config-mp-${llvm_ver}
configure.cxxflags-append -std=c++11
}
if {[variant_isset fltk] && [variant_isset qt4gui]} {
notes-append "unless octave is run with --no-gui-libs, graphics_toolkit(\"fltk\") will cause a crash"
}
variant sound description {enable audio support (file I/O and playback)} {
depends_lib-append port:libsndfile
depends_lib-append port:portaudio
configure.args-replace --without-sndfile --with-sndfile
configure.args-replace --without-portaudio --with-portaudio
}
default_variants-append +sound
variant app description "build application bundle to launch ${subport}" {
depends_build-append port:ImageMagick
global appName
set appName Octave_${version}.app
post-build {
xinstall -d -p -m 0755 ${worksrcpath}/${appName}/Contents
xinstall -d -p -m 0755 ${worksrcpath}/${appName}/Contents/Resources
xinstall -d -p -m 0755 ${worksrcpath}/${appName}/Contents/MacOS
set script [open "${worksrcpath}/${appName}/Contents/MacOS/Octave" w 0755]
if { [variant_isset qt4gui] } {
puts ${script} "#!/bin/sh"
puts ${script} ""
puts ${script} "${prefix}/bin/octave-${version} --force-gui"
} else {
puts ${script} "#!/usr/bin/osascript"
puts ${script} ""
puts ${script} "tell application \"Terminal\" to do script \"${prefix}/bin/octave-${version} --no-gui-libs; exit\""
}
close ${script}
#NSHumanReadableCopyright ''
#LSUIElement 1
set values "
CFBundleDevelopmentRegion English
CFBundleExecutable Octave
CFBundleIconFile Octave.icns
CFBundleDocumentTypes {-array \'{\"CFBundleTypeExtensions\" = (\"m\"); \"CFBundleTypeOSTypes\" = (\"Mfile\"); \"CFBundleTypeRole\" = \"Editor\";}\'}
CFBundleIdentifier org.octave.Octave
CFBundleInfoDictionaryVersion 6.0
CFBundleSignature Octave
CFBundleVersion ${version}
CFBundleShortVersionString ${version}
"
foreach {key value} ${values} {
system "/usr/bin/defaults write ${worksrcpath}/${appName}/Contents/Info ${key} ${value}"
}
# have Info.plist be human readable
system "/usr/bin/plutil -convert xml1 ${worksrcpath}/${appName}/Contents/Info.plist"
# conversion by plutil set verys limited permissions
system "/bin/chmod 0644 ${worksrcpath}/${appName}/Contents/Info.plist"
xinstall -d -m 0755 ${worksrcpath}/Octave.iconset
# values from original SVG file
set svg etc/icons/octave-logo.svg
set width 283.28912
set height 283.28833
set dpi 90
foreach res {16 32 128 256 512} {
set hres [expr 2*${res}]
# find new density so that converted PNG files do not look pixelated
set denw [expr ${dpi}*${res}/${width}]
set denh [expr ${dpi}*${res}/${height}]
set hdenw [expr 2*${denw}]
set hdenh [expr 2*${denh}]
system -W ${worksrcpath} "${prefix}/bin/convert -background transparent -resize ${res}x${res} -density ${denw}x${denh} ${svg} Octave.iconset/icon_${res}x${res}.png"
system -W ${worksrcpath} "${prefix}/bin/convert -background transparent -resize ${hres}x${hres} -density ${hdenw}x${hdenh} ${svg} Octave.iconset/icon_${res}x${res}@2x.png"
}
system -W ${worksrcpath} "/usr/bin/iconutil -c icns -o ${appName}/Contents/Resources/Octave.icns Octave.iconset"
}
post-destroot {
copy ${worksrcpath}/${appName} ${destroot}${applications_dir}
}
}
default_variants-append +app
variant docs description {build documentation files} {
depends_build-append port:texinfo
configure.env-append \
MAKEINFO=${prefix}/bin/makeinfo \
TEXI2DVI=${prefix}/bin/texi2dvi \
TEXI2PDF=${prefix}/bin/texi2pdf
# see https://lists.macosforge.org/pipermail/macports-dev/2016-January/032293.html
depends_build-append \
port:texlive-basic \
port:texlive-latex
configure.args-replace --disable-docs --enable-docs
}
default_variants-append +docs
# GraphicsMagick and octave need to be built with the same C++ standard library
# or else undefined symbols:
# "Magick::Image::ping(std::__cxx11::basic_string, std::allocator > const&)"
set magickConflict {}
set magickDefault yes
if {${configure.cxx_stdlib} ne "libstdc++"} {
foreach gccVar ${compilers.gcc_variants} {
if {[variant_exists ${gccVar}] } {
lappend magickConflict ${gccVar}
if {[variant_isset ${gccVar}] } {
set magickDefault no
}
}
}
}
eval "variant graphicsmagick description {use GraphicsMagick for image I/O} conflicts ${magickConflict} {
depends_lib-append port:GraphicsMagick
configure.args-replace --without-magick --with-magick=GraphicsMagick
}"
if {${magickDefault}} {
default_variants-append +graphicsmagick
}
if { ${subport} eq "octave-devel-rc" || ${subport} eq "octave-devel-release" } {
# remove architecture flags from header file
if { [variant_exists universal] && [variant_isset universal] } {
merger-post-destroot {
foreach arch ${universal_archs_to_use} {
set hfile ${destroot}-${arch}${prefix}/include/octave-${version}/octave/oct-conf.h
reinplace "s:-arch ${arch}::g" ${hfile}
reinplace {s:-m32::g} ${hfile}
reinplace {s:-m64::g} ${hfile}
}
}
} else {
post-destroot {
set hfile ${destroot}${prefix}/include/octave-${version}/octave/oct-conf.h
reinplace "s:-arch ${build_arch}::g" ${hfile}
reinplace {s:-m32::g} ${hfile}
reinplace {s:-m64::g} ${hfile}
}
}
}
# remove or rename conflicting files
post-destroot {
foreach bin {mkoctfile octave octave-cli octave-config} {
# delete since just a link to versioned name
file delete ${destroot}${prefix}/bin/${bin}
if { [variant_isset docs] } {
# put version number in man file to avoid conflict
move ${destroot}${prefix}/share/man/man1/${bin}.1 ${destroot}${prefix}/share/man/man1/${bin}-${version}.1
}
}
# put any startup commands in ${destroot}${prefix}/share/octave/${version}/m/startup/octaverc
# see https://www.gnu.org/software/octave/doc/interpreter/Startup-Files.html
file delete ${destroot}${prefix}/share/octave/site/m/startup/octaverc
# move appdata and icons into a versioned directory
xinstall -d -m 0755 ${destroot}${prefix}/share/octave/${version}/appdata
move \
${destroot}${prefix}/share/appdata/www.octave.org-octave.appdata.xml \
${destroot}${prefix}/share/octave/${version}/appdata/
foreach num {16 22 24 32 48 64 128 256 512} {
xinstall -d -m 0755 -p ${destroot}${prefix}/share/octave/${version}/icons/hicolor/${num}x${num}/apps
move \
${destroot}${prefix}/share/icons/hicolor/${num}x${num}/apps/octave.png \
${destroot}${prefix}/share/octave/${version}/icons/hicolor/${num}x${num}/apps/octave.png
}
xinstall -d -m 0755 -p ${destroot}${prefix}/share/octave/${version}/icons/hicolor/scalable/apps
move \
${destroot}${prefix}/share/icons/hicolor/scalable/apps/octave.svg \
${destroot}${prefix}/share/octave/${version}/icons/hicolor/scalable/apps/octave.svg
}
test.run yes
test.target check
livecheck.type regexm
livecheck.url http://hg.savannah.gnu.org/hgweb/octave/tags
livecheck.version ${hg.tag}