# Copyright 2016 Julian Ospald <hasufell@posteo.de>
# Distributed under the terms of the GNU General Public License v2

WORK=${WORKBASE}/${PN}-${PV%_*}

require cmake [ api=2 ] desktop-utils gtk-icon-cache flag-o-matic
require sourceforge [ pnv=${PNV//_/-}-src ]

SUMMARY="A multi-player, 3D action role-playing game"
HOMEPAGE="http://sumwars.org"

LICENCES="GPL-3 CCPL-Attribution-ShareAlike-3.0"
SLOT="0"
PLATFORMS="~amd64 ~x86"

DEPENDENCIES="
    build+run:
        dev-games/cegui[>=0.8][ogre]
        dev-games/ois
        dev-games/physfs
        dev-lang/lua:5.1
        dev-libs/boost
        dev-libs/ogre[freeimage][opengl]
        dev-libs/tinyxml
        media-libs/freealut
        media-libs/libogg
        media-libs/libvorbis
        media-libs/openal
        net-libs/enet
        x11-libs/libX11
        x11-libs/libXrandr
"

CMAKE_SRC_CONFIGURE_PARAMS=(
    -DCMAKE_INSTALL_PREFIX=""
    -DSUMWARS_NO_TINYXML=ON
    -DSUMWARS_NO_ENET=ON
    -DSUMWARS_DOC_DIR="/usr/share/doc/${PNVR}"
    -DSUMWARS_EXECUTABLE_DIR=/usr/$(exhost --target)/bin
    -DSUMWARS_SHARE_DIR=/usr/share/${PN}
    -DSUMWARS_STANDALONE_MODE=OFF
    -DSUMWARS_POST_BUILD_COPY=OFF
    -DSUMWARS_PORTABLE_MODE=OFF
    -DSUMWARS_RANDOM_REGIONS=ON
    -DSUMWARS_BUILD_TOOLS=ON
)

src_configure() {
    # QA
    append-flags -fno-strict-aliasing

    cmake_src_configure
}

src_install() {
    cmake_src_install

    # cleanup empty directories
    edo rm -r "${IMAGE}"/usr/share/sumwars/translation/{potfiles,extract}

    insinto /usr/share/icons/hicolor/128x128/apps
    newins "${CMAKE_SOURCE}"/share/icon/SumWarsIcon_128x128.png ${PN}.png

    install_desktop_entry "Name=Summoning Wars"
}