summaryrefslogtreecommitdiff
blob: d63a2f1d2a1972a6cdb48265c00055b54d2bff5a (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
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sci-chemistry/eden/eden-5.3-r1.ebuild,v 1.2 2011/12/16 12:59:33 jlec Exp $

EAPI="3"

PYTHON_DEPEND="2"

inherit eutils multilib python toolchain-funcs

MY_P="${PN}_V${PV}"

DESCRIPTION="A crystallographic real-space electron-density refinement and optimization program"
HOMEPAGE="http://www.gromacs.org/pipermail/eden-users/"
SRC_URI="mirror://gentoo/${MY_P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="double-precision"

RDEPEND="
	sci-libs/fftw:2.1
	sci-libs/gsl"
DEPEND="${RDEPEND}
	dev-util/pkgconfig"

S="${WORKDIR}/${PN}"

SRC="${S}/source"
EDENHOME="${EPREFIX}/usr/$(get_libdir)/eden"

pkg_setup() {
	python_set_active_version 2
}

src_prepare() {
	epatch "${FILESDIR}"/${PV}-makefile-fixes.patch

	sed -i \
		-e "s:^\(FFTW.*=\).*:\1 ${EPREFIX}/usr:g" \
		-e "s:^\(LIB.*=.*\$(FFTW)/\).*:\1$(get_libdir):g" \
		-e "s:^\(BIN.*=\).*:\1 ${D}usr/bin:g" \
		-e "s:^\(CFLAGS.*=\).*:\1 ${CFLAGS}:g" \
		-e "s:-lgsl -lgslcblas:$(pkg-config --libs gsl):g" \
		${SRC}/Makefile || die

	if ! use double-precision; then
		sed -i -e "s:^\(DOUBLESWITCH.*=\).*:\1 OFF:g" ${SRC}/Makefile || die
		EXE="seden"
	else
		EXE="deden"
	fi
}

src_compile() {
	emake CC=$(tc-getCC) -C ${SRC} || die "emake failed"
}

src_install() {
	emake -C ${SRC} install || die "install failed"

	exeinto ${EDENHOME}/python
	doexe python/* || die

	insinto ${EDENHOME}/help
	doins help/* || die

	insinto ${EDENHOME}/tools
	doins tools/* || die

	dodoc manual/UserManual.pdf || die

	cat >> "${T}"/eden <<- EOF
	#!/bin/bash
	export EDENHOME="${EDENHOME}"
	${EXE} \$*
	EOF

	dobin "${T}"/eden || die

	cat >> "${T}"/ieden <<- EOF
	#!/bin/bash
	export EDENHOME="${EDENHOME}"
	$(PYTHON) -O \${EDENHOME}/python/eden.py
	EOF

	dobin "${T}"/ieden || die
}

pkg_postinst() {
	python_mod_optimize ${EDENHOME}/python
}

pkg_postrm() {
	python_mod_cleanup ${EDENHOME}/python
}