Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 471330 | Differences between
and this patch

Collapse All | Expand All

(-)a/sys-devel/llvm/llvm-3.0-r2.ebuild (-7 / +91 lines)
Lines 11-17 HOMEPAGE="http://llvm.org/" Link Here
11
SRC_URI="http://llvm.org/releases/${PV}/${P}.tar.gz"
11
SRC_URI="http://llvm.org/releases/${PV}/${P}.tar.gz"
12
12
13
LICENSE="UoI-NCSA"
13
LICENSE="UoI-NCSA"
14
SLOT="0"
14
SLOT="${PV}"
15
KEYWORDS="amd64 ~ppc x86 ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos"
15
KEYWORDS="amd64 ~ppc x86 ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos"
16
IUSE="debug gold +libffi multitarget ocaml test udis86 vim-syntax"
16
IUSE="debug gold +libffi multitarget ocaml test udis86 vim-syntax"
17
17
Lines 27-32 DEPEND="dev-lang/perl Link Here
27
	ocaml? ( dev-lang/ocaml )
27
	ocaml? ( dev-lang/ocaml )
28
	udis86? ( dev-libs/udis86[pic(+)] )"
28
	udis86? ( dev-libs/udis86[pic(+)] )"
29
RDEPEND="dev-lang/perl
29
RDEPEND="dev-lang/perl
30
	app-admin/eselect-llvm
30
	libffi? ( virtual/libffi )
31
	libffi? ( virtual/libffi )
31
	vim-syntax? ( || ( app-editors/vim app-editors/gvim ) )"
32
	vim-syntax? ( || ( app-editors/vim app-editors/gvim ) )"
32
33
Lines 82-88 src_prepare() { Link Here
82
		-i tools/llvm-config/llvm-config.in.in || die "llvm-config sed failed"
83
		-i tools/llvm-config/llvm-config.in.in || die "llvm-config sed failed"
83
84
84
	einfo "Fixing rpath and CFLAGS"
85
	einfo "Fixing rpath and CFLAGS"
85
	sed -e 's,\$(RPATH) -Wl\,\$(\(ToolDir\|LibDir\)),$(RPATH) -Wl\,'"${EPREFIX}"/usr/$(get_libdir)/${PN}, \
86
	sed -e "s@\$(RPATH) -Wl,\$(\(ToolDir\|LibDir\))@\$(RPATH) -Wl,'${EPREFIX}/usr/$(get_libdir)/${PN}-${SLOT}'@" \
86
		-e '/OmitFramePointer/s/-fomit-frame-pointer//' \
87
		-e '/OmitFramePointer/s/-fomit-frame-pointer//' \
87
		-i Makefile.rules || die "rpath sed failed"
88
		-i Makefile.rules || die "rpath sed failed"
88
89
Lines 155-181 src_install() { Link Here
155
		doins utils/vim/*.vim
156
		doins utils/vim/*.vim
156
	fi
157
	fi
157
158
159
	# Register slot for app-admin/eselect-llvm
160
	local eselect_dir="/usr/share/eselect-llvm/slots/${SLOT}"
161
	dodir "${eselect_dir}"
162
	eselect_dir="${ED}/${eselect_dir}"
163
	echo "${CATEGORY}/${PF}" > "${eselect_dir}/ebuild"
164
165
	with_slot_suffix() {
166
		local file=$(echo "$1" | sed -e "s/-${SLOT}//")
167
		local ext=""
168
		if [[ "${file}" =~ \. ]] ; then
169
			ext=".${file#*.}"
170
		fi
171
		local base="${file%%.*}"
172
		echo "${base}-${SLOT}${ext}"
173
	}
174
175
	make_versioned() {
176
		local dir=$1
177
		local candidates=(${ED%/}/${dir})
178
		if [[ ! ${dir##*/} ]] ; then
179
			dir=${dir%/}
180
			candidates=( "${candidates}"* )
181
		else
182
			dir=$(dirname "${dir}")
183
		fi
184
185
		pushd ${ED%/}/${dir} >/dev/null || die
186
187
		local candidate
188
		for candidate in "${candidates[@]}" ; do
189
			if [[ -h "${candidate}" ]] ; then
190
				# Add slot suffix to symlink target
191
				local target=$(readlink -s "${candidate}")
192
				local slotted_target=$(with_slot_suffix "${target}")
193
				if [[ -e "${target}" ]] || [[ -e "${slotted_target}" ]] ; then
194
					ln -sf "${slotted_target}" "${candidate}" \
195
						|| die "Could not update symlink"
196
				fi
197
			fi
198
199
			local base_name=$(basename "${candidate}")
200
			local slotted_name=$(with_slot_suffix "${base_name}")
201
			mv "${candidate}" "${ED}/${dir}/${slotted_name}" \
202
				|| die "Could not rename ${candidate} to ${slotted_name}"
203
			echo "/${dir#/}/${base_name}" >> "${eselect_dir}/versioned"
204
		done
205
206
		popd >/dev/null || die
207
	}
208
209
	# Trailing slash => version the content
210
	# No trailing slash => version the directory itself
211
	local paths=(
212
		/usr/bin/
213
		/usr/$(get_libdir)/
214
		/usr/include/
215
		/usr/share/man/man1/
216
	)
217
	use vim-syntax && paths+=( /usr/share/vim/vimfiles/syntax/ )
218
219
	local path
220
	for path in "${paths[@]}" ; do
221
		make_versioned "${path}"
222
	done
223
158
	# Fix install_names on Darwin.  The build system is too complicated
224
	# Fix install_names on Darwin.  The build system is too complicated
159
	# to just fix this, so we correct it post-install
225
	# to just fix this, so we correct it post-install
160
	local lib= f= odylib=
226
	local lib= f= odylib=
161
	if [[ ${CHOST} == *-darwin* ]] ; then
227
	if [[ ${CHOST} == *-darwin* ]] ; then
162
		for lib in lib{EnhancedDisassembly,LLVM-${PV},LTO,profile_rt}.dylib {BugpointPasses,LLVMHello}.dylib ; do
228
		for lib in lib{EnhancedDisassembly,LLVM-${PV},LTO,profile_rt}.dylib {BugpointPasses,LLVMHello}.dylib ; do
163
			# libEnhancedDisassembly is Darwin10 only, so non-fatal
229
			# libEnhancedDisassembly is Darwin10 only, so non-fatal
164
			[[ -f ${ED}/usr/lib/${PN}/${lib} ]] || continue
230
			[[ -f ${ED}/usr/lib/${PN}-${SLOT}/${lib} ]] || continue
165
			ebegin "fixing install_name of $lib"
231
			ebegin "fixing install_name of $lib"
166
			install_name_tool \
232
			install_name_tool \
167
				-id "${EPREFIX}"/usr/lib/${PN}/${lib} \
233
				-id "${EPREFIX}"/usr/lib/${PN}-${SLOT}/${lib} \
168
				"${ED}"/usr/lib/${PN}/${lib}
234
				"${ED}"/usr/lib/${PN}-${SLOT}/${lib}
169
			eend $?
235
			eend $?
170
		done
236
		done
171
		for f in "${ED}"/usr/bin/* "${ED}"/usr/lib/${PN}/libLTO.dylib ; do
237
		for f in "${ED}"/usr/bin/* "${ED}"/usr/lib/${PN}-${SLOT}/libLTO.dylib ; do
172
			odylib=$(scanmacho -BF'%n#f' "${f}" | tr ',' '\n' | grep libLLVM-${PV}.dylib)
238
			odylib=$(scanmacho -BF'%n#f' "${f}" | tr ',' '\n' | grep libLLVM-${PV}.dylib)
173
			ebegin "fixing install_name reference to ${odylib} of ${f##*/}"
239
			ebegin "fixing install_name reference to ${odylib} of ${f##*/}"
174
			install_name_tool \
240
			install_name_tool \
175
				-change "${odylib}" \
241
				-change "${odylib}" \
176
					"${EPREFIX}"/usr/lib/${PN}/libLLVM-${PV}.dylib \
242
					"${EPREFIX}"/usr/lib/${PN}-${SLOT}/libLLVM-${PV}.dylib \
177
				"${f}"
243
				"${f}"
178
			eend $?
244
			eend $?
179
		done
245
		done
180
	fi
246
	fi
181
}
247
}
248
249
pkg_postinst() {
250
	if [[ $(eselect ${PN} show) = "(none)" ]] ; then
251
		eselect ${PN} set ${SLOT}
252
	fi
253
}
254
255
pkg_prerm() {
256
	if [[ $(eselect ${PN} show) = ${SLOT} ]] ; then
257
		eselect ${PN} clear
258
	fi
259
}
260
261
pkg_postrm() {
262
	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
263
		eselect ${PN} update
264
	fi
265
}

Return to bug 471330