summaryrefslogtreecommitdiff
blob: 75fdc4bc0d904e163b49aa1d84d4735c3bb9c4b8 (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
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-cpp/tbb/tbb-4.0.297.ebuild,v 1.2 2012/03/20 16:42:51 ago Exp $

EAPI=4
inherit eutils versionator toolchain-funcs

# those 2 below change pretty much every release
# url number
MYU="78/181"
# release update
MYR="%20update%203"

PV1="$(get_version_component_range 1)"
PV2="$(get_version_component_range 2)"
PV3="$(get_version_component_range 3)"
MYP="${PN}${PV1}${PV2}_${PV3}oss"

DESCRIPTION="High level abstract threading library"
HOMEPAGE="http://www.threadingbuildingblocks.org/"
SRC_URI="http://www.threadingbuildingblocks.org/uploads/${MYU}/${PV1}.${PV2}${MYR}/${MYP}_src.tgz"
LICENSE="GPL-2-with-exceptions"

SLOT="0"
KEYWORDS="amd64 ~x86"
IUSE="debug doc examples"

DEPEND=""
RDEPEND="${DEPEND}"
S="${WORKDIR}/${MYP}"

src_prepare() {
	epatch "${FILESDIR}"/${PN}-3.0.104-tests.patch
	# use fully qualified compilers. do not force pentium4 for x86 users
	local CC="$(tc-getCC)"
	sed -i \
		-e "s/-O2/${CXXFLAGS}/g" \
		-e 's/^\(CPLUS = \)g++ $/\1'"$(tc-getCXX)/" \
		-e 's/^\(CONLY = \)gcc$/\1'"${CC}/" \
		-e 's/\(shell \)gcc\( --version\)/\1'"${CC}"'\2/' \
		-e '/CPLUS_FLAGS +=/s/-march=pentium4//' \
		build/*.inc || die
	# - Strip the $(shell ... >$(NUL) 2>$(NUL)) wrapping, leaving just the
	#   actual command.
	# - Force generation of version_string.tmp immediately after the directory
	#   is created.  This avoids a race when the user builds tbb and tbbmalloc
	#   concurrently.  The choice of Makefile.tbb (instead of
	#   Makefile.tbbmalloc) is arbitrary.
	sed -i \
		-e 's/^\t\$(shell \(.*\) >\$(NUL) 2>\$(NUL))\s*/\t\1/' \
		-e 's!^\t@echo Created \$(work_dir)_\(debug\|release\).*$!&\n\t$(MAKE) -C "$(work_dir)_\1"  -r -f $(tbb_root)/build/Makefile.tbb cfg=\1 tbb_root=$(tbb_root) version_string.tmp!' \
		src/Makefile || die
	find include -name \*.html -delete

	cat <<-EOF > ${PN}.pc
		prefix=${EPREFIX}/usr
		libdir=\${prefix}/$(get_libdir)
		includedir=\${prefix}/include
		Name: ${PN}
		Description: ${DESCRIPTION}
		Version: ${PV}
		URL: ${HOMEPAGE}
		Libs: -L\${libdir} -ltbb -ltbbmalloc
		Cflags: -I\${includedir}/tbb
	EOF
}

src_compile() {
	if [[ $(tc-getCXX) == *g++ ]]; then
		myconf="compiler=gcc"
	elif [[ $(tc-getCXX) == *ic*c ]]; then
		myconf="compiler=icc"
	fi
	local ccconf="${myconf}"
	if use debug || use examples; then
		ccconf="${ccconf} tbb_debug tbbmalloc_debug"
	fi
	emake -C src ${ccconf} tbb_release tbbmalloc_release
}

src_test() {
	local ccconf="${myconf}"
	if use debug || use examples; then
		${ccconf}="${myconf} test_debug tbbmalloc_test_debug"
	fi
	emake -C src ${ccconf} test_release
}

src_install(){
	local l
	for l in $(find build -name lib\*.so.\*); do
		dolib.so ${l}
		local bl=$(basename ${l})
		dosym ${bl} /usr/$(get_libdir)/${bl%.*}
	done
	insinto /usr
	doins -r include
	insinto /usr/$(get_libdir)/pkgconfig
	doins ${PN}.pc
	dodoc README CHANGES doc/Release_Notes.txt
	use doc && dohtml -r doc/html/*

	if use examples ; then
		insinto /usr/share/doc/${PF}/examples/build
		doins build/*.inc
		insinto /usr/share/doc/${PF}/examples
		doins -r examples
	fi
}