Use https by default
[gentoo.git] / games-rpg / eternal-lands / eternal-lands-1.9.2-r1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=2
6 inherit eutils flag-o-matic games
7
8 DESCRIPTION="An online MMORPG written in C and SDL"
9 HOMEPAGE="http://www.eternal-lands.com"
10 SRC_URI="https://dev.gentoo.org/~rich0/distfiles/elc_1.9.2-20110618.tar.bz2
11         https://dev.gentoo.org/~rich0/distfiles/eternal-lands.png"
12
13 LICENSE="eternal_lands"
14 SLOT="0"
15 KEYWORDS="~amd64 ~x86 ~x86-fbsd"
16 IUSE="debug doc kernel_linux"
17
18 RDEPEND="x11-libs/libX11
19         x11-libs/libXau
20         x11-libs/libXdmcp
21         x11-libs/libXext
22         virtual/opengl
23         virtual/glu
24         media-libs/libsdl[X]
25         media-libs/sdl-net
26         media-libs/sdl-image
27         media-libs/openal
28         media-libs/freealut
29         media-libs/libvorbis
30         dev-libs/libxml2
31         media-libs/cal3d[-16bit-indices]
32         media-libs/libpng
33         >=games-rpg/eternal-lands-data-1.9.2"
34
35 DEPEND="${RDEPEND}
36         >=app-eselect/eselect-opengl-1.0.6-r1
37         app-arch/unzip
38         doc? ( app-doc/doxygen
39                 media-gfx/graphviz )"
40
41 #ECVS_SERVER="cvs.elc.berlios.de:/cvsroot/elc"
42 #ECVS_MODULE="elc"
43 #ECVS_USER="anonymous"
44 #ECVS_LOCALNAME="elc"
45 #ECVS_PASS=""
46 #ECVS_CVS_OPTIONS="-dP -z3"
47 #ECVS_BRANCH="elc_1_8_0"
48
49 #S="${WORKDIR}/${ECVS_MODULE}"
50 S="${WORKDIR}/elc"
51
52 src_unpack() {
53 #       cvs_src_unpack
54         OPTIONS="-DDATA_DIR="\\\\\"${GAMES_DATADIR}/${PN}/\\\\\"""
55         S_CLIENT="${WORKDIR}/elc"
56         BROWSER="firefox"
57         unpack ${A}
58         cd "${S}"
59 }
60
61 src_prepare() {
62         # Add debugging options
63         if use debug ; then
64                 OPTIONS="${OPTIONS} -DMEMORY_DEBUG"
65                 append-flags -ggdb
66         fi
67
68         # Clean compile flags (make Gentoo friendly)
69         sed -i \
70                 -e "s@CFLAGS=\$(PLATFORM) \$(CWARN) -O0 -ggdb -pipe@CFLAGS = ${CFLAGS} ${OPTIONS} @g" \
71                 -e "s@CXXFLAGS=\$(PLATFORM) \$(CXXWARN) -O0 -ggdb -pipe@CXXFLAGS = ${CXXFLAGS} ${OPTIONS} @g" \
72                 -e 's/lopenal/lopenal -l alut/' \
73                 Makefile.linux || die "sed failed"
74
75         sed -i \
76                 -e 's/#browser/browser/g' \
77                 -e "s/browser = mozilla/#browser = ${BROWSER}/g" \
78                 -e "s@#data_dir = /usr/local/games/el/@#data_dir = ${GAMES_DATADIR}/${PN}/@g" \
79                 el.ini || die "sed failed"
80
81         # Support BSD in the Linux makefile - it's easier
82         use kernel_linux || sed -i \
83                 -e 's/^CFLAGS=.*/& -DBSD/' \
84                 Makefile.linux || die "sed failed"
85
86         # Clean up library flag order for --as-needed
87 #       sed -i -e 's/@$(LINK) $(CFLAGS) $(LDFLAGS) -o $(EXE) $(OBJS)/@$(LINK) $(CFLAGS) -o $(EXE) $(OBJS) $(LDFLAGS)/' Makefile.linux
88
89         # Finally, update the server
90         sed -i -e '/#server_address =/ s/.*/#server_address = game.eternal-lands.com/' \
91                 el.ini || die "sed failed"
92
93         sed -i -e 's:FEATURES:EL_FEATURES:' make.defaults
94         sed -i -e 's:FEATURES:EL_FEATURES:' Makefile.linux
95
96         if use debug; then
97                 sed -i -e 's/#\(EL_FEATURES += MEMORY_DEBUG\)/\1/' make.defaults
98                 sed -i -e 's/#\(EL_FEATURES += MEMORY_DEBUG\)/\1/' Makefile.linux
99         fi
100
101         cp Makefile.linux Makefile
102
103         epatch "${FILESDIR}/${PN}-1.9.2-glext.patch"
104 #       epatch "${FILESDIR}/${PN}-1.9.1-libpng.patch"
105
106 # Fix for Gentoo zlib OF redefine
107
108         sed -i '1i#define OF(x) x' `find -name "*.c"` || die "sed failed"
109 }
110
111 src_compile() {
112         emake || die "make failed"
113
114         if use doc; then
115                 emake docs || die "Failed to create documentation, try with USE=-doc"
116                 mv ./docs/html/ ../client || die "Failed to move documentation directory"
117         fi
118 }
119
120 src_install() {
121         doicon "${DISTDIR}/eternal-lands.png" ${PN}.png
122
123         newgamesbin el.x86.linux.bin el \
124                 || die "newgamesbin failed"
125         make_desktop_entry el "Eternal Lands" \
126                 || die "make_desktop_entry failed"
127         insopts -m 0660
128         insinto "${GAMES_DATADIR}/${PN}"
129
130         doins -r *.ini *.txt commands.lst \
131                 || die "doins failed"
132
133         if use doc ; then
134                 dohtml -r client/*
135         fi
136
137         prepgamesdirs
138 }
139
140 pkg_postinst() {
141         games_pkg_postinst
142         elog "Auto Update is now enabled in Eternal Lands"
143         elog "If an update occurs then the client will suddenly exit"
144         elog "Updates only happen when the game first loads"
145         elog "Please don't report this behaviour as a bug"
146
147         # Ensure that the files are writable by the game group for auto
148         # updating.
149         chmod -R g+rw "${ROOT}/${GAMES_DATADIR}/${PN}"
150
151         # Make sure new files stay in games group
152         find "${ROOT}/${GAMES_DATADIR}/${PN}" -type d -exec chmod g+sx {} \;
153
154 }