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

github.setup        Pixinn Rgb2Hires 1da2fd8524d7c39d5ddc4c4cf0aa9e00198448c7
version             20231031
revision            0
checksums           rmd160  1b3389f15b6de6d6654658447cea7dcbffd6ebd7 \
                    sha256  42f7aea434b6d6de1532348b7c5a1d37de87297be73030dfe8e279c668d9be7a \
                    size    138650

categories          graphics
maintainers         {ryandesign @ryandesign} openmaintainer
license             GPL-3 MIT

description         a set of tools for converting images to Apple II format

long_description    ${name} is a set of tools to help convert a modern RGB \
                    image (JPEG, PNG) to the HIRES format for Apple II \
                    computers, either as a binary export or an assembly listing.

github.tarball_from archive

depends_build-append \
                    path:bin/pkg-config:pkgconfig

depends_lib         port:libsdl2 \
                    port:libsdl2_image

compiler.cxx_standard \
                    2017

cmake.source_dir    ${worksrcpath}/${name}_PC
cmake.build_type    Release

post-extract {
   # DOS to UNIX line endings so we can patch.
   reinplace "s|\r||g" ${cmake.source_dir}/CMakeLists.txt
}

patchfiles          CMakeLists.txt.patch

configure.cxxflags-prepend \
                    -I${cmake.source_dir}/src

pre-configure {
    configure.cxxflags-append [exec ${prefix}/bin/pkg-config SDL2_image --cflags]
    configure.ldflags-append [exec ${prefix}/bin/pkg-config SDL2_image --libs]
}

destroot {
    xinstall \
        {*}[glob ${cmake.source_dir}/bin/[string tolower ${cmake.build_type}]/*] \
        ${destroot}${prefix}/bin
    set docdir ${prefix}/share/doc/${subport}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} COPYING Readme.md ${destroot}${docdir}
}
