default_pre_build  &&

if  [  "$GLIBC_NPTL"  =  "y"  ];  then
  cd      $SOURCE_DIRECTORY                  &&
  patch $SOURCE_DIRECTORY/timezone/Makefile  \
        $SCRIPT_DIRECTORY/localtime.patch    &&

  #
  # Unpack glibc-kernel-headers
  #
  #
  # Set GLIBC_HEADERS_DIR for use later
  #
  persistent_add  GLIBC_HEADERS_DIR                        &&
  GLIBC_HEADERS_DIR=$SOURCE_DIRECTORY/${SOURCE3/.tar.bz2}  &&

  unpack_file 3                         &&
  if [[ $GLIBC_SANITIZE_HEADERS == n ]]; then
    cd  $GLIBC_HEADERS_DIR &&
    if [ ! -z $SOURCE3 ]; then
      bzcat ${SOURCE_CACHE}/$SOURCE3 > ${SOURCE3%.bz2}
    fi  &&
    make mrproper
  else
    cd  $GLIBC_HEADERS_DIR &&
    if [ ! -z $SOURCE7 ]; then
      verify_file 7 || return 1 &&
      bzcat ${SOURCE_CACHE}/$SOURCE7 > ${SOURCE7%.bz2} &&
      message "${MESSAGE_COLOR}Patching ${!patch}${DEFAULT_COLOR}" &&
      patch -p1 < ${SOURCE7%.bz2} &&
      if [[ $? != 0 ]]; then
        message "${PROBLEM_COLOR}Patch ${!patch} failed${DEFAULT_COLOR}" &&
        return 1
      fi
    fi &&
    make mrproper
  fi
else
  cd      $SOURCE_DIRECTORY                         &&
  #
  # Now unpack the rest of glibc fixes in the normal location
  #
  unpack_file 3                       &&
  #
  # Unpack glibc-kernel-headers
  #
  #
  # Set GLIBC_HEADERS_DIR for use later
  #
  persistent_add  GLIBC_HEADERS_DIR                   &&
  GLIBC_HEADERS_DIR=$SOURCE_DIRECTORY/kernel-headers  &&
  mkdir  -p  $GLIBC_HEADERS_DIR/usr/include         &&
  cd  $GLIBC_HEADERS_DIR/usr/include                &&
  unpack_file 5
fi  &&

#
# Remove kernel DRM headers
# Fixes Bug #15547
#
sed -i '/^header-y += drm\//d' $GLIBC_HEADERS_DIR/include/Kbuild &&
rm -rf $GLIBC_HEADERS_DIR/include/drm &&

#
# Now fixup the normal glibc
#
cd  $SOURCE_DIRECTORY                               &&
patch  -p0  <  $SCRIPT_DIRECTORY/Makefile.patch     &&
patch  -p1  <  $SCRIPT_DIRECTORY/as-test-x.patch &&
patch -p1 < $SPELL_DIRECTORY/gcc45.patch &&

# disabled libgd detection/building memusagestat for now until a better
# fix has been found, bug #8277
sedit  's/LIBGD=yes/LIBGD=no/'  $SOURCE_DIRECTORY/configure  &&

#
# Create the build directory
#
mk_source_dir  $SOURCE_DIRECTORY.bld &&

# fix #11832 - linking in /tmp doesn't work with grsecurity so do it elsewhere
local test_path=$SOURCE_DIRECTORY.bld/test-installation &&
mkdir $test_path &&
sed -i "s,/tmp,$test_path,g" scripts/test-installation.pl &&
sed -i 's/ot \$/ot:\n\ttouch $@\n$/' manual/Makefile


