# -*- 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

name                    enigma
subport                 enigma-devel {}

if {${subport} eq "enigma"} {
    conflicts               enigma-devel
    version                 1.21
    revision                7
    master_sites            sourceforge:project/enigma-game/Release%20${version}/
    checksums               rmd160  7942dd2acc1e21cb40200a9ae767a4673c569a2a \
                            sha256  d872cf067d8eb560d3bb1cb17245814bc56ac3953ae1f12e2229c8eb6f82ce01 \
                            size    56409951
                            
    patchfiles-append       patch-remove-SDL-frameworks-stop-static-linking.diff

    # /opt/local/libexec/llvm-9.0/bin/../include/c++/v1/system_error:434:1: note: candidate function not viable: no known conversion from 'basic_ifstream<char>' to 'const std::__1::error_condition' for 1st argument
    compiler.blacklist-append {macports-clang-[6-9].0}

} elseif {${subport} eq "enigma-devel"} {
    conflicts               enigma
    PortGroup               github 1.0
    
    github.setup            Enigma-Game Enigma 26a0ad7d8918f1e640bafac599976ddf18de23fa
    version                 20191107
    revision                5
    checksums               rmd160  156709b0dfedf9c9282562a2cabbe25241d572d4 \
                            sha256  4e546ffc456add0aa7747be01b1cd5f33993b4d40dd9bed8d20524fc586a7ed1 \
                            size    51867405

    # use SDL dylibs instead of frameworks
    patchfiles-append       patch-configure-ac-remove-frameworks.diff \
                            patch-src-makefile-am-remove-frameworks.diff

    # fix library links
    patchfiles-append       patch-configure-ac-fix-libiconv-libicuuc.diff \
                            patch-configure-ac-stop-static-linking.diff

    use_autoconf            yes
    autoconf.cmd            ./autogen.sh
    depends_build-append    port:autoconf port:automake

    compiler.cxx_standard   2011
}

categories              games
platforms               darwin
maintainers             nomaintainer
license                 GPL-2+
homepage                https://www.nongnu.org/enigma/

description             puzzle game inspired by the games Oxyd and Rock'n'Roll
    
long_description        Enigma is a puzzle game inspired by Oxyd on the Atari ST and Rock'n'Roll \
                        on the Amiga. The object of the game is to find and uncover pairs of \
                        identically colored Oxyd stones. Simple? Yes. Easy? Certainly not! Hidden \
                        traps, vast mazes, laser beams, and, most of all, countless hairy puzzles \
                        usually block your direct way to the Oxyd stones.

use_parallel_build      no

# c++17 has a conflicting header
post-patch {
    move ${worksrcpath}/intl/VERSION ${worksrcpath}/intl/VERSION.txt 
}

configure.args-append   --with-libintl-prefix=${prefix}

# uses a bundled lua-5.1 version
configure.cppflags-prepend \
                        -I${worksrcpath}/lib-src/lua

depends_build-append    port:pkgconfig \
                        port:ImageMagick \
                        port:texi2html \
                        port:osxutils

depends_lib             port:libsdl \
                        port:libsdl_image \
                        port:libsdl_mixer \
                        port:libsdl_ttf \
                        port:freetype \
                        port:gettext \
                        path:include/turbojpeg.h:libjpeg-turbo \
                        port:libpng \
                        port:xercesc3 \
                        port:curl \
                        port:zlib \
                        port:bzip2 \
                        port:libiconv \
                        path:lib/pkgconfig/icu-uc.pc:icu

build.target            all macapp

destroot {
    copy ${worksrcpath}/etc/macfiles/Enigma.app \
        ${destroot}${applications_dir}/
}
