summaryrefslogtreecommitdiff
blob: ed99b33a498481654d9a84763d06666e240e5d10 (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-libs/boost/boost-1.34_pre20061214.ebuild,v 1.1 2006/12/18 23:17:00 dev-zero Exp $

inherit distutils flag-o-matic multilib python toolchain-funcs versionator

KEYWORDS="~amd64 ~x86"

MY_P=${PN}_$(replace_all_version_separators _)

DESCRIPTION="Boost Libraries for C++"
HOMEPAGE="http://www.boost.org/"
SRC_URI="http://dev.gentoo.org/~dev-zero/distfiles/${MY_P}.tar.bz2"
LICENSE="freedist Boost-1.0"
SLOT="0"
IUSE="debug doc icc icu pyste static threads threadsonly tools"

DEPEND="icu? ( >=dev-libs/icu-3.2 )
		sys-libs/zlib
		~dev-util/boost-build-${PV}"
RDEPEND="${DEPEND}
		pyste? ( dev-cpp/gccxml dev-python/elementtree )"

S=${WORKDIR}/${MY_P}

src_unpack() {
	unpack ${A}
	cd "${S}"

	rm boost-build.jam

	mkdir -p libs/random/build
	cp "${FILESDIR}/random-Jamfile" libs/random/build/Jamfile.v2
}

generate_options() {
	LINK_OPTIONS="shared"
	use static && LINK_OPTIONS="${LINK_OPTIONS} static"

	if ! use debug ; then
		OPTIONS="release debug-symbols=none"
	else
		OPTIONS="debug"
	fi

	OPTIONS="${OPTIONS} optimization=none"

	if use threads ; then
		if use threadsonly ; then
			OPTIONS="${OPTIONS} threading=multi"
		else
			OPTIONS="${OPTIONS} threading=single,multi"
		fi
	else
		OPTIONS="${OPTIONS} threading=single"
	fi

	use icu && OPTIONS="${OPTIONS} -sHAVE_ICU=1 -sICU_PATH=\"${ROOT}/usr\""

}

generate_userconfig() {
	einfo "Writing new user-config.jam"
	python_version

	local compiler compilerVersion compilerExecutable
	if use icc ; then
		compiler=intel-linux
		compilerExecutable=icc
	elif [ "${ARCH}" == "ppc-macos" ] ; then
		compiler=darwin
		compilerExecutable=cc
	else
		compiler=gcc
		compilerVersion=$(gcc-version)
		compilerExecutable=$(tc-getCXX)
	fi

	cat > "${HOME}/user-config.jam" << __EOF__
import toolset : using ;
import toolset : flags ;
using ${compiler} : ${compilerVersion} : ${compilerExecutable} : <cxxflags>"${CXXFLAGS}" <linkflags>"${LDFLAGS}" ;
using python : ${PYVER} : ${ROOT}usr : ${ROOT}usr/include/python${PYVER} : ${ROOT}usr/lib/python${PYVER} ;
__EOF__

}

src_compile() {

	NUMJOBS=$(sed -e 's/.*\(\-j[ 0-9]\+\) .*/\1/' <<< ${MAKEOPTS})

	generate_userconfig
	generate_options

	BOOST_ROOT=${S}
	BOOST_BUILD_PATH=${ROOT}/usr/share/boost-build

	# Note: The line "debug-symbols=on" only adds '-g' to compiler and linker invocation
	# and prevents boost-build from stripping the libraries/binaries
	for linkoption in ${LINK_OPTIONS} ; do
		einfo "Building ${linkoption} libraries"
		bjam ${NUMJOBS} \
			${OPTIONS} \
			runtime-link=${linkoption} link=${linkoption} \
			--prefix="${D}/usr" \
			--layout=system \
			|| die "building boost failed"
	done

	if use pyste; then
		cd "${S}/libs/python/pyste/install"
		distutils_src_compile
	fi

	if use tools; then
		cd "${S}/tools/"
		# We have to set optimization to -O0 or -O1 to work aroudn a gcc-bug
		# optimization=off adds -O0 to the compiler call and overwrites our settings.
		bjam ${NUMJOBS} \
			release \
			debug-symbols=none \
			optimization=off \
			--prefix="${D}/usr" \
			--layout=system || die "building tools failed"
	fi
}

src_install () {

	generate_options

	BOOST_ROOT=${S}
	BOOST_BUILD_PATH=${ROOT}/usr/share/boost-build

	for linkoption in ${LINK_OPTIONS} ; do
		bjam \
			${OPTIONS} \
			runtime-link=${linkoption} link=${linkoption} \
			--prefix="${D}/usr" \
			--includedir="${D}/usr/include" \
			--libdir="${D}/usr/$(get_libdir)" \
			--layout=system \
			install || die "install failed"
	done

	dodoc README

	if use doc ; then
		dohtml -A .pdf,.txt \
			*.htm *.gif *.css \
			-r doc libs more people wiki
	fi

	cd "${D}/usr/$(get_libdir)"

	for lib in $(ls -1 libboost_thread-mt.*) ; do
		dosym ${lib} "/usr/$(get_libdir)/$(sed -e 's/-mt//' <<< ${lib})"
	done

	if use pyste; then
		cd "${S}/libs/python/pyste/install"
		distutils_src_install
	fi

	if use tools; then
		cd "${S}/dist"
		dobin bin/*
		insinto /usr
		doins -r share
	fi

}