summaryrefslogtreecommitdiff
blob: 8c50777f08df59594ec28470a1c885256fd1d56d (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
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/glibc-2.2.5-r10.ebuild,v 1.1 2005/02/06 07:45:23 vapier Exp $

inherit flag-o-matic eutils

PATCHVER=1.0
DESCRIPTION="GNU libc6 (also called glibc2) C library"
HOMEPAGE="http://www.gnu.org/software/libc/libc.html"
SRC_URI="ftp://sources.redhat.com/pub/glibc/releases/${P}.tar.bz2
	ftp://sources.redhat.com/pub/glibc/releases/glibc-linuxthreads-${PV}.tar.bz2
	mirror://gentoo/${P}-patches-${PATCHVER}.tar.bz2
	mirror://gentoo/${P}-manpages.tar.bz2"

LICENSE="LGPL-2"
SLOT="2.2"
KEYWORDS="x86 ppc sparc alpha"
IUSE="nls pic build"
RESTRICT="nostrip" # we'll handle stripping ourself #46186

DEPEND="virtual/os-headers
	nls? ( sys-devel/gettext )"
RDEPEND=""
PROVIDE="virtual/libc"

do_filter_flags() {
	# Over-zealous CFLAGS can often cause problems.  What may work for one
	# person may not work for another.  To avoid a large influx of bugs
	# relating to failed builds, we strip most CFLAGS out to ensure as few
	# problems as possible.
	strip-flags

	filter-flags -fomit-frame-pointer -malign-double

	# Sparc support
	replace-flags -mcpu=ultrasparc "-mcpu=v8 -mtune=ultrasparc"
	replace-flags -mcpu=v9 "-mcpu=v8 -mtune=v9"

	# Lock glibc at -O2 -- linuxthreads needs it and we want to be conservative here
	filter-flags -O?
	append-flags -O2
}

src_unpack() {
	unpack ${P}.tar.bz2 ${P}-patches-${PATCHVER}.tar.bz2
	cd "${S}"
	unpack ${P}-manpages.tar.bz2 glibc-linuxthreads-${PV}.tar.bz2
	epatch ${WORKDIR}/patch
}

src_compile() {
	do_filter_flags
	rm -rf buildhere
	mkdir buildhere
	cd buildhere

	local myconf="\
		--with-gd=no \
		--without-cvs \
		--enable-add-ons=linuxthreads \
		--disable-profile \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--libexecdir=/usr/lib/misc"
	use nls || myconf="${myconf} --disable-nls"
	[[ -n ${CBUILD} ]] && myconf="${myconf} --build=${CBUILD}"
	[[ -n ${CTARGET} ]] && myconf="${myconf} --target=${CTARGET}"
	myconf="${myconf} ${EXTRA_ECONF}"
	echo ../configure ${myconf}
	../configure ${myconf} || die "configure failed"

	make PARALLELMFLAGS="${MAKEOPTS}" || die "make failed"
	src_test
}

src_test() {
	unset LD_PRELOAD
	make check || die "make check failed"
}

src_install() {
	export LC_ALL="C"
	make \
		PARALLELMFLAGS="${MAKEOPTS}" \
		install_root="${D}" \
		install -C buildhere \
		|| die "install failed"
	# now, strip everything but the thread libs #46186
	mkdir "${T}"/thread-backup
	mv "${D}"/lib/lib{pthread,thread_db}* "${T}"/thread-backup/
	env -uRESTRICT CHOST=${CTARGET} prepallstrip
	mv "${T}"/thread-backup/* "${D}"/lib/

	if ! use build ; then
		make \
			PARALLELMFLAGS="${MAKEOPTS}" \
			install_root="${D}" \
			localedata/install-locales -C buildhere \
			|| die "install locales failed"

		if ! has noinfo ${FEATURES} ; then
			make \
				PARALLELMFLAGS="${MAKEOPTS}" \
				install_root="${D}" \
				info -C buildhere \
				|| die "install info failed"
		fi
		if ! has noman ${FEATURES} ; then
			dodir /usr/share/man/man3
			doman "${S}"/man/*.3thr
		fi

		# Install nscd config file
		insinto /etc
		doins "${S}"/nscd/nscd.conf
		doinitd "${FILESDIR}"/nscd

		dodoc BUGS ChangeLog* CONFORMANCE FAQ INTERFACE \
			NEWS NOTES PROJECTS README*
	else
		rm -r "${D}"/usr/share "${D}"/usr/lib/gconv
	fi

	if use pic ; then
		find "${S}"/buildhere -name "soinit.os" -exec cp {} "${D}"/lib/soinit.o \;
		find "${S}"/buildhere -name "sofini.os" -exec cp {} "${D}"/lib/sofini.o \;
		find "${S}"/buildhere -name "*_pic.a" -exec cp {} "${D}"/lib \;
		find "${S}"/buildhere -name "*.map" -exec cp {} "${D}"/lib \;
		for i in "${D}"/lib/*.map ; do
			mv "${i}" "${i%.map}"_pic.map
		done
	fi

	# Is this next line actually needed or does the makefile get it right?
	# It previously has 0755 perms which was killing things.
	fperms 4755 /usr/lib/misc/pt_chown

	rm -f "${D}"/etc/ld.so.cache

	# Prevent overwriting of the /etc/localtime symlink.  We'll handle the
	# creation of the "factory" symlink in pkg_postinst().
	rm -f "${D}"/etc/localtime

	# Some things want this, notably ash.
	dosym /usr/lib/libbsd-compat.a /usr/lib/libbsd.a
}

pkg_postinst() {
	if [[ ! -e ${ROOT}/etc/localtime ]] ; then
		echo "Please remember to set your timezone using the zic command."
		rm -f "${ROOT}"/etc/localtime
		ln -s ../usr/share/zoneinfo/Factory "${ROOT}"/etc/localtime
	fi
}