# -*- 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
PortGroup           cxx11 1.1

github.setup        Pingus pingus 06afdabb6b27c1314bb1d90a05d467697b72be58
version             0.8.0-20170511
categories          games
platforms           darwin
maintainers         gmail.com:ken.cunningham.webuse openmaintainer
license             GPL-3

description         A free Lemmings(tm) clone using SDL2.
long_description    ${description} It is a puzzle game where the player has to guide a group of penguins to safety.

fetch.type          git
post-extract {
    system -W ${worksrcpath} "git submodule update --init"
}

depends_build-append \
                    port:pkgconfig

depends_lib         port:boost \
                    port:libiconv \
                    port:libsdl2 \
                    port:libsdl2_image \
                    port:libsdl2_mixer \
                    port:libpng \
                    port:jsoncpp

configure.ldflags-append \
                    -liconv \
                    -framework CoreFoundation

cmake.out_of_source yes

configure.args      -DCMAKE_INSTALL_PREFIX:PATH="${applications_dir}/Pingus.app/Contents/MacOS"

# fix build against newer boost 
platform darwin powerpc {
    patchfiles          patch-cmakelists-gnu14.diff
}

pre-destroot {
    xinstall -d ${destroot}${applications_dir}/Pingus.app/Contents/Resources \
                ${destroot}${applications_dir}/Pingus.app/MacOS
    file copy ${worksrcpath}/data/images/icons/pingus-icon.icns ${destroot}${applications_dir}/Pingus.app/Contents/Resources/pingus.icns
    file copy ${worksrcpath}/Info.plist "${destroot}${applications_dir}/Pingus.app/Contents/Info.plist"
}

post-destroot {
    file copy ${destroot}${applications_dir}/Pingus.app/Contents/MacOS/bin/pingus ${destroot}${applications_dir}/Pingus.app/Contents/MacOS/pingus
    reinplace "s|\"$@\"||g" ${destroot}${applications_dir}/Pingus.app/Contents/MacOS/pingus
}
