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

name                    lisaem
version                 1.2.6
revision                2
maintainers             ryandesign
platforms               darwin
categories              emulators
license                 GPL-2
homepage                http://lisa.sunder.net/
master_sites            ${homepage}downloads/
use_bzip2               yes
use_parallel_build      no

description \
    Apple Lisa emulator

long_description \
    ${description}

checksums \
    md5 b236d7fa06c7589bb0de5d13ed680c9a \
    sha1 c3552eb2fc89ff6e47994767aa4e524de7000dc7 \
    rmd160 bc541ef181b417ee369ed960f29637f87cc1308a

patchfiles \
    patch-build.sh.diff

use_configure           no

build.cmd               ./build.sh
build.target            build
pre-build {
    build.env-append    CC="${configure.cc} [get_canonical_archflags cc] -Wno-error -Wno-return-type" \
                        CXX="${configure.cxx} [get_canonical_archflags cxx]"
}

destroot.destdir
pre-destroot {
    destroot.env-append CC="${configure.cc} [get_canonical_archflags cc] -Wno-error -Wno-return-type" \
                        CXX="${configure.cxx} [get_canonical_archflags cxx]" \
                        PREFIXAPP=${destroot}${applications_dir} \
                        PREFIXBIN=${destroot}${prefix}/bin \
                        PREFIXLIB=${destroot}${prefix}/share
}

post-activate {
    # lisaem 1.2.6_0 installed items to /usr/local/bin; remove them if found
    foreach file {lisadiskinfo lisafsh-tool} {
        set filepath /usr/local/bin/${file}
        if {[file exists ${filepath}] && [registry_file_registered ${filepath}] == "0"} {
            if {[catch {delete ${filepath}}]} {
                ui_warn "Cannot delete ${filepath}; please remove it manually"
            }
        }
    }
}

# the two wxWidgets variants can go away if lisaem gets ported to wxWidgets-3.0
variant wxwidgets28 conflicts wxgtk28 description {Use 32-bit Carbon-based wxWidgets 2.8} {
    wxWidgets.use       wxWidgets-2.8
    depends_lib-append  port:${wxWidgets.port}
    build.env-append    WX_CONFIG=${wxWidgets.wxconfig}
    destroot.env-append WX_CONFIG=${wxWidgets.wxconfig}
}

variant wxgtk28 conflicts wxwidgets28 description {Use wxWidgets 2.8 with GTK} {
    wxWidgets.use       wxGTK-2.8
    depends_lib-append  port:${wxWidgets.port}
    build.env-append    WX_CONFIG=${wxWidgets.wxconfig}
    destroot.env-append WX_CONFIG=${wxWidgets.wxconfig}
}

if {![variant_isset wxwidgets28] && ![variant_isset wxgtk28]} {
    if {[vercmp $xcodeversion 4.4] >= 0} {
        default_variants +wxgtk28
    } else {
        default_variants +wxwidgets28
    }
}

livecheck.type          regex
livecheck.url           ${homepage}downloads.html
livecheck.regex         ${name}-(\[0-9.\]+)\\.tar
