#!/bin/bash

source /usr/share/slackdev/buildkit.sh

# Package metadata:
export PKGNAM=glibc
export VERSION=${VERSION:-2.7}
# The architecture name component of the .tgz package file name:
export PKGARCH=${PKGARCH:-arm}
export BUILD=${BUILD:-7}
export PKGSERIES=${PKGSERIES:-l}
export SLACKPACKAGE=$PKGNAM-$VERSION-$PKGARCH-$BUILD.tgz

## ******************************************************************* ##
# For test packages - best to store in another location rather than
# overwriting the working copy in the main tree:
#export PKGSTORE=/tmp/
#mkdir -vpm755 $PKGSTORE/$PKGSERIES
## ******************************************************************* ##

# Reset the ARM file system: restore it to the 'factory settings'
# as it were (this has no effect when building natively):
sboxsysrestore

# Ensure base ARM packages are installed first:
slackbasedeps

# We require ARMedslack's kernel-header package to be installed
# This package replaces Scratchbox's 2.6's headers which RMK stated
# on the armlinux mailing list, cause gcc3.3.2 build failure.
# Ensure the kernel headers package is installed:
# 17-May-2005: Note - for glibc-2.3.5 I have two pre-made 2.4 & 2.6 header
#              archives, so I don't need to faff around with these anymore as
#              there's no chance that my header archives will become polluted
#              during package building (which was the purpose of the code below).
#removepkg kernel-headers
#( cd /usr/include
#  rm -rf linux asm-arm asm-generic asm
#  slackcheckpkgdeps kernel-headers || installpkg $PKGSTORE/d/kernel-headers-*.tgz
#  # This isn't necessary, but I like to reassure myself:
#  ln -s asm asm-arm )
#
# I used to do this when I'd previously been making broken kernel-headers & wanted
# to make sure I had the most recent working version.
# You still need working system-wide kernel headers for the compiler to work.
removepkg kernel-headers
installpkg $PKGSTORE/d/kernel-headers*tgz

# Launch the package build script:
BUILDLOG=$( basename $SLACKPACKAGE .tgz ).build.log
( ./$PKGNAM.SlackBuild ) >& /dev/stdout | tee $BUILDLOG

# Compress the build log:
bzip2 -9f $BUILDLOG

