Merge remote-tracking branch 'github/pr/626'.
[gentoo.git] / games-strategy / s25rttr / s25rttr-0.8.1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6 inherit eutils cmake-utils gnome2-utils games
7
8 DESCRIPTION="Open Source remake of The Settlers II game (needs original game files)"
9 HOMEPAGE="http://www.siedler25.org/"
10 # no upstream source tarball yet
11 # https://bugs.launchpad.net/s25rttr/+bug/1069546
12 SRC_URI="https://dev.gentoo.org/~hasufell/distfiles/${P}.tar.xz"
13
14 LICENSE="GPL-3"
15 SLOT="0"
16 KEYWORDS="amd64 x86"
17 IUSE="debug glfw"
18
19 RDEPEND="app-arch/bzip2
20         media-libs/libsamplerate
21         media-libs/libsdl[X,sound,opengl,video]
22         media-libs/libsndfile
23         media-libs/sdl-mixer[vorbis]
24         net-libs/miniupnpc
25         virtual/libiconv
26         virtual/opengl
27         glfw? ( <media-libs/glfw-3 )"
28 DEPEND="${RDEPEND}
29         sys-devel/gettext"
30
31 src_prepare() {
32         epatch "${FILESDIR}"/${P}-cmake.patch \
33                 "${FILESDIR}"/${P}-soundconverter.patch \
34                 "${FILESDIR}"/${P}-fpic.patch
35 }
36
37 src_configure() {
38         local arch
39         case ${ARCH} in
40                 amd64)
41                         arch="x86_64" ;;
42                 x86)
43                         arch="i386" ;;
44                 *) die "Architecture ${ARCH} not yet supported" ;;
45         esac
46
47         local mycmakeargs=(
48                 -DCOMPILEFOR="linux"
49                 -DCOMPILEARCH="${arch}"
50                 -DCMAKE_SKIP_RPATH=YES
51                 -DPREFIX="${GAMES_PREFIX}"
52                 -DBINDIR="${GAMES_BINDIR}"
53                 -DDATADIR="${GAMES_DATADIR}"
54                 -DLIBDIR="$(games_get_libdir)/${PN}"
55                 -DDRIVERDIR="$(games_get_libdir)/${PN}"
56                 -DGAMEDIR="~/.${PN}/S2"
57                 $(cmake-utils_use_build glfw GLFW_DRIVER)
58         )
59
60         cmake-utils_src_configure
61 }
62
63 src_compile() {
64         # work around some relative paths (CMAKE_IN_SOURCE_BUILD not supported)
65         ln -s "${CMAKE_USE_DIR}"/RTTR "${CMAKE_BUILD_DIR}"/RTTR || die
66
67         cmake-utils_src_compile
68
69         mv "${CMAKE_USE_DIR}"/RTTR/{sound-convert,s-c_resample} "${T}"/ || die
70 }
71
72 src_install() {
73         cd "${CMAKE_BUILD_DIR}" || die
74
75         exeinto "$(games_get_libdir)"/${PN}
76         doexe "${T}"/{sound-convert,s-c_resample}
77         exeinto "$(games_get_libdir)"/${PN}/video
78         doexe driver/video/SDL/src/libvideoSDL.so
79         use glfw && doexe driver/video/GLFW/src/libvideoGLFW.so
80         exeinto "$(games_get_libdir)"/${PN}/audio
81         doexe driver/audio/SDL/src/libaudioSDL.so
82
83         insinto "${GAMES_DATADIR}"
84         doins -r "${CMAKE_USE_DIR}"/RTTR
85         dosym ./LSTS/splash.bmp "${GAMES_DATADIR}"/RTTR/splash.bmp
86
87         doicon -s 64 "${CMAKE_USE_DIR}"/debian/${PN}.png
88         dogamesbin src/s25client
89         make_desktop_entry "s25client" "Settlers RTTR" "${PN}"
90         dodoc RTTR/texte/{keyboardlayout.txt,readme.txt}
91
92         prepgamesdirs
93 }
94
95 pkg_preinst() {
96         games_pkg_preinst
97         gnome2_icon_savelist
98 }
99
100 pkg_postinst() {
101         games_pkg_postinst
102         elog "Copy your Settlers2 game files into ~/.${PN}/S2"
103
104         gnome2_icon_cache_update
105 }
106
107 pkg_postrm() {
108         gnome2_icon_cache_update
109 }