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

github.setup    libsdl-org sdl12-compat 1.2.68 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 archive
checksums       rmd160 da29c45cb960066ed781b90833b92ce5bafa0ac2 \
                sha256 63c6e4dcc1154299e6f363c872900be7f3dcb3e42b9f8f57e05442ec3d89d02d

depends_lib     port:libsdl2

worksrcdir      ${name}-release-${version}

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