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

PortSystem 1.0

name            libsdl2
set my_name     SDL2
version         2.0.3
categories      devel multimedia
platforms       macosx freebsd
license         zlib
maintainers     jmr 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        http://www.libsdl.org/
master_sites    ${homepage}release/
distname        ${my_name}-${version}

checksums       rmd160 e6f3718c7366c5da793c1454cf0ec0972e8bd347 \
                sha256 a5a69a6abf80bcce713fa873607735fe712f44276a7f048d60a61bb2f6b3c90c

configure.args  --without-x

platform macosx {
    if {${os.major} <= 10} {
        # Build requires at least 10.7 SDK, even when targeting 10.6
        set lion_sdkpath ${developer_dir}/SDKs/MacOSX10.7.sdk
        if {[file exists $lion_sdkpath]} {
            configure.sdkroot $lion_sdkpath
        } else {
            pre-fetch {
                error "Building $name requires OS X 10.7 SDK or later"
            }
        }
    }
}

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-libXext \
        port:xorg-libXrandr \
        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 COPYING.txt CREDITS.txt \
        README.txt README-gesture.txt README-macosx.txt README-SDL.txt \
        README-touch.txt TODO.txt ${destroot}${docdir}
}

livecheck.type  regex
livecheck.url   ${homepage}download-2.0.php
livecheck.regex ${my_name}-(\\d+(?:\\.\\d+)*)