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

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

octave: Use linear_algebra port group.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 16.2 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 148996 2016-05-24 18:49:57Z dstrubbe@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.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
277pre-configure {
278    configure.args-append --with-blas="-L${prefix}/lib ${linalglib}" --with-lapack=""
279}
280
281variant java description {enable Java interface} {
282    PortGroup java 1.0
283    configure.args-replace --disable-java --enable-java
284}
285default_variants-append +java
286
287variant qt4gui description {build the GUI using Qt4} {
288    PortGroup qt4 1.0
289    depends_lib-append  port:qscintilla
290    configure.args-replace --disable-gui --enable-gui
291}
292default_variants-append +qt4gui
293
294variant fltk description {enable fltk as a graphics toolkit for plotting} {
295    depends_lib-append path:lib/libfltk.dylib:fltk
296
297    configure.args-replace --without-fltk --with-fltk
298}
299default_variants-append +fltk
300
301if {[variant_isset fltk] || [variant_isset qt4gui]} {
302
303    # native_graphics (fltk) and gui (Qt) require OpenGL and font and printing capabilities
304    depends_lib-append  \
305        port:fontconfig \
306        port:freetype   \
307        port:gl2ps
308
309    configure.args-replace --without-opengl --with-framework-opengl
310}
311
312if {[variant_isset fltk] && [variant_isset qt4gui]} {
313    notes-append "unless octave is run with --no-gui-libs, graphics_toolkit(\"fltk\") will cause a crash"
314}
315
316variant jit description {enable JIT compiler (EXPERIMENTAL)} {
317    # JIT requires LLVM, so select a version to use
318    set llvm_ver 3.8
319
320    # prevent multiple versions of llvm being required
321    # if clangXY compiler is requested, use llvm-X.Y
322    foreach clang ${compilers.clang_variants} {
323        if { [variant_exists ${clang}] && [variant_isset ${clang}] } {
324            set llvm_ver [string index ${clang} end-1].[string index ${clang} end]
325        }
326    }
327
328    depends_lib-append port:llvm-${llvm_ver}
329    configure.args-replace --disable-jit --enable-jit
330    configure.env-append LLVM_CONFIG=${prefix}/bin/llvm-config-mp-${llvm_ver}
331    configure.cxxflags-append -std=c++11
332}
333
334variant sound description {enable audio support (file I/O and playback)} {
335    depends_lib-append port:libsndfile
336    depends_lib-append port:portaudio
337
338    configure.args-replace --without-sndfile   --with-sndfile
339    configure.args-replace --without-portaudio --with-portaudio
340}
341default_variants-append +sound
342
343variant app description "build application bundle to launch ${subport}" {
344    depends_build-append port:ImageMagick
345
346    global appName
347    set appName Octave.app
348
349    post-build {
350        xinstall -d -p -m 0755 ${worksrcpath}/${appName}/Contents
351        xinstall -d -p -m 0755 ${worksrcpath}/${appName}/Contents/Resources
352        xinstall -d -p -m 0755 ${worksrcpath}/${appName}/Contents/MacOS
353
354        set script [open "${worksrcpath}/${appName}/Contents/MacOS/Octave" w 0755]
355        if { [variant_isset qt4gui] } {
356            puts ${script} "#!/bin/sh"
357            puts ${script} ""
358            puts ${script} "${prefix}/bin/octave-${version} --force-gui"
359        } else {
360            puts ${script} "#!/usr/bin/osascript"
361            puts ${script} ""
362            puts ${script} "tell application \"Terminal\" to do script \"${prefix}/bin/octave-${version} --no-gui-libs; exit\""
363        }
364        close ${script}
365
366        #NSHumanReadableCopyright      ''
367        #LSUIElement                   1
368        set values "
369            CFBundleDevelopmentRegion     English
370            CFBundleExecutable            Octave
371            CFBundleIconFile              Octave.icns
372            CFBundleDocumentTypes         {-array \'{\"CFBundleTypeExtensions\" = (\"m\"); \"CFBundleTypeOSTypes\" = (\"Mfile\"); \"CFBundleTypeRole\" = \"Editor\";}\'}
373            CFBundleIdentifier            org.octave.Octave
374            CFBundleInfoDictionaryVersion 6.0
375            CFBundleSignature             Octave
376            CFBundleVersion               ${version}
377            CFBundleShortVersionString    ${version}
378        "
379        foreach {key value} ${values} {
380            system "/usr/bin/defaults write ${worksrcpath}/${appName}/Contents/Info ${key} ${value}"
381        }
382
383        # have Info.plist be human readable
384        system "/usr/bin/plutil -convert xml1 ${worksrcpath}/${appName}/Contents/Info.plist"
385
386        # conversion by plutil set verys limited permissions
387        system "/bin/chmod 0644 ${worksrcpath}/${appName}/Contents/Info.plist"
388
389        xinstall -d -m 0755 ${worksrcpath}/Octave.iconset
390
391        # values from original SVG file
392        set svg    etc/icons/octave-logo.svg
393        set width  283.28912
394        set height 283.28833
395        set dpi    90
396
397        foreach res {16 32 128 256 512} {
398
399            set hres [expr 2*${res}]
400
401            # find new density so that converted PNG files do not look pixelated
402            set denw  [expr ${dpi}*${res}/${width}]
403            set denh  [expr ${dpi}*${res}/${height}]
404
405            set hdenw [expr 2*${denw}]
406            set hdenh [expr 2*${denh}]
407
408            system -W ${worksrcpath} "${prefix}/bin/convert -background transparent -resize ${res}x${res}   -density ${denw}x${denh}   ${svg} Octave.iconset/icon_${res}x${res}.png"
409            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"
410        }
411
412        system -W ${worksrcpath} "/usr/bin/iconutil -c icns -o ${appName}/Contents/Resources/Octave.icns Octave.iconset"
413    }
414
415    post-destroot {
416        copy ${worksrcpath}/${appName} ${destroot}${applications_dir}
417    }
418}
419default_variants-append +app
420
421variant docs description {build documentation files} {
422    depends_build-append port:texinfo
423    configure.env-append                \
424        MAKEINFO=${prefix}/bin/makeinfo \
425        TEXI2DVI=${prefix}/bin/texi2dvi \
426        TEXI2PDF=${prefix}/bin/texi2pdf
427
428    # see https://lists.macosforge.org/pipermail/macports-dev/2016-January/032293.html
429    depends_build-append \
430        port:texlive-basic \
431        port:texlive-latex
432
433    # see #51132
434    depends_build-append \
435        port:texlive-fonts-recommended
436
437    configure.args-replace --disable-docs --enable-docs
438}
439default_variants-append +docs
440
441# GraphicsMagick and octave need to be built with the same C++ standard library
442# or else undefined symbols:
443#    "Magick::Image::ping(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)"
444set magickConflict {}
445set magickDefault yes
446if {${configure.cxx_stdlib} ne "libstdc++"} {
447    foreach gccVar ${compilers.gcc_variants} {
448        if {[variant_exists ${gccVar}] } {
449            lappend magickConflict ${gccVar}
450
451            if {[variant_isset ${gccVar}] } {
452                set magickDefault no
453            }
454        }
455    }
456}
457eval "variant graphicsmagick description {use GraphicsMagick for image I/O} conflicts ${magickConflict} {
458    depends_lib-append port:GraphicsMagick
459    configure.args-replace --without-magick --with-magick=GraphicsMagick
460}"
461if {${magickDefault}} {
462    default_variants-append +graphicsmagick
463}
464
465# remove architecture flags from header file
466if { [variant_exists universal] && [variant_isset universal] } {
467    merger-post-destroot {
468        foreach arch ${universal_archs_to_use} {
469            set hfile ${destroot}-${arch}${prefix}/include/octave-${version}/octave/oct-conf.h
470            reinplace -E "s:\\w*-arch ${arch}::g" ${hfile}
471            reinplace -E {s:\\w*-m32::g}          ${hfile}
472            reinplace -E {s:\\w*-m64::g}          ${hfile}
473        }
474    }
475} else {
476    post-destroot {
477        set hfile ${destroot}${prefix}/include/octave-${version}/octave/oct-conf.h
478        reinplace -E "s:\\w*-arch ${build_arch}::g" ${hfile}
479        reinplace -E {s:\\w*-m32::g}                ${hfile}
480        reinplace -E {s:\\w*-m64::g}                ${hfile}
481    }
482}
483
484post-destroot {
485    # put any startup commands in ${destroot}${prefix}/share/octave/${version}/m/startup/octaverc
486    # see https://www.gnu.org/software/octave/doc/interpreter/Startup-Files.html
487    file delete ${destroot}${prefix}/share/octave/site/m/startup/octaverc
488
489    if {[file exists ${worksrcpath}/liboctave/operators/libcxx-fix.h]} {
490        # install the libc++ fix, no matter if used or not, since it is
491        # required for projects including these headers.
492        xinstall -m 644 ${worksrcpath}/liboctave/operators/libcxx-fix.h \
493            ${destroot}${prefix}/include/${name}-${version}/${name}/libcxx-fix.h
494    }
495}
496
497test.run    yes
498test.target check
Note: See TracBrowser for help on using the repository browser.