# $Id: Portfile 67062 2010-04-28 05:11:28Z ryandesign@macports.org $

PortSystem          1.0

name                bochs
version             2.4.5
categories          emulators
platforms           darwin
maintainers         nomaintainer

description         cross platform ia-32 emulator

long_description    Bochs is a highly portable open source IA-32 (x86) \
                    PC emulator written in C++, that runs on most popular \
                    platforms. It emulates the Intel x86 CPU, common I/O \
                    devices, and a custom BIOS.

homepage            http://bochs.sourceforge.net/
master_sites        sourceforge

checksums           md5     fda7eadcd9590934d2901f8439631463 \
                    sha1    e334d31efd79c80454018c9cdafaa0eb75cb018a \
                    rmd160  a5a52d8f58b8ad7b1d544d4f89043244d99fa242

patchfiles          patch-.bochsrc.diff

depends_run         port:wget

if {[info exists supported_archs]} {
    supported_archs i386 ppc
}
switch ${configure.build_arch} {
    x86_64 {
        configure.build_arch i386
    }
    ppc64 {
        configure.build_arch ppc
    }
}

configure.args      --exec-prefix=${prefix} \
                    --bindir=${prefix}/bin \
                    --mandir=${prefix}/share/man \
                    --enable-all-optimizations \
                    --enable-sb16=osx \
                    --enable-vbe \
                    --enable-cdrom

variant smp description {Enable symmetric multi-processor support} {
    configure.args-append --enable-smp --enable-cpu-level=6
}

post-destroot {
    xinstall -d ${destroot}${prefix}/share/bochs
    file copy ${worksrcpath}/bochs.app ${destroot}${prefix}/share/bochs
    system "ln -s ${prefix}/share/bochs/bochs.app ${destroot}${applications_dir}/bochs.app"
    xinstall -W ${worksrcpath} bochs bximage bxcommit ${destroot}${prefix}/bin
    reinplace "s|\$BXSHARE/|${prefix}/share/bochs/|g" \
        ${destroot}${prefix}/share/bochs/bochsrc-sample.txt
}

notes "
**** To prepare bochs for use ****

1) Rename file bochsrc-sample.txt to bochrc.txt for use.
   -cd ${prefix}/share/bochs
   -sudo cp bochsrc-sample.txt bochrc.txt

2) Create a disk image for the emulator.
   -cd ${prefix}/share/bochs
   -sudo bximage (prompts will guide you)
   -sudo chmod 777 <diskimg-name>

3) Remove the current 'ata0-master:' statement in ${prefix}/share/bochs/bochsrc.txt
   and replace it with the 'ata0-master:' string displayed at the end of the bximage
   process.

4) Format the disk image using FreeDOS (http://bochs.sourceforge.net/diskimages.html)
   according to the bochs documentation. (http://bochs.sourceforge.net/)

5) Now start bochs using the ${applications_dir}/bochs.app program;
   you may also use the bochs command line utility.
"

livecheck.type      regex
livecheck.url       http://sourceforge.net/projects/${name}/files/
livecheck.regex     /${name}-(\[0-9.\]+)${extract.suffix}
