| 1 |
# Copyright 1999-2012 Gentoo Foundation |
| 2 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
# $Header: $ |
| 4 |
|
| 5 |
EAPI="4" |
| 6 |
PYTHON_DEPEND="python? 2" |
| 7 |
|
| 8 |
inherit multilib eutils python bash-completion-r1 elisp-common autotools |
| 9 |
|
| 10 |
MY_P="${P/_/-}" |
| 11 |
DESCRIPTION="Program matching and transformation engine" |
| 12 |
HOMEPAGE="http://coccinelle.lip6.fr/" |
| 13 |
SRC_URI="http://coccinelle.lip6.fr/distrib/${MY_P}.tgz" |
| 14 |
|
| 15 |
LICENSE="GPL-2" |
| 16 |
SLOT="0" |
| 17 |
KEYWORDS="~amd64 ~x86" |
| 18 |
IUSE="doc emacs ocaml +ocamlopt pcre python test vim-syntax" |
| 19 |
|
| 20 |
# ocaml enables ocaml scripting (uses findlib) |
| 21 |
CDEPEND=">=dev-lang/ocaml-3.10[ocamlopt?] |
| 22 |
dev-ml/sexplib |
| 23 |
emacs? ( virtual/emacs ) |
| 24 |
ocaml? ( dev-ml/findlib ) |
| 25 |
pcre? ( dev-ml/pcre-ocaml )" |
| 26 |
|
| 27 |
RDEPEND="${CDEPEND} |
| 28 |
vim-syntax? ( || ( app-editors/vim app-editors/gvim ) )" |
| 29 |
|
| 30 |
# dev-texlive/texlive-fontsextra contains 'ifsym.sty' |
| 31 |
DEPEND="${CDEPEND} |
| 32 |
virtual/pkgconfig |
| 33 |
doc? ( |
| 34 |
virtual/latex-base |
| 35 |
dev-texlive/texlive-latexextra |
| 36 |
dev-texlive/texlive-fontsextra |
| 37 |
)" |
| 38 |
|
| 39 |
REQUIRED_USE="test? ( ocaml python )" |
| 40 |
|
| 41 |
DOCS=( authors.txt bugs.txt changes.txt credits.txt readme.txt ) |
| 42 |
|
| 43 |
S=${WORKDIR}/${MY_P} |
| 44 |
|
| 45 |
SITEFILE=50coccinelle-gentoo.el |
| 46 |
|
| 47 |
pkg_setup() { |
| 48 |
if use python ; then |
| 49 |
python_set_active_version 2 |
| 50 |
python_pkg_setup |
| 51 |
fi |
| 52 |
} |
| 53 |
|
| 54 |
src_prepare() { |
| 55 |
if use python ; then |
| 56 |
# Fix python install location |
| 57 |
sed -i -e "s:\$(SHAREDIR)/python:$(python_get_sitedir):" \ |
| 58 |
-e "s:PYTHON_TARGET:PYTHON_INSTALL_TARGET:" Makefile || die |
| 59 |
fi |
| 60 |
|
| 61 |
sed -i "s:^SHAREDIR=.*:SHAREDIR=/usr/$(get_libdir)/ocaml/${PN}/:" scripts/spatch.sh.in || die |
| 62 |
|
| 63 |
epatch "${FILESDIR}"/${PN}-1.0.0_rc14-findtool.patch |
| 64 |
cp Makefile Makefile.orig || die |
| 65 |
eautoreconf |
| 66 |
} |
| 67 |
|
| 68 |
src_configure() { |
| 69 |
econf \ |
| 70 |
$(use_enable python) \ |
| 71 |
$(use_enable ocaml) \ |
| 72 |
$(use_enable pcre) \ |
| 73 |
$(use_enable pcre pcre-syntax) |
| 74 |
|
| 75 |
sed -i -e "s:^LIBDIR=.*:LIBDIR=/usr/$(get_libdir)/ocaml/stublibs/:" \ |
| 76 |
-e "s:^SHAREDIR=.*:SHAREDIR=/usr/$(get_libdir)/ocaml/${PN}/:" \ |
| 77 |
Makefile.config || die |
| 78 |
|
| 79 |
cp Makefile.orig Makefile || die |
| 80 |
} |
| 81 |
|
| 82 |
src_compile() { |
| 83 |
emake depend |
| 84 |
emake |
| 85 |
|
| 86 |
use ocamlopt && emake opt |
| 87 |
|
| 88 |
if use doc ; then |
| 89 |
VARTEXFONTS="${T}"/fonts emake docs |
| 90 |
fi |
| 91 |
|
| 92 |
if use emacs ; then |
| 93 |
elisp-compile editors/emacs/cocci.el || die |
| 94 |
fi |
| 95 |
} |
| 96 |
|
| 97 |
src_test() { |
| 98 |
source env.sh # needed for built in-place python plugin |
| 99 |
./spatch standard.h -parse_c -dir tests/ || die |
| 100 |
yes | ./spatch -iso_file standard.iso -macro_file_builtins standard.h -testall || die |
| 101 |
if use ocamlopt ; then |
| 102 |
./spatch.opt -iso_file standard.iso -macro_file_builtins standard.h -testall || die |
| 103 |
fi |
| 104 |
} |
| 105 |
|
| 106 |
src_install() { |
| 107 |
default |
| 108 |
|
| 109 |
use doc && dodoc docs/manual/*.pdf |
| 110 |
newbashcomp scripts/spatch.bash_completion spatch |
| 111 |
|
| 112 |
if use emacs ; then |
| 113 |
elisp-install ${PN} editors/emacs/* |
| 114 |
elisp-site-file-install "${FILESDIR}"/${SITEFILE} |
| 115 |
fi |
| 116 |
|
| 117 |
if use vim-syntax ; then |
| 118 |
newdoc editors/vim/README README-vim |
| 119 |
rm editors/vim/README || die |
| 120 |
insinto /usr/share/vim/vimfiles |
| 121 |
doins -r editors/vim/* |
| 122 |
fi |
| 123 |
|
| 124 |
export STRIP_MASK='*/coccinelle/spatch' |
| 125 |
} |
| 126 |
|
| 127 |
pkg_postinst() { |
| 128 |
use emacs && elisp-site-regen |
| 129 |
} |
| 130 |
|
| 131 |
pkg_postrm() { |
| 132 |
use emacs && elisp-site-regen |
| 133 |
} |