# -*- 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
PortGroup           github 1.0
PortGroup           legacysupport 1.0
PortGroup           app 1.0
PortGroup           muniversal 1.0

github.setup        joncampbell123 dosbox-x 2025.10.07 dosbox-x-v
revision            0

checksums           rmd160  d4b2a2bb1d499a6bba10f7aadc376444796c51d2 \
                    sha256  fed630dba74f1ad1552bc5ec94cb68f70737e67a7ca1768f6071b255426ce117 \
                    size    124274305

categories          emulators
license             GPL-2+
maintainers         nomaintainer

description         maintained and updated fork of dosbox DOS emulator

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. \
                    ${name} is the most prominent updated fork of dosbox, supporting SDL2 \
                    and 64-bit processors

homepage            https://dosbox-x.com
github.tarball_from archive

patchfiles          patch-futimens.diff \
                    patch-mactypes.diff

supported_archs     i386 x86_64 arm64

set ffmpeg_ver      7

# build also looks for nasm, but doesn't use it even if it is found
depends_build-append \
                    port:pkgconfig

# also looks for GL/gl.h, but doesn't use mesa even if installed
depends_lib         port:ffmpeg${ffmpeg_ver} \
                    port:fluidsynth \
                    port:freetype \
                    port:libpcap \
                    port:libpng \
                    port:libsdl2 \
                    port:libsdl2_net \
                    port:zlib

use_autoreconf      yes
autoreconf.args     -fvi

configure.pkg_config_path   ${prefix}/libexec/ffmpeg${ffmpeg_ver}/lib/pkgconfig

# by default build the SDLv2 version of dosbox-x without
# slirp (TCP/IP # emulation) support by default

configure.args-append --enable-sdl2 --disable-libslirp

# add a slirp variant if TCP/IP emulation is desired

variant slirp description {Use the libslirp library} {
    depends_lib-append port:libslirp
    configure.args-delete --disable-libslirp
}

# add a SDL v1.x variant because when SDL2 is used dosbox-x
# may have display issues in high color and true color modes:
# https://github.com/joncampbell123/dosbox-x/issues/1431

variant sdl1 description {Use the SDL v1.x library} {
    configure.args-replace --enable-sdl2 --disable-sdl2
    configure.args-append --enable-sdl
    depends_lib-delete port:libsdl2
    depends_lib-delete port:libsdl2_net
    patchfiles-append patch-build-macos.diff
    use_configure no
    use_autoreconf no
}

if {[variant_isset sdl1]} {
   build {
      system -W "${workpath}/${name}-${version}/" \
                "PREFIX=${prefix} ./build-macos"
   }
}

# needs "___cpu_model" in compiler.rt
compiler.blacklist-append {clang < 900}

compiler.cxx_standard 2011
configure.cxxflags-append -Wno-unknown-warning-option

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -W ${worksrcpath} \
        README.MinGW \
        README.debugger \
        README.joystick \
        README.keyboard-layout-handling \
        README.md \
        README.video \
        README.xbrz \
        AUTHORS \
        COPYING \
        CHANGELOG \
        THANKS \
        ${destroot}${prefix}/share/doc/${name}
}

app.icon            contrib/icons/dosbox-x.png
