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

name                    hatari
version                 2.1.0
revision                2
categories              emulators
license                 GPL-2+
platforms               darwin

maintainers             nomaintainer
description             Atari ST/STe/STfm emulator
long_description        Hatari is an actively developed Atari ST/STe/STfm and Falcon emulator
homepage                http://hatari.tuxfamily.org/

master_sites            http://download.tuxfamily.org/hatari/${version}/

checksums               sha256  eb299460e92db4a8a2983a0725cbbc8c185f1470b8ecd791b3d102815da20924 \
                        rmd160  863a9428ab6d7cae7e7975e0b31fad5ee452b4c2

use_bzip2               yes

depends_lib             port:libsdl \
                        port:libpng \
                        port:readline \
                        port:portaudio \
                        port:zlib \
                        port:portmidi

# 1. fix hard-coded installation directory for mac bundle
# 2. delete warning flag in winuae emulator code not supported by GCC42
# 3. disable python ui - not needed for mac
post-patch {
    reinplace "s|/Applications|${applications_dir}|g" ${worksrcpath}/src/CMakeLists.txt
    reinplace "s|-Wno-maybe-uninitialized||g" ${worksrcpath}/src/cpu/CMakeLists.txt
    reinplace "s|add_subdirectory(python-ui)||g" ${worksrcpath}/CMakeLists.txt
}

platform darwin {
    # default to command line (SDL GUI) app and sdl version 1
    configure.args-append    -DENABLE_OSX_BUNDLE:BOOL=0
    configure.args-append    -DENABLE_SDL2:BOOL=0

    if { ${os.major} > 9 } {
        default_variants    +sdl2
    }

    if { ${os.major} > 15 } {
        default_variants    +macOSGUI
    }
}

variant macOSGUI description "Build macOS GUI Application (10.12+)" {
    use_xcode                yes
    configure.args-replace   -DENABLE_OSX_BUNDLE:BOOL=0 -DENABLE_OSX_BUNDLE:BOOL=1
    post-destroot {
        copy ${worksrcpath}/src/tos.img ${destroot}${applications_dir}/hatari.app/Contents/Resources/tos.img
    }
}

variant sdl2 description "Use SDL 2.0 instead of SDL 1.2 (10.6+)" {
    configure.args-replace   -DENABLE_SDL2:BOOL=0 -DENABLE_SDL2:BOOL=1
    depends_lib-replace      port:libsdl port:libsdl2
}

notes "
A free Atari-compatible ROM, EmuTOS, is installed with this port.

    http://sourceforge.net/projects/emutos

An online manual has been installed at

    file://${prefix}/share/doc/hatari/manual.html

and can be accessed via the Help menu in the macOS GUI application.
"
