aboutsummaryrefslogtreecommitdiff
blob: beb867e4c49b1398b0ed6f11d79b739592cbc56b (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
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit toolchain-funcs python eutils

DESCRIPTION="Phasing macromolecular crystal structures with maximum likelihood methods"
SRC_URI="ftp://ftp.ccp4.ac.uk/ccp4/6.1.1/${P}-cctbx-src.tar.gz"
HOMEPAGE="http://www-structmed.cimr.cam.ac.uk/phaser/"

SLOT="0"
LICENSE="ccp4"
KEYWORDS="~x86 ~amd64"
IUSE="openmp"

DEPEND="dev-util/scons"
RDEPEND="sci-libs/cctbx"

S="${WORKDIR}"

src_unpack() {
	unpack ${A}
	cd "${S}"
	rm -rf lib/*
	cp -rf $CCP4/lib/cctbx/cctbx_sources/libtbx "${WORKDIR}"

	mkdir -p "${WORKDIR}"/scons/src/
	ln -sf /usr/$(get_libdir)/scons-1.2.0 "${WORKDIR}"/scons/src/engine || die

	epatch "${FILESDIR}"/${PV}-sadf.patch
}

src_compile(){
	python_version

	local MYCONF
	local MAKEOPTS_EXP
	local OPTS
	local OPTSLD

	MYCONF="${S}/libtbx/configure.py"

	MYCONF="${MYCONF} --repository ${S}/ccp4-6.1.1/src/${PN}/source --repository /usr/$(get_libdir)/cctbx/cctbx_sources/ \
	--build=release ccp4io=${CCP4}/$(get_libdir)/cctbx/cctbx_sources/ccp4io/"

	MAKEOPTS_EXP=${MAKEOPTS/j/j }
	MAKEOPTS_EXP=${MAKEOPTS_EXP%-l[0-9]*}

	# Get CXXFLAGS in format suitable for substitition into SConscript
	for i in ${CXXFLAGS}; do
	OPTS="${OPTS} \"${i}\","
	done

	# Strip off the last comma
	OPTS=${OPTS%,}

	# Fix CXXFLAGS
	sed -i \
	-e "s:opts = \[.*\]$:opts = \[${OPTS}\]:g" \
	"${S}"/libtbx/SConscript

	# Get LDFLAGS in format suitable for substitition into SConscript
	for i in ${LDFLAGS}; do
	OPTSLD="${OPTSLD} \"${i}\","
	done

	# Fix LDFLAGS which should be as-needed ready
	sed -i \
	-e "s:env_etc.shlinkflags .* \"-shared\":env_etc.shlinkflags = \[ ${OPTSLD} \"-shared\":g" \
	"${S}"/libtbx/SConscript

	# Get compiler in the right way
	COMPILER=$(expr match "$(tc-getCC)" '.*\([a-z]cc\)')
	MYCONF="${MYCONF} --compiler=${COMPILER}"

	# Additional USE flag usage
	check_use openmp
	MYCONF="${MYCONF} --enable-openmp-if-possible=${USE_openmp}"
	use threads && USEthreads="--enable-boost-threads" && \
	ewarn "If using boost threads openmp support is disabled"

	MYCONF="${MYCONF} ${USE_threads} --scan-boost"

	MYCONF="${MYCONF} phaser"
	einfo "configuring with ${python} ${MYCONF}"

	${python} ${MYCONF} \
	|| die "configure failed"

	source setpaths_all.sh

	einfo "compiling with libtbx.scons ${MAKEOPTS_EXP}"
	libtbx.scons ${MAKEOPTS_EXP} .|| die "make failed"
}

src_install() {
	rm lib/libboost*
	dolib.so lib/*.so || die
	dolib.a lib/*.a || die
	dobin exe/phaser || die
}

check_use() {

	for var in $@; do
	if use ${var}; then
	printf -v "USE_$var" True
	else
	printf -v "USE_$var" False

	fi
	shift
	done
}