aboutsummaryrefslogtreecommitdiff
blob: 3e9dc991c5a422d0ed9492fef69d31fc79d3f3f8 (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
136
137
138
139
140
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=5

inherit eutils toolchain-funcs prefix

DESCRIPTION="Analysis of functional, structural, and diffusion MRI brain imaging data"
HOMEPAGE="http://www.fmrib.ox.ac.uk/fsl"
SRC_URI="https://dev.gentoo.org/~jlec/distfiles/${P}-sources.tar.gz"

LICENSE="FSL BSD-2 newmat"
SLOT="0"
KEYWORDS="~amd64"
IUSE=""

COMMON_DEPEND="
	dev-libs/boost
	media-gfx/graphviz
	media-libs/gd
	media-libs/glu
	media-libs/libpng:0=
	sys-libs/zlib
	"
DEPEND="${COMMON_DEPEND}"
RDEPEND="${COMMON_DEPEND}
	dev-lang/tcl:0=
	dev-lang/tk:0=
	"

S=${WORKDIR}/${PN}

src_prepare(){
	epatch \
		"${FILESDIR}/${PN}"-5.0.8-setup.patch \
		"${FILESDIR}/${PN}"-5.0.8-headers.patch \
		"${FILESDIR}/${PN}"-5.0.8-fsldir_redux.patch

	sed -i \
		-e "s:@@GENTOO_RANLIB@@:$(tc-getRANLIB):" \
		-e "s:@@GENTOO_CC@@:$(tc-getCC):" \
		-e "s:@@GENTOO_CXX@@:$(tc-getCXX):" \
		config/generic/systemvars.mk || die

	eprefixify $(grep -rl GENTOO_PORTAGE_EPREFIX src/*) \
		etc/js/label-div.html

	makefilelist=$(find src/ -name Makefile)

	sed -i \
		-e "s:-I\${INC_BOOST}::" \
		-e "s:-I\${INC_ZLIB}::" \
		-e "s:-I\${INC_GD}::" \
		-e "s:-I\${INC_PNG}::" \
		-e "s:-L\${LIB_GD}::" \
		-e "s:-L\${LIB_PNG}::" \
		-e "s:-L\${LIB_ZLIB}::" \
		${makefilelist} || die

	sed -i "s:\${FSLDIR}/bin/::g" \
		$(grep -rl "\${FSLDIR}/bin" src/*) \
		$(grep -rl "\${FSLDIR}/bin" etc/matlab/*)
	sed -i "s:\$FSLDIR/bin/::g" \
		$(grep -rl "\$FSLDIR/bin" src/*) \
		$(grep -rl "\$FSLDIR/bin" etc/matlab/*)

	sed -i "s:\$FSLDIR/data:${EPREFIX}/usr/share/fsl/data:g" \
		$(grep -rl "\$FSLDIR/data" src/*)

	sed -i "s:\${FSLDIR}/data:${EPREFIX}/usr/share/fsl/data:g" \
		$(grep -rl "\${FSLDIR}/data" src/*)

	sed -i "s:\$FSLDIR/etc:${EPREFIX}/etc:g" \
		$(grep -rl "\$FSLDIR/etc" src/*)

	sed -i "s:\${FSLDIR}/etc:${EPREFIX}/etc:g" \
		$(grep -rl "\${FSLDIR}/etc" src/*)

	sed -i "s:\$FSLDIR/doc:${EPREFIX}/usr/share/fsl/doc:g" \
		$(grep -rl "\$FSLDIR/doc" src/*)

	sed -i "s:\${FSLDIR}/doc:${EPREFIX}/usr/share/fsl/doc:g" \
		$(grep -rl "\${FSLDIR}/doc" src/*)

	sed -i "s:\'\${FSLDIR}\'/doc:${EPREFIX}/usr/share/fsl/doc:g" \
		$(grep -rl "\'\${FSLDIR}\'/doc" src/*)

	sed -i -e "s:\$FSLDIR/etc:/etc:g" `grep -rlI \$FSLDIR/etc *`
}

src_compile() {
	export FSLDIR=${WORKDIR}/${PN}
	export FSLCONDIR=${WORKDIR}/${PN}/config
	export FSLMACHTYPE=generic

	export USERLDFLAGS="${LDFLAGS}"
	export USERCFLAGS="${CFLAGS}"
	export USERCXXFLAGS="${CXXFLAGS}"

	./build || die
}

src_install() {
	sed -i "s:\${FSLDIR}/tcl:/usr/libexec/fsl:g" \
		$(grep -lI "\${FSLDIR}/tcl" bin/*) \
		$(grep -l "\${FSLDIR}/tcl"  tcl/*) || die
	sed -i "s:\$FSLDIR/tcl:/usr/libexec/fsl:g" \
		$(grep -l "\$FSLDIR/tcl" tcl/*) || die

	dobin bin/*

	insinto /usr/share/${PN}
	doins -r data
	dodoc -r doc/. refdoc

	insinto /usr/libexec/fsl
	doins -r tcl/*

	insinto /etc/fslconf
	doins etc/fslconf/fsl.sh

	insinto /etc
	doins etc/fslversion
	doins -r etc/default_flobs.flobs etc/flirtsch etc/js etc/luts
	#if use matlab; then
	#	doins etc/matlab
	#fi

	doenvd "${FILESDIR}"/99fsl
	mv "${ED}"/usr/bin/{,fsl_}cluster || die
}

pkg_postinst() {
	echo
	einfo "Please run the following commands if you"
	einfo "intend to use fsl from an existing shell:"
	einfo "env-update && source /etc/profile"
	echo
}