# -*- 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 92836 2012-05-09 00:43:18Z ryandesign@macports.org $

PortSystem          1.0
PortGroup           cmake 1.0

name                widelands
version             build17
categories          games
platforms           darwin
maintainers         nomaintainer
license             GPL-2+

description         open-source real-time strategy game inspired by Settlers

long_description    Widelands is an open-source real-time strategy game. It \
                    is built upon the SDL and other open source libraries and \
                    is (and will always be) under heavy development. If you \
                    knew Settlers I & II™ (© Bluebyte), then you already have \
                    a rough idea what Widelands is all about because \
                    widelands is heavily inspired by those two games.

homepage            http://wl.widelands.org/
master_sites        https://launchpad.net/${name}/${version}/build-17/+download/

use_bzip2           yes
distfiles           [suffix ${distname}-src]
worksrcdir          ${distname}-src/build

checksums           rmd160  4ea81d21d3b3e02fc22194d1a39e8c08e05aaa44 \
                    sha256  be48b3b8f342a537b39a3aec2f7702250a6a47e427188ba3bece67d7d90f3cc5

depends_lib         port:libsdl \
                    port:libsdl_image \
                    port:libsdl_mixer \
                    port:libsdl_net \
                    port:libsdl_ttf \
                    port:libsdl_gfx \
                    port:boost \
                    port:glew \
                    port:lua

# https://bugs.launchpad.net/widelands/+bug/744595
if {${configure.compiler} == "clang"} {
    configure.compiler llvm-gcc-4.2
}

configure.args      ../ \
                    -DCMAKE_INSTALL_PREFIX:PATH="${applications_dir}/Widelands.app/Contents/MacOS"

pre-destroot {
    xinstall -d ${destroot}${applications_dir}/Widelands.app/Contents/Resources \
                ${destroot}${applications_dir}/Widelands.app/MacOS
    file copy ${worksrcpath}/../pics/widelands.icns ${destroot}${applications_dir}/Widelands.app/Contents/Resources/widelands.icns
    set data    " {\n\
                CFBundleName = widelands;\n\
                CFBundleDisplayName = Widelands;\n\
                CFBundleIdentifier = \"org.widelands.wl\";\n\
                CFBundleVersion = ${version};\n\
                \"CFBundleInfoDictionaryVersion\" = \"6.0\";\n\
                CFBundlePackageType = APPL;\n\
                CFBundleSignature = \"????\";\n\
                CFBundleExecutable = widelands;\n\
                CFBundleIconFile = \"widelands.icns\";\n\
                }"
    set filename "${destroot}${applications_dir}/Widelands.app/Contents/Info.plist"
    set fileId [open $filename "w"]
    puts -nonewline $fileId $data
    close $fileId
}
