summaryrefslogtreecommitdiff
blob: 624d3292621d640c2c7dfa0211e18b95bf18a8d2 (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
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

MY_PN="NAMD"

inherit eutils multilib toolchain-funcs flag-o-matic

DESCRIPTION="A powerful and highly parallelized molecular dynamics code"
HOMEPAGE="http://www.ks.uiuc.edu/Research/namd/"
SRC_URI="${MY_PN}_${PV}_Source.tar"

LICENSE="namd"
SLOT="0"
KEYWORDS="~amd64"
IUSE=""

RESTRICT="fetch"

RDEPEND="
	>=sys-cluster/charm-6.5.1-r2
	sci-libs/fftw:3.0
	dev-lang/tcl:0="

DEPEND="${RDEPEND}
	virtual/pkgconfig
	app-shells/tcsh"

NAMD_ARCH="Linux-x86_64-g++"

NAMD_DOWNLOAD="http://www.ks.uiuc.edu/Development/Download/download.cgi?PackageName=NAMD"

S="${WORKDIR}/${MY_PN}_${PV}_Source"

PATCHES=(
	# apply a few small fixes to make NAMD compile and
	# link to the proper libraries
	"${FILESDIR}"/namd-2.10-gentoo.patch
	"${FILESDIR}"/namd-2.7-iml-dec.patch
)

pkg_nofetch() {
	echo
	einfo "Please download ${MY_PN}_${PV}_Source.tar.gz from"
	einfo "${NAMD_DOWNLOAD}"
	einfo "after agreeing to the license and then move it to"
	einfo "${DISTDIR}"
	einfo "Be sure to select the ${PV} version!"
	echo
}

src_prepare() {
	CHARM_VERSION=$(best_version sys-cluster/charm | cut -d- -f3)

	default

	sed \
		-e "/CHARMBASE =/s:= .*:= /usr/bin/charm-${CHARM_VERSION}:" \
		-i Make.charm || die

	# Remove charm distribution. We don't need it.
	rm -f charm-*.tar || die

	# proper compiler and cflags
	sed \
		-e "s/g++.*/$(tc-getCXX)/" \
		-e "s/gcc.*/$(tc-getCC)/" \
		-e "s/CXXOPTS = .*/CXXOPTS = ${CXXFLAGS} ${LDFLAGS}/" \
		-e "s/COPTS = .*/COPTS = ${CFLAGS} ${LDFLAGS}/" \
		-i arch/${NAMD_ARCH}.arch || die

	sed \
		-e "s/gentoo-libdir/$(get_libdir)/g" \
		-e "s/gentoo-charm/charm-${CHARM_VERSION}/g" \
		-i Makefile || die "Failed gentooizing Makefile."
	sed -e "s@/lib@/$(get_libdir)@g" -e '/FFTDIR=/s@=.*@=/usr@' -i arch/Linux-x86_64.fftw3 || die
	sed -e "s/gentoo-libdir/$(get_libdir)/g" -i arch/Linux-x86_64.tcl || die
}

src_configure() {
	# configure
	./config ${NAMD_ARCH} --with-fftw3 --charm-arch . || die
}

src_compile() {
	# build namd
	cd "${S}/${NAMD_ARCH}" || die
	TCLLIB="$($(tc-getPKG_CONFIG) --libs tcl) -ldl -pthread" \
		emake
}

src_install() {
	dodoc announce.txt license.txt notes.txt
	cd "${S}/${NAMD_ARCH}" || die

	# the binaries
	dobin ${PN}2 psfgen flipbinpdb flipdcd
}

pkg_postinst() {
	echo
	einfo "For detailed instructions on how to run and configure"
	einfo "NAMD please consults the extensive documentation at"
	einfo "http://www.ks.uiuc.edu/Research/namd/"
	einfo "and the NAMD tutorials available at"
	einfo "http://www.ks.uiuc.edu/Training/Tutorials/"
	einfo "Have fun :)"
	echo
}