# $Id: Portfile 58210 2009-09-24 06:56:08Z ryandesign@macports.org $

PortSystem          1.0

name                boswars
version             2.5
categories          games
platforms           darwin
maintainers         simon openmaintainer
description         Bos Wars is a futuristic real time strategy game.
long_description    Bos Wars is a futuristic real time strategy game (RTS). \
                    Bos Wars has a dynamic rate based economy. Energy is \
                    produced by power plants and magma gets pumped from hot \
                    spots. Buildings and mobile units are also built at a \
                    continuous rate. Control of larger parts of the map \
                    creates the potential to increase your economy \
                    throughput. Holding key points like roads and passages \
                    allow for different strategies.

homepage            http://boswars.org/
master_sites        ${homepage}dist/releases/
checksums           md5 9d280d086ccf81119f40bde98eb9a795 \
                    sha1 7305eaea67a0df8dd689df821573dab17e8de01a \
                    rmd160 dc42410f3d89c588b579ee7c0d47627c5d455362
distname            ${name}-${version}-src

depends_build       port:scons

depends_lib         port:libogg \
                    port:libpng \
                    path:lib/pkgconfig/sdl.pc:libsdl \
                    port:libtheora \
                    port:libvorbis \
                    port:lua \
                    port:zlib

patchfiles          patch-SConstruct.diff \
                    patch-build_options.py.diff \
                    patch-engine_video_graphic.cpp.diff

configure {
    reinplace "s|__PREFIX__|${prefix}|g" ${worksrcpath}/build_options.py
}

build {
    # Use scons to build boswars.
    system "cd ${worksrcpath}; scons debug"
}

destroot {
    # Path to the boswars resource directory ${prefix}/share/boswars.
    set share ${prefix}/share/boswars

    # Rename the boswars binary to boswars-bin and install it in destroot so a
    # helper script can be used which automatically sets the path to the
    # boswars files.
    move ${worksrcpath}/boswars-debug ${destroot}${prefix}/bin/boswars-bin
    # Copy the helper script to ${prefix}/bin.
    xinstall ${portpath}/${filesdir}/boswars ${destroot}${prefix}/bin
    # Set the correct path to the boswars files in the boswars helper script.
    reinplace "s|__BOSWARS__|${share}|g" ${destroot}${prefix}/bin/boswars

    # Create the resource directory in destroot.
    xinstall -d ${destroot}${share}
    # Install the boswar files into ${prefix}/share/boswars:
    set files {campaigns doc graphics intro languages maps scripts sounds \
               units}
    foreach file $files {
        move ${worksrcpath}/$file ${destroot}${share}/${file}
    }
}

post-install {
    ui_msg "****************************************************************"
    ui_msg "*                                                              *"
    ui_msg "* Attention! Changing display mode to OpenGL in the settings   *"
    ui_msg "* menu may not work and cause an application crash! If this    *"
    ui_msg "* happens remove ~/Library/boswars/preferences.lua to reset    *"
    ui_msg "* the setting.                                                 *"
    ui_msg "*                                                              *"
    ui_msg "****************************************************************"
}
