# $Header: /magellan-cvs/smage/glibc-nptl/glibc-nptl-2.7.0-r3.smage2,v 1.1 2008/10/06 18:35:31 niro Exp $ PNAME="glibc-nptl" PVER="2.7.0" PBUILD="r3" PCATEGORIE="sys-libs" STATE="unstable" DESCRIPTION="GNU libc6 (also called glibc2) C library with NPTL Threads." HOMEPAGE="http://www.gnu.org/software/libc/libc.html" DEPEND=">= sys-libs/libstdc++-4.2 >= sys-apps/base-files-0.1" # we force headers to one specific version # (for x86_64 2.6.12.0-r2 bi-arch headers are needed!) SDEPEND="== sys-kernel/linux-libc-headers-2.6.24" PROVIDE="virtual/glibc" # functions to include in the mage file SPECIAL_FUNCTIONS="fix_db_files" SRCFILE="glibc-${PVER/.0/}.tar.bz2" SRCDIR="${BUILDDIR}/glibc-${PVER/.0/}" GLIBC_LIBIDN="glibc-libidn-${PVER/.0/}.tar.bz2" GLIBC_LIBIDN_SRCDIR="${BUILDDIR}/glibc-libidn-${PVER/.0/}" sminclude mtools SRC_URI=( gnu://glibc/${SRCFILE} mirror://glibc/${SRCFILE} gnu://glibc/${GLIBC_LIBIDN} mirror://glibc/${GLIBC_LIBIDN} mirror://glibc/nsswitch.conf mirror://glibc/nscd.conf mirror://glibc/glibc.envd mirror://glibc/locale-gen mirror://glibc/locale.gen mirror://glibc/glibc-2.3.5-localedef_segfault-1.patch mirror://glibc/glibc-2.7.0-static__vdso_clock_gettime.patch ) # glibc don't like strong CFLAGS export CFLAGS="${CFLAGS//-O?} -O2" # glibc -> nptl thread don't like striping NOSTRIP=true # gcc 3.0 - 3.3 needs this: export CFLAGS="${CFLAGS} -finline-limit=2000" export CXXFLAGS="${CFLAGS}" export LDFLAGS="${LDFLAGS//-Wl,--relax}" # hack to fix NPTL issues with xen, only required on 32bit arches if [[ ${ARCH} = i*86 ]] then export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs" fi # glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic # first filter -mtune and -march from flags for flag in ${CFLAGS} do case ${flag} in -mtune=*) continue ;; -march=*) continue ;; esac newflags="${newflags} ${flag}" done # than add our defaults for glibc [[ ${ARCH} = i*86 ]] && export CFLAGS="${CFLAGS} -march=${ARCH}" # only i*86 export CFLAGS="${CFLAGS} -mtune=generic" # all arches export CXXFLAGS="${CFLAGS}" # use other linux-headers [[ -z ${ALT_HEADERS} ]] && export ALT_HEADERS="/usr/include" src_prepare() { munpack ${SRCFILE} || die # use the full libidn library not the bundled addon # many apps that rely on libidn needs the full lib munpack ${GLIBC_LIBIDN} || die mv ${GLIBC_LIBIDN_SRCDIR} ${SRCDIR}/libidn || die cd ${SRCDIR} # disable binutils -as-needed sed -i 's/^have-as-needed.*/have-as-needed = no/' ${SRCDIR}/config.make.in || die # fix segfault of localdef on arches beside x86-32 mpatch glibc-2.3.5-localedef_segfault-1.patch || die # fixes errors with the __vdso_clock_gettime symbol # while compiling static linked code. # see: http://bbs.archlinux.org/viewtopic.php?pid=297346 # and http://sourceware.org/ml/glibc-bugs/2008-01/msg00006.html mpatch glibc-2.7.0-static__vdso_clock_gettime.patch || die # fix permissions on some of the scripts chmod u+x ${SRCDIR}/scripts/*.sh || die install -d ${SRCDIR}/build || die cd ${SRCDIR}/build if [ ! -f /etc/ld.so.conf ] then touch /etc/ld.so.conf || die fi } src_compile() { # support multilib lib64 dir (x86_64 only) if [[ ${ARCH} = x86_64 ]] then # first build a -m32 version install -d ${SRCDIR}/build-m32 cd ${SRCDIR}/build-m32 CC="gcc -m32" CXX="g++ -m32" \ CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \ CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \ ../configure \ --build=${CHOST} \ --host=i686-pc-linux-gnu \ --prefix=/usr \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --disable-profile \ --enable-add-ons=nptl,libidn \ --with-tls \ --with-__thread \ --enable-kernel=2.6.0 \ --without-cvs \ --without-gd \ --libdir=/usr/lib \ --libexecdir=/usr/lib/glibc \ --with-headers=${ALT_HEADERS} \ || die make PARALLELMFLAGS="${MAKEOPTS}" || die fi cd ${SRCDIR}/build if [[ ${ARCH} = x86_64 ]]; then # make sure the -m64 libs goes really to /lib64 echo "slibdir=/$(mlibdir)" >> ${SRCDIR}/build/configparms || die fi # kernel-2.6 with nptl needs this ../configure \ --build=${CHOST} \ --host=${CHOST} \ --prefix=/usr \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --disable-profile \ --enable-add-ons=nptl,libidn \ --with-tls \ --with-__thread \ --enable-kernel=2.6.0 \ --without-cvs \ --without-gd \ --libdir=/usr/$(mlibdir) \ --libexecdir=/usr/$(mlibdir)/glibc \ --with-headers=${ALT_HEADERS} \ || die make PARALLELMFLAGS="${MAKEOPTS}" || die } src_install() { if [[ ${ARCH} = x86_64 ]] then # install -m32 libs cd ${SRCDIR}/build-m32 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die fi cd ${SRCDIR}/build make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die # do not generate the locales here, let it the user do with the locale-gen tool # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die # install locales list and generate tools # to generate this listing see the glibc-2.5/localedata/SUPPORTED file minstalletc locale.gen || die minstalldir /usr/sbin || die minstallexec -s locale-gen /usr/sbin || die # nsswitch configuration file minstalletc nsswitch.conf || die # nscd configuration file minstalletc nscd.conf || die # we use Berlin as default cp --remove-destination ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; } [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; } # base environment minstallenv glibc.envd 00glibc || die if [[ ${ARCH} = x86_64 ]] then echo "LDPATH=\"/usr/local/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00glibc || die echo "LDPATH=\"/opt/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00glibc || die fi # move some libs and tools to proper locations # will suppress some ldconfig errors too mv ${BINDIR}/$(mlibdir)/libmemusage.so ${BINDIR}/usr/$(mlibdir) || die mv ${BINDIR}/$(mlibdir)/libpcprofile.so ${BINDIR}/usr/$(mlibdir) || die mlink ../usr/$(mlibdir)/libmemusage.so /$(mlibdir)/libmemusage.so || die mlink ../usr/$(mlibdir)/libpcprofile.so /$(mlibdir)/libpcprofile.so || die # strip all binaries find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die # strip all libraries # want to be safe here; --strip-unneeded seems to cause pthread problems # strip all but libpthread install -d ${BUILDDIR}/thread-backup || die mv ${BINDIR}/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die # now strip find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/$(mlibdir)/ || die # remove stale directory rm -rf ${BUILDDIR}/thread-backup || die # prepare glibc for installation; slackware method minstalldir /incoming || die mv ${BINDIR}/$(mlibdir)/* ${BINDIR}/incoming || die mv ${BINDIR}/incoming ${BINDIR}/$(mlibdir)/incoming || die mv ${BINDIR}/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/$(mlibdir) || die } fix_db_files() { local i local DB_ENTRY="${BUILDDIR}/${PKGNAME}" for i in .files .symlinks .dirs do [ ! -f ${DB_ENTRY}/${i} ] && continue [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue echo " fixing /$(mlibdir)/incoming from db-entry '${i}' ..." # /lib/incoming -> empty line; sed2 removes all empty lines #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i} # do not simply emtpy the line, but change it the the correct path, # so no stale libs are around if the package gets updated! sed -i -e "s:/$(mlibdir)/incoming:/$(mlibdir):g" \ -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i} done } preinstall() { # remove libmemusage and libpcprofile as these libs now # resides in /usr/lib and are symlinked to /lib if [[ -f ${MROOT}/$(mlibdir)/libmemusage.so ]] then rm ${MROOT}/$(mlibdir)/libmemusage.so fi if [[ -f ${MROOT}/$(mlibdir)/libpcprofile.so ]] then rm ${MROOT}/$(mlibdir)/libpcprofile.so fi } postinstall() { # first save the old libpthread.so.0; # it will later used to determinate that there are no stale # libpthreads that breaks ldconfig local OLD_PTHREAD OLD_PTHREAD="$(readlink ${MROOT}/$(mlibdir)/libpthread.so.0)" # slackware install method # we cannot easily install the glibc libs, # because our tools for cp etc needs them to run local file echo " Switching to new glibc ..." # swap libraries on the fly: if [ -x /sbin/ldconfig -a -d /$(mlibdir)/incoming ] && [[ -z ${MROOT} ]] then # first create copies of the incoming libraries: cd /$(mlibdir)/incoming for file in $(find /$(mlibdir)/incoming -type f) do if [ ! -r "../$(basename ${file}).incoming" ] then cp -a ${file} ../$(basename ${file}).incoming fi done # then switch to them all at once: /sbin/ldconfig -l /$(mlibdir)/*.incoming 2> /dev/null # finally, rename them and clean up: cd /$(mlibdir) for file in *.incoming do rm -f $(basename ${file} .incoming) cp -a ${file} $(basename ${file} .incoming) /sbin/ldconfig -l $(basename ${file} .incoming) rm -f ${file} done # no ldconfig? # good, it's safe to just jam it on home (and make links below): else ( cd ${MROOT}/$(mlibdir)/incoming for file in * do cp -a ${file} .. done local my_sym local my_dest # rebuild symlinks echo " Recreating Symlinks:" for i in $(find ${MROOT}/$(mlibdir)/incoming -type l) do my_sym="$(readlink ${i})" my_dest="$(basename ${i})" echo " ${my_dest} -> ${my_dest}" # assure to remove the old ones; [ -L ${MROOT}/$(mlibdir)/"${my_dest}" ] && \ rm ${MROOT}/$(mlibdir)/"${my_dest}" ln -snf "${my_sym}" ${MROOT}/$(mlibdir)/"${my_dest}" done ) fi # now, get rid of the temporary directory: rm -rf ${MROOT}/$(mlibdir)/incoming # remove stale nptl libpthread-2.?.?.so, # fix only needed for glibc with linuxthreads; # prevent reloc errors such as: # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory # get our new libpthread.so.0 local NEW_PTHREAD NEW_PTHREAD="$(readlink ${MROOT}/$(mlibdir)/libpthread.so.0)" if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ] then echo " Removing stale libpthread libraries ..." for file in ${MROOT}/$(mlibdir)/libpthread-* do if [ "$(basename ${file})" != "${NEW_PTHREAD}" ] then rm -f ${file} fi done #rm -f /lib/${OLD_PTHREAD} ln -snf ${NEW_PTHREAD} ${MROOT}/$(mlibdir)/libpthread.so.0 fi if [ -x /usr/sbin/iconvconfig ] then # generate fastloading iconv module configuration file. echo " Generate iconv module config ..." /usr/sbin/iconvconfig --prefix=${MROOT}/ fi # reloading init echo " Reloading init ..." [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null # generating user def locales echo " Generating user defined locales ..." [[ -z ${MROOT} ]] && /usr/sbin/locale-gen # now we must fix the mage db files # to stop the annoying errors messages fix_db_files }