summaryrefslogtreecommitdiff
blob: d04d3f7e769cf5719b531be7185e79f215133871 (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
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sci-physics/xfoil/xfoil-6.97.ebuild,v 1.1 2008/08/22 15:55:41 bicatali Exp $

inherit eutils fortran

DESCRIPTION="Design and analysis of subsonic isolated airfoils"
HOMEPAGE="http://raphael.mit.edu/xfoil/"
SRC_URI="http://web.mit.edu/drela/Public/web/${PN}/${PN}${PV}.tar.gz
	doc? ( http://web.mit.edu/drela/Public/web/${PN}/dataflow.pdf )"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86 ~amd64 ~ppc"
IUSE="doc examples"

DEPEND="x11-libs/libX11"

S="${WORKDIR}/Xfoil"
FORTRAN="gfortran ifc g77"

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

	sed -i \
		-e 's/-O3//g' \
		plotlib/config.make || die "sed plotlib/config.make failed"
	cat >> plotlib/config.make <<-EOF
		FC = ${FORTRANC}
		CFLAGS += ${CFLAGS}
		FFLAGS += ${FFLAGS:--O2}
	EOF

	sed -i \
		-e '/^FC/d' \
		-e '/^FFLAGS/d' \
		-e '/^CC/d' \
		-e 's/^\(FFLOPT .*\)/FFLOPT = $(FFLAGS)/g' \
		bin/Makefile orrs/bin/Makefile \
		|| die "sed for flags and compilers failed"

	# fix bug #147033
	[[ ${FORTRANC} == gfortran ]] && \
		epatch "${FILESDIR}"/${PN}-6.96-gfortran.patch
	epatch "${FILESDIR}"/${P}-overflow.patch
	sed -i \
		-e 's:/var/local/codes/orrs/osmap.dat:/usr/share/xfoil/orrs/osmap.dat:' \
		orrs/src/osmap.f || die "sed osmap.f failed"
}

src_compile() {
	cd "${S}"/orrs/bin
	emake FLG="${FFLAGS}" FTNLIB="" OS || die "failed to build orrs"
	cd "${S}"/orrs
	bin/osgen osmaps_ns.lst
	cd "${S}"/plotlib
	emake || die "failed to build plotlib"
	cd "${S}"/bin
	for i in xfoil pplot pxplot; do
		emake \
			PLTOBJ="../plotlib/libPlt.a" \
			CFLAGS="${CFLAGS} -DUNDERSCORE" \
			${i} || die "failed to build ${i}"
	done
}

src_install() {
	dobin bin/pplot bin/pxplot bin/xfoil || die "dobin failed"
	insinto /usr/share/xfoil/orrs
	doins orrs/osm*.dat || die "orrs data install failed"
	dodoc *.txt README || die "dodoc failed"
	insinto /usr/share/doc/${PF}/
	use examples && { doins -r runs || die "examples install failed"; }
	use doc && { doins "${DISTDIR}"/dataflow.pdf || die "doc install failed"; }
}