# $Id: Portfile,v 1.18 2006/03/28 06:51:45 markd Exp $

PortSystem 1.0
name		bochs
version		2.2.6
categories	emulators
maintainers	darwinports@opendarwin.org
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.

platforms	darwin
homepage	http://bochs.sourceforge.net/
master_sites     sourceforge
checksums	md5 961482eb78b55fe3e0e0639e34b4c2c1

patchfiles      patch-Makefile.in patch-.bochsrc

depends_run     port:wget

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

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

pre-destroot {
        xinstall -m 755 -d ${destroot}${prefix}/bin      
        xinstall -m 755 -d ${destroot}${prefix}/share/bochs
	xinstall -m 755 -d ${destroot}/Applications/DarwinPorts
}

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

post-activate {
	ui_msg "\n

	**** 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/DarwinPorts/bochs.app program;
   you may also use the bochs command line utility. \n"
}
