summaryrefslogtreecommitdiff
blob: 07b44eb65254aac1aa195dc51d4e8eef1651fd24 (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
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit flag-o-matic toolchain-funcs

MY_P="${PN}_${PV}"
DESCRIPTION="A sequence assembler for very short reads"
HOMEPAGE="https://www.ebi.ac.uk/~zerbino/velvet/"
SRC_URI="https://www.ebi.ac.uk/~zerbino/velvet/${MY_P}.tgz"
S="${WORKDIR}"/${MY_P}

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

BDEPEND="
	doc? ( virtual/latex-base )
	openmp? (
		|| (
			sys-devel/gcc[openmp]
			sys-devel/clang-runtime[openmp]
		)
	)
"

PATCHES=( "${FILESDIR}/${P}-incompatible-pointers.patch" )

pkg_pretend() {
	[[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
}

pkg_setup() {
	[[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
}

src_prepare() {
	default
	if ! use doc; then
		sed -i -e '/default :/ s/doc//' "${S}"/Makefile || die
	fi
	elog "Upstream recommends using -O3 in CFLAGS"
	echo
	elog "To adjust the MAXKMERLENGTH, CATEGORIES, BIGASSEMBLY, LONGSEQUENCES parameters"
	elog "as described in the PDF manual, please set the variables by prepending VELVET_ in"
	elog "front of it. For example VELVET_MAXKMERLENGTH, VELVET_CATEGORIES, ..."
	elog "Set them either in your environment or in /etc/portage/make.conf, then re-emerge"
	elog "the package. For example:"
	elog "  VELVET_MAXKMERLENGTH=NN emerge [options] velvet"

	if [[ $(tc-getCC) =~ gcc ]]; then
		local eopenmp=-fopenmp
	elif [[ $(tc-getCC) =~ icc ]]; then
		local eopenmp=-openmp
	else
		elog "Cannot detect compiler type so not setting openmp support"
	fi
	append-flags -fPIC ${eopenmp}
	append-ldflags ${eopenmp}

	tc-export CC

	MAKE_XOPTS=(
		CC="$(tc-getCC)"
		CFLAGS="${CFLAGS}"
		OPT="${CFLAGS}"
	)
	use openmp && MAKE_XOPTS+=( OPENMP=1 )
	[[ ! -z "${VELVET_MAXKMERLENGTH}" ]] && MAKE_XOPTS+=( MAXKMERLENGTH=${VELVET_MAXKMERLENGTH} )
	[[ ! -z "${VELVET_CATEGORIES}" ]] && MAKE_XOPTS+=( CATEGORIES=${VELVET_CATEGORIES} )
	[[ ! -z "${VELVET_BIGASSEMBLY}" ]] && MAKE_XOPTS+=( BIGASSEMBLY=${VELVET_BIGASSEMBLY} )
	[[ ! -z "${VELVET_LONGSEQUENCES}" ]] && MAKE_XOPTS+=( LONGSEQUENCES=${VELVET_LONGSEQUENCES} )
}

src_compile() {
	emake "${MAKE_XOPTS[@]}" -j1
	emake "${MAKE_XOPTS[@]}" -j1 color
}

src_test() {
	emake "${MAKE_XOPTS[@]}" -j1 test
}

src_install() {
	dobin velvet{g,h,g_de,h_de}
	insinto /usr/share/${PN}
	doins -r contrib
	dodoc Manual.pdf CREDITS.txt ChangeLog
}