# Copyright 2012 Johannes Nixdorf <mixi@exherbo.org>
# Distributed under the terms of the GNU General Public License v2

CMAKE_SOURCE=${WORK}-src

require cmake [ api=2 ] gtk-icon-cache freedesktop-desktop

SUMMARY="A free multiplayer action game where you control clonks, small but witty and nimble humanoid beings"
HOMEPAGE="http://www.openclonk.org/"
DOWNLOADS="http://www.openclonk.org/builds/release/${PV}/openclonk-${PV}-src.tar.bz2"

LICENCES="
    clonk-trademark
    ISC
    ZLIB [[ note = [ tinyxml ] ]]
"
SLOT="0"
PLATFORMS="~amd64"
MYOPTIONS="
    ( providers: ijg-jpeg jpeg-turbo ) [[ number-selected = exactly-one ]]
"

DEPENDENCIES="
    build:
        virtual/pkg-config
    build+run:
        dev-libs/glib:2[>=2.8]
        dev-libs/tinyxml
        media-libs/freealut[>=1.1.0]
        media-libs/freetype:2
        media-libs/glew
        providers:ijg-jpeg? ( media-libs/jpeg )
        providers:jpeg-turbo? ( media-libs/libjpeg-turbo )
        media-libs/libogg[>=1.2.2]
        media-libs/libpng:=
        media-libs/libvorbis[>=1.3.2]
        media-libs/openal[>=1.13]
        net-libs/libupnp
        sys-libs/readline
        sys-libs/zlib
        x11-dri/glu
        x11-dri/mesa[>=9]
        x11-libs/gdk-pixbuf:2.0
        x11-libs/gtk+:3
        x11-libs/libX11
        x11-libs/libXrandr
    test:
        dev-cpp/gtest
"

CMAKE_SRC_CONFIGURE_PARAMS=(
    -DUSE_GCC_PCH:BOOL=FALSE
    -DUSE_GTK:BOOL=TRUE
    -DUSE_SDL_MAINLOOP:BOOL=FALSE
    -DUSE_X11:BOOL=TRUE
    -DWITH_AUTOMATIC_UPDATE:BOOL=FALSE
    -DAudio_TK="OpenAL"
)

DEFAULT_SRC_COMPILE_PARAMS=(
    all data
)

src_test() {
    emake tests
    edo ./tests
}

pkg_postrm() {
    freedesktop-desktop_pkg_postrm
    gtk-icon-cache_pkg_postrm

}

pkg_postinst() {
    freedesktop-desktop_pkg_postinst
    gtk-icon-cache_pkg_postinst
}