summaryrefslogtreecommitdiffstats
path: root/sys-libs/glibc/files/eblits/src_unpack.eblit
blob: 94f33b5e72c67be2b7542832cc8a468c900ad5c5 (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
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/src_unpack.eblit,v 1.27 2014/09/10 05:59:03 vapier Exp $

[[ ${EAPI:-0} == [01] ]] && source "${FILESDIR}/eblits/src_prepare.eblit"

int_to_KV() {
	local version=$1 major minor micro
	major=$((version / 65536))
	minor=$(((version % 65536) / 256))
	micro=$((version % 256))
	echo ${major}.${minor}.${micro}
}

eend_KV() {
	[[ $(KV_to_int $1) -ge $(KV_to_int $2) ]]
	eend $?
}

get_kheader_version() {
	printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
	$(tc-getCPP ${CTARGET}) -I "${EPREFIX}/$(alt_build_headers)" - | \
	tail -n 1
}

check_nptl_support() {
	# don't care about the compiler here as we arent using it
	just_headers && return

	local run_kv build_kv want_kv
	run_kv=$(int_to_KV $(get_KV))
	build_kv=$(int_to_KV $(get_kheader_version))
	want_kv=${NPTL_KERN_VER}

	ebegin "Checking gcc for __thread support"
	if ! eend $(want__thread ; echo $?) ; then
		echo
		eerror "Could not find a gcc that supports the __thread directive!"
		eerror "Please update your binutils/gcc and try again."
		die "No __thread support in gcc!"
	fi

	if ! is_crosscompile && ! tc-is-cross-compiler ; then
		# Building fails on an non-supporting kernel
		ebegin "Checking kernel version (${run_kv} >= ${want_kv})"
		if ! eend_KV ${run_kv} ${want_kv} ; then
			echo
			eerror "You need a kernel of at least ${want_kv} for NPTL support!"
			die "Kernel version too low!"
		fi
	fi

	ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})"
	if ! eend_KV ${build_kv} ${want_kv} ; then
		echo
		eerror "You need linux-headers of at least ${want_kv} for NPTL support!"
		die "linux-headers version too low!"
	fi
}

unpack_pkg() {
	local a=${PN}
	[[ -n ${SNAP_VER} ]] && a="${a}-${RELEASE_VER}"
	[[ -n $1 ]] && a="${a}-$1"
	if [[ -n ${SNAP_VER} ]] ; then
		a="${a}-${SNAP_VER}"
	else
		if [[ -n $2 ]] ; then
			a="${a}-$2"
		else
			a="${a}-${RELEASE_VER}"
		fi
	fi
	if has ${a}.tar.xz ${A} ; then
		unpacker ${a}.tar.xz
	else
		unpack ${a}.tar.bz2
	fi
	[[ -n $1 ]] && { mv ${a} $1 || die ; }
}

toolchain-glibc_src_unpack() {
	# Check NPTL support _before_ we unpack things to save some time
	want_nptl && check_nptl_support

	if [[ -n ${EGIT_REPO_URIS} ]] ; then
		local i d
		for ((i=0; i<${#EGIT_REPO_URIS[@]}; ++i)) ; do
			EGIT_REPO_URI=${EGIT_REPO_URIS[$i]}
			EGIT_SOURCEDIR=${EGIT_SOURCEDIRS[$i]}
			git-2_src_unpack
		done
	else
		unpack_pkg
	fi

	cd "${S}"
	touch locale/C-translit.h #185476 #218003
	[[ -n ${LT_VER}     ]] && unpack_pkg linuxthreads ${LT_VER}
	[[ -n ${PORTS_VER}  ]] && unpack_pkg ports ${PORTS_VER}
	[[ -n ${LIBIDN_VER} ]] && unpack_pkg libidn

	if [[ -n ${PATCH_VER} ]] ; then
		cd "${WORKDIR}"
		unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.bz2
		# pull out all the addons
		local d
		for d in extra/*/configure ; do
			d=${d%/configure}
			[[ -d ${S}/${d} ]] && die "${d} already exists in \${S}"
			mv "${d}" "${S}" || die "moving ${d} failed"
		done
	fi
}

eblit-glibc-src_unpack() {
	setup_env

	toolchain-glibc_src_unpack
	[[ ${EAPI:-0} == [01] ]] && cd "${S}" && eblit-glibc-src_prepare
}