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

epoch               2
# TechSmith/mp4v2 4.1.4 introduced a breaking API change that totally
# broke the ability for C code to use this library. Don't upgrade to a
# newer version unless the API breakage has been reverted. So far, the
# developers have not responded to this issue, which was filed 20201211.
# https://github.com/TechSmith/mp4v2/issues/47
github.setup        TechSmith mp4v2 4.1.3 Release-ThirdParty-MP4v2-
revision            1
checksums           rmd160  8727c9cb5d256073e3ed46fb6ab9502e1bec66e5 \
                    sha256  e3ad6c2dc451b0875dbe34bfe7f51f4fe278b391434c886083e6d3ecd5fa08c2 \
                    size    2682188

categories          multimedia
license             MPL-1.1 BSD-old
maintainers         nomaintainer
description         Read, create, and modify mp4 files.
long_description    The mp4v2 library provides an API to create and modify mp4 \
                    files as defined by ISO-IEC:14496-1:2001 MPEG-4 Systems. \
                    mp4v2 used to be part of the mpeg4ip library.

github.tarball_from archive

depends_build       port:help2man

patchfiles          configure-version.patch \
                    mp4tags-metadata.patch \
                    20210111-8d6307ea1e70c0a44dd2a64c4fa1a8f42b803ebf.patch \
                    20210318-aa06c07ec0b0e0e1b6dd82bf32821668059e8662.patch

post-patch {
    reinplace "s|@@VERSION@@|${version}|g" \
        ${worksrcpath}/configure.ac
}

# error: 'nullptr' was not declared in this scope
compiler.cxx_standard 2011
configure.cxxflags-append -std=c++11

# Teach glibtool about -stdlib
# Also we are patching configure.ac.
use_autoreconf      yes
autoreconf.args     -fvi

# mp4subtitle.cpp: error: narrowing conversion of 'mp4v2::util::SubtitleUtility::LC_LIST' from 'unsigned int' to 'int'
# The error is not specific to 32-bit and happens with gcc and clang both.
if {[string match *clang* ${configure.compiler}]} {
    configure.cxxflags-append \
                    -Wno-error=c++11-narrowing
} elseif {[string match *gcc* ${configure.compiler}]} {
    configure.cxxflags-append \
                    -Wno-narrowing
}

platform darwin {
    if {${os.major} < 10} {
        patchfiles-append mp4v2-1.9.1-libversion.patch
    }
}

variant universal {
    configure.args-append  --disable-gch
}
