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

PortSystem      1.0
PortGroup       xcodeversion 1.0

name            libsdl2-snowleopard
conflicts       libsdl2-powerpc
set my_name     SDL2
version         2.0.22
revision        0
categories      devel multimedia
platforms       macosx freebsd
supported_archs arm64 i386 x86_64
license         zlib
maintainers     nomaintainer
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. This port \
    will maintain the last version that can build on 10.6.8 SnowLeopard.

homepage        http://www.libsdl.org/
master_sites    ${homepage}release/
distname        ${my_name}-${version}

checksums       rmd160  887c0414e1e3ad1a74900eae89c071a053d9a178 \
                sha256  fe7cbf3127882e3fc7259a75a0cb585620272c51745d3852ab9dd87960697f2e \
                size    7250633

configure.args  --without-x
build.args      V=1

compiler.blacklist *gcc* { clang < 211 }

minimum_xcodeversions   {11 4.3}

platform macosx {
    if {${os.major} <= 10} {
        # Build requires at least 10.7.3 SDK, even when targeting 10.6
        configure.sdk_version   10.7
        if {${configure.sdkroot} eq ""} {
            pre-fetch {
                error "Building $name @${version} on Mac OS X 10.6 requires the MacOSX10.7.sdk to be present in ${developer_dir}/SDKs/"
            }
        }
    }
}

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}
}

livecheck.type  none
