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

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

octave: remove duplications in list of compiler variants to exclude.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 16.9 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 148771 2016-05-17 18:22:03Z dstrubbe@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         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    -gcc47          \
144    -gcc46          \
145    -gcc45          \
146    -gcc44          \
147    -g95            \
148    -llvm           \
149    -clang36        \
150    -clang35        \
151    -clang34        \
152    -clang33
153
154# offscreen rendering with OpenGL via osmesa would be nice to have, but the following
155#    causes a segmentation fault:
156#    h = figure ("visible", "off"); fn = tempname (); sombrero (); __osmesa_print__ (h, fn, "svg");
157#
158# solution is ???
159#
160#depends_lib-append port:mesa
161configure.args-append       \
162    --without-OSMesa
163
164#configure.args-append --with-shell=???
165
166configure.args-append       \
167    --with-framework-carbon \
168    --without-x             \
169    --enable-static
170
171configure.args-append       \
172    --disable-openmp
173
174configure.args-append       \
175    --disable-java          \
176    --disable-gui           \
177    --without-fltk          \
178    --without-opengl        \
179    --disable-jit           \
180    --without-sndfile       \
181    --without-portaudio     \
182    --without-magick        \
183    --disable-docs
184
185# in configure.ac, listed as one of "[p]rograms used when running Octave"
186depends_lib-append port:python27
187configure.python ${prefix}/bin/python2.7
188
189# in configure.ac, listed as one of "[p]rograms used when running Octave"
190depends_lib-append port:ghostscript
191configure.env-append GHOSTSCRIPT=${prefix}/bin/gs
192
193# in configure.ac, listed as one of "[p]rograms used when running Octave"
194depends_lib-append port:gnuplot
195configure.env-append GNUPLOT=${prefix}/bin/gnuplot
196
197# in configure.ac, listed as one of "[p]rograms used when running Octave"
198depends_lib-append port:less
199configure.env-append DEFAULT_PAGER=${prefix}/bin/less
200
201depends_lib-append   port:ncurses
202depends_lib-append   port:readline
203depends_lib-append   port:pcre
204
205#--without-amd
206#--without-camd
207#--without-colamd
208#--without-cholmod
209#--without-cxsparse
210#--without-umfpack
211depends_lib-append  port:SuiteSparse
212foreach lib {amd camd colamd cholmod cxsparse umfpack} {
213    configure.args-append \
214        --with-${lib}="-l${lib} -lsuitesparseconfig"
215}
216
217#--without-qhull
218depends_lib-append  port:qhull
219
220#--without-z
221depends_lib-append  port:zlib
222
223#--without-hdf5
224depends_lib-append  port:hdf5
225
226#--disable-fftw-threads
227#--without-fftw3
228#--without-fftw3f
229depends_lib-append  port:fftw-3
230depends_lib-append  port:fftw-3-single
231
232#--without-glpk
233depends_lib-append  port:glpk
234
235#--without-curl
236depends_lib-append  port:curl
237
238#--without-qrupdate
239depends_lib-append port:qrupdate
240
241#--without-arpack
242depends_lib-append port:arpack
243
244#--without-openssl
245depends_lib-append port:openssl
246
247# fortran arch flag is not set automatically
248if {![variant_isset universal]} {
249    if {${build_arch} eq "x86_64" || ${build_arch} eq "ppc64"} {
250        configure.fflags-append -m64
251    } else {
252        configure.fflags-append -m32
253    }
254}
255
256# see etc/README.MacOS
257depends_run-append   \
258    port:epstool     \
259    port:ghostscript \
260    port:transfig    \
261    port:pstoedit
262
263variant accelerate description {use BLAS from Apple's Accelerate.framework} conflicts atlas openblas {
264    depends_lib-append port:vecLibFort
265
266    configure.args-append        \
267        --with-blas=-lvecLibFort \
268        --with-lapack=""
269}
270
271variant openblas description {use BLAS from MacPorts' openblas port} conflicts atlas accelerate {
272
273    depends_lib-append path:lib/libopenblas.dylib:OpenBLAS
274    # LAPACK required
275    require_active_variants path:lib/libopenblas.dylib:OpenBLAS lapack
276
277    # replicate default values if configure script finds openblas on its own
278    configure.args-append        \
279        --with-blas=-lopenblas   \
280        --with-lapack=""
281}
282
283variant atlas description {use BLAS from MacPorts' atlas port} conflicts accelerate openblas {
284    depends_lib-append port:atlas
285
286    # replicate default values if configure script finds atlas on its own
287    configure.args-append        \
288        --with-blas="-lcblas -lf77blas -latlas" \
289        --with-lapack=-llapack
290}
291
292if {![variant_isset accelerate] && ![variant_isset openblas] && ![variant_isset atlas] } {
293    default_variants-append +accelerate
294}
295
296if {![variant_isset accelerate] && ![variant_isset openblas] && ![variant_isset atlas] } {
297    ui_error "\n\nYou must select either the +accelerate, +atlas, or +openblas variant.\n"
298    return -code error "Invalid variant selection"
299}
300
301variant java description {enable Java interface} {
302    PortGroup java 1.0
303    configure.args-replace --disable-java --enable-java
304}
305default_variants-append +java
306
307variant qt4gui description {build the GUI using Qt4} {
308    PortGroup qt4 1.0
309    depends_lib-append  port:qscintilla
310    configure.args-replace --disable-gui --enable-gui
311}
312default_variants-append +qt4gui
313
314variant fltk description {enable fltk as a graphics toolkit for plotting} {
315    depends_lib-append path:lib/libfltk.dylib:fltk
316
317    configure.args-replace --without-fltk --with-fltk
318}
319default_variants-append +fltk
320
321if {[variant_isset fltk] || [variant_isset qt4gui]} {
322
323    # native_graphics (fltk) and gui (Qt) require OpenGL and font and printing capabilities
324    depends_lib-append  \
325        port:fontconfig \
326        port:freetype   \
327        port:gl2ps
328
329    configure.args-replace --without-opengl --with-framework-opengl
330}
331
332if {[variant_isset fltk] && [variant_isset qt4gui]} {
333    notes-append "unless octave is run with --no-gui-libs, graphics_toolkit(\"fltk\") will cause a crash"
334}
335
336variant jit description {enable JIT compiler (EXPERIMENTAL)} {
337    # JIT requires LLVM, so select a version to use
338    set llvm_ver 3.8
339
340    # prevent multiple versions of llvm being required
341    # if clangXY compiler is requested, use llvm-X.Y
342    foreach clang ${compilers.clang_variants} {
343        if { [variant_exists ${clang}] && [variant_isset ${clang}] } {
344            set llvm_ver [string index ${clang} end-1].[string index ${clang} end]
345        }
346    }
347
348    depends_lib-append port:llvm-${llvm_ver}
349    configure.args-replace --disable-jit --enable-jit
350    configure.env-append LLVM_CONFIG=${prefix}/bin/llvm-config-mp-${llvm_ver}
351    configure.cxxflags-append -std=c++11
352}
353
354variant sound description {enable audio support (file I/O and playback)} {
355    depends_lib-append port:libsndfile
356    depends_lib-append port:portaudio
357
358    configure.args-replace --without-sndfile   --with-sndfile
359    configure.args-replace --without-portaudio --with-portaudio
360}
361default_variants-append +sound
362
363variant app description "build application bundle to launch ${subport}" {
364    depends_build-append port:ImageMagick
365
366    global appName
367    set appName Octave.app
368
369    post-build {
370        xinstall -d -p -m 0755 ${worksrcpath}/${appName}/Contents
371        xinstall -d -p -m 0755 ${worksrcpath}/${appName}/Contents/Resources
372        xinstall -d -p -m 0755 ${worksrcpath}/${appName}/Contents/MacOS
373
374        set script [open "${worksrcpath}/${appName}/Contents/MacOS/Octave" w 0755]
375        if { [variant_isset qt4gui] } {
376            puts ${script} "#!/bin/sh"
377            puts ${script} ""
378            puts ${script} "${prefix}/bin/octave-${version} --force-gui"
379        } else {
380            puts ${script} "#!/usr/bin/osascript"
381            puts ${script} ""
382            puts ${script} "tell application \"Terminal\" to do script \"${prefix}/bin/octave-${version} --no-gui-libs; exit\""
383        }
384        close ${script}
385
386        #NSHumanReadableCopyright      ''
387        #LSUIElement                   1
388        set values "
389            CFBundleDevelopmentRegion     English
390            CFBundleExecutable            Octave
391            CFBundleIconFile              Octave.icns
392            CFBundleDocumentTypes         {-array \'{\"CFBundleTypeExtensions\" = (\"m\"); \"CFBundleTypeOSTypes\" = (\"Mfile\"); \"CFBundleTypeRole\" = \"Editor\";}\'}
393            CFBundleIdentifier            org.octave.Octave
394            CFBundleInfoDictionaryVersion 6.0
395            CFBundleSignature             Octave
396            CFBundleVersion               ${version}
397            CFBundleShortVersionString    ${version}
398        "
399        foreach {key value} ${values} {
400            system "/usr/bin/defaults write ${worksrcpath}/${appName}/Contents/Info ${key} ${value}"
401        }
402
403        # have Info.plist be human readable
404        system "/usr/bin/plutil -convert xml1 ${worksrcpath}/${appName}/Contents/Info.plist"
405
406        # conversion by plutil set verys limited permissions
407        system "/bin/chmod 0644 ${worksrcpath}/${appName}/Contents/Info.plist"
408
409        xinstall -d -m 0755 ${worksrcpath}/Octave.iconset
410
411        # values from original SVG file
412        set svg    etc/icons/octave-logo.svg
413        set width  283.28912
414        set height 283.28833
415        set dpi    90
416
417        foreach res {16 32 128 256 512} {
418
419            set hres [expr 2*${res}]
420
421            # find new density so that converted PNG files do not look pixelated
422            set denw  [expr ${dpi}*${res}/${width}]
423            set denh  [expr ${dpi}*${res}/${height}]
424
425            set hdenw [expr 2*${denw}]
426            set hdenh [expr 2*${denh}]
427
428            system -W ${worksrcpath} "${prefix}/bin/convert -background transparent -resize ${res}x${res}   -density ${denw}x${denh}   ${svg} Octave.iconset/icon_${res}x${res}.png"
429            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"
430        }
431
432        system -W ${worksrcpath} "/usr/bin/iconutil -c icns -o ${appName}/Contents/Resources/Octave.icns Octave.iconset"
433    }
434
435    post-destroot {
436        copy ${worksrcpath}/${appName} ${destroot}${applications_dir}
437    }
438}
439default_variants-append +app
440
441variant docs description {build documentation files} {
442    depends_build-append port:texinfo
443    configure.env-append                \
444        MAKEINFO=${prefix}/bin/makeinfo \
445        TEXI2DVI=${prefix}/bin/texi2dvi \
446        TEXI2PDF=${prefix}/bin/texi2pdf
447
448    # see https://lists.macosforge.org/pipermail/macports-dev/2016-January/032293.html
449    depends_build-append \
450        port:texlive-basic \
451        port:texlive-latex
452
453    # see #51132
454    depends_build-append \
455        port:texlive-fonts-recommended
456
457    configure.args-replace --disable-docs --enable-docs
458}
459default_variants-append +docs
460
461# GraphicsMagick and octave need to be built with the same C++ standard library
462# or else undefined symbols:
463#    "Magick::Image::ping(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)"
464set magickConflict {}
465set magickDefault yes
466if {${configure.cxx_stdlib} ne "libstdc++"} {
467    foreach gccVar ${compilers.gcc_variants} {
468        if {[variant_exists ${gccVar}] } {
469            lappend magickConflict ${gccVar}
470
471            if {[variant_isset ${gccVar}] } {
472                set magickDefault no
473            }
474        }
475    }
476}
477eval "variant graphicsmagick description {use GraphicsMagick for image I/O} conflicts ${magickConflict} {
478    depends_lib-append port:GraphicsMagick
479    configure.args-replace --without-magick --with-magick=GraphicsMagick
480}"
481if {${magickDefault}} {
482    default_variants-append +graphicsmagick
483}
484
485# remove architecture flags from header file
486if { [variant_exists universal] && [variant_isset universal] } {
487    merger-post-destroot {
488        foreach arch ${universal_archs_to_use} {
489            set hfile ${destroot}-${arch}${prefix}/include/octave-${version}/octave/oct-conf.h
490            reinplace -E "s:\\w*-arch ${arch}::g" ${hfile}
491            reinplace -E {s:\\w*-m32::g}          ${hfile}
492            reinplace -E {s:\\w*-m64::g}          ${hfile}
493        }
494    }
495} else {
496    post-destroot {
497        set hfile ${destroot}${prefix}/include/octave-${version}/octave/oct-conf.h
498        reinplace -E "s:\\w*-arch ${build_arch}::g" ${hfile}
499        reinplace -E {s:\\w*-m32::g}                ${hfile}
500        reinplace -E {s:\\w*-m64::g}                ${hfile}
501    }
502}
503
504post-destroot {
505    # put any startup commands in ${destroot}${prefix}/share/octave/${version}/m/startup/octaverc
506    # see https://www.gnu.org/software/octave/doc/interpreter/Startup-Files.html
507    file delete ${destroot}${prefix}/share/octave/site/m/startup/octaverc
508
509    if {[file exists ${worksrcpath}/liboctave/operators/libcxx-fix.h]} {
510        # install the libc++ fix, no matter if used or not, since it is
511        # required for projects including these headers.
512        xinstall -m 644 ${worksrcpath}/liboctave/operators/libcxx-fix.h \
513            ${destroot}${prefix}/include/${name}-${version}/${name}/libcxx-fix.h
514    }
515}
516
517test.run    yes
518test.target check
Note: See TracBrowser for help on using the repository browser.