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

name                dosbox
version             0.74
revision            6
categories          emulators
platforms           darwin
license             GPL-2+
maintainers         nomaintainer

description         DOS emulator featuring 386 realmode, filesystem, XMS, EMS

long_description    DOSBox is a DOS emulator supporting 286/386 realmode, directory \
                    file system, XMS/EMS and many sound cards. \
                    It can be configured to run a wide range of DOS games, from \
                    CGA/Tandy/PCjr classics up to games from the Quake era.

homepage            http://dosbox.sourceforge.net/
master_sites        sourceforge:project/dosbox/dosbox/${version}

checksums           sha1    2d99f0013350efb29b769ff19ddc8e4d86f4e77e \
                    rmd160  4534d87206de8401cd0de471d8172726f2c6b788

depends_lib         port:libsdl \
                    port:libsdl_net \
                    port:libsdl_sound \
                    port:libpng

post-extract {
    move ${worksrcpath}/configure.in ${worksrcpath}/configure.ac
}

# src__cpu__core_dynrec__risc_x64.h.diff: http://www.freebsd.org/cgi/query-pr.cgi?pr=164243
patchfiles          3689.diff 3694.diff 3776.diff 3777.diff \
                    patch-src-fpu-fpu_instructions_x86.h.diff \
                    src__cpu__core_dynrec__risc_x64.h.diff \
                    clang-4.diff

# Assembly language issues
universal_variant no

use_autoreconf      yes
autoreconf.args     -fvi

configure.args      --disable-sdltest \
                    --disable-alsatest
configure.cxxflags-append   -mdynamic-no-pic

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -W ${worksrcpath} \
        README \
        AUTHORS \
        COPYING \
        ChangeLog \
        INSTALL \
        THANKS \
        ${destroot}${prefix}/share/doc/${name}
}

# The 64-bit build is broken in 0.74 ("core dynamic" crashes), but even if that
# is fixed, the 64-bit build is much slower.
supported_archs     i386 ppc

platform darwin {
    configure.args-append --build=${configure.build_arch}-apple-darwin${os.major}
}

variant debug description {Enable debug mode} {
    depends_lib-append port:ncurses
    patchfiles-append patch-configure.ac.diff
    configure.args-append --enable-debug
    configure.cppflags-append -I${prefix}/include/ncurses
}