# -*- 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.76 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 c138f251b5e34bc2817ccf539dff45bdd5216e40 \
                sha256 a68477009c24bc6e876326b1e8dd0bedec2b0c37acbddbddf90acba48fba4b38

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