source: trunk/dports/math/octave/Portfile @ 148698

Last change on this file since 148698 was 148698, checked in by mcalhoun@…, 4 years ago

octave: update version 3.8.2->4.0.2 (major changes; fixes #47979)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 17.0 KB
Line 
1# -*- 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
2# $Id: Portfile 148698 2016-05-15 09:55:48Z mcalhoun@macports.org $
3
4PortSystem          1.0
5PortGroup           compilers  1.0
6PortGroup           muniversal 1.0
7PortGroup           active_variants 1.1
8PortGroup           compiler_blacklist_versions 1.0
9
10name                octave
11version             4.0.2
12categories          math science
13platforms           darwin
14license             GPL-3+
15maintainers         michaelld mcalhoun openmaintainer
16description         a high-level language for numerical computations
17long_description    \
18    GNU Octave is a high-level language, primarily intended for numerical \
19    computations.  It provides a convenient command line interface for \
20    solving linear and nonlinear problems numerically.
21
22homepage            http://www.gnu.org/software/octave
23
24master_sites        gnu:octave
25
26checksums           rmd160  2f910e95b01d49d9ecfece61c901709b124227ac \
27                    sha256  39cd8fd36c218fc00adace28d74a6c7c9c6faab7113a5ba3c4372324c755bdc1
28
29# Block compilers: Some older versions of CLANG do not honor the CPATH
30# environment variables, which is required for compiling this port
31# when using MacPorts.  The versions seem to be: MacPorts CLANG 2.9 or
32# earlier, and Apple CLANG 318.0.58 or older.
33#
34# See also < http://llvm.org/bugs/show_bug.cgi?id=8971 >
35#          < https://trac.macports.org/ticket/40250 >.
36compiler.blacklist-append { clang <= 318.0.61 }
37
38# see http://savannah.gnu.org/bugs/?func=detailitem&item_id=46592
39patchfiles-append \
40    patch-e870a68742a6.diff
41
42# see http://savannah.gnu.org/bugs/?41027
43patchfiles-append   \
44    octave-bug_41027.patch
45
46# Don't link with "-flat_namespace -undefined suppress"
47# on Mac OS X 10.10 Yosemite and later.
48patchfiles-append   patch-yosemite-libtool.diff
49
50pre-patch {
51    # code located in pre-patch because variants from PortGroup compilers must
52    #    be evaluated before it can be determined if clang is being used
53
54    # see http://trac.macports.org/ticket/45011
55    # see http://savannah.gnu.org/bugs/?43298
56    set libcxxbug no
57    if { ${configure.cc} eq "/usr/bin/clang" && [lindex [split ${xcodeversion} .] 0] eq 6 } {
58        set libcxxbug yes
59    } elseif { [variant_exists clang35] && [variant_isset clang35] } {
60        set libcxxbug yes
61    }
62    if { ${libcxxbug} } {
63        patchfiles-append   \
64            clang-libcxx-fix.patch
65    }
66
67    # see https://trac.macports.org/ticket/44704
68    set gl2psbug no
69    if { ${configure.cc} eq "/usr/bin/clang" && [vercmp ${xcodeversion} 5.0.0] < 0 } {
70        set gl2psbug yes
71    } elseif { [variant_exists clang33] && [variant_isset clang33] } {
72        set gl2psbug yes
73    }
74    if { ${gl2psbug} } {
75        patchfiles-append   patch-gl2ps_renderer.diff
76    }
77}
78
79# avoid depends_build-append port:coreutils
80configure.env-append MKDIR_P="/bin/mkdir -p"
81
82# avoid depends_build-append port:cctools
83configure.env-append RANLIB=/usr/bin/ranlib
84
85# main octave port lists as a depends_lib
86# configure.ac list it among the "[p]rograms used in Makefiles"
87depends_build-append port:gawk
88configure.awk ${prefix}/bin/gawk
89
90# in configure.ac, said to be "[p]rograms used to generate icons file formats
91depends_build-append \
92    port:icoutils    \
93    port:librsvg
94configure.env-append              \
95    ICOTOOL=${prefix}/bin/icotool \
96    RSVG_CONVERT=${prefix}/bin/rsvg-convert
97
98# main octave port lists as a depends_lib
99# configure.ac list it among the "[p]rograms used in Makefiles"
100depends_build-append port:grep
101configure.env-append  GREP=${prefix}/bin/grep
102configure.env-append EGREP=${prefix}/bin/egrep
103configure.env-append FGREP=${prefix}/bin/fgrep
104
105# configure.ac list it among the "[p]rograms used in Makefiles"
106depends_build-append port:findutils
107configure.env-append FIND=${prefix}/bin/gfind
108
109# main octave port lists as a depends_lib
110# configure.ac list it among the "[p]rograms used in Makefiles"
111depends_build-append port:gsed
112configure.env-append SED=${prefix}/bin/gsed
113
114depends_build-append port:flex
115configure.env-append LEX=${prefix}/bin/flex
116
117depends_build-append port:bison
118configure.env-append YACC="${prefix}/bin/bison -y"
119
120depends_build-append port:gperf
121configure.env-append GPERF=/usr/bin/gperf
122
123# configure.ac list it among the "[p]rograms used in Makefiles"
124depends_build-append port:perl5
125configure.perl ${prefix}/bin/perl5
126
127# avoid depends_build-append port:desktop-file-utils
128#configure.env-append DESKTOP_FILE_INSTALL=""
129configure.env-append ac_cv_prog_DESKTOP_FILE_INSTALL=""
130
131depends_build-append \
132    port:pkgconfig
133
134compilers.choose    fc f77 f90 cc cxx
135
136# for now, limit the number of variants
137# some of these compilers may work fine
138compilers.setup     \
139    require_fortran \
140    -dragonegg      \
141    -gcc49          \
142    -gcc48          \
143    -gcc46          \
144    -gcc45          \
145    -gcc44          \
146    -g95            \
147    -llvm           \
148    -gcc47          \
149    -gcc46          \
150    -gcc45          \
151    -gcc44          \
152    -clang36        \
153    -clang35        \
154    -clang34        \
155    -clang33
156
157# offscreen rendering with OpenGL via osmesa would be nice to have, but the following
158#    causes a segmentation fault:
159#    h = figure ("visible", "off"); fn = tempname (); sombrero (); __osmesa_print__ (h, fn, "svg");
160#
161# solution is ???
162#
163#depends_lib-append port:mesa
164configure.args-append       \
165    --without-OSMesa
166
167#configure.args-append --with-shell=???
168
169configure.args-append       \
170    --with-framework-carbon \
171    --without-x             \
172    --enable-static
173
174configure.args-append       \
175    --disable-openmp
176
177configure.args-append       \
178    --disable-java          \
179    --disable-gui           \
180    --without-fltk          \
181    --without-opengl        \
182    --disable-jit           \
183    --without-sndfile       \
184    --without-portaudio     \
185    --without-magick        \
186    --disable-docs
187
188# in configure.ac, listed as one of "[p]rograms used when running Octave"
189depends_lib-append port:python27
190configure.python ${prefix}/bin/python2.7
191
192# in configure.ac, listed as one of "[p]rograms used when running Octave"
193depends_lib-append port:ghostscript
194configure.env-append GHOSTSCRIPT=${prefix}/bin/gs
195
196# in configure.ac, listed as one of "[p]rograms used when running Octave"
197depends_lib-append port:gnuplot
198configure.env-append GNUPLOT=${prefix}/bin/gnuplot
199
200# in configure.ac, listed as one of "[p]rograms used when running Octave"
201depends_lib-append port:less
202configure.env-append DEFAULT_PAGER=${prefix}/bin/less
203
204depends_lib-append   port:ncurses
205depends_lib-append   port:readline
206depends_lib-append   port:pcre
207
208#--without-amd
209#--without-camd
210#--without-colamd
211#--without-cholmod
212#--without-cxsparse
213#--without-umfpack
214depends_lib-append  port:SuiteSparse
215foreach lib {amd camd colamd cholmod cxsparse umfpack} {
216    configure.args-append \
217        --with-${lib}="-l${lib} -lsuitesparseconfig"
218}
219
220#--without-qhull
221depends_lib-append  port:qhull
222
223#--without-z
224depends_lib-append  port:zlib
225
226#--without-hdf5
227depends_lib-append  port:hdf5
228
229#--disable-fftw-threads
230#--without-fftw3
231#--without-fftw3f
232depends_lib-append  port:fftw-3
233depends_lib-append  port:fftw-3-single
234
235#--without-glpk
236depends_lib-append  port:glpk
237
238#--without-curl
239depends_lib-append  port:curl
240
241#--without-qrupdate
242depends_lib-append port:qrupdate
243
244#--without-arpack
245depends_lib-append port:arpack
246
247#--without-openssl
248depends_lib-append port:openssl
249
250# fortran arch flag is not set automatically
251if {![variant_isset universal]} {
252    if {${build_arch} eq "x86_64" || ${build_arch} eq "ppc64"} {
253        configure.fflags-append -m64
254    } else {
255        configure.fflags-append -m32
256    }
257}
258
259# see etc/README.MacOS
260depends_run-append   \
261    port:epstool     \
262    port:ghostscript \
263    port:transfig    \
264    port:pstoedit
265
266variant accelerate description {use BLAS from Apple's Accelerate.framework} conflicts atlas openblas {
267    depends_lib-append port:vecLibFort
268
269    configure.args-append        \
270        --with-blas=-lvecLibFort \
271        --with-lapack=""
272}
273
274variant openblas description {use BLAS from MacPorts' openblas port} conflicts atlas accelerate {
275
276    depends_lib-append path:lib/libopenblas.dylib:OpenBLAS
277    # LAPACK required
278    require_active_variants path:lib/libopenblas.dylib:OpenBLAS lapack
279
280    # replicate default values if configure script finds openblas on its own
281    configure.args-append        \
282        --with-blas=-lopenblas   \
283        --with-lapack=""
284}
285
286variant atlas description {use BLAS from MacPorts' atlas port} conflicts accelerate openblas {
287    depends_lib-append port:atlas
288
289    # replicate default values if configure script finds atlas on its own
290    configure.args-append        \
291        --with-blas="-lcblas -lf77blas -latlas" \
292        --with-lapack=-llapack
293}
294
295if {![variant_isset accelerate] && ![variant_isset openblas] && ![variant_isset atlas] } {
296    default_variants-append +accelerate
297}
298
299if {![variant_isset accelerate] && ![variant_isset openblas] && ![variant_isset atlas] } {
300    ui_error "\n\nYou must select either the +accelerate, +atlas, or +openblas variant.\n"
301    return -code error "Invalid variant selection"
302}
303
304variant java description {enable Java interface} {
305    PortGroup java 1.0
306    configure.args-replace --disable-java --enable-java
307}
308default_variants-append +java
309
310variant qt4gui description {build the GUI using Qt4} {
311    PortGroup qt4 1.0
312    depends_lib-append  port:qscintilla
313    configure.args-replace --disable-gui --enable-gui
314}
315default_variants-append +qt4gui
316
317variant fltk description {enable fltk as a graphics toolkit for plotting} {
318    depends_lib-append path:lib/libfltk.dylib:fltk
319
320    configure.args-replace --without-fltk --with-fltk
321}
322default_variants-append +fltk
323
324if {[variant_isset fltk] || [variant_isset qt4gui]} {
325
326    # native_graphics (fltk) and gui (Qt) require OpenGL and font and printing capabilities
327    depends_lib-append  \
328        port:fontconfig \
329        port:freetype   \
330        port:gl2ps
331
332    configure.args-replace --without-opengl --with-framework-opengl
333}
334
335if {[variant_isset fltk] && [variant_isset qt4gui]} {
336    notes-append "unless octave is run with --no-gui-libs, graphics_toolkit(\"fltk\") will cause a crash"
337}
338
339variant jit description {enable JIT compiler (EXPERIMENTAL)} {
340    # JIT requires LLVM, so select a version to use
341    set llvm_ver 3.8
342
343    # prevent multiple versions of llvm being required
344    # if clangXY compiler is requested, use llvm-X.Y
345    foreach clang ${compilers.clang_variants} {
346        if { [variant_exists ${clang}] && [variant_isset ${clang}] } {
347            set llvm_ver [string index ${clang} end-1].[string index ${clang} end]
348        }
349    }
350
351    depends_lib-append port:llvm-${llvm_ver}
352    configure.args-replace --disable-jit --enable-jit
353    configure.env-append LLVM_CONFIG=${prefix}/bin/llvm-config-mp-${llvm_ver}
354    configure.cxxflags-append -std=c++11
355}
356
357variant sound description {enable audio support (file I/O and playback)} {
358    depends_lib-append port:libsndfile
359    depends_lib-append port:portaudio
360
361    configure.args-replace --without-sndfile   --with-sndfile
362    configure.args-replace --without-portaudio --with-portaudio
363}
364default_variants-append +sound
365
366variant app description "build application bundle to launch ${subport}" {
367    depends_build-append port:ImageMagick
368
369    global appName
370    set appName Octave.app
371
372    post-build {
373        xinstall -d -p -m 0755 ${worksrcpath}/${appName}/Contents
374        xinstall -d -p -m 0755 ${worksrcpath}/${appName}/Contents/Resources
375        xinstall -d -p -m 0755 ${worksrcpath}/${appName}/Contents/MacOS
376
377        set script [open "${worksrcpath}/${appName}/Contents/MacOS/Octave" w 0755]
378        if { [variant_isset qt4gui] } {
379            puts ${script} "#!/bin/sh"
380            puts ${script} ""
381            puts ${script} "${prefix}/bin/octave-${version} --force-gui"
382        } else {
383            puts ${script} "#!/usr/bin/osascript"
384            puts ${script} ""
385            puts ${script} "tell application \"Terminal\" to do script \"${prefix}/bin/octave-${version} --no-gui-libs; exit\""
386        }
387        close ${script}
388
389        #NSHumanReadableCopyright      ''
390        #LSUIElement                   1
391        set values "
392            CFBundleDevelopmentRegion     English
393            CFBundleExecutable            Octave
394            CFBundleIconFile              Octave.icns
395            CFBundleDocumentTypes         {-array \'{\"CFBundleTypeExtensions\" = (\"m\"); \"CFBundleTypeOSTypes\" = (\"Mfile\"); \"CFBundleTypeRole\" = \"Editor\";}\'}
396            CFBundleIdentifier            org.octave.Octave
397            CFBundleInfoDictionaryVersion 6.0
398            CFBundleSignature             Octave
399            CFBundleVersion               ${version}
400            CFBundleShortVersionString    ${version}
401        "
402        foreach {key value} ${values} {
403            system "/usr/bin/defaults write ${worksrcpath}/${appName}/Contents/Info ${key} ${value}"
404        }
405
406        # have Info.plist be human readable
407        system "/usr/bin/plutil -convert xml1 ${worksrcpath}/${appName}/Contents/Info.plist"
408
409        # conversion by plutil set verys limited permissions
410        system "/bin/chmod 0644 ${worksrcpath}/${appName}/Contents/Info.plist"
411
412        xinstall -d -m 0755 ${worksrcpath}/Octave.iconset
413
414        # values from original SVG file
415        set svg    etc/icons/octave-logo.svg
416        set width  283.28912
417        set height 283.28833
418        set dpi    90
419
420        foreach res {16 32 128 256 512} {
421
422            set hres [expr 2*${res}]
423
424            # find new density so that converted PNG files do not look pixelated
425            set denw  [expr ${dpi}*${res}/${width}]
426            set denh  [expr ${dpi}*${res}/${height}]
427
428            set hdenw [expr 2*${denw}]
429            set hdenh [expr 2*${denh}]
430
431            system -W ${worksrcpath} "${prefix}/bin/convert -background transparent -resize ${res}x${res}   -density ${denw}x${denh}   ${svg} Octave.iconset/icon_${res}x${res}.png"
432            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"
433        }
434
435        system -W ${worksrcpath} "/usr/bin/iconutil -c icns -o ${appName}/Contents/Resources/Octave.icns Octave.iconset"
436    }
437
438    post-destroot {
439        copy ${worksrcpath}/${appName} ${destroot}${applications_dir}
440    }
441}
442default_variants-append +app
443
444variant docs description {build documentation files} {
445    depends_build-append port:texinfo
446    configure.env-append                \
447        MAKEINFO=${prefix}/bin/makeinfo \
448        TEXI2DVI=${prefix}/bin/texi2dvi \
449        TEXI2PDF=${prefix}/bin/texi2pdf
450
451    # see https://lists.macosforge.org/pipermail/macports-dev/2016-January/032293.html
452    depends_build-append \
453        port:texlive-basic \
454        port:texlive-latex
455
456    # see #51132
457    depends_build-append \
458        port:texlive-fonts-recommended
459
460    configure.args-replace --disable-docs --enable-docs
461}
462default_variants-append +docs
463
464# GraphicsMagick and octave need to be built with the same C++ standard library
465# or else undefined symbols:
466#    "Magick::Image::ping(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)"
467set magickConflict {}
468set magickDefault yes
469if {${configure.cxx_stdlib} ne "libstdc++"} {
470    foreach gccVar ${compilers.gcc_variants} {
471        if {[variant_exists ${gccVar}] } {
472            lappend magickConflict ${gccVar}
473
474            if {[variant_isset ${gccVar}] } {
475                set magickDefault no
476            }
477        }
478    }
479}
480eval "variant graphicsmagick description {use GraphicsMagick for image I/O} conflicts ${magickConflict} {
481    depends_lib-append port:GraphicsMagick
482    configure.args-replace --without-magick --with-magick=GraphicsMagick
483}"
484if {${magickDefault}} {
485    default_variants-append +graphicsmagick
486}
487
488# remove architecture flags from header file
489if { [variant_exists universal] && [variant_isset universal] } {
490    merger-post-destroot {
491        foreach arch ${universal_archs_to_use} {
492            set hfile ${destroot}-${arch}${prefix}/include/octave-${version}/octave/oct-conf.h
493            reinplace -E "s:\\w*-arch ${arch}::g" ${hfile}
494            reinplace -E {s:\\w*-m32::g}          ${hfile}
495            reinplace -E {s:\\w*-m64::g}          ${hfile}
496        }
497    }
498} else {
499    post-destroot {
500        set hfile ${destroot}${prefix}/include/octave-${version}/octave/oct-conf.h
501        reinplace -E "s:\\w*-arch ${build_arch}::g" ${hfile}
502        reinplace -E {s:\\w*-m32::g}                ${hfile}
503        reinplace -E {s:\\w*-m64::g}                ${hfile}
504    }
505}
506
507post-destroot {
508    # put any startup commands in ${destroot}${prefix}/share/octave/${version}/m/startup/octaverc
509    # see https://www.gnu.org/software/octave/doc/interpreter/Startup-Files.html
510    file delete ${destroot}${prefix}/share/octave/site/m/startup/octaverc
511
512    if {[file exists ${worksrcpath}/liboctave/operators/libcxx-fix.h]} {
513        # install the libc++ fix, no matter if used or not, since it is
514        # required for projects including these headers.
515        xinstall -m 644 ${worksrcpath}/liboctave/operators/libcxx-fix.h \
516            ${destroot}${prefix}/include/${name}-${version}/${name}/libcxx-fix.h
517    }
518}
519
520test.run    yes
521test.target check
Note: See TracBrowser for help on using the repository browser.