source: trunk/dports/math/octave/Portfile

Last change on this file was 153773, checked in by mps@…, 12 months ago

octave: revbump due to recent gcc updates.

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