summaryrefslogtreecommitdiff
blob: 7498144c08343d2225e72b44f9a43cb9eed73d07 (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
64
65
66
67
68
69
70
71
72
73
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit flag-o-matic toolchain-funcs

DESCRIPTION="A dynamic Lisp dialect and bytecode vm"
HOMEPAGE="https://janet-lang.org https://github.com/janet-lang/janet/"
SRC_URI="https://github.com/janet-lang/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="static-libs"

MY_RELEASE="${PV::-2}"

src_configure() {
	tc-export CC

	append-ldflags -Wl,-soname,libjanet.so.1.${MY_RELEASE}
	append-cflags -fPIC
}

src_compile() {
	# janet_build is the git hash of the commit related to the
	# current release - it defines a constant which is then shown
	# when starting janet
	local janet_build='\"'${PV}'\"'

	local target
	for target in '' build/janet.pc docs ; do
		einfo "Building: ${target:-main}"
		emake \
			LIBDIR="/usr/$(get_libdir)" \
			PREFIX="/usr" \
			JANET_BUILD="${janet_build}" \
			CFLAGS="${CFLAGS}" \
			LDFLAGS="${LDFLAGS}" \
			${target}
	done
}

src_install() {
	dobin build/janet

	insinto /usr/include/janet
	doheader src/include/janet.h
	doheader src/conf/janetconf.h

	dolib.so build/libjanet.so
	dosym libjanet.so /usr/$(get_libdir)/libjanet.so.${MY_RELEASE}
	dosym libjanet.so.${MY_RELEASE} /usr/$(get_libdir)/libjanet.so.${PV}

	if use static-libs; then
		dolib.a build/libjanet.a
	fi

	doman janet.1

	insinto /usr/$(get_libdir)/pkgconfig/
	doins build/janet.pc

	dodoc -r examples
	dodoc build/doc.html
}

pkg_postinst() {
	elog "Note: jpm has been extracted to its own repository upstream."
	elog "Follow the upstream instructions on how to install it."
	elog "Enable use flag \"static-libs\" for building stand-alone executables with jpm"
}