# $Id: Portfile 75924 2011-02-13 03:27:41Z raimue@macports.org $

PortSystem          1.0

name                bochs
version             2.4.5
revision            4
categories          emulators
license             LGPL-2.1+
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_lib         port:xorg-libX11 \
                    port:xorg-libsm \
                    port:xpm \
                    port:gettext

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

# Disable sound support, see ticket #23938
#configure.args-append --enable-sb16=osx

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

variant gdbstub description {Enable GDB stub debugging} conflicts smp {
    configure.args-append --enable-gdb-stub
}

post-destroot {
    reinplace "s|\$BXSHARE/|${prefix}/share/bochs/|g" \
        ${destroot}${prefix}/share/doc/bochs/bochsrc-sample.txt
}

post-activate {
    if {![file exists ${prefix}/share/bochs/bochsrc.txt]} {
        ui_msg "File ${prefix}/share/bochs/bochsrc.txt not found, installing sample configuration file"
        xinstall -m 0644 ${prefix}/share/doc/bochs/bochsrc-sample.txt ${prefix}/share/bochs/bochsrc.txt
    }
}

notes "
To prepare bochs for use:

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

2) 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.

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

4) Now start bochs from the command line.
"

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