# $Id: Portfile 51530 2009-05-27 15:48:31Z ryandesign@macports.org $

PortSystem              1.0

name                    minivmac
version                 2.8.2
revision                2
categories              emulators aqua
maintainers             ryandesign
homepage                http://minivmac.sourceforge.net/
master_sites            sourceforge
use_configure           no
worksrcdir              projects/bgcmachs
build.target
platforms               darwin
universal_variant       no
use_parallel_build      yes

description \
    a Mac 128K, Mac 512K, Mac 512KE, Mac Plus and Mac SE emulator

long_description \
    Mini vMac is a Macintosh emulator. It emulates the earliest Macs, \
    from the original Mac 128K (built 1984-85) to the Mac SE (1987-1990). \
    The default is to emulate a Mac Plus (1986-1990)\; this is also \
    the best-tested and therefore recommended emulation.

distfiles \
    ${distname}.prj.tgz \
    ${distname}.src.tgz

checksums \
    ${distname}.prj.tgz \
        md5     cfd3c6b60080d2184d6895b84c616fbf \
        sha1    8aa54b5708e280d1ed0c1f68aca8a38965cad4e2 \
        rmd160  d0e8d7734109b12caaf909efea231fe2a3a55979 \
    ${distname}.src.tgz \
        md5     ff6e67f654f09098ffbb8f26a5a7ae20 \
        sha1    6cdc4b514f3b45869a9fd2c5ee528499e772ad5e \
        rmd160  dc7a827fc1821014b2ac0f9b5cd025e1133d83ef

set romfile             vMac.ROM
set romfile_model       "Macintosh Plus or 512Ke"

post-extract {
    reinplace "s|maintained by unknown|maintained by MacPorts|" \
        ${worksrcpath}/config/Info.plist
    reinplace "s|#define kMaintainerName \"unknown\"|#define kMaintainerName \"MacPorts\"|" \
        ${worksrcpath}/config/CNFGGLOB.h
}

destroot {
    xinstall -m 755 -d ${destroot}${applications_dir}
    file copy ${worksrcpath}/minivmac.app \
        ${destroot}${applications_dir}/Mini\ vMac.app
}

post-install {
    if { ! [file exists ${applications_dir}/${romfile}] } {
        ui_msg "**************************************************************"
        ui_msg "Mini vMac requires a ROM file from the type of machine you're"
        ui_msg "emulating in order to work. The ROM file is not included with"
        ui_msg "this package because it is copyrighted Apple software."
        ui_msg "Download the CopyRoms program from the Mini vMac web site"
        ui_msg "(${homepage} > More > Extras)"
        ui_msg "and transfer it to a real physical ${romfile_model}"
        ui_msg "that you own. Run the CopyRoms program there, then transfer"
        ui_msg "the ROM file back to this Mac, name it ${romfile},"
        ui_msg "and put it in ${applications_dir}."
        ui_msg "**************************************************************"
    }
}

if { ![variant_isset mac128k] && ![variant_isset mac512k] && ![variant_isset mac512ke] && ![variant_isset macse] } {
    default_variants +macplus
}

variant mac128k conflicts mac512k mac512ke macplus macse description {Emulate a Macintosh with 128K RAM and 2 drives} {
    patchfiles-append patch-CNFGGLOB.h-mac128k.diff
    set romfile Mac128K.ROM
    set romfile_model "Macintosh 128K or 512K"
}

variant mac512k conflicts mac128k mac512ke macplus macse description {Emulate a Macintosh 512K with 512K RAM and 2 drives} {
    patchfiles-append patch-CNFGGLOB.h-mac512k.diff
    set romfile Mac128K.ROM
    set romfile_model "Macintosh 128K or 512K"
}

variant mac512ke conflicts mac128k mac512k macplus macse description {Emulate a Macintosh 512Ke with 512K RAM and 6 drives} {
    patchfiles-append patch-CNFGGLOB.h-mac512ke.diff
}

variant macplus conflicts mac128k mac512k mac512ke macse description {Emulate a Macintosh Plus with 4 MB RAM and 6 drives (default)} {
    # Mac Plus emulation is the default so we don't need to do anything here
}

variant macse conflicts mac128k mac512k mac512ke macplus description {Emulate a Macintosh SE with 4 MB RAM and 6 drives} {
    patchfiles-append patch-CNFGGLOB.h-macse.diff
    set romfile MacSE.ROM
    set romfile_model "Macintosh SE"
}

livecheck.check         regex
livecheck.url           ${homepage}download.html
livecheck.regex         ${name}-(\[0-9.\]+)\\.src
