games-puzzle/sgt-puzzles: Bump to 20171029
[gentoo.git] / games-puzzle / sgt-puzzles / sgt-puzzles-20171029.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit eutils gnome2-utils toolchain-funcs autotools
7
8 if [[ ${PV} == "99999999" ]] ; then
9         inherit git-r3
10         EGIT_REPO_URI="git://git.tartarus.org/simon/puzzles.git"
11         GENTOO_ICONS="20160315"
12         SRC_URI="https://dev.gentoo.org/~np-hardass/distfiles/${PN}/${PN}-icons-${GENTOO_ICONS}.tar.xz"
13         KEYWORDS=""
14 else
15         MAGIC=69773d8
16         SRC_URI="https://www.chiark.greenend.org.uk/~sgtatham/puzzles/puzzles-${PV}.${MAGIC}.tar.gz"
17         S=${WORKDIR}/puzzles-${PV}.${MAGIC}
18         KEYWORDS="~amd64 ~x86"
19 fi
20
21 DESCRIPTION="Simon Tatham's Portable Puzzle Collection"
22 HOMEPAGE="https://www.chiark.greenend.org.uk/~sgtatham/puzzles/"
23
24 LICENSE="MIT"
25 SLOT="0"
26 IUSE="+doc gtk3"
27
28 COMMON_DEPEND="
29         !gtk3? ( x11-libs/gtk+:2 )
30         gtk3? ( x11-libs/gtk+:3 )"
31
32 RDEPEND="${COMMON_DEPEND}
33         x11-misc/xdg-utils" # Used by builtin help patch
34
35 DEPEND="${COMMON_DEPEND}
36         dev-lang/perl
37         virtual/pkgconfig
38         doc? ( >=app-doc/halibut-1.2 )"
39
40 PATCHES=( "${FILESDIR}/${PN}-20161207-builtin-help.patch" )
41
42 src_unpack() {
43         default
44         if [[ ${PV} == "99999999" ]]; then
45                 git-r3_src_unpack
46         fi
47 }
48
49 src_prepare() {
50         default
51
52         sed -i \
53                 -e 's/-O2 -Wall -Werror -ansi -pedantic -g//' \
54                 -e "s/libstr =/libstr = '\$(LDFLAGS) ' ./" \
55                 mkfiles.pl || die
56         ./mkfiles.pl || die
57         eautoreconf
58
59         # Import icons from latest Gentoo tarball for live
60         if [[ ${PV} == "99999999" ]]; then
61                 cp -R ../${PN}-icons/icons . || die
62         fi
63 }
64
65 src_configure() {
66         econf \
67                 --program-prefix="${PN}_" \
68                 --with-gtk=$(usex gtk3 3 2)
69 }
70
71 src_compile() {
72         emake CC="$(tc-getCC)"
73         if use doc ; then
74                 halibut --text --html --info --pdf --ps puzzles.but || die
75         fi
76 }
77
78 src_install() {
79         default
80
81         local file name
82         for file in *.R ; do
83                 [[ ${file} == "nullgame.R" ]] && continue
84                 name=$(awk -F: '/exe:/ { print $3 }' "${file}")
85                 file=${file%.R}
86                 newicon -s 48 icons/${file}-48d24.png ${PN}_${file}.png
87                 make_desktop_entry "${PN}_${file}" "${name}" "${PN}_${file}" "Game;LogicGame;X-${PN};"
88         done
89
90         if use doc ; then
91                 DOCS=( puzzles.{pdf,ps,txt} )
92                 HTML_DOCS=( *.html )
93                 einstalldocs
94                 doinfo puzzles.info{,-1,-2,-3}
95         fi
96
97         insinto /etc/xdg/menus/applications-merged
98         doins "${FILESDIR}/${PN}.menu"
99         insinto /usr/share/desktop-directories
100         doins "${FILESDIR}/${PN}.directory"
101 }
102
103 pkg_preinst() {
104         gnome2_icon_savelist
105 }
106
107 pkg_postinst() {
108         gnome2_icon_cache_update
109 }
110
111 pkg_postrm() {
112         gnome2_icon_cache_update
113 }