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

github.setup    libsdl-org sdl12-compat 1.2.72 release-
categories      devel multimedia
platforms       macosx freebsd
license         zlib
maintainers     {jmr @jmroot} openmaintainer
description     SDL 1.2 compatibility layer

long_description \
    This is a compatibility layer that allows programs written for \
    SDL 1.2.x to run with SDL 2.x.

homepage        https://www.libsdl.org/

github.tarball_from releases
checksums       rmd160 0c2405c4c5d5c994a05742a4a5c5f4460341c19e \
                sha256 86b201257e3073546b00e276bc6668412458b3bb8eeb7b365ff65f0c0ce14133

depends_lib     port:libsdl2

patchfiles      SDL2path.patch
post-patch {
    reinplace "s|__PREFIX__|${prefix}|" ${worksrcpath}/src/SDL12_compat.c
}

cmake.out_of_source yes
configure.args-append   -DSDL2_PATH=${prefix}

post-destroot {
    # Allow installing in parallel with libsdl12
    set my_prefix ${prefix}/libexec/${name}
    xinstall -d ${destroot}${my_prefix}/bin \
                ${destroot}${my_prefix}/include \
                ${destroot}${my_prefix}/lib \
                ${destroot}${my_prefix}/share
    move ${destroot}${prefix}/bin/sdl-config ${destroot}${my_prefix}/bin
    move ${destroot}${prefix}/include/SDL ${destroot}${my_prefix}/include
    move {*}[glob ${destroot}${prefix}/lib/*] ${destroot}${my_prefix}/lib
    move ${destroot}${prefix}/share/aclocal ${destroot}${my_prefix}/share

    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}

    xinstall -m 0644 -W ${worksrcpath} BUGS.md COMPATIBILITY.md LICENSE.txt README.md \
        ${destroot}${docdir}
}
