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

name            libsdl2
github.setup    libsdl-org SDL 2.32.10 release-
categories      devel multimedia
platforms       macosx freebsd
license         zlib
maintainers     {jmr @jmroot} openmaintainer
description     Cross-platform multi-media development API

long_description \
    Simple DirectMedia Layer is a cross-platform development library \
    designed to provide low level access to audio, keyboard, mouse, \
    joystick, and graphics hardware via OpenGL and Direct3D.

homepage        https://www.libsdl.org/

github.tarball_from releases
distname        SDL2-${version}
checksums       rmd160 4212372b886f8dbab92141c520951e245e0c9657 \
                sha256 5f5993c530f084535c65a6879e9b26ad441169b3e25d789d83287040a9ca5165

depends_lib     port:libiconv

patchfiles      available.patch

configure.args  --without-x \
                --disable-jack \
                --disable-esd \
                --disable-pulseaudio \
                --disable-libsamplerate \
                --disable-dbus
build.args      V=1

if {${os.subplatform} eq "macosx" && ${os.major} <= 10} {
    if {${configure.build_arch} in [list ppc ppc64]} {
        depends_lib port:libsdl2-powerpc
    } else {
        depends_lib port:libsdl2-snowleopard
    }
    distfiles
    patchfiles
    use_configure no
    build {}
    destroot {
        xinstall -d ${destroot}${prefix}/share/doc/${name}
        system "echo $name is a stub port > ${destroot}${prefix}/share/doc/${name}/README"
    }
} else {
conflicts libsdl2-powerpc libsdl2-snowleopard

platform macosx {
    # Uses ObjC ARC, which can't be used with the legacy runtime (as
    # used on 32-bit) before LLVM 3.8, which is roughly Xcode 7.3.
    compiler.blacklist *gcc*
    if {(!($universal_possible && [variant_isset universal]) && ${configure.build_arch} eq "i386")
        || (($universal_possible && [variant_isset universal]) && "i386" in ${configure.universal_archs})} {
        compiler.blacklist-append   {clang < 703}
    } else {
        compiler.blacklist-append   {clang < 211}
    }
}

variant x11 {
    configure.args-delete --without-x
    configure.args-append --x-includes=${prefix}/include \
                          --x-libraries=${prefix}/lib \
                          --disable-x11-shared
    depends_lib-append \
        port:xorg-libX11 \
        port:xorg-libXcursor \
        port:xorg-libXext \
        port:xorg-libXi \
        port:xorg-libXinerama \
        port:xorg-libXrandr \
        port:xorg-libXScrnSaver \
        port:xorg-libXxf86vm \
        port:xrender
}
if {${os.subplatform} ne "macosx"} {
    default_variants +x11
}

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} BUGS.txt CREDITS.txt LICENSE.txt \
        README-SDL.txt TODO.txt WhatsNew.txt \
        {*}[glob ${worksrcpath}/docs/*.md] ${destroot}${docdir}
}

}

github.livecheck.regex  {(2\.[^"]+)}
