summaryrefslogtreecommitdiff
blob: a0b4ab8ffd9c3a03726ecf819f0e41d316001236 (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
# this script is expected to be sourced by ghc ebuilds built against libgmp.so.3 library
#
# > source "${FILESDIR}/ghc-apply-gmp-hack"
#
# What it does and why it works:
#  > GMP 5.0 is upwardly source and binary compatible with 4.x, and 3.x versions,
#  > except for applications that use the semi-documented mpn_bdivmod  function.
#
#  > The solib numbers now reflect the removal of the documented but preliminary
#  > mpn_bdivmod function; we correctly flag incompatibility with GMP 4.3.
#  > GMP 5.0.0 has this wrong, and should perhaps be uninstalled to avoid confusion.
#
# taken from http://gmplib.org/gmp5.0.html
#
# Luckily, ghc does not use the 'mpn_bdivmod' function, so we can easily use
# libgmp.so.10 for binaries which require libgmp.so.3
#
# So, this script checks whether this system has libgmp.so.10 and if has
# shows it to bootstrapper-compiler via populating LD_LIBRARY_PATH
# (it actually exports function doing this)
#
# After bootstrapping resulting compiler will not depend on old libgmp
# Newer ghc binaries must be built against newer gmp
#
# Blames should be directed to Sergei Trofimovich <slyfox@gentoo.org>

# should be used:
# > inherit multilib
# > ...
# > # somewhere in src_unpack() { # as early as possible, right after unpacking source/binary
# > source "${FILESDIR}/ghc-apply-gmp-hack" "$(get_libdir)"

local libdir_name=$1
# let's see if we are in affected system
if has_version '>=dev-libs/gmp-5.0.1'; then
	local libgmpso3=$ROOT/usr/$libdir_name/libgmp.so.3
	local libgmpso10=$ROOT/usr/$libdir_name/libgmp.so.10

	# bother user only if things won't work for him
	if [[ ! -e "$libgmpso3" ]]; then
		if use binary; then
			eerror "You have requested precompiled binary installation, which is"
			eerror "built against 'libgmp.so.3'. You can create compatibility symlink"
			eerror "if you have '$libgmpso10' and wish to use installed binary:"
			eerror " # ln -s libgmp.so.10 '$libgmpso3'"
			die "libgmp.so.3 not found"
		else
			if [[ -e "$libgmpso10" ]]; then
				local fake_solib_dir=${S}/fake_solibs
				mkdir "$fake_solib_dir" || die "failed to make fake lib dir"
				elog "Enabling libgmp hack:"
				elog "| Making symlink: '$fake_solib_dir/libgmp.so.3' -> '$libgmpso10'"
				ln -s "$libgmpso10" "$fake_solib_dir/libgmp.so.3" || die "failed to make fake symlink"
				export LD_LIBRARY_PATH=$fake_solib_dir${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
				elog "| setting new LD_LIBRARY_PATH='$LD_LIBRARY_PATH'"
			else
				eerror "'$libgmpso3' and '$libgmpso10' are not found. Please, report the breakage."
			fi
		fi
	fi
fi