summaryrefslogtreecommitdiff
blob: 06a38861e0d20756fb35368fc0860fc0ed697778 (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
114
115
116
117
118
119
120
121
122
123
124
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sci-physics/mpb/mpb-1.4.2-r2.ebuild,v 1.4 2012/05/04 07:55:34 jdhore Exp $

EAPI=2
inherit eutils autotools flag-o-matic

DESCRIPTION="Photonic band structure program"
SRC_URI="http://ab-initio.mit.edu/mpb/${P}.tar.gz"
HOMEPAGE="http://ab-initio.mit.edu/mpb/"

LICENSE="GPL-2"
KEYWORDS="amd64 x86"
IUSE="doc examples hdf5 mpi"

SLOT="0"

RDEPEND="virtual/lapack
	dev-scheme/guile
	sci-libs/libctl
	sci-libs/fftw:2.1[mpi?]
	sys-libs/readline
	hdf5? ( sci-libs/hdf5 )
	mpi? ( virtual/mpi )"

DEPEND="${RDEPEND}
	virtual/pkgconfig"

src_prepare() {
	epatch "${FILESDIR}"/${P}-autotools.patch
	epatch "${FILESDIR}"/${P}-headers.patch
	cd "${S}"
	rm -f config.*
	AT_NOELIBTOOLIZE=yes eautoreconf
	# version with inversion symmetry (mpbi).
	cp -r "${S}" "${S}_inv"
	# version with hermitian eps (mpbh).
	cp -r "${S}" "${S}_herm"
	# mpi versions (mpb-mpi).
	if use mpi; then
		cp -r "${S}" "${S}_mpi"
		cp -r "${S}" "${S}_inv_mpi"
		cp -r "${S}" "${S}_herm_mpi"
	fi
}

src_configure() {
	# enable legacy API for hdf-1.8
	use hdf5 && append-cflags -DH5_USE_16_API

	local myconf="$(use_with hdf5)"
	export BLAS_LIBS="$(pkg-config --libs blas)"
	export LAPACK_LIBS="$(pkg-config --libs lapack)"

	econf ${myconf}

	cd "${S}_inv"
	econf ${myconf} \
		--with-inv-symmetry

	cd "${S}_herm"
	econf ${myconf} \
		--with-hermitian-eps

	if use mpi; then
		cd "${S}_mpi"
		econf ${myconf} \
			--with-mpi
		cd "${S}_inv_mpi"
		econf ${myconf} \
			--with-inv-symmetry \
			--with-mpi
		cd "${S}_herm_mpi"
		econf ${myconf} \
			--with-hermitian-eps \
			--with-mpi \
			CC=mpicc
	fi
}

src_compile() {
	local dirs="${S} ${S}_inv ${S}_herm"
	for d in ${dirs}; do
		cd "${d}"
		emake -C mpb-ctl ctl-io.c || die
		emake || die "emake in ${d} failed"
	done
	local dirs="${S} ${S}_inv ${S}_herm"
	if use mpi; then
		for d in ${dirs}; do
			cd "${d}_mpi"
			emake -C mpb-ctl ctl-io.c CC=mpicc || die
			emake CC=mpicc LD=mpicc || die "emake in ${d}_mpi failed"
		done
	fi
}

src_install() {
	einstall || die "einstall failed"
	dodoc README NEWS AUTHORS COPYRIGHT ChangeLog TODO

	if use doc; then
		dohtml doc/* || die
	fi
	if use examples; then
		insinto /usr/share/doc/${PF}
		doins -r mpb-ctl/examples || die
	fi

	newbin "${d}"/mpb-ctl/.mpb mpbi || die
	newbin "${S}_herm"/mpb-ctl/.mpb mpbh || die
	einfo "Several versions of mpb have been installed:"
	einfo "mpb : regular version"
	einfo "mpbi: configured for inversion symmetry"
	einfo "mpbh: configured for hermitian epsilon"
	if use mpi; then
		newbin "${S}_mpi"/mpb-ctl/.mpb mpb-mpi || die
		newbin "${S}_inv_mpi"/mpb-ctl/.mpb mpbh-mpi || die
		newbin "${S}_herm_mpi"/mpb-ctl/.mpb mpbi-mpi || die
		einfo "mpb-mpi : regular version with mpi"
		einfo "mpbi-mpi: configured for inversion symmetry with mpi"
		einfo "mpbh-mpi: configured for hermitian epsilon with mpi"
	fi
}