summaryrefslogtreecommitdiff
blob: 29d1576f78ad2f0eb070f7d1cdc2b14c6aea96b5 (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
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=5

inherit common-lisp-3 eutils flag-o-matic git-2 multilib toolchain-funcs

DESCRIPTION="Linedit is a readline-style library written in Common Lisp."
HOMEPAGE="http://www.common-lisp.net/project/linedit/"
EGIT_REPO_URI="https://gitlab.common-lisp.net/${PN}/${PN}.git"

LICENSE="MIT"
SLOT="0"
IUSE=""

RDEPEND="!dev-lisp/cl-${PN}
		dev-lisp/alexandria
		dev-lisp/madeira-port
		>=dev-lisp/osicat-0.6.0
		dev-lisp/terminfo
		dev-lisp/uffi"

CFILES="terminal_glue"

@cc() {
	local cc=$(tc-getCC)
	echo "${cc}" "${@}"
	"${cc}" "${@}"
}

create_uffi_loader() {
	cat > uffi-loader.lisp <<-EOF
	;;;; -*- mode: lisp; syntax: common-lisp; indent-tabs-mode: nil; base: 10; package: linedit -*-
	(in-package :linedit)
                                                             
	(uffi:load-foreign-library #p"/usr/$(get_libdir)/linedit/terminal_glue.so")
	EOF
}

cleanup_terminfo_files() {
	rm "${D}/${CLSOURCEROOT}/${PN}/terminfo.lisp" || die
	rm "${D}/${CLSYSTEMROOT}/terminfo.asd" || die
}

src_prepare() {
	epatch "${FILESDIR}"/${PV}-${PN}.asd-uffi-glue-gentoo.patch
	create_uffi_loader
}

src_compile() {
	strip-flags
	for filename in "${CFILES}" ; do
		@cc "${filename}.c" ${CFLAGS} ${LDFLAGS} \
	    	-fPIC -DPIC -shared -Wl,-soname="${filename}" -o "${filename}.so" \
	       	|| die "Cannot compile ${filename}.c"
	done
}

src_install() {
	common-lisp-install-sources *.lisp ports/
	common-lisp-install-asdf
	cleanup_terminfo_files
	exeinto "/usr/$(get_libdir)/${PN}"
	doexe *.so
}