Ticket #60518: Portfile

File Portfile, 20.4 KB (added by dardo82 (Michele Venturi), 4 years ago)

fixed port file

Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
2
3PortSystem              1.0
4PortGroup               github 1.0
5PortGroup               waf 1.0
6PortGroup               legacysupport 1.0
7
8# Please revbump mpv whenever ffmpeg{,-devel} is updated!
9github.setup            mpv-player mpv 0.32.0 v
10revision                0
11categories              multimedia
12license                 GPL-2+
13maintainers             {ionic @Ionic}
14platforms               darwin
15
16description             mpv is a movie player based on MPlayer and mplayer2.
17long_description        ${description} It plays most MPEG/VOB, AVI, Ogg/OGM, \
18                        VIVO, ASF/WMA/WMV, QT/MOV/MP4, RealMedia, Matroska, \
19                        NUT, NuppelVideo, FLI, YUV4MPEG, FILM, RoQ, PVA files, \
20                        supported by many native, XAnim, and Win32 DLL codecs. \
21                        You can watch VideoCD, SVCD, DVD, 3ivx, DivX 3/4/5, WMV \
22                        and even H.264 movies.
23homepage                http://www.mpv.io/
24
25set waf_version         2.0.20
26set waf_distfile        waf-${waf_version}
27set mpv_distfile        ${distfiles}
28master_sites-append     https://waf.io/:waf
29distfiles-append        ${waf_distfile}:waf
30
31extract.only-delete     ${waf_distfile}
32
33checksums               ${mpv_distfile} \
34                        rmd160  f1edb330a1ed7de701480aeb323c076422c5b47c \
35                        sha256  ba59bfc96a633b48a5b635aae7be6f9cf544f8bff42a6d06f20634ead28d11b2 \
36                        size    3148937 \
37                        ${waf_distfile} \
38                        rmd160  213ef296fe7b942b0395af7c0031f9b1c916a68b \
39                        sha256  bf971e98edc2414968a262c6aa6b88541a26c3cd248689c89f4c57370955ee7f \
40                        size    104725
41
42installs_libs           no
43
44depends_build           port:pkgconfig
45depends_lib             path:lib/libavcodec.dylib:ffmpeg \
46                        path:bin/perl:perl5 \
47                        port:libiconv \
48                        port:zlib \
49                        port:libass \
50                        port:libbluray \
51                        port:lcms2
52
53universal_variant       no
54
55default_variants        +network +osd +opengl +dvd +audiocd +libarchive
56
57if {${os.platform} eq "darwin" && ${os.major} > 10} {
58    # current macOS bundle errors on < 10.7 due to unhandled -psn_* argument
59    default_variants-append +bundle
60}
61
62# at this moment in time (20190127) rubberband does not build on PPC
63platform darwin i386 {
64    default_variants-append +rubberband
65}
66
67
68# Current waf doesn't support --nocache anymore. Set by PortGroup.
69configure.post_args-delete   --nocache
70
71# I'd *really* love to see what's going on in waf, but even the continue-on-failure option
72# makes waf bail out on the first optional component that was not found (which will always
73# happen, especially since tests for Win32 are bound to fail on other platforms...)
74#configure.args-append   -vvv -kk
75
76# Default configuration options. Mostly macOS specific.
77# We cannot use --enable-cplayer here. Only --disable-cplayer
78# is recognized. Boo!
79configure.args-append   --enable-manpage-build \
80                        --enable-libass \
81                        --enable-coreaudio \
82                        --enable-cocoa \
83                        --enable-cplugins \
84                        --enable-zlib \
85                        --enable-swift \
86                        --disable-html-build \
87                        --disable-videotoolbox-gl \
88                        --disable-cuda-hwaccel \
89                        --disable-opensles \
90                        --disable-egl-drm \
91                        --disable-egl-angle-lib \
92                        --disable-egl-angle-win32 \
93                        --disable-audiounit \
94                        --disable-ios-gl \
95                        --disable-direct3d \
96                        --disable-android \
97                        --disable-rpi \
98                        --disable-dvbin
99
100# mpv autodetects many support libs. To prevent undeclared
101# dependencies, explicitly disable everything optional first.
102# This list should be expanded each time the port is updated to a
103# new version, disabling any newly added options.
104configure.args-append   --disable-pdf-build \
105                        --disable-test \
106                        --disable-clang-database \
107                        --disable-debug-build \
108                        --disable-libsmbclient \
109                        --disable-libass-osd \
110                        --disable-dvdnav \
111                        --disable-cdda \
112                        --disable-vapoursynth \
113                        --disable-libarchive \
114                        --disable-rubberband \
115                        --disable-pulse \
116                        --disable-jack \
117                        --disable-openal \
118                        --disable-gl-cocoa \
119                        --disable-x11 \
120                        --disable-xv \
121                        --disable-gl-x11 \
122                        --disable-egl-x11 \
123                        --disable-caca \
124                        --disable-jpeg \
125                        --disable-tv \
126                        --disable-lua \
127                        --disable-gl \
128                        --disable-javascript \
129                        --disable-uchardet
130
131# Fix picking up the correct talloc version.
132# -isystem has the added benefit of moving the include
133# directory specified to the end of the include path list.
134# This will help the build system respect custom include
135# paths correctly (i.e., searching them before the MP include
136# directory.)
137configure.cppflags-replace  -I${prefix}/include -isystem${prefix}/include
138
139build.args-append           -v
140
141# Clear CPATH and LIBRARY_PATH because a ncurses include file
142# conflicts with the one in MacPorts. It doesn't matter much anyway
143# because the swift module in mpv doesn't have any dependencies to
144# link against.
145compiler.cpath
146compiler.library_path
147
148platform macosx {
149    if {${os.major} > 10} {
150        # Force recent enough Xcode.
151        # We have to compile with the compiler provided by Xcode/CLT
152        # due to only it shipping libarclite on 10.7 and knowing where
153        # it is.
154        # Could "emulate" the same behavior by using MacPorts' clang
155        # and appending -L/usr/lib/arc/ to CFLAGS/CXXFLAGS on 10.7,
156        # but I don't particularly like that idea (yet.)
157        # Keep using the "system compiler" for now. Also means one less
158        # dependency on recent systems, so yay.
159        PortGroup                   xcodeversion 1.0
160        minimum_xcodeversions       {11 4.4}
161
162        # Force recent enough SDK.
163        if {[vercmp ${configure.sdk_version} 10.8] < 0} {
164            configure.sdk_version   10.8
165        }
166
167        # Force clang compiler as installed by Xcode's CLT's... hopefully.
168        compiler.blacklist-append   *gcc* cc macports-*
169    }
170
171    if {${os.major} <= 10 || ${configure.build_arch} ne "x86_64"} {
172        # Disable Cocoa output.
173        # Users on old systems will need to embrace X11.
174        configure.args-replace      --enable-cocoa \
175                                    --disable-cocoa
176
177        default_variants-append     +x11
178    }
179}
180
181platform darwin {
182    notes-append [subst {
183                    The maintainer ships his personal config file in
184                    * ${prefix}/share/doc/${name}/examples/config-maintainer.
185
186                    You are strongly encouraged to copy this file to either
187                    * ${prefix}/etc/${name}/${name}.conf (globally for all users of the system) or
188                    * ~/.config/${name}/config (only for your current user)
189                    and adjust it to your needs.
190
191                    If you previously had your configuration file in
192                    * ~/.${name}/config
193                    please migrate it to
194                    * ~/.config/${name}/config
195                    which is the location preferred by upstream.
196    }]
197
198    # cocoa-cb backend requires Swift 5 or 4 support, which is only available
199    # in Xcode 9.1 onwards.
200    # if {[vercmp ${xcodeversion} 9.1] < 0} {
201    #     configure.args-replace  --enable-swift \
202    #                             --disable-swift
203    # }
204
205    # VideotoolBox, a new hardware acceleration framework, is supported on 10.8+ and "here to stay".
206    # It provides support for H264, H263, MPEG1, MPEG2 and MPEG4.
207    if {${os.major} > 11} {
208        configure.args-delete   --disable-videotoolbox-gl
209        configure.args-append   --enable-videotoolbox-gl
210    }
211
212    if {${os.major} > 11} {
213        notes-append {
214                        This config file already defines the necessary video output settings to make\
215                        use of the hardware acceleration features provided by your operating system.
216        }
217    } else {
218        notes-append {
219                        Sadly, your system is incapable of utilizing mpv's hardware decoding features.
220
221                        The example config file will not include a hardware decoding option.\
222                        Consult ``man mpv'' for further information.
223        }
224    }
225
226    # Fix for building on 10.15
227    if {[vercmp ${xcodeversion} 11] >= 0 || ${os.major} >= 19} {
228        use_xcode yes
229    }
230
231    # Shared build fixes for 10.6 and 10.7.
232    if {${os.major} < 12} {
233        patchfiles-append   patch-misc-import-CoreVideo.diff
234        patchfiles-append   patch-waftools-detection-compiler-py-no-tautological.diff
235    }
236
237    # Make mpv work as good as possible on 10.6 and below. No Cocoa support, instead concentrate
238    # on getting the OpenGL output to work via X11.
239    # Also fix some other minor compile issues only manifesting on 10.6 and below along the way.
240    if {${os.major} < 11} {
241        patchfiles-append   patch-audio_out_ao_coreaudio_utils.c-add-missing-header-for-getpid.diff
242        patchfiles-append   patch-waftools_detections_compiler.py-support-older-GCC.diff
243
244        notes-append {
245                        On systems older than Lion (10.7) or on architectures other than x86_64, Cocoa output support is not available.
246
247                        The X11 backend should have been enabled automatically.
248        }
249    }
250
251    # coreaudio does not build on < 10.6 so use pulseaudio instead (tested and works).
252    if {${os.major} < 10} {
253        configure.args-delete   --enable-coreaudio
254        configure.args-append   --disable-coreaudio
255
256        default_variants-append +pulseaudio
257        notes-append {
258                        On systems older than SnowLeopard (10.6), coreaudio output support is not available.
259
260                        The pulseaudio backend should have been enabled automatically.
261        }
262    }
263
264    post-extract {
265        xinstall -m 0644 -W "${filespath}" config-maintainer "${worksrcpath}/TOOLS/"
266    }
267
268    pre-configure {
269        if {[variant_isset network]} {
270            reinplace -W "${worksrcpath}/TOOLS" "s/@@NETWORK@@//" config-maintainer
271        } else {
272            reinplace -W "${worksrcpath}/TOOLS" "/@@NETWORK@@/d" config-maintainer
273        }
274
275        if {${os.major} > 11} {
276            reinplace -W "${worksrcpath}/TOOLS" "s/@@HWDEC@@//" config-maintainer
277        } else {
278            reinplace -W "${worksrcpath}/TOOLS" "/@@HWDEC@@/d" config-maintainer
279        }
280
281        if {${os.major} > 12} {
282            reinplace -W "${worksrcpath}/TOOLS" "s/@@HWDEC_CUDA@@//" config-maintainer
283        } else {
284            reinplace -W "${worksrcpath}/TOOLS" "/@@HWDEC_CUDA@@/d" config-maintainer
285        }
286
287        if {${os.major} < 11 || ${configure.build_arch} ne "x86_64"} {
288            reinplace -W "${worksrcpath}/TOOLS" "s/@@BACKEND@@/x11/" config-maintainer
289        } else {
290            reinplace -W "${worksrcpath}/TOOLS" "s/@@BACKEND@@/cocoa/" config-maintainer
291        }
292    }
293}
294
295
296# Shameless copy from ipe-tools.
297set python.versions         {27 38}
298dict set python.legacy_versions 37 38
299# After Python 3.9 is released, and mpv can be built with it,
300# replace with the above lines with the following:
301#set python.versions         {27 39}
302#dict set python.legacy_versions 38 39
303
304set python.default_version  38
305set python.version          ""
306
307# Create python variants.
308foreach ver ${python.versions} {
309    set variant_line {variant python${ver} description }
310    append variant_line " {Use python${ver} to generate man pages}"
311
312    foreach over ${python.versions} {
313        if {${ver} == ${over}} {
314            continue
315        }
316
317        append variant_line " conflicts python${over}"
318    }
319
320    append variant_line " {
321        depends_build-append    port:py${ver}-docutils
322        license_noconflict      py${ver}-docutils
323    }"
324    eval $variant_line
325}
326
327# Create legacy python variants, mapping to the replacement version.
328dict for {legacy_ver replace_ver} ${python.legacy_versions} {
329    set variant_line {variant python${legacy_ver} description }
330    append variant_line " {Legacy variant for python${legacy_ver} mapping to python${replace_ver}}"
331    append variant_line " requires python${replace_ver}"
332
333    foreach over ${python.versions} {
334        if {${legacy_ver} == ${over} || ${replace_ver} == ${over}} {
335            continue
336        }
337
338        append variant_line " conflicts python${over}"
339    }
340
341    append variant_line " { }"
342    eval $variant_line
343}
344
345# Set default python variant.
346set variant_none true
347foreach ver ${python.versions} {
348    if {[variant_isset python${ver}]} {
349        set variant_none [expr $variant_none && ![variant_isset python${ver}]]
350    }
351}
352
353if {${variant_none}} {
354    default_variants-append "+python${python.default_version}"
355}
356
357# Set ${python.version} to the currently active variant.
358foreach ver ${python.versions} {
359    if {[variant_isset python${ver}]} {
360        set python.version ${ver}
361    }
362}
363
364if {[string length ${python.version}] == 0} {
365    ui_error "No python variant selected. You must select at least one. The highest value will be used."
366    error "Select a python variant."
367}
368
369post-patch {
370    set python_ver_dot [join [split ${python.version} {}] "."]
371    reinplace -W "${worksrcpath}" "s|'rst2man'|'rst2man-${python_ver_dot}'|" wscript
372}
373
374post-extract {
375    xinstall -m 0644 -W "${distpath}" "${waf_distfile}" "${worksrcpath}/waf"
376}
377
378post-destroot {
379    # Since we don't have conffiles handling, install mpv.conf as mpv.conf.example
380    # to not overwrite this file on each (re-)build.
381    file rename ${worksrcpath}/etc/mpv.conf ${worksrcpath}/etc/mpv.conf.example
382
383    xinstall -d -m 0755 ${destroot}${prefix}/etc/${name}
384    foreach etcfile {encoding-profiles.conf mpv.conf.example input.conf} {
385        xinstall -m 0644 ${worksrcpath}/etc/${etcfile} \
386            ${destroot}${prefix}/etc/${name}/${etcfile}
387    }
388    xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}/examples
389    copy {*}[glob ${worksrcpath}/TOOLS/lua ${worksrcpath}/TOOLS/*.pl \
390                  ${worksrcpath}/TOOLS/*.sh ${worksrcpath}/TOOLS/*.py \
391                  ${worksrcpath}/TOOLS/umpv ${worksrcpath}/TOOLS/lib] \
392         ${destroot}${prefix}/share/doc/${name}/examples
393
394    if {${os.platform} eq "darwin"} {
395        xinstall -m 0644 ${worksrcpath}/TOOLS/config-maintainer \
396                         ${destroot}${prefix}/share/doc/${name}/examples
397    }
398}
399
400
401# When enabling features, make sure to replace the "disable" flags with
402# "enable" flags in order to make the waf build system error out in case
403# a feature cannot be used/found. Problems like that indicate a missing
404# runtime dependency.
405
406variant bundle description {Enable the optional macOS bundle of mpv} {
407    post-build {
408        system -W "${worksrcpath}" "${waf.python} TOOLS/osxbundle.py -s build/mpv"
409    }
410
411    post-destroot {
412        xinstall -d -m 0755 ${destroot}${applications_dir}
413        copy ${worksrcpath}/build/mpv.app ${destroot}${applications_dir}
414    }
415}
416
417variant screenshot description {Enable optional screenshot support} {
418    depends_lib-append      path:lib/libjpeg.dylib:jpeg
419    configure.args-replace  --disable-jpeg \
420                            --enable-jpeg
421}
422
423variant network description {Enable networking support via youtube-dl (supports wide variety of pages)} {
424    depends_run-append      port:youtube-dl
425}
426
427variant dvd description {Enable DVD and DeCSS support} {
428    depends_lib-append      port:libdvdread \
429                            port:libdvdnav
430    configure.args-replace  --disable-dvdnav \
431                            --enable-dvdnav
432}
433
434variant audiocd description {Enable Audio CD support via libcdio-paranoia} {
435    depends_lib-append      port:libcdio-paranoia
436    configure.args-replace   --disable-cdda \
437                             --enable-cdda
438}
439
440variant libarchive description {Enable transparent handling of Zip files and other compressed formats} {
441    depends_lib-append      port:libarchive
442    configure.args-replace  --disable-libarchive \
443                            --enable-libarchive
444}
445
446variant rubberband description {Enable support for the Rubber Band library, adding audio pitch and speed control} {
447    depends_lib-append      port:rubberband
448    configure.args-replace  --disable-rubberband \
449                            --enable-rubberband
450}
451
452variant pulseaudio description {Enable PulseAudio support} {
453    depends_lib-append      port:pulseaudio
454    configure.args-replace  --disable-pulse \
455                            --enable-pulse
456}
457
458variant jack description {Enable Jack Audio Connection Kit support} {
459    depends_lib-append      port:jack
460    configure.args-replace  --disable-jack \
461                            --enable-jack
462}
463
464# TODO: switch that to openal-soft? Leave it as-is?
465variant openal description {Enable OpenAL support} {
466    depends_lib-append      port:openal
467    configure.args-replace  --disable-openal \
468                            --enable-openal
469}
470
471variant x11 {
472    depends_lib-append      port:xorg-libXext \
473                            port:xorg-libXScrnSaver \
474                            port:xorg-libXinerama \
475                            port:xorg-libXv \
476                            port:xorg-libXrandr
477
478    configure.args-delete   --disable-x11 \
479                            --disable-xv
480    configure.args-append   --enable-x11 \
481                            --enable-xv
482}
483
484variant opengl description {Enable OpenGL output support. Both the CoreVideo and X11 (GLX) outputs are supported} {
485    if {${os.platform} eq "darwin" && ${os.major} > 10} {
486        configure.args-replace  --disable-gl-cocoa \
487                                --enable-gl-cocoa
488    }
489
490    configure.args-replace  --disable-gl \
491                            --enable-gl
492
493    if {[variant_isset x11]} {
494        depends_lib-append      port:mesa
495        configure.args-replace  --disable-gl-x11 \
496                                --enable-gl-x11
497        # FIXME: add EGL? Leave it disabled? Test!
498        # As far as testing went, EGL is not available on macOS yet.
499        #configure.args-replace  --disable-egl-x11 \
500        #                        --enable-egl-x11
501    }
502}
503
504variant caca description {Enable animated ASCII art video output} {
505    depends_lib-append      port:libcaca
506    configure.args-replace  --disable-caca \
507                            --enable-caca
508}
509
510variant osd description {Enable onscreen display and TrueType font support} {
511    depends_lib-append      port:lua52
512    configure.args-delete   --disable-lua \
513                            --disable-libass-osd
514    configure.args-append   --enable-lua \
515                            --lua=52fbsd \
516                            --enable-libass-osd
517}
518
519variant smb description {Enable Samba support} {
520    depends_lib-append      path:lib/pkgconfig/smbclient.pc:samba3
521    configure.args-replace  --disable-libsmbclient \
522                            --enable-libsmbclient
523}
524
525variant debug description {Compile with debugging symbols} {
526    configure.args-replace  --disable-debug-build \
527                            --enable-debug-build
528}
529
530variant printable_doc description {Generate printable documents (PDF help)} {
531    # py27-pdfrw and py27-Pillow are needed by rst2pdf.
532    depends_build-append    port:rst2pdf \
533                            port:py27-pdfrw \
534                            port:py27-Pillow
535    configure.args-replace  --disable-pdf-build \
536                            --enable-pdf-build
537}
538
539#variant javascript description {Enable JavaScript support via mujs} {
540#   depends_lib-append      port:mujs
541#   configure.args-replace  --disable-javascript \
542#                           --enable-javascript
543#}
544
545variant uchardet description {Enable the uchardet encoding detector} {
546    depends_lib-append      port:uchardet
547    configure.args-replace  --disable-uchardet \
548                            --enable-uchardet
549}