summaryrefslogtreecommitdiff
blob: 9506fdd82542595f7812e62162dcf825a3ebb692 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI="5"

inherit elisp-common eutils multilib

MY_PN="${PN}-src"
MY_P="${MY_PN}-${PV}"

DESCRIPTION="Implementation of the logical framework LF"
HOMEPAGE="http://twelf.org/"
SRC_URI="http://twelf.plparty.org/releases/${MY_P}.tar.gz"

SLOT="0/${PV}"
KEYWORDS="~amd64 ~x86"
LICENSE="BSD-2"
IUSE="doc emacs examples"

# tests reference non-existing directory TEST
RESTRICT="test"

RDEPEND="
	dev-lang/mlton
	doc? (
		virtual/latex-base
		app-text/texi2html
	)
	emacs? (
		>=app-editors/emacs-23.1:*
	)"
DEPEND="${RDEPEND}"

S=${WORKDIR}/${PN}

SITEFILE=50${PN}-gentoo.el

PATCHES=(
	"${FILESDIR}/${PN}-1.7.1-doc-guide-twelf-dot-texi.patch"
	"${FILESDIR}/${PN}-1.7.1-doc-guide-Makefile.patch"
	"${FILESDIR}/${PN}-1.7.1-emacs-twelf.patch"
	"${FILESDIR}/${PN}-1.7.1-emacs-twelf-init.patch"
	"${FILESDIR}/${PN}-1.7.1-Makefile.patch"
	"${FILESDIR}/${PN}-1.7.1-mlton-mlb.patch"
)

src_prepare() {
	epatch "${PATCHES[@]}"
	sed \
		-e "s@/usr/bin@${ROOT}usr/bin@g" \
		-e "s@/usr/share@${ROOT}usr/share@" \
		-i "${S}"/emacs/twelf-init.el \
		|| die "Could not set ROOT in ${S}/emacs/twelf-init.el"
}

src_compile() {
	emake mlton CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS} -fno-PIE"
	if use emacs ; then
		pushd "${S}/emacs" || die "Could change directory to emacs"
		elisp-compile \
			auc-menu.el \
			twelf-font.el \
			twelf-init.el \
			twelf.el \
			|| die "emacs elisp compile failed"
		popd
	fi
	if use doc; then
		pushd doc/guide
		emake all
		popd
	fi
}

ins_example_dir() {
	insinto "/usr/share/${PN}/examples/${1}"
	pushd "${S}/${1}"
	doins -r *
	popd
}

src_install() {
	if use emacs ; then
		elisp-install ${PN} emacs/*.{el,elc}
		cp "${FILESDIR}"/${SITEFILE} "${S}"
		elisp-site-file-install ${SITEFILE}
	fi
	if use examples; then
		ins_example_dir examples
		ins_example_dir examples-clp
		ins_example_dir examples-delphin
	fi
	dobin bin/twelf-server
	if use doc; then
		dohtml doc/html/index.html
		doinfo doc/guide/twelf.info
		dodoc doc/guide/twelf.dvi doc/guide/twelf.ps doc/guide/twelf.pdf
		dohtml doc/guide/twelf/*
	fi
}

pkg_postinst() {
	if use emacs; then
		elisp-site-regen
		ewarn "For twelf emacs, add this line to ~/.emacs"
		ewarn ""
		ewarn '(load (concat twelf-root "/twelf-init.el"))'
	fi
}

pkg_postrm() {
	use emacs && elisp-site-regen
}