# -*- 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

PortSystem          1.0
PortGroup           compiler_blacklist_versions 1.0
PortGroup           muniversal 1.0

name                libvpx
conflicts           libvpx-devel
set my_name         libvpx
version             1.11.0
revision            1
categories          multimedia
maintainers         {mascguy @mascguy} openmaintainer
platforms           darwin
license             Permissive

description         WebM VP8/VP9 Codec SDK
long_description    The WebM VP8/VP9 codecs are being developed \
                    specifically to meet the demand for the consumption \
                    of video over the Internet, including professionally \
                    and amateur produced video-on-demand and conversational \
                    video content. VP9 is an evolution of the VP8 video \
                    codec and includes a number of enhancements and new \
                    coding tools that have been added to improve coding efficiency. \
                    The VP9 encoder in this release is not, as yet, feature complete.

homepage            http://webmproject.org/tools/

distname            ${my_name}-${version}
dist_subdir         ${my_name}

# use git fetch rather than downloading a snapshot tarball
# which delivers a different checksum and size on each download
# this is not a stealth upgrade but a "feature" of this repo

fetch.type          git
git.url             https://chromium.googlesource.com/webm/${my_name}
git.branch          v${version}

# support for non-intel archs removed in version 1.5.0
supported_archs     ppc

patchfiles          patch-c.sh.diff \
                    patch-c.diff \
                    patch-v8.diff \
                    patch-vpx_ports.mk.diff 
#                     makefile.diff

# uses newer assembly features on Intel
compiler.blacklist-append  {*gcc-[3-4].*} {clang < 800} {macports-clang-3.*}

# As of 1.7.0: builds both static and shared libraries
# doesn't install docs or examples correctly, so disable them.
configure.args      --enable-vp8 \
                    --enable-vp9 \
                    --enable-internal-stats \
                    --enable-pic \
                    --enable-postproc \
                    --enable-multithread \
                    --enable-experimental \
                    --disable-shared \
                    --enable-runtime-cpu-detect \
                    --enable-libyuv \
                    --disable-install-docs \
                    --disable-debug-libs \
                    --disable-examples \
                    --disable-unit-tests \
                    --force-target=generic-gnu

# configure.args      --enable-vp8 \
#                     --enable-vp9 \
#                     --enable-internal-stats \
#                     --enable-pic \
#                     --enable-postproc \
#                     --enable-multithread \
#                     --enable-runtime-cpu-detect \
#                     --enable-libyuv \
#                     --disable-install-docs \
#                     --disable-debug-libs \
#                     --disable-examples \
#                     --disable-unit-tests \
#                     --force-target=generic-gnu

configure.env       LD="${configure.cc}"

build.target
build.args          verbose=1
destroot.args       verbose=1

if {"${configure.sdkroot}" eq ""} {
    configure.sdkroot "/"
}

platform darwin 10 {
    # Tiger's make 3.80 experiences "virtual memory exhausted" during destroot
    depends_build-append    port:gmake
    build.cmd               ${prefix}/bin/gmake
}

# if {![info exists universal_possible]} {
#     set universal_possible [expr {${os.universal_supported} && [llength ${configure.universal_archs}] >= 2}]
# }

# if {${universal_possible} && [variant_isset universal]} {
# 
#     # universal build using muniversal portgroup
# 
#     foreach my_arch {i386 x86_64 arm64} {
# 
#         # strip the automatic setting of host
#         set merger_host(${my_arch}) ""
# 
#         # force the target
#         set merger_configure_args(${my_arch})     --force-target=${my_arch}-${os.platform}${os.major}-gcc
# 
#         # set LD
#         set merger_configure_env(${my_arch})      LD=${configure.cc}
#     }
# 
#     if {"x86_64" in ${configure.universal_archs} || "i386" in ${configure.universal_archs}} {
#         depends_build-append  port:yasm
#         depends_skip_archcheck-append yasm
# 
#         # for Intel archs, allow runtime cpu detection
#         lappend merger_configure_args(i386)   --enable-runtime-cpu-detect
#         lappend merger_configure_args(x86_64) --enable-runtime-cpu-detect
# 
#         # parses the assembly output by default even when emitting assembly
#         if {[string match {*clang*} ${configure.compiler}]} {
#             lappend merger_build_args(i386)   CFLAGS_S=-fno-integrated-as
#             lappend merger_build_args(x86_64) CFLAGS_S=-fno-integrated-as
#         }
# 
#     }
# 
# } else {
# 
#     # normal build
# 
#     # force the target
#     configure.args-append --force-target=${configure.build_arch}-${os.platform}${os.major}-gcc
# 
#     # set LD
#     configure.env-append  LD=${configure.cc}
# 
#     if {${configure.build_arch} in {i386 x86_64}} {
#         depends_build-append     port:yasm
#         depends_skip_archcheck-append yasm
# 
#         configure.args-append    --enable-runtime-cpu-detect
# 
#         # parses the assembly output by default even when emitting assembly
#         if {[string match {*clang*} ${configure.compiler}]} {
#             build.args-append CFLAGS_S=-fno-integrated-as
#         }
#     }
# }

# shared library uses relative path in install name
# override with absolute path
# post-destroot {
#     foreach f [glob ${destroot}${prefix}/lib/${my_name}.*.dylib] {
#         system "install_name_tool -id [string map [list ${destroot} ""] ${f}] ${f}"
#     }
# }

livecheck.type  regex
livecheck.url   https://chromium.googlesource.com/webm/${my_name}
livecheck.regex ">v(\\d+(?:\\.\\d+)*)<"
