1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit prefix toolchain-funcs toolchain-glibc
8 DESCRIPTION="GNU libc C library"
9 HOMEPAGE="https://www.gnu.org/software/libc/"
11 LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE"
14 # Configuration variables
16 if [[ ${PV} == 9999* ]]; then
17 EGIT_REPO_URI="https://sourceware.org/git/glibc.git"
20 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 m68k ~mips ppc ppc64 s390 sparc x86"
21 SRC_URI="mirror://gnu/glibc/${P}.tar.xz"
26 GCC_BOOTSTRAP_VER=20180511
31 SRC_URI+=" https://dev.gentoo.org/~dilfridge/distfiles/${P}-patches-${PATCH_VER}.tar.bz2"
32 SRC_URI+=" multilib? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )"
34 IUSE="audit caps debug doc gd hardened multilib nscd selinux systemtap profile suid vanilla headers-only"
36 # Min kernel version glibc requires
37 : ${NPTL_KERN_VER:="3.2.0"}
39 # Here's how the cross-compile logic breaks down ...
40 # CTARGET - machine that will target the binaries
41 # CHOST - machine that will host the binaries
42 # CBUILD - machine that will build the binaries
43 # If CTARGET != CHOST, it means you want a libc for cross-compiling.
44 # If CHOST != CBUILD, it means you want to cross-compile the libc.
45 # CBUILD = CHOST = CTARGET - native build/install
46 # CBUILD != (CHOST = CTARGET) - cross-compile a native build
47 # (CBUILD = CHOST) != CTARGET - libc for cross-compiler
48 # CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler
50 # CHOST = CTARGET - install into /
51 # CHOST != CTARGET - install into /usr/CTARGET/
53 export CBUILD=${CBUILD:-${CHOST}}
54 export CTARGET=${CTARGET:-${CHOST}}
55 if [[ ${CTARGET} == ${CHOST} ]] ; then
56 if [[ ${CATEGORY} == cross-* ]] ; then
57 export CTARGET=${CATEGORY#cross-}
61 # Note [Disable automatic stripping]
62 # Disabling automatic stripping for a few reasons:
63 # - portage's attempt to strip breaks non-native binaries at least on
65 # - portage's attempt to strip libpthread.so.0 breaks gdb thread
66 # enumeration: bug #697910. This is quite subtle:
67 # * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
68 # * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
69 # via 'ps_pglobal_lookup' symbol defined in gdb.
70 # * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
71 # known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
72 # (unexported) is used to sanity check compatibility before enabling
74 # Also see https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
75 # * normal 'strip' command trims '.symtab'
76 # Thus our main goal here is to prevent 'libpthread.so.0' from
77 # losing it's '.symtab' entries.
78 # As Gentoo's strip does not allow us to pass less aggressive stripping
79 # options and does not check the machine target we disable stripping
84 [[ ${CHOST} != ${CTARGET} ]]
89 # General: We need a new-enough binutils/gcc to match upstream baseline.
90 # arch: we need to make sure our binutils/gcc supports TLS.
93 audit? ( sys-process/audit )
94 caps? ( sys-libs/libcap )
96 suid? ( caps? ( sys-libs/libcap ) )
97 selinux? ( sys-libs/libselinux )
98 systemtap? ( dev-util/systemtap )
100 DEPEND="${COMMON_DEPEND}
101 >=app-misc/pax-utils-0.1.10
102 doc? ( sys-apps/texinfo )
104 RDEPEND="${COMMON_DEPEND}
105 sys-apps/gentoo-functions
108 if [[ ${CATEGORY} == cross-* ]] ; then
109 DEPEND+=" !headers-only? (
110 >=${CATEGORY}/binutils-2.24
111 >=${CATEGORY}/gcc-4.9
113 [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers"
116 >=sys-devel/binutils-2.24
120 RDEPEND+=" vanilla? ( !sys-libs/timezone-data )"
121 PDEPEND+=" !vanilla? ( sys-libs/timezone-data )"
129 # Make sure devpts is mounted correctly for use w/out setuid pt_chown
132 # Prevent native builds from downgrading
133 if [[ ${MERGE_TYPE} != "buildonly" ]] && \
134 [[ ${ROOT} == "/" ]] && \
135 [[ ${CBUILD} == ${CHOST} ]] && \
136 [[ ${CHOST} == ${CTARGET} ]] ; then
137 # The high rev # is to allow people to downgrade between -r# versions.
138 # We want to block 2.20->2.19, but 2.20-r3->2.20-r2 should be fine.
139 # Hopefully we never actually use a r# this high.
140 if has_version ">${CATEGORY}/${P}-r10000" ; then
141 eerror "Sanity check to keep you from breaking your system:"
142 eerror " Downgrading glibc is not supported and a sure way to destruction"
143 [[ ${I_ALLOW_TO_BREAK_MY_SYSTEM} = yes ]] || die "Aborting to save your system."
146 if ! glibc_run_test '#include <pwd.h>\nint main(){return getpwuid(0)==0;}\n'
148 eerror "Your patched vendor kernel is broken. You need to get an"
149 eerror "update from whoever is providing the kernel to you."
150 eerror "https://sourceware.org/bugzilla/show_bug.cgi?id=5227"
151 eerror "https://bugs.gentoo.org/262698"
152 die "Keeping your system alive, say thank you"
155 if ! glibc_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n'
157 eerror "Your old kernel is broken. You need to update it to"
158 eerror "a newer version as syscall(<bignum>) will break."
159 eerror "https://bugs.gentoo.org/279260"
160 die "Keeping your system alive, say thank you"
164 # Users have had a chance to phase themselves, time to give em the boot
165 if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then
166 eerror "You still haven't deleted ${EROOT}/etc/locales.build."
167 eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher."
168 die "Lazy upgrader detected"
171 if [[ ${CTARGET} == i386-* ]] ; then
172 eerror "i386 CHOSTs are no longer supported."
173 eerror "Chances are you don't actually want/need i386."
174 eerror "Please read https://www.gentoo.org/doc/en/change-chost.xml"
175 die "Please fix your CHOST"
178 if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then
179 ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS."
180 ewarn "This will result in a 50% performance penalty when running with a 32bit"
181 ewarn "hypervisor, which is probably not what you want."
184 # Make sure host system is up to date #394453
185 if has_version '<sys-libs/glibc-2.13' && \
186 [[ -n $(scanelf -qys__guard -F'#s%F' "${EROOT}"/lib*/l*-*.so) ]]
188 ebegin "Scanning system for __guard to see if you need to rebuild first ..."
190 scanelf -qys__guard -F'#s%F' \
193 "${EROOT}"/usr/*bin/ \
194 "${EROOT}"/usr/lib* | \
196 -e "^${EROOT}/lib.*/(libc|ld)-2.*.so$" \
197 -e "^${EROOT}/sbin/(ldconfig|sln)$"
201 eerror "Your system still has old SSP __guard symbols. You need to"
202 eerror "rebuild all the packages that provide these files first:"
204 die "old __guard detected"
208 # Check for sanity of /etc/nsswitch.conf
209 if [[ -e ${EROOT}/etc/nsswitch.conf ]] ; then
211 for entry in passwd group shadow; do
212 if ! egrep -q "^[ \t]*${entry}:.*files" "${EROOT}"/etc/nsswitch.conf; then
213 eerror "Your ${EROOT}/etc/nsswitch.conf is out of date."
214 eerror "Please make sure you have 'files' entries for"
215 eerror "'passwd:', 'group:' and 'shadow:' databases."
216 eerror "For more details see:"
217 eerror " https://wiki.gentoo.org/wiki/Project:Toolchain/nsswitch.conf_in_glibc-2.26"
218 die "nsswitch.conf has no 'files' provider in '${entry}'."
225 use multilib && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz
229 # Check NPTL support _before_ we unpack things to save some time
232 if [[ -n ${EGIT_REPO_URI} ]] ; then
239 touch locale/C-translit.h #185476 #218003
242 unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.bz2
246 if ! use vanilla ; then
247 elog "Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER}"
248 eapply "${WORKDIR}"/patches
252 if just_headers ; then
253 if [[ -e ports/sysdeps/mips/preconfigure ]] ; then
254 # mips peeps like to screw with us. if building headers,
255 # we don't have a real compiler, so we can't let them
256 # insert -mabi on us.
257 sed -i '/CPPFLAGS=.*-mabi/s|.*|:|' ports/sysdeps/mips/preconfigure || die
258 find ports/sysdeps/mips/ -name Makefile -exec sed -i '/^CC.*-mabi=/s:-mabi=.*:-D_MIPS_SZPTR=32:' {} +
267 find . -name configure -exec touch {} +
269 eprefixify extra/locale/locale-gen
271 # Fix permissions on some of the scripts.
272 chmod u+x "${S}"/scripts/*.sh
276 if use hardened ; then
277 # We don't enable these for non-hardened as the output is very terse --
278 # it only states that a crash happened. The default upstream behavior
279 # includes backtraces and symbols.
280 einfo "Installing Hardened Gentoo SSP and FORTIFY_SOURCE handler"
281 cp "${FILESDIR}"/2.20/glibc-2.20-gentoo-stack_chk_fail.c debug/stack_chk_fail.c || die
282 cp "${FILESDIR}"/2.25/glibc-2.25-gentoo-chk_fail.c debug/chk_fail.c || die
285 # Allow SIGABRT to dump core on non-hardened systems, or when debug is requested.
287 -e '/^CFLAGS-backtrace.c/ iCPPFLAGS-stack_chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
288 -e '/^CFLAGS-backtrace.c/ iCPPFLAGS-chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
289 debug/Makefile || die
294 glibc_do_configure() {
295 # Glibc does not work with gold (for various reasons) #269274.
298 # CXX isnt handled by the multilib system, so if we dont unset here
299 # we accumulate crap across abis
302 einfo "Configuring glibc for $1"
305 export MAKEINFO=makeinfo
307 export MAKEINFO=/dev/null
311 for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO ; do
312 einfo " $(printf '%15s' ${v}:) ${!v}"
315 # The glibc configure script doesn't properly use LDFLAGS all the time.
316 export CC="$(tc-getCC ${CTARGET}) ${LDFLAGS}"
317 einfo " $(printf '%15s' 'Manual CC:') ${CC}"
319 # Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548
320 export CXX="$(tc-getCXX ${CTARGET}) $(get_abi_CFLAGS)"
321 einfo " $(printf '%15s' 'Manual CXX:') ${CXX}"
328 pushd "${S}" > /dev/null
329 local addons=$(echo */configure | sed \
330 -e 's:/configure::g' \
331 -e 's:\(linuxthreads\|nptl\|rtkaio\|glibc-compat\)\( \|$\)::g' \
336 [[ -d ports ]] && addons+=",ports"
341 # Currently gcc on powerpc32 generates invalid code for
342 # __builtin_return_address(0) calls. Normally programs
343 # don't do that but malloc hooks in glibc do:
344 # https://gcc.gnu.org/PR81996
345 # https://bugs.gentoo.org/629054
346 myconf+=( --enable-stack-protector=no )
349 myconf+=( --enable-stack-protector=all )
352 myconf+=( --enable-stackguard-randomization )
354 # Keep a whitelist of targets supporing IFUNC. glibc's ./configure
355 # is not robust enough to detect proper support:
356 # https://bugs.gentoo.org/641216
357 # https://sourceware.org/PR22634#c0
358 case $(tc-arch ${CTARGET}) in
359 # Keep whitelist of targets where autodetection mostly works.
360 amd64|x86|sparc|ppc|ppc64|arm|arm64|s390) ;;
361 # Blacklist everywhere else
362 *) myconf+=( libc_cv_ld_gnu_indirect_function=no ) ;;
365 [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp )
367 if [[ $1 == "nptl" ]] ; then
368 myconf+=( --enable-kernel=${NPTL_KERN_VER} )
370 die "invalid pthread option"
372 myconf+=( --enable-add-ons="${addons#,}" )
374 # Since SELinux support is only required for nscd, only enable it if:
376 # 2. only for the primary ABI on multilib systems
377 # 3. Not a crosscompile
378 if ! is_crosscompile && use selinux ; then
379 if use multilib ; then
380 if is_final_abi ; then
381 myconf+=( --with-selinux )
383 myconf+=( --without-selinux )
386 myconf+=( --with-selinux )
389 myconf+=( --without-selinux )
392 # Force a few tests where we always know the answer but
393 # configure is incapable of finding it.
394 if is_crosscompile ; then
396 libc_cv_c_cleanup=yes \
397 libc_cv_forced_unwind=yes
404 --build=${CBUILD_OPT:-${CBUILD}}
405 --host=${CTARGET_OPT:-${CTARGET}}
406 $(use_enable profile)
408 --with-headers=$(alt_build_headers)
409 --prefix="${EPREFIX}/usr"
410 --sysconfdir="${EPREFIX}/etc"
411 --localstatedir="${EPREFIX}/var"
412 --libdir='$(prefix)'/$(get_libdir)
413 --mandir='$(prefix)'/share/man
414 --infodir='$(prefix)'/share/info
415 --libexecdir='$(libdir)'/misc/glibc
416 --with-bugurl=https://bugs.gentoo.org/
417 --with-pkgversion="$(glibc_banner)"
418 $(use_multiarch || echo --disable-multi-arch)
419 $(in_iuse systemtap && use_enable systemtap)
420 $(in_iuse nscd && use_enable nscd)
424 # We rely on sys-libs/timezone-data for timezone tools normally.
425 myconf+=( $(use_enable vanilla timezone-tools) )
427 # These libs don't have configure flags.
428 ac_cv_lib_audit_audit_log_user_avc_message=$(in_iuse audit && usex audit || echo no)
429 ac_cv_lib_cap_cap_init=$(in_iuse caps && usex caps || echo no)
431 # There is no configure option for this and we need to export it
432 # since the glibc build will re-run configure on itself
433 export libc_cv_rootsbindir="${EPREFIX}/sbin"
434 export libc_cv_slibdir="${EPREFIX}/$(get_libdir)"
436 # We take care of patching our binutils to use both hash styles,
437 # and many people like to force gnu hash style only, so disable
438 # this overriding check. #347761
439 export libc_cv_hashstyle=no
441 local builddir=$(builddir "$1")
442 mkdir -p "${builddir}"
444 set -- "${S}"/configure "${myconf[@]}"
446 "$@" || die "failed to configure glibc"
448 # ia64 static cross-compilers are a pita in so much that they
449 # can't produce static ELFs (as the libgcc.a is broken). so
450 # disable building of the programs for those targets if it
452 # XXX: We could turn this into a compiler test, but ia64 is
453 # the only one that matters, so this should be fine for now.
454 if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then
455 sed -i '1i+link-static = touch $@' config.make
458 # If we're trying to migrate between ABI sets, we need
459 # to lie and use a local copy of gcc. Like if the system
460 # is built with MULTILIB_ABIS="amd64 x86" but we want to
461 # add x32 to it, gcc/glibc don't yet support x32.
462 if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib ; then
463 echo 'main(){}' > "${T}"/test.c
464 if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then
465 sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die
470 glibc_headers_configure() {
473 local builddir=$(builddir "headers")
474 mkdir -p "${builddir}"
477 # if we don't have a compiler yet, we can't really test it now ...
478 # hopefully they don't affect header generation, so let's hope for
481 ac_cv_header_cpuid_h=yes
482 libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes
483 libc_cv_asm_cfi_directives=yes
484 libc_cv_broken_visibility_attribute=no
485 libc_cv_c_cleanup=yes
486 libc_cv_forced_unwind=yes
487 libc_cv_gcc___thread=yes
488 libc_cv_mlong_double_128=yes
489 libc_cv_mlong_double_128ibm=yes
490 libc_cv_ppc_machine=yes
491 libc_cv_ppc_rel16=yes
492 libc_cv_predef_fortify_source=no
493 libc_cv_visibility_attribute=yes
494 libc_cv_z_combreloc=yes
495 libc_cv_z_execstack=yes
496 libc_cv_z_initfirst=yes
497 libc_cv_z_nodelete=yes
498 libc_cv_z_nodlopen=yes
501 libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard)
502 # These libs don't have configure flags.
503 ac_cv_lib_audit_audit_log_user_avc_message=no
504 ac_cv_lib_cap_cap_init=no
507 einfo "Forcing cached settings:"
508 for v in "${vars[@]}" ; do
513 # Blow away some random CC settings that screw things up. #550192
514 if [[ -d ${S}/sysdeps/mips ]]; then
515 pushd "${S}"/sysdeps/mips >/dev/null
516 sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die
517 sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die
519 # Force the mips ABI to the default. This is OK because the set of
520 # installed headers in this phase is the same between the 3 ABIs.
521 # If this ever changes, this hack will break, but that's unlikely
522 # as glibc discourages that behavior.
523 # https://crbug.com/647033
524 sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die
531 --disable-sanity-checks
536 --build=${CBUILD_OPT:-${CBUILD}}
537 --host=${CTARGET_OPT:-${CTARGET}}
538 --with-headers=$(alt_build_headers)
539 --prefix="${EPREFIX}/usr"
544 [[ -d ${S}/ports ]] && addons+=",ports"
545 myconf+=( --enable-add-ons="${addons#,}" )
547 # Nothing is compiled here which would affect the headers for the target.
548 # So forcing CC/CFLAGS is sane.
549 local headers_only_CC=$(tc-getBUILD_CC)
550 local headers_only_CFLAGS="-O1 -pipe"
551 local headers_only_CPPFLAGS="-U_FORTIFY_SOURCE"
552 local headers_only_LDFLAGS=""
553 set -- "${S}"/configure "${myconf[@]}"
555 "CC=${headers_only_CC}" \
556 "CFLAGS=${headers_only_CFLAGS}" \
557 "CPPFLAGS=${headers_only_CPPFLAGS}" \
558 "LDFLAGS=${headers_only_LDFLAGS}" \
560 CC=${headers_only_CC} \
561 CFLAGS=${headers_only_CFLAGS} \
562 CPPFLAGS=${headers_only_CPPFLAGS} \
564 "$@" || die "failed to configure glibc"
568 if just_headers ; then
569 glibc_headers_configure
571 glibc_do_configure nptl
576 foreach_abi do_src_configure
580 emake -C "$(builddir nptl)"
584 if just_headers ; then
588 foreach_abi do_src_compile
606 if just_headers ; then
609 # Give tests more time to complete.
610 export TIMEOUTFACTOR=5
612 foreach_abi do_src_test || die "tests failed"
615 glibc_do_src_install() {
616 local builddir=$(builddir nptl)
619 emake install_root="${D}$(alt_prefix)" install
621 # This version (2.26) provides some compatibility libraries for the NIS/NIS+ support
622 # which come without headers etc. Only needed for binary packages since the
623 # external net-libs/libnsl has increased soversion. Keep only versioned libraries.
624 find "${D}" -name "libnsl.a" -delete
625 find "${D}" -name "libnsl.so" -delete
627 # Normally upstream_pv is ${PV}. Live ebuilds are exception, there we need
628 # to infer upstream version:
629 # '#define VERSION "2.26.90"' -> '2.26.90'
630 local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h)
632 if [[ -e ${ED}$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then
633 # Move versioned .a file out of libdir to evade portage QA checks
634 # instead of using gen_usr_ldscript(). We fix ldscript as:
635 # "GROUP ( /usr/lib64/libm-<pv>.a ..." -> "GROUP ( /usr/lib64/glibc-<pv>/libm-<pv>.a ..."
636 sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" "${ED}"$(alt_usrlibdir)/libm.a || die
637 dodir $(alt_usrlibdir)/${P}
638 mv "${ED}"$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die
641 # We'll take care of the cache ourselves
642 rm -f "${ED}"/etc/ld.so.cache
644 # Everything past this point just needs to be done once ...
645 is_final_abi || return 0
647 # Make sure the non-native interp can be found on multilib systems even
648 # if the main library set isn't installed into the right place. Maybe
649 # we should query the active gcc for info instead of hardcoding it ?
650 local i ldso_abi ldso_name
651 local ldso_abi_list=(
653 amd64 /lib64/ld-linux-x86-64.so.2
654 x32 /libx32/ld-linux-x32.so.2
655 x86 /lib/ld-linux.so.2
662 ppc64 /lib64/ld64.so.1
667 sparc32 /lib/ld-linux.so.2
668 sparc64 /lib64/ld-linux.so.2
674 arm64 /lib/ld-linux-aarch64.so.1
680 arm64 /lib/ld-linux-aarch64_be.so.1
684 if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then
685 dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib
687 for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do
688 ldso_abi=${ldso_abi_list[i]}
689 has ${ldso_abi} $(get_install_abis) || continue
691 ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}"
692 if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then
693 dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name}
697 # With devpts under Linux mounted properly, we do not need the pt_chown
698 # binary to be setuid. This is because the default owners/perms will be
699 # exactly what we want.
700 if in_iuse suid && ! use suid ; then
701 find "${ED}" -name pt_chown -exec chmod -s {} +
704 #################################################################
705 # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY #
706 # Make sure we install some symlink hacks so that when we build
707 # a 2nd stage cross-compiler, gcc finds the target system
708 # headers correctly. See gcc/doc/gccinstall.info
709 if is_crosscompile ; then
710 # We need to make sure that /lib and /usr/lib always exists.
711 # gcc likes to use relative paths to get to its multilibs like
712 # /usr/lib/../lib64/. So while we don't install any files into
713 # /usr/lib/, we do need it to exist.
714 cd "${ED}"$(alt_libdir)/..
715 [[ -e lib ]] || mkdir lib
716 cd "${ED}"$(alt_usrlibdir)/..
717 [[ -e lib ]] || mkdir lib
719 dosym usr/include $(alt_prefix)/sys-include
723 # Files for Debian-style locale updating
724 dodir /usr/share/i18n
727 -e "/SUPPORTED-LOCALES=/d" \
728 -e "s: \\\\::g" -e "s:/: :g" \
729 "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \
730 || die "generating /usr/share/i18n/SUPPORTED failed"
731 cd "${WORKDIR}"/extra/locale
737 # Make sure all the ABI's can find the locales and so we only
738 # have to generate one set
740 keepdir /usr/$(get_libdir)/locale
741 for a in $(get_install_abis) ; do
742 if [[ ! -e ${ED}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
743 dosym ../$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
749 # Install misc network config files
751 doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf
752 doins "${WORKDIR}"/extra/etc/*.conf
755 doinitd "$(prefixify_ro "${WORKDIR}"/extra/etc/nscd)"
758 -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):"
761 sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd
763 systemd_dounit nscd/nscd.service
764 systemd_newtmpfilesd nscd/nscd.tmpfiles nscd.conf
766 # Do this since extra/etc/*.conf above might have nscd.conf.
767 rm -f "${ED}"/etc/nscd.conf
770 echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc
771 doenvd "${T}"/00glibc
773 for d in BUGS ChangeLog* CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do
774 [[ -s ${d} ]] && dodoc ${d}
777 # Prevent overwriting of the /etc/localtime symlink. We'll handle the
778 # creation of the "factory" symlink in pkg_postinst().
779 rm -f "${ED}"/etc/localtime
782 glibc_headers_install() {
783 local builddir=$(builddir "headers")
785 emake install_root="${D}$(alt_prefix)" install-headers
787 insinto $(alt_headers)/gnu
788 doins "${S}"/include/gnu/stubs.h
790 # Make sure we install the sys-include symlink so that when
791 # we build a 2nd stage cross-compiler, gcc finds the target
792 # system headers correctly. See gcc/doc/gccinstall.info
793 dosym usr/include $(alt_prefix)/sys-include
797 if just_headers ; then
799 glibc_headers_install
803 foreach_abi glibc_do_src_install
807 # nothing to do if just installing headers
808 just_headers && return
810 # prepare /etc/ld.so.conf.d/ for files
811 mkdir -p "${EROOT}"/etc/ld.so.conf.d
813 # Default /etc/hosts.conf:multi to on for systems with small dbs.
814 if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then
815 sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf
816 einfo "Defaulting /etc/host.conf:multi to on"
819 [[ ${ROOT} != "/" ]] && return 0
820 [[ -d ${ED}/$(get_libdir) ]] || return 0
821 [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check
825 # nothing to do if just installing headers
826 just_headers && return
828 if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then
829 # Generate fastloading iconv module configuration file.
830 "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}"
833 if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then
834 # if the host locales.gen contains no entries, we'll install everything
835 local locale_list="${EROOT}etc/locale.gen"
836 if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then
837 ewarn "Generating all locales; edit /etc/locale.gen to save time/space"
838 locale_list="${EROOT}usr/share/i18n/SUPPORTED"
840 locale-gen -j $(makeopts_jobs) --config "${locale_list}"
843 # Check for sanity of /etc/nsswitch.conf, take 2
844 if [[ -e ${EROOT}/etc/nsswitch.conf ]] && ! has_version sys-auth/libnss-nis ; then
846 for entry in passwd group shadow; do
847 if egrep -q "^[ \t]*${entry}:.*nis" "${EROOT}"/etc/nsswitch.conf; then
849 ewarn "Your ${EROOT}/etc/nsswitch.conf uses NIS. Support for that has been"
850 ewarn "removed from glibc and is now provided by the package"
851 ewarn " sys-auth/libnss-nis"
852 ewarn "Install it now to keep your NIS setup working."