#!/bin/sh
cd $LFS/usr/src/glibc-*/ || exit

#we use cvs version to have nptl (and unused linuxthreads too):
#cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/glibc login
#{enter "anoncvs" as the password}
#cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/glibc co libc

#   This package is known to behave badly when you have changed its
#   default optimization flags (including the -march and -mcpu options).
#   Therefore, if you have defined any environment variables that override
#   default optimizations, such as CFLAGS and CXXFLAGS, we recommend
#   unsetting them when building Glibc.


patch -p 1 <../glibc-2.3.5-allow-gcc4-string.patch
patch -p 1 <../glibc-2.3.5-allow-gcc4-symbols.patch
patch -p 1 <../glibc-2.3.5-gcc4_fix_elf-2.patch
patch -p 1 <../glibc-2.3.5-gcc41_jis208-1.patch


cd ..
#--without-gd: dont build memusagestat (this insists on linking to host libs)
#--enable-add-ons: NPTL
#warning about msgfmt is harmless
rm -rf _glibc &&
mkdir _glibc &&
cd _glibc &&
#--libexecdir=/prelfs/lib \
../glibc-[0-9]*/configure --prefix=/prelfs \
  --disable-profile --enable-add-ons --enable-kernel=2.6.0 \
  --with-binutils=/prelfs/bin --without-gd --without-cvs \
  --with-headers=/prelfs/include --disable-selinux &&
make &&
## make check
#avoid install warning:
mkdir -p /prelfs/etc &&
touch /prelfs/etc/ld.so.conf &&
make install &&
#this would install all locales:
# make localedata/install-locales
#this installs only locales needed for gc tests:
mkdir -p /prelfs/lib/locale &&
localedef -i de_DE -f ISO-8859-1 de_DE &&
localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro &&
localedef -i en_HK -f ISO-8859-1 en_HK
localedef -i en_PH -f ISO-8859-1 en_PH
localedef -i en_US -f ISO-8859-1 en_US
localedef -i es_MX -f ISO-8859-1 es_MX
localedef -i fa_IR -f UTF-8 fa_IR
localedef -i fr_FR -f ISO-8859-1 fr_FR
localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro
localedef -i it_IT -f ISO-8859-1 it_IT
localedef -i ja_JP -f EUC-JP ja_JP
