#!/bin/sh
## build glibc-2.1.3 for Slackware
## by Patrick J. Volkerding <volkerdi@slackware.com>
CWD=`pwd`
cd /tmp

if [ -d /usr/include/sys ]; then
  cat << EOF
*** WARNING:  It's a good idea to move /usr/include out of the way if
you're planning to extract this as a binary package.  Otherwise some of
the include files may not be replaced.

Press enter to continue, or control-c to abort.
EOF
  read junk_input;
fi

tar xzvf $CWD/glibc-2.1.3.tar.gz
cd glibc-2.1.3
tar xzvf $CWD/glibc-linuxthreads-2.1.3.tar.gz

## Install docs:
( mkdir -p /usr/doc/glibc-2.1.3
  cp -a BUGS CONFORMANCE COPYING COPYING.LIB FAQ INSTALL INTERFACE \
    NEWS NOTES PROJECTS README README.libm /usr/doc/glibc-2.1.3
  cd linuxthreads
  mkdir -p /usr/doc/glibc-2.1.3/linuxthreads
  cp -a Banner FAQ.html LICENSE README README.Xfree3.2 linuxthreads.texi \
    Examples /usr/doc/glibc-2.1.3/linuxthreads
  cd man
  for file in *.man ; do
    cat $file | gzip -9c > /usr/man/man3/`basename $file .man`.3.gz
  done 
  chown -R root.root /usr/doc/glibc-2.1.3 
  find /usr/doc/glibc-2.1.3 -type d | xargs chmod 755 
  find /usr/doc/glibc-2.1.3 -type f | xargs chmod 644 )

## configure for glibc2 using MD5 crypt() instead of DES crypt() by default.
## These should be kept seperate, since some countries restrict DES encryption.
## Use the descrypt.SlackBuild to build DES crypt() as an add-on package.
./configure --prefix=/usr \
            --enable-add-ons=linuxthreads \
            --disable-sanity-checks \
            --without-cvs \
            i386-slackware-linux

make

## If you want glibc-2.1.3 installed, uncomment the lines below.
# Save the ldd from ldso.tgz:
mv /usr/bin/ldd /usr/bin/ldd-ldso
make install
mv /usr/bin/ldd /usr/bin/ldd-glibc
mv /usr/bin/ldd-ldso /usr/bin/ldd

# Set correct location for mail spool directory:
( cd /usr/include ; zcat $CWD/paths.h.diff.gz | patch -p0 )

# Don't forget to add the /usr/share/zoneinfo/localtime -> /etc/localtime symlink! :)
if [ ! -r /usr/share/zoneinfo/localtime ]; then
  ( cd /usr/share/zoneinfo ; ln -sf /etc/localtime . )
fi