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

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

octave: for now, GCC C++ compilers fail (fixes #51399)

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