summaryrefslogtreecommitdiff
blob: 7eb255b57e6373c08f58c2823c452e37c3b9ddf7 (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
125
126
127
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=4

inherit eutils autotools flag-o-matic toolchain-funcs

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 ~amd64-linux ~x86-linux"
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 \
		"${FILESDIR}"/${P}-guile18.patch \
		"${FILESDIR}"/${P}-headers.patch
	cd "${S}"
	eautoreconf
	# version with inversion symmetry (mpbi).
	cp -r "${S}" "${S}_inv" || die
	# version with hermitian eps (mpbh).
	cp -r "${S}" "${S}_herm" || die
	# mpi versions (mpb-mpi).
	if use mpi; then
		cp -r "${S}" "${S}_mpi" || die
		cp -r "${S}" "${S}_inv_mpi" || die
		cp -r "${S}" "${S}_herm_mpi" || die
	fi
	tc-export CC
}

src_configure() {
	# enable legacy API for hdf-1.8
	use hdf5 && append-cflags -DH5_USE_16_API
	#
	local myconf=(
		--with-libctl="${EPREFIX}/usr/share/libctl"
		--with-blas="$($(tc-getPKG_CONFIG) --libs blas)"
		--with-lapack="$($(tc-getPKG_CONFIG) --libs lapack)"
		$(use_with hdf5)
	)

	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 d
	for d in .  _inv _herm; do
		cd "${S}${d}"
		emake -C mpb-ctl ctl-io.c
		emake
	done
	if use mpi; then
		for d in .  _inv _herm; do
			cd "${S}${d}_mpi"
			emake -C mpb-ctl ctl-io.c CC=mpicc
			emake CC=mpicc LD=mpicc
		done
	fi
}

src_install() {
	einstall
	dodoc README NEWS AUTHORS COPYRIGHT ChangeLog TODO
	use doc && dohtml doc/*
	if use examples; then
		insinto /usr/share/doc/${PF}
		doins -r mpb-ctl/examples
	fi

	newbin "${S}_inv"/mpb-ctl/.mpb mpbi
	newbin "${S}_herm"/mpb-ctl/.mpb mpbh

	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
		newbin "${S}_inv_mpi"/mpb-ctl/.mpb mpbh-mpi
		newbin "${S}_herm_mpi"/mpb-ctl/.mpb mpbi-mpi
		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
}