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

name                libmpeg2
version             0.5.1
revision            3
categories          multimedia
license             GPL-2+
maintainers         nomaintainer
homepage            https://libmpeg2.sourceforge.net/
description         A free library for decoding mpeg-2 and mpeg-1 video streams.
long_description    libmpeg2 is a free library for decoding \
                    mpeg-2 and mpeg-1 video streams.  The main \
                    goals in libmpeg2 development are \
                    conformance, speed, portability, and reuseability.
master_sites        ${homepage}files/

checksums           rmd160  00b2d669655ed3f7a176f5eecc925045159a0301 \
                    sha256  dee22e893cb5fc2b2b6ebd60b88478ab8556cb3b93f9a0d7ce8f3b61851871d4 \
                    size    524776

patchfiles          universal.patch patch-arm64.diff

configure.args      --enable-shared \
                    --disable-sdl \
                    --without-x \
                    --mandir=${prefix}/share/man

configure.cflags-append \
                    -std=gnu89

variant sdl description {Use libsdl} {
    depends_lib-append      port:libsdl
    configure.args-replace  --disable-sdl --enable-sdl
}

variant x11 {
    depends_lib-append      port:xorg-libXv \
                            port:xorg-libX11 \
                            port:xorg-libXext \
                            port:xorg-libice \
                            port:xorg-libsm
    configure.args-replace  --without-x --with-x
    configure.args-append   --x-includes=${prefix}/include \
                            --x-libraries=${prefix}/lib
}

default_variants    +sdl +x11

platform darwin 10 powerpc {
    # Build otherwise is broken on Rosetta: https://trac.macports.org/ticket/68143
    configure.args-append   --build=powerpc-apple-darwin${os.major}
}

livecheck.type      regex
livecheck.url       ${homepage}downloads.html
livecheck.regex     "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
