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

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

octave family: generate icons with XCode prior to 4.5 (#51487)

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