打印

请能读懂spec文件的学长帮忙解析一下这个

请能读懂spec文件的学长帮忙解析一下这个

我想借鉴以下方法手工编译这个glibc,i686的,该如何操作?
引用:
%define glibcdate 20050324T0715
%define glibcname glibc
%define glibcversion 2.3.4
%define glibcrelease 1mgc
%define auxarches i586 i686 athlon sparcv9 alphaev6
%define prelinkarches noarch
%define nptlarches i386 i686 athlon x86_64 ia64 s390 s390x sparcv9 ppc ppc64
%define rtkaioarches noarch
%define withtlsarches i386 i686 athlon x86_64 ia64 s390 s390x alpha alphaev6 sparc sparcv9 ppc ppc64
%define debuginfocommonarches %{ix86} alpha alphaev6 sparc sparcv9
%define _unpackaged_files_terminate_build 0
Summary: The GNU libc libraries.
Name: glibc
Version: %{glibcversion}
Release: %{glibcrelease}
License: LGPL
Group: System Environment/Libraries
%define glibcsrcdir %{glibcname}-%{glibcdate}
Source0: %{glibcsrcdir}.tar.bz2
Source1: %{glibcname}-fedora-%{glibcdate}.tar.bz2
Patch0: %{glibcname}-fedora.patch
Patch1: %{name}-nptl-check.patch
Patch2: %{name}-ppc-assume.patch
Patch3: %{name}-ia64-lib64.patch
Buildroot: %{_tmppath}/glibc-%{PACKAGE_VERSION}-root
Obsoletes: zoneinfo, libc-static, libc-devel, libc-profile, libc-headers,
Obsoletes:  linuxthreads, gencat, locale, ldconfig, locale-ja
Provides: ldconfig
Autoreq: false
Requires: glibc-common = %{version}-%{release}
%ifarch sparc
Obsoletes: libc
%endif
# Require libgcc in case some program calls pthread_cancel in its %%post
Prereq: basesystem, libgcc
# This is for building auxiliary programs like memusage, nscd
# For initial glibc bootstraps it can be commented out
#BuildPreReq: gd-devel libpng-devel zlib-devel texinfo, libselinux-devel >= 1.17.10-1
#BuildPreReq: sed >= 3.95
%ifarch %{prelinkarches}
BuildPreReq: prelink >= 0.2.0-5
%endif
# This is to ensure that __frame_state_for is exported by glibc
# will be compatible with egcs 1.x.y
#BuildPreReq: gcc >= 3.2
Conflicts: rpm <= 4.0-0.65
Conflicts: glibc-devel < 2.2.3
Conflicts: gcc4 <= 4.0.0-0.6
# Earlier shadow-utils packages had too restrictive permissions on
# /etc/default
Conflicts: shadow-utils < 4.0.3
Conflicts: nscd < 2.3.3-52
%ifarch ia64 sparc64 s390x x86_64
Conflicts: kernel < 2.4.0
%define enablekernel 2.4.0
%else
%ifarch ppc64
Conflicts: kernel < 2.4.19
%define enablekernel 2.4.19
%else
%define enablekernel 2.2.5
%ifarch i686 athlon
%define enablekernelltfs 2.4.1
%endif
%endif
%endif
%ifarch %{nptlarches}
%define enablekernelnptl 2.4.20
%ifarch i386
%define nptl_target_cpu i486
%define tls_subdir tls/i486
%else
%define nptl_target_cpu %{_target_cpu}
%define tls_subdir tls
%endif
%endif
# Need AS_NEEDED directive
#BuildRequires: binutils >= 2.15.94.0.2-1
#BuildRequires: gcc >= 3.2.1-5
%if "%{_enable_debug_packages}" == "1"
#BuildPreReq: elfutils >= 0.72
#BuildPreReq: rpm >= 4.2-0.56
%endif
%define __find_provides %{_builddir}/%{glibcsrcdir}/find_provides.sh
%define _filter_GLIBC_PRIVATE 1

%description
The glibc package contains standard libraries which are used by
multiple programs on the system. In order to save disk space and
memory, as well as to make upgrading easier, common system code is
kept in one place and shared between programs. This particular package
contains the most important sets of shared libraries: the standard C
library and the standard math library. Without these two libraries, a
Linux system will not function.

%package devel
Summary: Object files for development using standard C libraries.
Group: Development/Libraries
Conflicts: texinfo < 3.11
# Need AS_NEEDED directive
Conflicts: binutils < 2.15.94.0.2-1
Prereq: /sbin/install-info
Obsoletes: libc-debug, libc-headers, libc-devel, linuxthreads-devel
Obsoletes: glibc-debug
Prereq: %{name}-headers
Requires: %{name}-headers = %{version}-%{release}, %{name} = %{version}
%ifarch %{ix86}
# Earlier gcc's had atexit reference in crtendS.o, which does not
# work with this glibc where atexit is in libc_nonshared.a
Conflicts: gcc < 2.96-79
%endif
Autoreq: true

%description devel
The glibc-devel package contains the object files necessary
for developing programs which use the standard C libraries (which are
used by nearly all programs).  If you are developing programs which
will use the standard C libraries, your system needs to have these
standard object files available in order to create the
executables.

Install glibc-devel if you are going to develop programs which will
use the standard C libraries.

%package headers
Summary: Header files for development using standard C libraries.
Group: Development/Libraries
Provides: %{name}-headers(%{_target_cpu})
%ifarch x86_64
# If both -m32 and -m64 is to be supported on AMD64, x86_64 glibc-headers
# have to be installed, not i386 ones.
Obsoletes: %{name}-headers(i386)
%endif
Obsoletes: libc-debug, libc-headers, libc-devel, linuxthreads-devel
Prereq: kernel-headers
Requires: kernel-headers >= 2.2.1, %{name} = %{version}
Autoreq: true

%description headers
The glibc-headers package contains the header files necessary
for developing programs which use the standard C libraries (which are
used by nearly all programs).  If you are developing programs which
will use the standard C libraries, your system needs to have these
standard header files available in order to create the
executables.

Install glibc-headers if you are going to develop programs which will
use the standard C libraries.

%package -n nptl-devel
Summary: Header files and static libraries for development using NPTL library.
Group: Development/Libraries
Requires: glibc-devel = %{version}-%{release}
Autoreq: true

%description -n nptl-devel
The nptl-devel package contains the header and object files necessary
for developing programs which use the NPTL library (and either need
NPTL specific header files or want to link against NPTL statically).

%package profile
Summary: The GNU libc libraries, including support for gprof profiling.
Group: Development/Libraries
Obsoletes: libc-profile
Autoreq: true

%description profile
The glibc-profile package includes the GNU libc libraries and support
for profiling using the gprof program.  Profiling is analyzing a
program's functions to see how much CPU time they use and determining
which functions are calling other functions during execution.  To use
gprof to profile a program, your program needs to use the GNU libc
libraries included in glibc-profile (instead of the standard GNU libc
libraries included in the glibc package).

If you are going to use the gprof program to profile a program, you'll
need to install the glibc-profile package.

%package common
Summary: Common binaries and locale data for glibc
Conflicts: %{name} < %{version}
Conflicts: %{name} > %{version}
Autoreq: false
Requires: tzdata >= 2003a
Group: System Environment/Base

%description common
The glibc-common package includes common binaries for the GNU libc
libraries, as well as national language (locale) support.

%package -n nscd
Summary: A Name Service Caching Daemon (nscd).
Group: System Environment/Daemons
Conflicts: kernel < 2.2.0
#Requires: libselinux >= 1.17.10-1
Conflicts: selinux-policy-targeted < 1.17.30-2.2
Prereq: /sbin/chkconfig, /usr/sbin/useradd, /usr/sbin/userdel, sh-utils
Autoreq: true

%description -n nscd
Nscd caches name service lookups and can dramatically improve
performance with NIS+, and may help with DNS as well. Note that you
can't use nscd with 2.0 kernels because of bugs in the kernel-side
thread support. Unfortunately, nscd happens to hit these bugs
particularly hard.

%package utils
Summary: Development utilities from GNU C library
Group: Development/Tools
Requires: glibc = %{version}-%{release}

%description utils
The glibc-utils package contains memusage, a memory usage profiler,
mtrace, a memory leak tracer and xtrace, a function call tracer
which can be helpful during program debugging.

If unsure if you need this, don't install this package.

%if "%{_enable_debug_packages}" == "1"
%define debug_package %{nil}

%package debuginfo
Summary: Debug information for package %{name}
Group: Development/Debug
%ifarch %{debuginfocommonarches}
Requires: glibc-debuginfo-common = %{version}-%{release}
%endif

%description debuginfo
This package provides debug information for package %{name}.
Debug information is useful when developing applications that use this
package or when debugging this package.

This package also contains static standard C libraries with
debugging information.  You need this only if you want to step into
C library routines during debugging programs statically linked against
one or more of the standard C libraries.
To use this debugging information, you need to link binaries
with -static -L%{_prefix}/lib/debug%{_prefix}/%{_lib} compiler options.

%ifarch %{debuginfocommonarches}

%package debuginfo-common
Summary: Debug information for package %{name}
Group: Development/Debug

%description debuginfo-common
This package provides debug information for package %{name}.
Debug information is useful when developing applications that use this
package or when debugging this package.

%endif
%endif

%prep
%setup -q -n %{glibcsrcdir} -a1
%patch0 -E -p1
case "`gcc --version | head -1`" in
gcc*\ 3.[34]*)
%ifarch %{nptlarches}
%patch1 -p1
%endif
  ;;
gcc*\ 3.2.3*)
  case "`uname -r`" in *.ent*|*.EL*)
%patch2 -p1
  ;; esac ;;
esac
%ifarch ia64
%if "%{_lib}" == "lib64"
%patch3 -p1
%endif
%endif

# Hack till glibc-kernheaders get updated, argh
mkdir asm
cat > asm/unistd.h <<EOF
#ifndef _HACK_ASM_UNISTD_H
#include_next <asm/unistd.h>
%ifarch alpha
#ifndef __NR_stat64
#define __NR_stat64                        425
#define __NR_lstat64                        426
#define __NR_fstat64                        427
#endif
#ifndef __NR_mq_open
#define __NR_mq_open                        432
#define __NR_mq_unlink                        433
#define __NR_mq_timedsend                434
#define __NR_mq_timedreceive                435
#define __NR_mq_notify                        436
#define __NR_mq_getsetattr                437
#endif
#ifndef __NR_waitid
#define __NR_waitid                        438
#endif
%endif
%ifarch %{ix86}
#ifndef __NR_mq_open
#define __NR_mq_open                 277
#define __NR_mq_unlink                (__NR_mq_open+1)
#define __NR_mq_timedsend        (__NR_mq_open+2)
#define __NR_mq_timedreceive        (__NR_mq_open+3)
#define __NR_mq_notify                (__NR_mq_open+4)
#define __NR_mq_getsetattr        (__NR_mq_open+5)
#endif
#ifndef __NR_waitid
#define __NR_waitid                284
#endif
%endif
%ifarch ia64
#ifndef __NR_timer_create
#define __NR_timer_create                1248
#define __NR_timer_settime                1249
#define __NR_timer_gettime                1250
#define __NR_timer_getoverrun                1251
#define __NR_timer_delete                1252
#define __NR_clock_settime                1253
#define __NR_clock_gettime                1254
#define __NR_clock_getres                1255
#define __NR_clock_nanosleep                1256
#endif
#ifndef __NR_mq_open
#define __NR_mq_open                        1262
#define __NR_mq_unlink                        1263
#define __NR_mq_timedsend                1264
#define __NR_mq_timedreceive                1265
#define __NR_mq_notify                        1266
#define __NR_mq_getsetattr                1267
#endif
#ifndef __NR_waitid
#define __NR_waitid                        1270
#endif
%endif
%ifarch ppc
#ifndef __NR_utimes
#define __NR_utimes                251
#endif
#ifndef __NR_statfs64
#define __NR_statfs64                252
#define __NR_fstatfs64                253
#endif
#ifndef __NR_fadvise64_64
#define __NR_fadvise64_64        254
#endif
#ifndef __NR_mq_open
#define __NR_mq_open                262
#define __NR_mq_unlink                263
#define __NR_mq_timedsend        264
#define __NR_mq_timedreceive        265
#define __NR_mq_notify                266
#define __NR_mq_getsetattr        267
#endif
%endif
%ifarch ppc64
#ifndef __NR_utimes
#define __NR_utimes                251
#endif
#ifndef __NR_mq_open
#define __NR_mq_open                262
#define __NR_mq_unlink                263
#define __NR_mq_timedsend        264
#define __NR_mq_timedreceive        265
#define __NR_mq_notify                266
#define __NR_mq_getsetattr        267
#endif
%endif
%ifarch s390
#ifndef __NR_timer_create
#define __NR_timer_create        254
#define __NR_timer_settime        (__NR_timer_create+1)
#define __NR_timer_gettime        (__NR_timer_create+2)
#define __NR_timer_getoverrun        (__NR_timer_create+3)
#define __NR_timer_delete        (__NR_timer_create+4)
#define __NR_clock_settime        (__NR_timer_create+5)
#define __NR_clock_gettime        (__NR_timer_create+6)
#define __NR_clock_getres        (__NR_timer_create+7)
#define __NR_clock_nanosleep        (__NR_timer_create+
#endif
#ifndef __NR_fadvise64_64
#define __NR_fadvise64_64        264
#endif
#ifndef __NR_statfs64
#define __NR_statfs64                265
#define __NR_fstatfs64                266
#endif
#ifndef __NR_mq_open
#define __NR_mq_open                271
#define __NR_mq_unlink                272
#define __NR_mq_timedsend        273
#define __NR_mq_timedreceive        274
#define __NR_mq_notify                275
#define __NR_mq_getsetattr        276
#endif
%endif
%ifarch s390x
#ifndef __NR_timer_create
#define __NR_timer_create        254
#define __NR_timer_settime        (__NR_timer_create+1)
#define __NR_timer_gettime        (__NR_timer_create+2)
#define __NR_timer_getoverrun        (__NR_timer_create+3)
#define __NR_timer_delete        (__NR_timer_create+4)
#define __NR_clock_settime        (__NR_timer_create+5)
#define __NR_clock_gettime        (__NR_timer_create+6)
#define __NR_clock_getres        (__NR_timer_create+7)
#define __NR_clock_nanosleep        (__NR_timer_create+
#endif
#ifndef __NR_mq_open
#define __NR_mq_open                271
#define __NR_mq_unlink                272
#define __NR_mq_timedsend        273
#define __NR_mq_timedreceive        274
#define __NR_mq_notify                275
#define __NR_mq_getsetattr        276
#endif
%endif
%ifarch sparc sparc64
#ifndef __NR_mq_open
#define __NR_mq_open                273
#define __NR_mq_unlink                274
#define __NR_mq_timedsend        275
#define __NR_mq_timedreceive        276
#define __NR_mq_notify                277
#define __NR_mq_getsetattr        278
#endif
#ifndef __NR_waitid
#define __NR_waitid                279
#endif
%endif
%ifarch x86_64
#ifndef __NR_mq_open
#define __NR_mq_open                240
#define __NR_mq_unlink                241
#define __NR_mq_timedsend        242
#define __NR_mq_timedreceive        243
#define __NR_mq_notify                244
#define __NR_mq_getsetattr        245
#endif
#ifndef __NR_waitid
#define __NR_waitid                247
#endif
%endif
#endif
EOF

%ifnarch %{ix86} alpha alphaev6 sparc sparcv9
rm -rf glibc-compat
%endif

# A lot of programs still misuse memcpy when they have to use
# memmove. The memcpy implementation below is not tolerant at
# all.
rm -f sysdeps/alpha/alphaev6/memcpy.S

find . -type f -size 0 -o -name "*.orig" -exec rm -f {} \;
cat > find_provides.sh <<EOF
#!/bin/sh
/usr/lib/rpm/find-provides | grep -v GLIBC_PRIVATE
exit 0
EOF
chmod +x find_provides.sh
touch `find . -name configure`

%build
rm -rf build-%{_target_cpu}-linux
mkdir build-%{_target_cpu}-linux ; cd build-%{_target_cpu}-linux
GCC=gcc
%ifarch %{ix86}
BuildFlags="-march=%{_target_cpu}"
%endif
%ifarch i686
BuildFlags="-march=i686 -mtune=pentium4"
%endif
%ifarch alphaev6
BuildFlags="-mcpu=ev6"
%endif
%ifarch sparc
BuildFlags="-fcall-used-g6"
GCC="gcc -m32"
%endif
%ifarch sparcv9
BuildFlags="-mcpu=ultrasparc -fcall-used-g6"
GCC="gcc -m32"
%endif
%ifarch sparc64
BuildFlags="-mcpu=ultrasparc -mvis -fcall-used-g6"
GCC="gcc -m64"
%endif
%ifarch ppc64
BuildFlags="-mno-minimal-toc"
GCC="gcc -m64"
%endif




# If gcc supports __thread, test it even in --with-tls --without-__thread
# builds.
if echo '__thread int a;' | $GCC -xc - -S -o /dev/null 2>/dev/null; then
  sed -ie 's/0 [|][|]/1 ||/' ../elf/tst-tls10.h ../linuxthreads/tst-tls1.h
fi

BuildFlags="$BuildFlags -DNDEBUG=1"
if gcc -v 2>&1 | grep -q 'gcc version 3.[0123]'; then
  BuildFlags="$BuildFlags -finline-limit=2000"
fi
EnableKernel="--enable-kernel=%{enablekernel}"
echo "$BuildFlags" > ../BuildFlags
echo "$GCC" > ../Gcc
AddOns=`cd .. && echo */configure | sed -e 's!/configure!!g;s!\(linuxthreads\|nptl\|rtkaio\)\( \|$\)!!g;s! \+$!!;s! !,!g;s!^!,!;/^,\*$/d'`
echo "$AddOns" > ../AddOns
Pthreads=linuxthreads
%ifarch %{withtlsarches}
WithTls="--with-tls --without-__thread"
%else
WithTls="--without-tls --without-__thread"
%endif
CC="$GCC" CFLAGS="$BuildFlags -g -O3" ../configure --prefix=%{_prefix} \
        --enable-add-ons=$Pthreads$AddOns --without-cvs $EnableKernel \
        --with-headers=%{_prefix}/include --enable-bind-now \
        $WithTls --build %{_target_cpu}-redhat-linux --host %{_target_cpu}-redhat-linux --without-selinux
if [ -x /usr/bin/getconf ] ; then
  numprocs=$(/usr/bin/getconf _NPROCESSORS_ONLN)
  if [ $numprocs -eq 0 ]; then
    numprocs=1
  fi
else
  numprocs=1
fi
make -j$numprocs -r CFLAGS="$BuildFlags -g -O3" PARALLELMFLAGS=-s
$GCC -static -L. -Os ../fedora/glibc_post_upgrade.c -o glibc_post_upgrade.%{_target_cpu} \
%ifarch i386
    -DARCH_386 \
%endif
%ifarch %{nptlarches}
    '-DLIBTLS="/%{_lib}/tls/"' \
%endif
    '-DGCONV_MODULES_DIR="%{_prefix}/%{_lib}/gconv"' \
    '-DLD_SO_CONF="/etc/ld.so.conf"' \
    '-DICONVCONFIG="%{_sbindir}/iconvconfig.%{_target_cpu}"'
cd ..

# hack
unset LD_ASSUME_KERNEL || :

%ifarch %{rtkaioarches}
AddOns=,rtkaio$AddOns
%endif

%ifarch i686 athlon
rm -rf build-%{_target_cpu}-linuxltfs
mkdir build-%{_target_cpu}-linuxltfs ; cd build-%{_target_cpu}-linuxltfs
EnableKernel="--enable-kernel=%{enablekernelltfs} --disable-profile"
Pthreads=linuxthreads
%ifarch %{withtlsarches}
WithTls="--with-tls --without-__thread"
%else
WithTls="--without-tls --without-__thread"
%endif
CC="$GCC" CFLAGS="$BuildFlags -g -O3" ../configure --prefix=%{_prefix} \
        --enable-add-ons=$Pthreads$AddOns --without-cvs $EnableKernel \
        --with-headers=%{_prefix}/include --enable-bind-now \
        $WithTls --build %{_target_cpu}-redhat-linux --host %{_target_cpu}-redhat-linux
make -j$numprocs -r CFLAGS="$BuildFlags -g -O3" PARALLELMFLAGS=-s

cd ..
%endif

%ifarch %{nptlarches}
rm -rf build-%{nptl_target_cpu}-linuxnptl
mkdir build-%{nptl_target_cpu}-linuxnptl ; cd build-%{nptl_target_cpu}-linuxnptl
EnableKernel="--enable-kernel=%{enablekernelnptl} --disable-profile"
Pthreads=nptl
WithTls="--with-tls --with-__thread"
CC="$GCC" CFLAGS="$BuildFlags -g -O3" ../configure --prefix=%{_prefix} \
        --enable-add-ons=$Pthreads$AddOns --without-cvs $EnableKernel \
        --with-headers=%{_prefix}/include --enable-bind-now \
        $WithTls --build %{nptl_target_cpu}-redhat-linux --host %{nptl_target_cpu}-redhat-linux
make -j$numprocs -r CFLAGS="$BuildFlags -g -O3" PARALLELMFLAGS=-s

cd ..
%endif

%install
# hack
unset LD_ASSUME_KERNEL || :

BuildFlags=`cat BuildFlags`
GCC=`cat Gcc`
AddOns=`cat AddOns`

%ifarch %{rtkaioarches}
AddOns=,rtkaio$AddOns
%endif

if [ -x /usr/bin/getconf ] ; then
  numprocs=$(/usr/bin/getconf _NPROCESSORS_ONLN)
  if [ $numprocs -eq 0 ]; then
    numprocs=1
  fi
else
  numprocs=1
fi
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT
make -j1 install_root=$RPM_BUILD_ROOT install -C build-%{_target_cpu}-linux PARALLELMFLAGS=-s
%ifnarch %{auxarches}
cd build-%{_target_cpu}-linux && \
    make -j$numprocs install_root=$RPM_BUILD_ROOT install-locales -C ../localedata objdir=`pwd` && \
    cd ..
%endif

SubDir=

%ifarch i686 athlon
cd build-%{_target_cpu}-linuxltfs
Pthreads=linuxthreads
SubDir=i686
mkdir -p $RPM_BUILD_ROOT/lib/$SubDir/
cp -a libc.so $RPM_BUILD_ROOT/lib/$SubDir/`basename $RPM_BUILD_ROOT/lib/libc-*.so`
ln -sf `basename $RPM_BUILD_ROOT/lib/libc-*.so` $RPM_BUILD_ROOT/lib/$SubDir/`basename $RPM_BUILD_ROOT/lib/libc.so.*`
cp -a math/libm.so $RPM_BUILD_ROOT/lib/$SubDir/`basename $RPM_BUILD_ROOT/lib/libm-*.so`
ln -sf `basename $RPM_BUILD_ROOT/lib/libm-*.so` $RPM_BUILD_ROOT/lib/$SubDir/`basename $RPM_BUILD_ROOT/lib/libm.so.*`
cp -a $Pthreads/libpthread.so $RPM_BUILD_ROOT/lib/$SubDir/`basename $RPM_BUILD_ROOT/lib/libpthread-*.so`
pushd $RPM_BUILD_ROOT/lib/$SubDir
ln -sf libpthread-*.so `basename $RPM_BUILD_ROOT/lib/libpthread.so.*`
popd
%ifarch %{rtkaioarches}
cp -a rtkaio/librtkaio.so $RPM_BUILD_ROOT/lib/$SubDir/`basename $RPM_BUILD_ROOT/lib/librt-*.so | sed s/librt-/librtkaio-/`
ln -sf `basename $RPM_BUILD_ROOT/lib/librt-*.so | sed s/librt-/librtkaio-/` $RPM_BUILD_ROOT/lib/$SubDir/`basename $RPM_BUILD_ROOT/lib/librt.so.*`
%else
cp -a rt/librt.so $RPM_BUILD_ROOT/lib/$SubDir/`basename $RPM_BUILD_ROOT/lib/librt-*.so`
ln -sf `basename $RPM_BUILD_ROOT/lib/librt-*.so` $RPM_BUILD_ROOT/lib/$SubDir/`basename $RPM_BUILD_ROOT/lib/librt.so.*`
%endif

cd ..
%endif

%ifarch %{nptlarches}
cd build-%{nptl_target_cpu}-linuxnptl
Pthreads=nptl
SubDir=%{tls_subdir}
mkdir -p $RPM_BUILD_ROOT/%{_lib}/$SubDir/
cp -a libc.so $RPM_BUILD_ROOT/%{_lib}/$SubDir/`basename $RPM_BUILD_ROOT/%{_lib}/libc-*.so`
ln -sf `basename $RPM_BUILD_ROOT/%{_lib}/libc-*.so` $RPM_BUILD_ROOT/%{_lib}/$SubDir/`basename $RPM_BUILD_ROOT/%{_lib}/libc.so.*`
cp -a math/libm.so $RPM_BUILD_ROOT/%{_lib}/$SubDir/`basename $RPM_BUILD_ROOT/%{_lib}/libm-*.so`
ln -sf `basename $RPM_BUILD_ROOT/%{_lib}/libm-*.so` $RPM_BUILD_ROOT/%{_lib}/$SubDir/`basename $RPM_BUILD_ROOT/%{_lib}/libm.so.*`
cp -a $Pthreads/libpthread.so $RPM_BUILD_ROOT/%{_lib}/$SubDir/libpthread-%{version}.so
pushd $RPM_BUILD_ROOT/%{_lib}/$SubDir
ln -sf libpthread-*.so `basename $RPM_BUILD_ROOT/%{_lib}/libpthread.so.*`
popd
%ifarch %{rtkaioarches}
cp -a rtkaio/librtkaio.so $RPM_BUILD_ROOT/%{_lib}/$SubDir/`basename $RPM_BUILD_ROOT/%{_lib}/librt-*.so | sed s/librt-/librtkaio-/`
ln -sf `basename $RPM_BUILD_ROOT/%{_lib}/librt-*.so | sed s/librt-/librtkaio-/` $RPM_BUILD_ROOT/%{_lib}/$SubDir/`basename $RPM_BUILD_ROOT/%{_lib}/librt.so.*`
%else
cp -a rt/librt.so $RPM_BUILD_ROOT/%{_lib}/$SubDir/`basename $RPM_BUILD_ROOT/%{_lib}/librt-*.so`
ln -sf `basename $RPM_BUILD_ROOT/%{_lib}/librt-*.so` $RPM_BUILD_ROOT/%{_lib}/$SubDir/`basename $RPM_BUILD_ROOT/%{_lib}/librt.so.*`
%endif
cp -a ${Pthreads}_db/libthread_db.so $RPM_BUILD_ROOT/%{_lib}/$SubDir/`basename $RPM_BUILD_ROOT/%{_lib}/libthread_db-*.so`
ln -sf `basename $RPM_BUILD_ROOT/%{_lib}/libthread_db-*.so` $RPM_BUILD_ROOT/%{_lib}/$SubDir/`basename $RPM_BUILD_ROOT/%{_lib}/libthread_db.so.*`

mkdir -p $RPM_BUILD_ROOT%{_prefix}/%{_lib}/nptl
cp -a libc.a nptl/libpthread.a nptl/libpthread_nonshared.a rt/librt.a \
  $RPM_BUILD_ROOT%{_prefix}/%{_lib}/nptl/
sed "s| /%{_lib}/| /%{_lib}/$SubDir/|" $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libc.so \
  > $RPM_BUILD_ROOT%{_prefix}/%{_lib}/nptl/libc.so
sed "s|^GROUP (.*)|GROUP ( /%{_lib}/$SubDir/"`basename $RPM_BUILD_ROOT/%{_lib}/libpthread.so.*`' %{_prefix}/%{_lib}/nptl/libpthread_nonshared.a )|' \
  $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libc.so \
  > $RPM_BUILD_ROOT%{_prefix}/%{_lib}/nptl/libpthread.so
%ifarch %{rtkaioarches}
ln -sf /%{_lib}/$SubDir/`basename $RPM_BUILD_ROOT/%{_lib}/librt-*.so | sed 's/librt-/librtkaio-/'` \
  $RPM_BUILD_ROOT%{_prefix}/%{_lib}/nptl/librt.so
%else
ln -sf /%{_lib}/$SubDir/`basename $RPM_BUILD_ROOT/%{_lib}/librt-*.so` \
  $RPM_BUILD_ROOT%{_prefix}/%{_lib}/nptl/librt.so
%endif
strip -g $RPM_BUILD_ROOT%{_prefix}/%{_lib}/nptl/*.a
mkdir -p $RPM_BUILD_ROOT/nptl $RPM_BUILD_ROOT%{_prefix}/include/nptl
make -j1 install_root=$RPM_BUILD_ROOT/nptl install-headers PARALLELMFLAGS=-s
pushd $RPM_BUILD_ROOT/nptl%{_prefix}/include
  for i in `find . -type f`; do
    if ! [ -f $RPM_BUILD_ROOT%{_prefix}/include/$i ] \
       || ! cmp -s $i $RPM_BUILD_ROOT%{_prefix}/include/$i; then
      mkdir -p $RPM_BUILD_ROOT%{_prefix}/include/nptl/`dirname $i`
      cp -a $i $RPM_BUILD_ROOT%{_prefix}/include/nptl/$i
    fi
  done
popd
rm -rf $RPM_BUILD_ROOT/nptl

cd ..

%ifarch i386
for i in i586 i686; do
  mkdir $RPM_BUILD_ROOT/%{_lib}/tls/$i
  pushd $RPM_BUILD_ROOT/%{_lib}/tls/$i
    ln -sf ../i486/*.so .
    cp -a ../i486/*.so.* .
  popd
done
%endif
%endif

# compatibility hack: this locale has vanished from glibc, but some other
# programs are still using it. Normally we would handle it in the %pre
# section but with glibc that is simply not an option
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/locale/ru_RU/LC_MESSAGES

# Remove the files we don't want to distribute
rm -f $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libNoVersion*
%ifnarch %{ix86} alpha alphaev6 sparc sparcv9
rm -f $RPM_BUILD_ROOT/%{_lib}/libNoVersion*
%endif

# the man pages for the linuxthreads require special attention
make -C linuxthreads/man
mkdir -p $RPM_BUILD_ROOT%{_mandir}/man3
install -m 0644 linuxthreads/man/*.3thr $RPM_BUILD_ROOT%{_mandir}/man3
gzip -9nvf $RPM_BUILD_ROOT%{_mandir}/man3/*

if [ -d $RPM_BUILD_ROOT%{_prefix}/info -a "%{_infodir}" != "%{_prefix}/info" ]; then
    mkdir -p $RPM_BUILD_ROOT%{_infodir}
    mv -f $RPM_BUILD_ROOT%{_prefix}/info/* $RPM_BUILD_ROOT%{_infodir}
    rm -rf $RPM_BUILD_ROOT%{_prefix}/info
fi

gzip -9nvf $RPM_BUILD_ROOT%{_infodir}/libc*

ln -sf libbsd-compat.a $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libbsd.a

install -p -m 644 fedora/nsswitch.conf $RPM_BUILD_ROOT/etc/nsswitch.conf

mkdir -p $RPM_BUILD_ROOT/etc/default
install -p -m 644 nis/nss $RPM_BUILD_ROOT/etc/default/nss

# Take care of setuids
# -- new security review sez that this shouldn't be needed anymore
#chmod 755 $RPM_BUILD_ROOT%{_prefix}/libexec/pt_chown

# This is for ncsd - in glibc 2.2
install -m 644 nscd/nscd.conf $RPM_BUILD_ROOT/etc
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
install -m 755 nscd/nscd.init $RPM_BUILD_ROOT/etc/rc.d/init.d/nscd

# Don't include ld.so.cache
rm -f $RPM_BUILD_ROOT/etc/ld.so.cache

# Include ld.so.conf
echo 'include ld.so.conf.d/*.conf' > $RPM_BUILD_ROOT/etc/ld.so.conf
touch $RPM_BUILD_ROOT/etc/ld.so.cache
chmod 644 $RPM_BUILD_ROOT/etc/ld.so.conf
mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d

# Include %{_prefix}/%{_lib}/gconv/gconv-modules.cache
> $RPM_BUILD_ROOT%{_prefix}/%{_lib}/gconv/gconv-modules.cache
chmod 644 $RPM_BUILD_ROOT%{_prefix}/%{_lib}/gconv/gconv-modules.cache

# Install the upgrade program
install -m 700 build-%{_target_cpu}-linux/glibc_post_upgrade.%{_target_cpu} \
  $RPM_BUILD_ROOT/usr/sbin/glibc_post_upgrade.%{_target_cpu}

strip -g $RPM_BUILD_ROOT%{_prefix}/%{_lib}/*.o

mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/debug%{_prefix}/%{_lib}
cp -a $RPM_BUILD_ROOT%{_prefix}/%{_lib}/*.a \
  $RPM_BUILD_ROOT%{_prefix}/lib/debug%{_prefix}/%{_lib}/
rm -f $RPM_BUILD_ROOT%{_prefix}/lib/debug%{_prefix}/%{_lib}/*_p.a
# Now strip debugging info from static libraries
pushd $RPM_BUILD_ROOT%{_prefix}/%{_lib}/
for i in *.a; do
  if [ -f $i ]; then
    case "$i" in
    *_p.a) ;;
    *) strip -g -R .comment $i ;;
    esac
  fi
done
popd

%ifarch %{prelinkarches}
%ifarch i686 athlon
# Prelink ld.so and libc.so
> prelink.conf
# For now disable prelinking of ld.so, as it breaks statically linked
# binaries built against non-NDEBUG old glibcs (assert unknown dynamic tag)
# /usr/sbin/prelink -c ./prelink.conf -C ./prelink.cache \
#  --mmap-region-start=0x00101000 $RPM_BUILD_ROOT/%{_lib}/ld-*.so
/usr/sbin/prelink --reloc-only=0x00e80000 $RPM_BUILD_ROOT/%{_lib}/$SubDir/libc-*.so
%endif
%ifarch alpha alphaev6
# Prelink ld.so and libc.so
> prelink.conf
# For now disable prelinking of ld.so, as it breaks statically linked
# binaries built against non-NDEBUG old glibcs (assert unknown dynamic tag)
# /usr/sbin/prelink -c ./prelink.conf -C ./prelink.cache \
# --mmap-region-start=0x0000020000000000 $RPM_BUILD_ROOT/%{_lib}/ld-*.so
/usr/sbin/prelink --reloc-only=0x0000020010000000 $RPM_BUILD_ROOT/%{_lib}/$SubDir/libc-*.so
%endif
%endif

# rquota.x and rquota.h are now provided by quota
rm -f $RPM_BUILD_ROOT%{_prefix}/include/rpcsvc/rquota.[hx]

# Hardlink identical locale files together
%ifnarch %{auxarches}
gcc -O2 -o build-%{_target_cpu}-linux/hardlink fedora/hardlink.c
build-%{_target_cpu}-linux/hardlink -vc $RPM_BUILD_ROOT%{_prefix}/lib/locale
%endif

%ifarch %{ix86} alpha alphaev6 sparc sparcv9
rm -f ${RPM_BUILD_ROOT}/%{_lib}/libnss1-*
rm -f ${RPM_BUILD_ROOT}/%{_lib}/libnss-*.so.1
%endif

# Ugly hack for buggy rpm
ln -f ${RPM_BUILD_ROOT}%{_sbindir}/iconvconfig{,.%{_target_cpu}}

# BUILD THE FILE LIST
find $RPM_BUILD_ROOT -type f -or -type l |
        sed -e 's|.*/etc|%config &|' \
            -e 's|.*/gconv/gconv-modules$|%verify(not md5 size mtime) %config(noreplace) &|' \
            -e 's|.*/gconv/gconv-modules.cache|%verify(not md5 size mtime) &|' \
            -e '/lib\/debug/d' > rpm.filelist.in
for n in %{_prefix}/share %{_prefix}/include %{_prefix}/lib/locale; do
    find ${RPM_BUILD_ROOT}${n} -type d | \
        grep -v '%{_prefix}/share$' | \
        grep -v '\(%{_mandir}\|%{_infodir}\)' | \
        sed "s/^/%dir /" >> rpm.filelist.in
done

# primary filelist
SHARE_LANG='s|.*/share/locale/\([^/_]\+\).*/LC_MESSAGES/.*\.mo|%lang(\1) &|'
LIB_LANG='s|.*/lib/locale/\([^/_]\+\)|%lang(\1) &|'
# rpm does not handle %lang() tagged files hardlinked together accross
# languages very well, temporarily disable
# LIB_LANG=''

sed -e "s|$RPM_BUILD_ROOT||" -e "$LIB_LANG" -e "$SHARE_LANG" < rpm.filelist.in |
        grep -v '/etc/\(localtime\|nsswitch.conf\|ld.so.conf\|ld.so.cache\|default\)'  | \
        grep -v '/%{_lib}/lib\(pcprofile\|memusage\).so' | \
#        grep -v 'bin/\(memusage\|mtrace\|xtrace\|pcprofiledump\)' | \
        grep -v 'bin/\(mtrace\|xtrace\|pcprofiledump\)' | \
        sort > rpm.filelist

mkdir -p $RPM_BUILD_ROOT%{_prefix}/%{_lib}
mv -f $RPM_BUILD_ROOT/%{_lib}/lib{pcprofile,memusage}.so $RPM_BUILD_ROOT%{_prefix}/%{_lib}
#for i in $RPM_BUILD_ROOT%{_prefix}/bin/{xtrace,memusage}; do
#  cp -a $i $i.tmp
#  sed -e 's~=/%{_lib}/libpcprofile.so~=%{_prefix}/%{_lib}/libpcprofile.so~' \
#      -e 's~=/%{_lib}/libmemusage.so~=%{_prefix}/%{_lib}/libmemusage.so~' \
#    $i.tmp > $i
#  chmod 755 $i; rm -f $i.tmp
#done


grep '%{_prefix}/%{_lib}/lib.*_p\.a' < rpm.filelist > profile.filelist || :
grep '%{_infodir}' < rpm.filelist | grep -v '%{_infodir}/dir' > devel.filelist
grep '%{_prefix}/include/gnu/stubs-[32164]\+\.h' < rpm.filelist >> devel.filelist || :

grep '%{_prefix}/include' < rpm.filelist |
        egrep -v '%{_prefix}/include/(nptl|gnu/stubs-[32164]+\.h)' \
                > headers.filelist

mv rpm.filelist rpm.filelist.full
grep -v '%{_prefix}/%{_lib}/lib.*_p.a' rpm.filelist.full |
        egrep -v "(%{_prefix}/include)|(%{_infodir})" > rpm.filelist

grep '%{_prefix}/%{_lib}/lib.*\.a' < rpm.filelist >> devel.filelist
grep '%{_prefix}/%{_lib}/.*\.o' < rpm.filelist >> devel.filelist
grep '%{_prefix}/%{_lib}/lib.*\.so' < rpm.filelist >> devel.filelist
grep '%{_mandir}' < rpm.filelist >> devel.filelist

mv rpm.filelist rpm.filelist.full
grep -v '%{_prefix}/%{_lib}/lib.*\.a' < rpm.filelist.full |
        grep -v '%{_prefix}/%{_lib}/.*\.o' |
        grep -v '%{_prefix}/%{_lib}/lib.*\.so'|
        grep -v '%{_prefix}/%{_lib}/nptl' |
        grep -v '%{_mandir}' |
        grep -v 'nscd' > rpm.filelist

grep '%{_prefix}/bin' < rpm.filelist >> common.filelist
grep '%{_prefix}/lib/locale' < rpm.filelist >> common.filelist
grep '%{_prefix}/libexec/pt_chown' < rpm.filelist >> common.filelist
grep '%{_prefix}/sbin/[^gi]' < rpm.filelist >> common.filelist
grep '%{_prefix}/share' < rpm.filelist \
  | grep -v '%{_prefix}/share/zoneinfo' >> common.filelist

mv rpm.filelist rpm.filelist.full
grep -v '%{_prefix}/bin' < rpm.filelist.full |
        grep -v '%{_prefix}/lib/locale' |
        grep -v '%{_prefix}/libexec/pt_chown' |
        grep -v '%{_prefix}/sbin/[^gi]' |
        grep -v '%{_prefix}/share' > rpm.filelist

echo '%{_prefix}/sbin/build-locale-archive' >> common.filelist
echo '%{_prefix}/sbin/nscd' > nscd.filelist

cat > utils.filelist <<EOF
%{_prefix}/%{_lib}/libmemusage.so
%{_prefix}/%{_lib}/libpcprofile.so
#%{_prefix}/bin/memusage
#%{_prefix}/bin/memusagestat
%{_prefix}/bin/mtrace
%{_prefix}/bin/pcprofiledump
#%{_prefix}/bin/xtrace
EOF

# /etc/localtime
rm -f $RPM_BUILD_ROOT/etc/localtime
cp -f $RPM_BUILD_ROOT%{_prefix}/share/zoneinfo/Asia/Shanghai $RPM_BUILD_ROOT/etc/localtime
#ln -sf ..%{_prefix}/share/zoneinfo/US/Eastern $RPM_BUILD_ROOT/etc/localtime

rm -rf $RPM_BUILD_ROOT%{_prefix}/share/zoneinfo

cd fedora
$GCC -Os -static -o build-locale-archive build-locale-archive.c \
  ../build-%{_target_cpu}-linux/locale/locarchive.o \
  ../build-%{_target_cpu}-linux/locale/md5.o \
  -DDATADIR=\"%{_datadir}\" -DPREFIX=\"%{_prefix}\" \
  -L../build-%{_target_cpu}-linux
install -m 700 build-locale-archive $RPM_BUILD_ROOT/usr/sbin/build-locale-archive
cd ..

# the last bit: more documentation
rm -rf documentation
mkdir documentation
cp linuxthreads/ChangeLog  documentation/ChangeLog.threads
cp linuxthreads/Changes documentation/Changes.threads
cp linuxthreads/README documentation/README.threads
cp linuxthreads/FAQ.html documentation/FAQ-threads.html
cp -r linuxthreads/Examples documentation/examples.threads
cp crypt/README.ufc-crypt documentation/README.ufc-crypt
cp timezone/README documentation/README.timezone
cp ChangeLog* documentation
gzip -9n documentation/ChangeLog*

%ifarch s390x
# Compatibility symlink
mkdir -p $RPM_BUILD_ROOT/lib
ln -sf /%{_lib}/ld64.so.1 $RPM_BUILD_ROOT/lib/ld64.so.1
%endif
%ifarch ia64
%if "%{_lib}" == "lib64"
# Compatibility symlink
mkdir -p $RPM_BUILD_ROOT/lib
ln -sf /%{_lib}/ld-linux-ia64.so.2 $RPM_BUILD_ROOT/lib/ld-linux-ia64.so.2
%endif
%endif

# Increase timeouts
export TIMEOUTFACTOR=16
echo ====================TESTING=========================
cd build-%{_target_cpu}-linux
make -j$numprocs -k check PARALLELMFLAGS=-s 2>&1 | tee check.log || :
cd ..
%ifarch i686 athlon
echo ====================TESTING LINUXTHREADS FS=========
cd build-%{_target_cpu}-linuxltfs
make -j$numprocs -k check PARALLELMFLAGS=-s 2>&1 | tee check.log || :
cd ..
%endif
%ifarch %{nptlarches}
echo ====================TESTING NPTL====================
cd build-%{nptl_target_cpu}-linuxnptl
make -j$numprocs -k check PARALLELMFLAGS=-s 2>&1 | tee check.log || :
cd ..
%endif
echo ====================TESTING DETAILS=================
for i in `sed -n 's|^.*\*\*\* \[\([^]]*\.out\)\].*$|\1|p' build-*-linux*/check.log`; do
  echo =====$i=====
  cat $i || :
  echo ============
done
%ifarch i686 athlon
echo ====================TESTING LINUXTHREADS FS LD.SO===
cd build-%{_target_cpu}-linuxltfs
mv elf/ld.so elf/ld.so.orig
cp -a ../build-%{_target_cpu}-linux/elf/ld.so elf/ld.so
find . -name \*.out -exec mv -f '{}' '{}'.origldso \;
make -j$numprocs -k check PARALLELMFLAGS=-s 2>&1 | tee check2.log || :
cd ..
%endif
%ifarch %{nptlarches}
echo ====================TESTING NPTL LD.SO==============
cd build-%{nptl_target_cpu}-linuxnptl
mv elf/ld.so elf/ld.so.orig
cp -a ../build-%{_target_cpu}-linux/elf/ld.so elf/ld.so
find . -name \*.out -exec mv -f '{}' '{}'.origldso \;
make -j$numprocs -k check PARALLELMFLAGS=-s 2>&1 | tee check2.log || :
cd ..
%endif
echo ====================TESTING DETAILS=================
for i in `sed -n 's|^.*\*\*\* \[\([^]]*\.out\)\].*$|\1|p' build-*-linux*/check2.log`; do
  echo =====$i=====
  cat $i || :
  echo ============
done
echo ====================TESTING END=====================
PLTCMD='/^Relocation section .*\(\.rela\?\.plt\|\.rela\.IA_64\.pltoff\)/,/^$/p'
echo ====================PLT RELOCS LD.SO================
readelf -Wr $RPM_BUILD_ROOT/%{_lib}/ld-*.so | sed -n -e "$PLTCMD"
echo ====================PLT RELOCS LIBC.SO==============
readelf -Wr $RPM_BUILD_ROOT/%{_lib}/$SubDir/libc-*.so | sed -n -e "$PLTCMD"
echo ====================PLT RELOCS END==================

%if "%{_enable_debug_packages}" == "1"

case "$-" in *x*) save_trace=yes;; esac
set +x
echo Building debuginfo subpackage...

blf=debugfiles.list
sf=debugsources.list
cblf=debugcommonfiles.list
csf=debugcommonsources.list

echo -n > $sf
echo -n > $csf

strip $RPM_BUILD_ROOT/{sbin/ldconfig,usr/sbin/glibc_post_upgrade.%{_target_cpu},usr/sbin/build-locale-archive}

# Strip ELF binaries
for f in `grep -v '%%\(dir\|lang\|config\|verify\)' rpm.filelist`; do
  bf=$RPM_BUILD_ROOT$f
  if [ -f $bf -a -x $bf -a ! -h $bf ]; then
    if `file $bf 2>/dev/null | grep 'ELF.*, not stripped' | grep -vq 'statically linked'`; then
      bd=`dirname $f`
      outd=$RPM_BUILD_ROOT/usr/lib/debug$bd
      mkdir -p $outd
      echo extracting debug info from $f
      /usr/lib/rpm/debugedit -b $RPM_BUILD_DIR -d /usr/src/debug -l $sf $bf
      bn=`basename $f`
      case $f in
        /%{_lib}/*) eu-strip -g -f $outd/$bn.debug $bf || :;;
        *) eu-strip -f $outd/$bn.debug $bf || :;;
      esac
      if [ -f $outd/$bn.debug ]; then echo /usr/lib/debug$bd/$bn.debug >> $blf; fi
    fi
  fi
done

for f in `cat common.filelist utils.filelist nscd.filelist \
          | grep -v '%%\(dir\|lang\|config\|verify\)'`; do
  bf=$RPM_BUILD_ROOT$f
  if [ -f $bf -a -x $bf -a ! -h $bf ]; then
    if `file $bf 2>/dev/null | grep 'ELF.*, not stripped' | grep -vq 'statically linked'`; then
      bd=`dirname $f`
      outd=$RPM_BUILD_ROOT/usr/lib/debug$bd
      mkdir -p $outd
      echo extracting debug info from $f
      /usr/lib/rpm/debugedit -b $RPM_BUILD_DIR -d /usr/src/debug -l $csf $bf
      bn=`basename $f`
      eu-strip -f $outd/$bn.debug $bf || :
      if [ -f $outd/$bn.debug ]; then echo /usr/lib/debug$bd/$bn.debug >> $cblf; fi
    fi
  fi
done

for f in `find $RPM_BUILD_ROOT/%{_lib} -type l`; do
  l=`ls -l $f`
  l=${l#* -> }
  t=/usr/lib/debug`dirname ${f#$RPM_BUILD_ROOT}`
  if grep -q "^$t/$l.debug\$" $blf; then
    ln -sf $l.debug $RPM_BUILD_ROOT$t/`basename $f`.debug
    echo $t/`basename $f`.debug >> $blf
  elif grep -q "^$t.debug/$l\$" $cblf; then
    ln -sf $l.debug $RPM_BUILD_ROOT$t/`basename $f`.debug
    echo $t/`basename $f`.debug >> $cblf
  fi
done

echo Sorting source file lists. Might take a while...
xargs -0 -n 1 echo < $sf | LC_ALL=C grep -v '/<internal>$' | LC_ALL=C sort -u > $sf.sorted
xargs -0 -n 1 echo < $csf | LC_ALL=C grep -v '/<internal>$' | LC_ALL=C sort -u > $csf.sorted
mkdir -p $RPM_BUILD_ROOT/usr/src/debug
cat $sf.sorted $csf.sorted \
  | (cd $RPM_BUILD_DIR; LC_ALL=C sort -u | cpio -pdm ${RPM_BUILD_ROOT}/usr/src/debug)
# stupid cpio creates new directories in mode 0700, fixup
find $RPM_BUILD_ROOT/usr/src/debug -type d -print | xargs chmod a+rx

%ifarch %{debuginfocommonarches}
%ifarch %{auxarches}
%ifarch %{ix86}
%define basearch i386
%endif
%ifarch alpha alphaev6
%define basearch alpha
%endif
%ifarch sparc sparcv9
%define basearch sparc
%endif
cat $blf > debuginfo.filelist
find $RPM_BUILD_ROOT/usr/src/debug/%{glibcsrcdir} -type d \
  | sed "s#^$RPM_BUILD_ROOT#%%dir #" >> debuginfo.filelist
grep '/generic/\|/linux/\|/%{basearch}/\|/nptl\(_db\)\?/\|^%{glibcsrcdir}/build' \
  $sf.sorted | sed 's|^|/usr/src/debug/|' >> debuginfo.filelist
touch debuginfocommon.filelist
%else
( grep '^%{glibcsrcdir}/build-\|dl-osinfo\.h' $csf.sorted || : ) > $csf.sorted.build
cat $blf > debuginfo.filelist
cat $cblf > debuginfocommon.filelist
grep '^%{glibcsrcdir}/build-\|dl-osinfo\.h' $sf.sorted \
  | sed 's|^|/usr/src/debug/|' >> debuginfo.filelist
find $RPM_BUILD_ROOT/usr/src/debug/%{glibcsrcdir} -type d \
  | sed "s#^$RPM_BUILD_ROOT#%%dir #" >> debuginfocommon.filelist
( cat $csf.sorted; grep -v -f $csf.sorted.build $sf.sorted ) \
  | grep -v 'dl-osinfo\.h' | LC_ALL=C sort -u \
  | sed 's|^|/usr/src/debug/|' >> debuginfocommon.filelist
%endif
%else
cat $blf $cblf | LC_ALL=C sort -u > debuginfo.filelist
echo '/usr/src/debug/%{glibcsrcdir}' >> debuginfo.filelist
%endif

[ "x$save_trace" = xyes ] && set -x

%endif

%ifarch %{auxarches}
case "$-" in *x*) save_trace=yes;; esac
set +x
echo Cutting down the list of unpackaged files
for i in `sed '/%%dir/d;/%%config/d;/%%verify/d;s/%%lang([^)]*) //' \
          common.filelist devel.filelist headers.filelist profile.filelist \
          utils.filelist nscd.filelist`; do
  [ -f "$RPM_BUILD_ROOT$i" ] && rm -f "$RPM_BUILD_ROOT$i" || :
done
[ "x$save_trace" = xyes ] && set -x

%else

mkdir -p $RPM_BUILD_ROOT/var/{db,run}/nscd
touch $RPM_BUILD_ROOT/var/{db,run}/nscd/{passwd,group,hosts}
touch $RPM_BUILD_ROOT/var/run/nscd/{socket,nscd.pid}
%endif

touch $RPM_BUILD_ROOT/%{_prefix}/lib/locale/locale-archive

%post -p /usr/sbin/glibc_post_upgrade.%{_target_cpu}

%postun -p /sbin/ldconfig

%post common -p /usr/sbin/build-locale-archive

%post devel
/sbin/install-info %{_infodir}/libc.info.gz %{_infodir}/dir

%pre headers
# this used to be a link and it is causing nightmares now
if [ -L %{_prefix}/include/scsi ] ; then
    rm -f %{_prefix}/include/scsi
fi

%preun devel
if [ "$1" = 0 ]; then
    /sbin/install-info --delete %{_infodir}/libc.info.gz %{_infodir}/dir
fi

%post utils -p /sbin/ldconfig

%postun utils -p /sbin/ldconfig

%pre -n nscd
/usr/sbin/useradd -M -o -r -d / -s /sbin/nologin \
        -c "NSCD Daemon" -u 28 nscd > /dev/null 2>&1 || :

%post -n nscd
/sbin/chkconfig --add nscd

%preun -n nscd
if [ $1 = 0 ] ; then
    service nscd stop > /dev/null 2>&1
    /sbin/chkconfig --del nscd
fi

%postun -n nscd
if [ $1 = 0 ] ; then
    /usr/sbin/userdel nscd > /dev/null 2>&1 || :
fi
if [ "$1" -ge "1" ]; then
    service nscd condrestart > /dev/null 2>&1 || :
fi

%clean
rm -rf "$RPM_BUILD_ROOT"
rm -f *.filelist*

%files -f rpm.filelist
%defattr(-,root,root)
%ifarch %{nptlarches}
%dir /%{_lib}/%{tls_subdir}
%ifarch i386
%dir /%{_lib}/tls/i586
%dir /%{_lib}/tls/i686
%endif
%endif
%ifarch i686 athlon
%dir /lib/i686
%endif
%ifarch s390x
%dir /lib
/lib/ld64.so.1
%endif
%ifarch ia64
%if "%{_lib}" == "lib64"
%dir /lib
/lib/ld-linux-ia64.so.2
%endif
%endif
%verify(not md5 size mtime) %config(noreplace) /etc/localtime
%verify(not md5 size mtime) %config(noreplace) /etc/nsswitch.conf
%verify(not md5 size mtime) %config(noreplace) /etc/ld.so.conf
%dir /etc/ld.so.conf.d
%dir %{_prefix}/libexec/getconf
%dir %{_prefix}/%{_lib}/gconv
%attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /etc/ld.so.cache
%doc README NEWS INSTALL FAQ BUGS NOTES PROJECTS CONFORMANCE
%doc COPYING COPYING.LIB README.libm LICENSES
%doc hesiod/README.hesiod

%ifnarch %{auxarches}
%files -f common.filelist common
%defattr(-,root,root)
%attr(0644,root,root) %verify(not md5 size mtime mode) %ghost %config(missingok,noreplace) %{_prefix}/lib/locale/locale-archive
%dir %attr(755,root,root) /etc/default
%verify(not md5 size mtime) %config(noreplace) /etc/default/nss
%doc documentation/*

%files -f devel.filelist devel
%defattr(-,root,root)

%files -f headers.filelist headers
%defattr(-,root,root)
%ifarch %{nptlarches}
%{_prefix}/include/nptl
%endif

%files -f profile.filelist profile
%defattr(-,root,root)

%files -f utils.filelist utils
%defattr(-,root,root)

%files -f nscd.filelist -n nscd
%defattr(-,root,root)
%config(noreplace) /etc/nscd.conf
%config /etc/rc.d/init.d/nscd
%dir %attr(0755,root,root) /var/run/nscd
%dir %attr(0755,root,root) /var/db/nscd
%attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/nscd.pid
%attr(0666,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/socket
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/passwd
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/group
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/hosts
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/db/nscd/passwd
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/db/nscd/group
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/db/nscd/hosts
%endif

%ifarch %{nptlarches}
%files -n nptl-devel
%defattr(-,root,root)
%{_prefix}/%{_lib}/nptl
%endif

%if "%{_enable_debug_packages}" == "1"
%files debuginfo -f debuginfo.filelist
%defattr(-,root,root)
%ifarch %{debuginfocommonarches}
%ifnarch %{auxarches}
%files debuginfo-common -f debuginfocommon.filelist
%defattr(-,root,root)
%dir %{_prefix}/lib/debug
%dir %{_prefix}/lib/debug/%{_prefix}
%dir %{_prefix}/lib/debug/%{_prefix}/%{_lib}
%{_prefix}/lib/debug/%{_prefix}/%{_lib}/*.a
%endif
%else
%dir %{_prefix}/lib/debug
%dir %{_prefix}/lib/debug/%{_prefix}
%dir %{_prefix}/lib/debug/%{_prefix}/%{_lib}
%{_prefix}/lib/debug/%{_prefix}/%{_lib}/*.a
%endif
%endif

TOP

这是为打包做处理了,手工编译不用这么麻烦的,不过glibc尽量编译成i386吧。

TOP

对于 glibc 来说,i486 到 i686 都差不多的。
./configure 的时候加上相应的参数因该就差不多了吧。
当然,你要编译 i686 的,还需要一个 i686 的 gcc 。

不过不同意副主席的 i386 ,glibc 在 386 上面似乎部分功能不能打开。
除非用 patch 。
好像 nptl 就是一个。

TOP