# -*- 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
# $Id: Portfile 118475 2014-04-02 22:20:38Z cal@macports.org $

PortSystem          1.0

name                openttd

categories          games
platforms           macosx

maintainers         cal openmaintainer


if {${name} eq ${subport}} {
    version             1.4.0
    checksums           rmd160  1cef42f9378a2448dd7dc8aa683dcd540eef04f8 \
                        sha256  d85bcb89d499a177a904f627ce407a086db8b26bc9a021030ee7f5534fbe0955

    license             GPL-2

    description         OpenTTD is an open source simulation game based upon Transport Tycoon Deluxe
    long_description    \
        OpenTTD is an open source simulation game based upon the popular Microprose \
        game \"Transport Tycoon Deluxe\", written by Chris Sawyer. It attempts to \
        mimic the original game as closely as possible while extending it with new \
        features.

    homepage            http://www.openttd.org/en/
    master_sites        http://binaries.openttd.org/releases/${version}
    distfiles           openttd-${version}-source.tar.xz
    use_xz              yes

    depends_build       port:pkgconfig

    depends_lib         port:zlib \
                        port:lzo2 \
                        port:xz \
                        port:libpng \
                        port:freetype \
                        port:fontconfig \
                        port:icu \
                        port:libiconv

    depends_run         port:openttd-opengfx \
                        port:openttd-opensfx \
                        port:openttd-openmsx

    patchfiles          patch-config.lib-remove-deployment-target.diff

    configure.env-append \
                        CFLAGS_BUILD="${configure.cflags}" \
                        CXXFLAGS_BUILD="${configure.cxxflags}" \
                        LDFLAGS_BUILD="${configure.ldflags}"
    configure.args      --prefix-dir=${prefix} \
                        --binary-dir=bin \
                        --icon-theme-dir=share/icons/hicolor \
                        --install-dir=${destroot} \
                        --with-cocoa \
                        --with-zlib \
                        --with-liblzma \
                        --with-liblzo2 \
                        --with-png \
                        --with-freetype \
                        --with-fontconfig \
                        --with-icu \
                        --without-application-bundle \
                        --enable-strip

    build.args-append   VERBOSE=1
    destroot.args-append VERBOSE=1

    livecheck.type      regex
    livecheck.url       ${homepage}
    livecheck.regex     {Download stable \((\d+(\.\d+)+)\)}
}

subport openttd-opengfx {
    version             0.4.7
    checksums           rmd160  6f37ebe23e75137f204e5d13233cf7b92b28a9e0 \
                        sha256  10032c683f98b4d378c0651118a4858ae6d3f0a5059302dc3f96bfbfcdc67241

    supported_archs     noarch
    license             GPL-2

    description         OpenGFX is a free set of graphics for OpenTTD.
    long_description    \
        The OpenGFX project for OpenTTD: a free replacement of the base \
        graphics so that OpenTTD can be shipped finally fully functional \
        without the need for additional downloads.

    homepage            http://dev.openttdcoop.org/projects/opengfx
    master_sites        http://binaries.openttd.org/extra/opengfx/${version}
    distfiles           opengfx-${version}-all.zip
    worksrcdir          opengfx-${version}
    use_zip             yes

    use_configure       no
    build               {}
    destroot {
        set target ${destroot}${prefix}/share/games/openttd/baseset/opengfx
        xinstall -d -m 755 ${target}
        fs-traverse file ${worksrcpath} {
            if {[file isfile ${file}]} {
                xinstall -m 644 ${file} ${target}
            }
        }
    }

    livecheck.url       http://www.openttd.org/en/download-opengfx
    livecheck.regex     {Latest release in opengfx is (\d+(\.\d+)+),}
}

subport openttd-opensfx {
    version             0.2.3
    checksums           rmd160  426b641b5a29556598d8a3033b4c4dc5b98630ce \
                        sha256  6831b651b3dc8b494026f7277989a1d757961b67c17b75d3c2e097451f75af02

    supported_archs     noarch
    # actually CC Sampling Plus 1.0
    license             Permissive

    description         OpenSFX is a free set of sounds for OpenTTD.
    long_description    \
        The OpenSFX project for OpenTTD: a free replacement of the base sounds \
        so that OpenTTD can be shipped finally fully functional without the \
        need for non-free files.

    homepage            http://dev.openttdcoop.org/projects/opensfx
    master_sites        http://binaries.openttd.org/extra/opensfx/${version}
    distfiles           opensfx-${version}-all.zip
    worksrcdir          opensfx-${version}
    use_zip             yes

    use_configure       no
    build               {}
    destroot {
        set target ${destroot}${prefix}/share/games/openttd/baseset/opensfx
        xinstall -d -m 755 ${target}
        fs-traverse file ${worksrcpath} {
            if {[file isfile ${file}]} {
                xinstall -m 644 ${file} ${target}
            }
        }
    }

    livecheck.url       http://www.openttd.org/en/download-opensfx
    livecheck.regex     {Latest release in opensfx is (\d+(\.\d+)+),}
}

subport openttd-openmsx {
    version             0.3.1
    checksums           rmd160  8eff246e89e44f63ca480e9acef94a1da5fa81d2 \
                        sha256  92e293ae89f13ad679f43185e83fb81fb8cad47fe63f4af3d3d9f955130460f5

    supported_archs     noarch
    license             GPL-2

    description         OpenMSX is a free set of music for OpenTTD.
    long_description    \
        The OpenMSX project for OpenTTD: a free replacement of the base music \
        so that OpenTTD can be shipped finally fully functional without the \
        need for non-free files.

    homepage            http://dev.openttdcoop.org/projects/openmsx
    master_sites        http://binaries.openttd.org/extra/openmsx/${version}
    distfiles           openmsx-${version}-all.zip
    worksrcdir          openmsx-${version}
    use_zip             yes

    use_configure       no
    build               {}
    destroot {
        set target ${destroot}${prefix}/share/games/openttd/baseset/openmsx
        xinstall -d -m 755 ${target}
        fs-traverse file ${worksrcpath} {
            if {[file isfile ${file}]} {
                xinstall -m 644 ${file} ${target}
            }
        }
    }

    livecheck.url       http://www.openttd.org/en/download-openmsx
    livecheck.regex     {Latest release in openmsx is (\d+(\.\d+)+),}
}
