summaryrefslogtreecommitdiff
blob: 317eab7b26e471de46f693d45f018eacee42dcc2 (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
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sci-mathematics/twelf/twelf-1.7.1.ebuild,v 1.2 2012/12/12 13:12:19 gienah Exp $

EAPI="5"

inherit base elisp-common multilib

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

DESCRIPTION="Twelf is an 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
	)
	emacs? (
		virtual/emacs
	)"
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")

src_prepare() {
	base_src_prepare
	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}"
	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() {
	dodir "/usr/share/${PN}/examples/${1}"
	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
	exeinto /usr/bin
	doexe bin/twelf-server
	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/*
}

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
}