games-strategy/widelands: Fixed build with media-libs/libglvnd
[gentoo.git] / games-strategy / freeciv / freeciv-2.5.12.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 inherit autotools eutils flag-o-matic gnome2-utils ltprune
6
7 DESCRIPTION="multiplayer strategy game (Civilization Clone)"
8 HOMEPAGE="http://www.freeciv.org/"
9 SRC_URI="mirror://sourceforge/freeciv/${P}.tar.bz2"
10
11 LICENSE="GPL-2+"
12 SLOT="0"
13 KEYWORDS="~amd64 ~ppc64 ~x86"
14 IUSE="auth aimodules dedicated +gtk ipv6 mapimg modpack mysql nls qt5 readline sdl +server +sound sqlite system-lua"
15
16 # postgres isn't yet really supported by upstream
17 RDEPEND="app-arch/bzip2
18         app-arch/xz-utils
19         net-misc/curl
20         sys-libs/zlib
21         auth? (
22                 mysql? ( dev-db/mysql-connector-c:0= )
23                 sqlite? ( dev-db/sqlite:3 )
24                 !mysql? ( ( !sqlite? ( dev-db/mysql-connector-c:0= ) ) )
25         )
26         readline? ( sys-libs/readline:0= )
27         dedicated? ( aimodules? ( dev-libs/libltdl:0 ) )
28         !dedicated? (
29                 media-libs/libpng:0
30                 gtk? ( x11-libs/gtk+:2 )
31                 mapimg? ( media-gfx/imagemagick:= )
32                 modpack? ( x11-libs/gtk+:2 )
33                 nls? ( virtual/libintl )
34                 qt5? (
35                         dev-qt/qtcore:5
36                         dev-qt/qtgui:5
37                         dev-qt/qtwidgets:5
38                 )
39                 sdl? (
40                         media-libs/libsdl[video]
41                         media-libs/sdl-gfx
42                         media-libs/sdl-image[png]
43                         media-libs/sdl-ttf
44                 )
45                 server? ( aimodules? ( sys-devel/libtool:2 ) )
46                 sound? (
47                         media-libs/libsdl[sound]
48                         media-libs/sdl-mixer[vorbis]
49                 )
50                 !sdl? ( !gtk? ( x11-libs/gtk+:2 ) )
51         )
52         system-lua? ( >=dev-lang/lua-5.2 )"
53 DEPEND="${RDEPEND}
54         virtual/pkgconfig
55         !dedicated? (
56                 x11-base/xorg-proto
57                 nls? ( sys-devel/gettext )
58         )"
59
60 pkg_setup() {
61         if use !dedicated && use !server ; then
62                 ewarn "Disabling server USE flag will make it impossible"
63                 ewarn "to start local games, but you will still be able to"
64                 ewarn "join multiplayer games."
65         fi
66 }
67
68 src_prepare() {
69         default
70
71         eautoreconf
72
73         # install the .desktop in /usr/share/applications
74         # install the icons in /usr/share/pixmaps
75         sed -i \
76                 -e 's:^.*\(desktopfiledir = \).*:\1/usr/share/applications:' \
77                 -e 's:^\(icon[0-9]*dir = \)$(prefix)\(.*\):\1/usr\2:' \
78                 -e 's:^\(icon[0-9]*dir = \)$(datadir)\(.*\):\1/usr/share\2:' \
79                 client/Makefile.in \
80                 server/Makefile.in \
81                 tools/Makefile.in \
82                 data/icons/Makefile.in || die
83         sed -i -e 's/=SDL/=X-SDL/' bootstrap/freeciv-sdl.desktop.in || die
84 }
85
86 src_configure() {
87         local myclient mydatabase myeconfargs
88
89         if use auth ; then
90                 if ! use mysql && ! use sqlite ; then
91                         einfo "No database backend chosen, defaulting"
92                         einfo "to mysql!"
93                         mydatabase=mysql
94                 else
95                         use mysql && mydatabase+=" mysql"
96                         use sqlite && mydatabase+=" sqlite3"
97                 fi
98         else
99                 mydatabase=no
100         fi
101
102         if use dedicated ; then
103                 myclient="no"
104                 myeconfargs+=( --enable-server )
105         else
106                 if use !sdl && use !gtk && ! use qt5 ; then
107                         einfo "No client backend given, defaulting to"
108                         einfo "gtk2 client!"
109                         myclient="gtk2"
110                 else
111                         use sdl && myclient+=" sdl"
112                         use gtk && myclient+=" gtk2"
113                         if use qt5 ; then
114                                 myclient+=" qt"
115                                 append-cxxflags -std=c++11
116                         fi
117                 fi
118                 myeconfargs+=( $(use_enable server) --without-ggz-client )
119         fi
120
121         myeconfargs+=(
122                 --enable-aimodules="$(usex aimodules "yes" "no")"
123                 --enable-client="${myclient}"
124                 --enable-fcdb="${mydatabase}"
125                 --enable-fcmp="$(usex modpack "gtk2" "no")"
126                 # disabling shared libs will break aimodules USE flag
127                 --enable-shared
128                 --localedir=/usr/share/locale
129                 $(use_enable ipv6)
130                 $(use_enable mapimg)
131                 $(use_enable nls)
132                 $(use_enable sound sdl-mixer)
133                 $(use_enable system-lua sys-lua)
134                 $(use_with readline)
135         )
136         econf "${myeconfargs[@]}"
137 }
138
139 src_install() {
140         default
141
142         if use dedicated ; then
143                 rm -rf "${ED%/}/usr/share/pixmaps"
144                 rm -f "${ED%/}"/usr/share/man/man6/freeciv-{client,gtk2,gtk3,modpack,qt,sdl,xaw}*
145         else
146                 if use server ; then
147                         # Create and install the html manual. It can't be done for dedicated
148                         # servers, because the 'freeciv-manual' tool is then not built. Also
149                         # delete freeciv-manual from the GAMES_BINDIR, because it's useless.
150                         # Note: to have it localized, it should be ran from _postinst, or
151                         # something like that, but then it's a PITA to avoid orphan files...
152                         ./tools/freeciv-manual || die
153                         docinto html
154                         dodoc manual*.html
155                 fi
156                 if use sdl ; then
157                         make_desktop_entry freeciv-sdl "Freeciv (SDL)" freeciv-client
158                 else
159                         rm -f "${ED%/}"/usr/share/man/man6/freeciv-sdl*
160                 fi
161                 rm -f "${ED%/}"/usr/share/man/man6/freeciv-xaw*
162         fi
163         find "${ED}" -name "freeciv-manual*" -delete
164
165         rm -f "${ED%/}/usr/$(get_libdir)"/*.a
166         prune_libtool_files
167 }
168
169 pkg_preinst() {
170         gnome2_icon_savelist
171 }
172
173 pkg_postinst() {
174         gnome2_icon_cache_update
175 }
176
177 pkg_postrm() {
178         gnome2_icon_cache_update
179 }