Reorganize the tree for easier and better handling.

- Template helpers have been moved to templates/helpers.
- Documentation to docs/.
- Common scripts have been moved to utils/sh.
- Fixed install-destdir when executed via chroot.
- Added a build-pkg target that builds a binary package.
  The package must be installed into destdir before using.
- Misc tweaks and fixes.

--HG--
extra : convert_revision : 0896e8f24bb7592116aaf77ae9c776033818a3d8
This commit is contained in:
Juan RP 2008-12-13 03:01:24 +01:00
parent 8373117030
commit 23fa45a18b
20 changed files with 65 additions and 79 deletions

89
utils/sh/binpkg.sh Normal file
View file

@ -0,0 +1,89 @@
#
# This function writes the metadata files into package's destdir,
# these will be used for binary packages.
#
xbps_write_metadata_pkg()
{
local destdir=$XBPS_DESTDIR/$pkgname-$version
if [ ! -d "$destdir" ]; then
echo "ERROR: $pkgname not installed into destdir."
exit 1
fi
if [ ! -d $destdir/xbps-metadata ]; then
mkdir -p $destdir/xbps-metadata >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR: you don't have enough perms for this."
exit 1
fi
fi
# Write the files list.
local TMPFLIST=$(mktemp -t flist.XXXXXXXXXX) || exit 1
find $destdir | sort -ur | \
sed -e "s|$destdir||g;s|^\/$||g;s|/xbps-metadata||g;/^$/d" \
> $TMPFLIST
# Write the property list file.
local TMPFPROPS=$(mktemp -t fprops.XXXXXXXXXX) || exit 1
cat > $TMPFPROPS <<_EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>architecture</key>
<string>$(uname -m)</string>
<key>installed_size</key>
<integer>$(du -sb $destdir|awk '{print $1}')</integer>
_EOF
# Dependencies
if [ -n "$run_depends" ]; then
printf "\t<key>run_depends</key>\n" >> $TMPFPROPS
printf "\t<array>\n" >> $TMPFPROPS
for f in ${run_depends}; do
printf "\t\t<string>$f</string>\n" >> $TMPFPROPS
done
printf "\t</array>\n" >> $TMPFPROPS
fi
# Configuration files
if [ -n "$config_files" ]; then
printf "\t<key>config_files</key>\n" >> $TMPFPROPS
printf "\t<array>\n" >> $TMPFPROPS
for f in ${config_files}; do
printf "\t\t<string>$f</string>\n" >> $TMPFPROPS
done
printf "\t</array>\n" >> $TMPFPROPS
fi
# Terminate the property list file.
printf "</dict>\n</plist>\n" >> $TMPFPROPS
# Write metadata files into destdir and cleanup.
cp -f $TMPFLIST $destdir/xbps-metadata/flist
cp -f $TMPFPROPS $destdir/xbps-metadata/props.plist
chmod 644 $destdir/xbps-metadata/*
rm -f $TMPFLIST $TMPFPROPS
}
#
# This functions builds a binary package from an installed xbps
# package in destdir.
#
xbps_make_binpkg()
{
local destdir=$XBPS_DESTDIR/$pkgname-$version
local pkgsdir=$XBPS_DISTRIBUTIONDIR/packages
cd $destdir || exit 1
tar cfjp $destdir-xbps.tbz2 .
[ ! -d $pkgsdir ] && mkdir -p $pkgsdir
mv -f $destdir-xbps.tbz2 $pkgsdir
echo "=> Built package: $pkgname-$version-xbps.tbz2."
}

162
utils/sh/chroot.sh Normal file
View file

@ -0,0 +1,162 @@
#
# Script to install packages into a sandbox in masterdir.
# Actually this needs the xbps-base-chroot package installed.
#
# Umount stuff if SIGINT or SIGQUIT was caught
trap umount_chroot_fs INT QUIT
[ -n "$base_chroot" ] && return 0
check_installed_pkg xbps-base-chroot 0.1
[ $? -ne 0 ] && msg_error "xbps-base-chroot pkg not installed."
if [ "$(id -u)" -ne 0 ]; then
if [ -n "$origin_tmpl" ]; then
reset_tmpl_vars
run_file $XBPS_TEMPLATESDIR/$origin_tmpl.tmpl
fi
if [ -z "$base_chroot" ]; then
msg_error "this package must be built inside of the chroot."
else
msg_error "you must be root to use this target."
fi
fi
if [ ! -f $XBPS_MASTERDIR/.xbps_perms_done ]; then
echo -n "==> Preparing chroot on $XBPS_MASTERDIR... "
chown -R root:root $XBPS_MASTERDIR
cp -af /etc/passwd /etc/shadow /etc/group /etc/hosts \
/etc/resolv.conf $XBPS_MASTERDIR/etc
touch $XBPS_MASTERDIR/.xbps_perms_done
echo "done."
else
msg_normal "Entering into the chroot on $XBPS_MASTERDIR."
fi
EXTDIRS="xbps xbps_builddir xbps_destdir xbps_srcdistdir xbps_crossdir"
REQDIRS="bin sbin tmp var sys proc dev ${EXTDIRS}"
for f in ${REQDIRS}; do
[ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f
done
unset f REQDIRS
echo "XBPS_DISTRIBUTIONDIR=/xbps" > $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_MASTERDIR=/" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_DESTDIR=/xbps_destdir" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_BUILDDIR=/xbps_builddir" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_SRCDISTDIR=/xbps_srcdistdir" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_CFLAGS=\"$XBPS_CFLAGS\"" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_CXXFLAGS=\"\$XBPS_CFLAGS\"" >> $XBPS_MASTERDIR/etc/xbps.conf
if [ -n "$XBPS_MAKEJOBS" ]; then
echo "XBPS_MAKEJOBS=$XBPS_MAKEJOBS" >> $XBPS_MASTERDIR/etc/xbps.conf
fi
if [ -n "$XBPS_CROSS_TARGET" -a -d "$XBPS_CROSS_DIR" ]; then
echo "XBPS_CROSS_TARGET=$XBPS_CROSS_TARGET" >> \
$XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_CROSS_DIR=/xbps_crossdir" >> $XBPS_MASTERDIR/etc/xbps.conf
fi
rebuild_ldso_cache()
{
echo -n "==> Rebuilding chroot's dynamic linker cache..."
chroot $XBPS_MASTERDIR /sbin/ldconfig -c /etc/ld.so.conf
chroot $XBPS_MASTERDIR /sbin/ldconfig -C /etc/ld.so.cache
echo " done."
}
xbps_chroot_handler()
{
local action="$1"
local pkg="$2"
local only_destdir="$3"
[ -z "$action" -o -z "$pkg" ] && return 1
[ "$action" != "configure" -a "$action" != "build" -a \
"$action" != "install" -a "$action" != "chroot" ] && return 1
rebuild_ldso_cache
mount_chroot_fs
if [ "$action" = "chroot" ]; then
env in_chroot=yes chroot $XBPS_MASTERDIR /bin/bash
else
[ -n "$only_destdir" ] && \
local lenv="install_destdir_target=yes"
env in_chroot=yes ${lenv} chroot $XBPS_MASTERDIR \
/xbps/xbps.sh $action $pkg
fi
msg_normal "Exiting from the chroot on $XBPS_MASTERDIR."
umount_chroot_fs
}
mount_chroot_fs()
{
local cnt=
REQFS="sys proc dev xbps xbps_builddir xbps_destdir xbps_srcdistdir"
if [ -d "$XBPS_CROSS_DIR" ]; then
local cross=yes
REQFS="$REQFS xbps_crossdir"
fi
for f in ${REQFS}; do
if [ ! -f $XBPS_MASTERDIR/.${f}_mount_bind_done ]; then
echo -n "=> Mounting $f in chroot... "
local blah=
case $f in
xbps) blah=$XBPS_DISTRIBUTIONDIR;;
xbps_builddir) blah=$XBPS_BUILDDIR;;
xbps_destdir) blah=$XBPS_DESTDIR;;
xbps_srcdistdir) blah=$XBPS_SRCDISTDIR;;
xbps_crossdir)
[ -n $cross ] && blah=$XBPS_CROSS_DIR
;;
*) blah=/$f;;
esac
mount --bind $blah $XBPS_MASTERDIR/$f
if [ $? -eq 0 ]; then
echo 1 > $XBPS_MASTERDIR/.${f}_mount_bind_done
echo "done."
else
echo "failed."
fi
else
cnt=$(cat $XBPS_MASTERDIR/.${f}_mount_bind_done)
cnt=$(($cnt + 1))
echo $cnt > $XBPS_MASTERDIR/.${f}_mount_bind_done
fi
done
unset f
}
umount_chroot_fs()
{
local fs=
local dir=
local cnt=
for fs in ${REQFS}; do
[ ! -f $XBPS_MASTERDIR/.${fs}_mount_bind_done ] && continue
cnt=$(cat $XBPS_MASTERDIR/.${fs}_mount_bind_done)
if [ $cnt -gt 1 ]; then
cnt=$(($cnt - 1))
echo $cnt > $XBPS_MASTERDIR/.${fs}_mount_bind_done
else
echo -n "=> Unmounting $fs from chroot... "
umount -f $XBPS_MASTERDIR/$fs
if [ $? -eq 0 ]; then
rm -f $XBPS_MASTERDIR/.${fs}_mount_bind_done
echo "done."
else
echo "failed."
fi
fi
unset fs
done
for dir in ${EXTDIRS}; do
[ -f $XBPS_MASTERDIR/.${dir}_mount_bind_done ] && continue
[ -d $XBPS_MASTERDIR/$dir ] && rmdir $XBPS_MASTERDIR/$dir
done
}

View file

@ -0,0 +1,45 @@
#
# This helper sets some required vars to be able to cross build
# packages on xbps. The target is specified in the configuration file
# and will be read any time the cross compilation flag is used.
#
[ -z "$XBPS_CROSS_TARGET" -o ! -d $XBPS_CROSS_DIR/bin ] && return 1
# Check if all required bins are there.
for bin in gcc g++ cpp ar as ranlib ld strip; do
if [ ! -x $XBPS_CROSS_DIR/bin/$XBPS_CROSS_TARGET-${bin} ]; then
msg_error "cross-compilation: cannot find ${bin}, aborting."
fi
done
SAVE_PATH="$PATH"
if [ "$xbps_machine" = "x86_64" ]; then
XBPS_CROSS_HOST="x86_64-unknown-linux-gnu"
else
XBPS_CROSS_HOST="$xbps_machine-pc-linux-gnu"
fi
cross_compile_setvars()
{
export GCC=$XBPS_CROSS_TARGET-gcc
export CC=$XBPS_CROSS_TARGET-gcc
export CXX=$XBPS_CROSS_TARGET-g++
export CPP=$XBPS_CROSS_TARGET-cpp
export AR=$XBPS_CROSS_TARGET-ar
export AS=$XBPS_CROSS_TARGET-as
export RANLIB=$XBPS_CROSS_TARGET-ranlib
export LD=$XBPS_CROSS_TARGET-ld
export STRIP=$XBPS_CROSS_TARGET-strip
export PATH="$XBPS_CROSS_DIR/bin:$PATH"
}
cross_compile_unsetvars()
{
unset GCC CC CXX CPP AR AS RANLIB LD STRIP PATH
export PATH="$SAVE_PATH"
}
if [ "$build_style" = "gnu_configure" ]; then
configure_args="--build=$XBPS_CROSS_HOST --host=$XBPS_CROSS_TARGET"
configure_args="$configure_args --target=$XBPS_CROSS_TARGET"
fi

414
utils/sh/mktoolchain.sh Executable file
View file

@ -0,0 +1,414 @@
#!/bin/sh
#
# Script to be able to build a full cross toolchain for Linux/x86.
# This has been made thanks to various sources recollected from wikipedia
# and other cross compiling related pages.
# Setup some defaults
: ${GNU_URL_BASE:=http://ftp.gnu.org/gnu}
: ${KERNEL_URL_BASE:=http://www.kernel.org/pub/linux/kernel/v2.6}
: ${GCC_VER:=4.3.2}
: ${BINUTILS_VER:=2.19}
: ${GLIBC_VER:=2.7}
: ${KERNEL_VER:=2.6.27.3}
: ${CROSSDIR:=$HOME/mktoolchain}
: ${BUILDDIR:=$CROSSDIR/build}
: ${SOURCEDISTDIR:=$BUILDDIR/sources}
: ${FETCH_CMD:=wget}
usage()
{
echo "usage: $0 [-b dir] [-c dir] [-s dir] <target triplet>"
echo
echo "Optional flags:"
echo " -b Directory to be used for temporary building."
echo " -c Directory to be used for final cross tools."
echo " -s Directory where the sources are available."
exit 1
}
check_path()
{
local orig="$1"
case "$orig" in
/) ;;
/*) orig="${orig%/}" ;;
*) orig="$PWD/${orig%/}" ;;
esac
SANITIZED_DESTDIR=$orig
}
fetch_sources()
{
local pkg=
cd $SOURCEDISTDIR || exit 1
pkg=linux
if [ ! -f $pkg-$KERNEL_VER.tar.bz2 ]; then
echo "Fetching $pkg kernel-$KERNEL_VER sources..."
$FETCH_CMD $KERNEL_URL_BASE/$pkg-$KERNEL_VER.tar.bz2 || exit 1
fi
pkg=gcc
if [ ! -f $pkg-$GCC_VER.tar.bz2 ]; then
echo "Fetching $pkg-$GCC_VER..."
$FETCH_CMD $GNU_URL_BASE/$pkg/$pkg-$GCC_VER/$pkg-$GCC_VER.tar.bz2 || exit 1
fi
pkg=binutils
if [ ! -f $pkg-$BINUTILS_VER.tar.bz2 ]; then
echo "Fetching $pkg-$BINUTILS_VER..."
$FETCH_CMD $GNU_URL_BASE/$pkg/$pkg-$BINUTILS_VER.tar.bz2 \
|| exit 1
fi
pkg=glibc
if [ ! -f $pkg-$GLIBC_VER.tar.bz2 ]; then
echo "Fetching $pkg-$GLIBC_VER..."
$FETCH_CMD $GNU_URL_BASE/$pkg/$pkg-$GLIBC_VER.tar.bz2 || exit 1
fi
}
kernel_headers()
{
local pkg="linux-$KERNEL_VER"
cd $BUILDDIR || exit 1
tar xfj $SOURCEDISTDIR/$pkg.tar.bz2 -C $BUILDDIR || exit 1
cd $pkg || exit 1
make ARCH=$KERNEL_ARCH headers_check || exit 1
make ARCH=$KERNEL_ARCH headers_install \
INSTALL_HDR_PATH=$SYSROOT/usr || exit 1
cd $SYSROOT/usr/include && ln -s asm asm-$KERNEL_ARCH
cd $BUILDDIR && rm -rf $pkg || exit 1
touch -f $BUILDDIR/.kernel_headers_done
}
binutils()
{
local pkg="binutils-$BINUTILS_VER"
cd $BUILDDIR || exit 1
if [ ! -d $pkg ]; then
tar xfj $SOURCEDISTDIR/$pkg.tar.bz2 -C $BUILDDIR || exit 1
fi
cd $pkg || exit 1
[ ! -d build ] && mkdir build || exit 1
cd build || exit 1
../configure --prefix=$CROSSDIR \
--target=$CROSS_TARGET \
--with-sysroot=$SYSROOT \
--with-build-sysroot=$SYSROOT \
--disable-nls --enable-shared \
--disable-multilib || exit 1
make configure-host && make && make install || exit 1
# Remove unneeded stuff
for f in info man share; do
[ -d $CROSSDIR/$f ] && rm -rf $CROSSDIR/$f
done
cd $BUILDDIR && rm -rf $pkg || exit 1
touch -f $BUILDDIR/.binutils_done
}
glibc_patches()
{
# Apply some required patches for i[56]86-pc-linux-gnu and
# common targets.
$FETCH_CMD http://www.freesa.org/toolchain/patches/glibc-2.7-fixup_for_gcc43-1.patch
$FETCH_CMD http://www.freesa.org/toolchain/patches/glibc-2.7-i586_chk-1.patch
$FETCH_CMD http://www.freesa.org/toolchain/patches/glibc-2.7-libgcc_eh-1.patch
$FETCH_CMD http://svn.exactcode.de/t2/trunk/package/base/glibc/x86-fnstsw.patch
patch -Np1 -i glibc-2.7-fixup_for_gcc43-1.patch || exit 1
patch -Np1 -i glibc-2.7-i586_chk-1.patch || exit 1
patch -Np1 -i glibc-2.7-libgcc_eh-1.patch || exit 1
patch -Np1 -i x86-fnstsw.patch || exit 1
touch -f $BUILDDIR/glibc-$GLIBC_VER/.patches_done
}
gcc()
{
local stage="$1"
local pkg="gcc-$GCC_VER"
local configure_args=
local make_args=
local make_install_args=
local touch_f=
cd $BUILDDIR || exit 1
if [ ! -d $pkg ]; then
tar xfj $SOURCEDISTDIR/$pkg.tar.bz2 -C $BUILDDIR || exit 1
fi
[ ! -d $pkg/build ] && mkdir $pkg/build
cd $pkg/build || exit 1
case $stage in
full)
# gcc with support for C and C++.
touch_f=".gcc_full_done"
make_args="AS_FOR_TARGET=$CROSS_TARGET-as"
make_args="$make_args LD_FOR_TARGET=$CROSS_TARGET-ld"
make_install_args="install"
configure_args="--enable-shared --enable-threads=posix"
configure_args="$configure_args --enable-languages=c,c++"
configure_args="$configure_args --enable-__cxa_atexit"
configure_args="$configure_args --enable-tls"
;;
libgcc)
# Enough to be able to build full glibc.
make all-target-libgcc && make install-target-libgcc || exit 1
rm -rf $SYSROOT/lib/crt* || exit 1
touch -f $BUILDDIR/.gcc_libgcc_done
cd $BUILDDIR/$pkg && rm -rf build
return 0
;;
bootstrap)
# gcc bootstrap
touch_f=".gcc_bootstrap_done"
make_args="all-gcc"
make_install_args="install-gcc"
configure_args="--disable-shared --disable-libmudflap"
configure_args="$configure_args --disable-threads"
configure_args="$configure_args --disable-libssp"
configure_args="$configure_args --enable-languages=c"
;;
*) ;;
esac
../configure --prefix=$CROSSDIR \
--build=$CROSS_HOST --host=$CROSS_HOST \
--target=$CROSS_TARGET \
--with-sysroot=$SYSROOT \
--with-build-sysroot=$SYSROOT \
--disable-multilib \
${configure_args} || exit 1
env LDFLAGS_FOR_TARGET="--sysroot=$SYSROOT" \
CPPFLAGS_FOR_TARGET="--sysroot=$SYSROOT" \
make ${make_args} && make ${make_install_args} || exit 1
# Remove unneeded stuff
for f in info share man; do
[ -d $CROSSDIR/$f ] && rm -rf $CROSSDIR/$f
done
# Do not remove builddir if bootstrap, we want all objs for
# the libgcc pass.
if [ "$stage" != "bootstrap" ]; then
cd $BUILDDIR/$pkg && rm -rf build || exit 1
fi
touch -f $BUILDDIR/$touch_f
}
glibc()
{
local stage="$1"
local pkg="glibc-$GLIBC_VER"
local touch_f=
local cross_binutils="$CROSSDIR/$CROSS_TARGET/bin"
local configure_args=
local CC=
local BUILD_CC=
local RANLIB=
local AR=
cd $BUILDDIR || exit 1
if [ ! -d $pkg ]; then
tar xfj $SOURCEDISTDIR/$pkg.tar.bz2 -C $BUILDDIR || exit 1
fi
cd $pkg || exit 1
[ ! -f .patches_done ] && glibc_patches
[ ! -d build ] && mkdir build
cd build || exit 1
# NPTL support.
echo "libc_cv_forced_unwind=yes" > config.cache
echo "libc_cv_c_cleanup=yes" >> config.cache
if [ "$KERNEL_ARCH" = "i386" ]; then
echo "CFLAGS+=-march=${CROSS_TARGET%%-*} -mtune=generic" \
> configparms
fi
case $stage in
startup|full)
BUILD_CC=$CROSS_TARGET-gcc
CC=$CROSS_TARGET-gcc
AR=$CROSS_TARGET-ar
RANLIB=$CROSS_TARGET-ranlib
configure_args="${configure_args} --with-binutils=$CROSSDIR/bin"
configure_args="${configure_args} --cache-file=config.cache"
;;
headers)
CC=gcc
configure_args="${configure_args} --with-binutils=$cross_binutils"
configure_args="${configure_args} --disable-sanity-checks"
;;
*) ;;
esac
CC=${CC} BUILD_CC=${BUILD_CC} AR=${AR} RANLIB=${RANLIB} \
../configure --prefix=/usr \
--host=$CROSS_TARGET --build=$CROSS_HOST \
--enable-kernel=2.6.25 --with-tls \
--with-__thread --without-selinux \
--without-gd --without-cvs --disable-profile \
--enable-add-ons \
--with-headers=$SYSROOT/usr/include \
${configure_args} || exit 1
case $stage in
startup)
touch_f=".glibc_startup_done"
make -r -C ../csu objdir=$PWD $PWD/csu/crt1.o || exit 1
make -r -C ../csu objdir=$PWD $PWD/csu/crti.o || exit 1
make -r -C ../csu objdir=$PWD $PWD/csu/crtn.o || exit 1
mkdir -p $SYSROOT/lib || exit 1
cp -f csu/crt1.o csu/crti.o csu/crtn.o $SYSROOT/lib || exit 1
;;
headers)
touch_f=".glibc_headers_done"
make cross-compiling=yes \
install_root=$SYSROOT install-headers || exit 1
cp -v bits/stdio_lim.h $SYSROOT/usr/include/bits || exit 1
touch $SYSROOT/usr/include/gnu/stubs.h || exit 1
cp -v ../nptl/sysdeps/pthread/pthread.h \
$SYSROOT/usr/include || exit 1
if [ "$KERNEL_ARCH" = "i386" ]; then
local bitsdir="nptl/sysdeps/unix/sysv/linux/i386/bits"
cp -v ../$bitsdir/pthreadtypes.h \
$SYSROOT/usr/include/bits || exit 1
fi
;;
full)
touch_f=".glibc_full_done"
make && make install_root=$SYSROOT install || exit 1
;;
esac
if [ "$stage" != "headers" ]; then
cd $BUILDDIR/$pkg && rm -rf build || exit 1
fi
touch -f $BUILDDIR/$touch_f
}
while getopts "b:c:s:" opt; do
case $opt in
b) BUILDDIR=$OPTARG
check_path $BUILDDIR
BUILDDIR=$SANITIZED_DESTDIR
;;
c) CROSSDIR=$OPTARG
check_path $CROSSDIR
CROSSDIR=$SANITIZED_DESTDIR
;;
s) SOURCEDISTDIR=$OPTARG
check_path $SOURCEDISTDIR
SOURCEDISTDIR=$SANITIZED_DESTDIR
;;
--) shift; break;;
esac
done
shift $(($OPTIND - 1))
[ $# -ne 1 ] && usage
if [ -z "$1" ]; then
echo "ERROR: missing target triplet."
exit 1
else
CROSS_TARGET=$1
case $CROSS_TARGET in
i686-pc-linux-gnu)
KERNEL_ARCH=i386
CROSS_HOST="$(uname -m)-unknown-linux-gnu"
;;
x86-64-unknown-linux-gnu)
KERNEL_ARCH=x86_64
CROSS_HOST="$(uname -m)-pc-linux-gnu"
;;
*)
echo "ERROR: unknown target triplet $CROSS_TARGET."
exit 1
;;
esac
fi
CROSSDIR=$CROSSDIR/$CROSS_TARGET
SYSROOT=$CROSSDIR/sysroot
[ ! -d $SYSROOT/usr ] && mkdir -p $SYSROOT/usr
[ ! -d $BUILDDIR ] && mkdir -p $BUILDDIR
[ ! -d $SOURCEDISTDIR ] && mkdir -p $SOURCEDISTDIR
unset CFLAGS CXXFLAGS CC CXX AR AS RANLIB LD_STRIP
unset LD_LIBRARY_PATH LD_RUN_PATH
export PATH="$CROSSDIR/bin:/bin:/usr/bin"
fetch_sources
if [ ! -f $BUILDDIR/.kernel_headers_done ]; then
echo "Installing kernel headers..."
kernel_headers
fi
if [ ! -f $BUILDDIR/.binutils_done ]; then
echo "Installing binutils..."
binutils
fi
if [ ! -f $BUILDDIR/.glibc_headers_done ]; then
echo "Installing glibc headers..."
glibc headers
fi
if [ ! -f $BUILDDIR/.gcc_bootstrap_done ]; then
echo "Installing gcc (bootstrap)..."
gcc bootstrap
fi
if [ ! -f $BUILDDIR/.glibc_startup_done ]; then
echo "Installing glibc (startup)..."
glibc startup
fi
if [ ! -f $BUILDDIR/.gcc_libgcc_done ]; then
echo "Installing gcc (libgcc)..."
gcc libgcc
fi
if [ ! -f $BUILDDIR/.glibc_full_done ]; then
echo "Installing glibc (full)..."
glibc full
fi
if [ ! -f $BUILDDIR/.gcc_full_done ]; then
echo "Installing gcc (full)..."
gcc full
fi
[ -d $BUILDDIR ] && rm -rf $BUILDDIR
echo "Finished. Toolchain for $CROSS_TARGET at $CROSSDIR."
exit 0