summaryrefslogtreecommitdiff
blob: 886220cc5ad9abe71e6985cdd6294f9e8f40d0d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit flag-o-matic multilib toolchain-funcs

DESCRIPTION="An embeddable JavaScript interpreter written in C"
HOMEPAGE="https://mujs.com/ https://github.com/ccxvii/mujs"
SRC_URI="https://mujs.com/downloads/${P}.tar.gz"

LICENSE="ISC"
# The subslot matches the SONAME
SLOT="0/${PV}"
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~ppc-macos ~x64-macos"

RDEPEND="sys-libs/readline:="
DEPEND="${RDEPEND}"

PATCHES=(
	"${FILESDIR}"/${PN}-1.3.3-flags.patch
)

src_prepare() {
	default

	tc-export AR CC

	append-cflags -fPIC

	# The library's ABI (and API) might change in new releases
	# Diff 'usr/include/mujs.h' across releases to validate
	if [[ ${CHOST} == *-darwin* ]] ; then
		append-cflags -Wl,-install_name,"${EPREFIX}"/usr/$(get_libdir)/lib${PN}.${PV}.dylib
	else
		append-cflags -Wl,-soname=lib${PN}.so.${PV}
	fi
}

src_compile() {
	# We need to use ${PV} for the pkgconfig file, see: #784461
	emake \
		VERSION=${PV} \
		XCFLAGS="${CFLAGS}" \
		XLDFLAGS="${LDFLAGS}" \
		prefix=/usr \
		release
}

src_install() {
	emake \
		DESTDIR="${ED}" \
		VERSION=${PV} \
		libdir="/usr/$(get_libdir)" \
		prefix=/usr \
		install-shared

	mv -v "${ED}"/usr/$(get_libdir)/lib${PN}$(get_libname) \
		"${ED}"/usr/$(get_libdir)/lib${PN}$(get_libname ${PV}) \
		|| die "Failed adding version suffix to mujs shared library"
	dosym lib${PN}$(get_libname ${PV}) /usr/$(get_libdir)/lib${PN}$(get_libname)
	dosym lib${PN}$(get_libname ${PV}) /usr/$(get_libdir)/lib${PN}$(get_libname ${PV:0:1})
}