#!/bin/bash
function print_section() {
echo "-----------------------"
echo " $1"
echo "-----------------------"
}
function echocall() {
echo "$@"
"$@"
}
function unpacklib() {
local lib=$1
mkdir -p $lib
cd $lib
echocall $AR -x "$prefix/lib/lib$lib.a"
cd ..
}
function download() {
mkdir -p download
cd download
for package in $packages; do
if [ ! -f "$package.done" ]; then
print_section "download $package"
local vu=url_$package
local vt=tar_$package
local vs=sha_$package
wget -c "${!vu}"
echo "${!vs} ${!vt}" | sha256sum -c
touch "$package.done"
fi
done
cd ..
}
function unpack() {
mkdir -p unpack
cd unpack
for package in $packages; do
if [ ! -f "$package.done" ]; then
print_section "unpack $package"
local v=tar_$package
tar -xf ../download/${!v}
touch "$package.done"
fi
done
cd ..
}
function build() {
bits=$1
host=$2
toolchain $host
prefix="$ROOT/usr-$bits"
export CFLAGS="$ADDCFLAGS -I$prefix/include"
export CPPFLAGS="-I$prefix/include"
export LDFLAGS="-L$prefix/lib"
export PKG_CONFIG_PATH="$prefix/lib/pkgconfig"
export PKG_CONFIG_LIBDIR="$prefix/lib/pkgconfig"
mkdir -p build-$bits
cd build-$bits
for package in $packages $newpackages; do
if [ ! -f "$package.done" ]; then
print_section "build-$bits $package"
local v=dir_$package
srcdir="$ROOT/unpack/${!v}"
mkdir -p $package
cd $package
build_$package
cd ..
touch "$package.done"
fi
done
cd ..
}