| 1 |  | # Copyright 1999-2024 Gentoo Authors | 
  |  | 1 | # Copyright 1999-2025 Gentoo Authors | 
  | 2 | 2 | # Distributed under the terms of the GNU General Public License v2 | 
  | 3 | 3 |  | 
  | 4 |  | EAPI=7 | 
  |  | 4 | EAPI=8 | 
  | 5 | 5 |  | 
  | 6 |  | inherit autotools desktop toolchain-funcs xdg-utils | 
  | 7 |  |  | 
  | 8 |  | if [[ ${PV} == "99999999" ]] ; then | 
  | 9 |  | 	inherit git-r3 | 
  | 10 |  | 	EGIT_REPO_URI="https://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 |  | else | 
  | 14 |  | 	MAGIC=e2135d5 | 
  | 15 |  | 	SRC_URI="https://www.chiark.greenend.org.uk/~sgtatham/puzzles/puzzles-${PV}.${MAGIC}.tar.gz" | 
  | 16 |  | 	S=${WORKDIR}/puzzles-${PV}.${MAGIC} | 
  | 17 |  | 	KEYWORDS="~amd64 ~x86" | 
  | 18 |  | fi | 
  |  | 6 | inherit cmake xdg-utils | 
  | 19 | 7 |  | 
  | 20 | 8 | DESCRIPTION="Simon Tatham's Portable Puzzle Collection" | 
  | 21 | 9 | HOMEPAGE="https://www.chiark.greenend.org.uk/~sgtatham/puzzles/" | 
  |  | 10 | MY_HASH=8314b03 | 
  |  | 11 | SRC_URI="https://www.chiark.greenend.org.uk/~sgtatham/puzzles/puzzles-${PV}.${MY_HASH}.tar.gz -> ${P}.tar.gz" | 
  |  | 12 | S="${WORKDIR}"/puzzles-${PV}.${MY_HASH} | 
  | 22 | 13 |  | 
  | 23 | 14 | LICENSE="MIT" | 
  | 24 | 15 | SLOT="0" | 
  | 25 |  | IUSE="+doc" | 
  | 26 |  |  | 
  | 27 |  | COMMON_DEPEND=" | 
  | 28 |  | 	x11-libs/gtk+:3" | 
  | 29 |  |  | 
  | 30 |  | RDEPEND="${COMMON_DEPEND} | 
  | 31 |  | 	x11-misc/xdg-utils" # Used by builtin help patch | 
  |  | 16 | KEYWORDS="~amd64 ~x86" | 
  | 32 | 17 |  | 
  |  | 18 | COMMON_DEPEND="x11-libs/gtk+:3" | 
  |  | 19 | RDEPEND=" | 
  |  | 20 | 	${COMMON_DEPEND} | 
  |  | 21 | 	x11-misc/xdg-utils | 
  |  | 22 | " | 
  | 33 | 23 | DEPEND="${COMMON_DEPEND}" | 
  | 34 |  |  | 
  | 35 | 24 | BDEPEND=" | 
  |  | 25 | 	app-text/halibut | 
  | 36 | 26 | 	dev-lang/perl | 
  | 37 | 27 | 	virtual/pkgconfig | 
  | 38 |  | 	doc? ( >=app-text/halibut-1.2 )" | 
  | 39 |  |  | 
  | 40 |  | PATCHES=( "${FILESDIR}/${PN}-20161207-builtin-help.patch" ) | 
  |  | 28 | " | 
  | 41 | 29 |  | 
  | 42 |  | src_unpack() { | 
  | 43 |  | 	default | 
  | 44 |  | 	if [[ ${PV} == "99999999" ]]; then | 
  | 45 |  | 		git-r3_src_unpack | 
  | 46 |  | 	fi | 
  | 47 |  | } | 
  | 48 |  |  | 
  | 49 |  | src_prepare() { | 
  | 50 |  | 	default | 
  |  | 30 | DOCS=( puzzles.txt HACKING ) | 
  | 51 | 31 |  | 
  | 52 |  | 	sed -i \ | 
  | 53 |  | 		-e 's|-Werror||g' \ | 
  | 54 |  | 		configure.ac || die | 
  | 55 |  | 	sed -i \ | 
  | 56 |  | 		-e 's/-O2 -Wall .* -g/-Wall/' \ | 
  | 57 |  | 		-e "s/libstr =/libstr = '\$(LDFLAGS) ' ./" \ | 
  | 58 |  | 		mkfiles.pl || die | 
  | 59 |  | 	./mkfiles.pl || die | 
  | 60 |  | 	eautoreconf | 
  | 61 |  |  | 
  | 62 |  | 	# Import icons from latest Gentoo tarball for live | 
  | 63 |  | 	if [[ ${PV} == "99999999" ]]; then | 
  | 64 |  | 		cp -R ../${PN}-icons/icons . || die | 
  | 65 |  | 	fi | 
  | 66 |  | } | 
  |  | 32 | PATCHES=( | 
  |  | 33 | 	"${FILESDIR}"/${PN}-20250627-fix-linking.patch | 
  |  | 34 | ) | 
  | 67 | 35 |  | 
  | 68 | 36 | src_configure() { | 
  | 69 |  | 	econf \ | 
  | 70 |  | 		--program-prefix="${PN}_" \ | 
  | 71 |  | 		--with-gtk=3 | 
  | 72 |  | } | 
  |  | 37 | 	local mycmakeargs=( | 
  |  | 38 | 		-DNAME_PREFIX="${PN}_" | 
  |  | 39 | 		-DPUZZLES_GTK_VERSION=3 | 
  |  | 40 | 	) | 
  | 73 | 41 |  | 
  | 74 |  | src_compile() { | 
  | 75 |  | 	emake CC="$(tc-getCC)" | 
  | 76 |  | 	if use doc ; then | 
  | 77 |  | 		halibut --text --html --info --pdf --ps puzzles.but || die | 
  | 78 |  | 	fi | 
  |  | 42 | 	cmake_src_configure | 
  | 79 | 43 | } | 
  | 80 | 44 |  | 
  | 81 | 45 | src_install() { | 
  | 82 |  | 	default | 
  |  | 46 | 	sed -i "s/^Categories=.*/&X-${PN};/" "${BUILD_DIR}"/*.desktop || die | 
  |  | 47 |  | 
  |  | 48 | 	cmake_src_install | 
  | 83 | 49 |  | 
  | 84 |  | 	local file name | 
  | 85 |  | 	for file in *.R ; do | 
  | 86 |  | 		[[ ${file} == "nullgame.R" ]] && continue | 
  | 87 |  | 		name=$(awk -F: '/exe:/ { print $3 }' "${file}") | 
  | 88 |  | 		file=${file%.R} | 
  | 89 |  | 		newicon -s 48 icons/${file}-48d24.png ${PN}_${file}.png | 
  | 90 |  | 		make_desktop_entry "${PN}_${file}" "${name}" "${PN}_${file}" "LogicGame;X-${PN};" | 
  | 91 |  | 	done | 
  | 92 |  |  | 
  | 93 |  | 	if use doc ; then | 
  | 94 |  | 		local DOCS=( puzzles.{pdf,ps,txt} ) | 
  | 95 |  | 		local HTML_DOCS=( *.html ) | 
  | 96 |  | 		einstalldocs | 
  | 97 |  | 		doinfo puzzles.info{,-1,-2,-3} | 
  | 98 |  | 	fi | 
  |  | 50 | 	einstalldocs | 
  | 99 | 51 |  | 
  | 100 | 52 | 	insinto /etc/xdg/menus/applications-merged | 
  | 101 | 53 | 	doins "${FILESDIR}/${PN}.menu" |