aboutsummaryrefslogtreecommitdiff
blob: d9532a87b18ead3145b9510b11c12a143d151606 (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
128
129
130
131
132
133
134
135
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit autotools eutils flag-o-matic mpi versionator toolchain-funcs

MY_PV=$(replace_version_separator 2 '-')

DESCRIPTION="Solve PDEs using FEM on 2d and 3d domains"
HOMEPAGE="http://www.freefem.org/ff++/"
SRC_URI="http://www.freefem.org/ff%2B%2B/ftp/${PN}-${MY_PV}.tar.gz"

LICENSE="LGPL-2.1"
SLOT="0"
KEYWORDS="~amd64"
IUSE="doc examples mpi opengl vim-syntax X"

RDEPEND="
	sci-libs/fftw
	virtual/cblas
	virtual/lapack
	sci-libs/umfpack
	sci-libs/arpack
	mpi? ( $(mpi_pkg_deplist) )
	opengl? (
		media-libs/freeglut
		virtual/opengl
		)
	vim-syntax? ( app-vim/freefem++-syntax )
	X? (
		media-fonts/font-misc-misc
		x11-libs/libX11
		x11-libs/libXext
		x11-libs/libXpm
		x11-libs/libXxf86vm
		)"

DEPEND="${RDEPEND}
	virtual/pkgconfig
	doc? (
		|| (
			(
				dev-texlive/texlive-latexrecommended
				dev-texlive/texlive-latexextra
			)
			app-text/ptex
			)
		virtual/latex-base
		media-gfx/imagemagick
		)"

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

src_unpack() {
	unpack ${A}
	cd "${S}"

	# acoptim.m4 forced -O2 removal
	epatch "${FILESDIR}"/${PN}-acoptim.patch
	# do not try to do a forced "manual" installation of
	# examples and documentation
	epatch "${FILESDIR}"/${PN}-no-doc-autobuild.patch
	# Honor FHS
	epatch "${FILESDIR}"/${PN}-path.patch

	eautoreconf
}

src_compile() {
	local myconf

	if use mpi; then
		myconf="${myconf} --with-mpi=$(mpi_pkg_cxx)"
	else
		myconf="--without-mpi"
	fi

	econf \
		--disable-download \
		--disable-optim \
		--enable-generic \
		--with-blas="$($(tc-getPKG_CONFIG) --libs blas)" \
		--with-lapack="$($(tc-getPKG_CONFIG) --libs lapack)" \
		$(use_enable opengl) \
		$(use_with X x) \
		${myconf}

	emake || die "emake failed"

	if use doc; then
		emake documentation || die "emake documentation failed"
	fi
}

src_test() {
	if use mpi; then
		# This may depend on the used MPI implementation. It is needed
		# with mpich2, but should not be needed with lam-mpi or mpich
		# (if the system is configured correctly).
		ewarn "Please check that your MPI root ring is on before running"
		ewarn "the test phase. Failing to start it before that phase may"
		ewarn "result in a failing emerge."
		epause
	fi
	emake -j1 check || die "check test failed"
}

src_install() {
	emake DESTDIR="${D}" install || die "emake install failed"

	dodoc AUTHORS INNOVATION HISTORY* README

	insinto /usr/share/doc/${PF}
	if use doc; then
		doins DOC/freefem++doc.pdf || die
	fi

	if use examples; then
		einfo "Installing examples..."

		# Remove compiled examples:
		emake clean || die "emake clean failed"

		einfo "Some of the installed examples assumes that the user has write"
		einfo "permissions in the working directory and other will look for"
		einfo "data files in the working directory. For this reason in order to"
		einfo "run the examples it's better to temporary copy them somewhere"
		einfo "in the user folder. For example to run the tutorial examples"
		einfo "it's better to copy the entire examples++-tutorial folder into"
		einfo "the user directory."

		rm -f examples*/Makefile*
		doins -r examples*
	fi
}