# Available variables
# $BOSH_COMPILE_TARGET - where this package & spec'd source files are available
# $BOSH_INSTALL_TARGET - where you copy/install files to be included in package

set -e # exit immediately if a simple command exits with a non-zero status
set -u # report the usage of uninitialized variables

# Detect # of CPUs so make jobs can be parallelized
CPUS=$(grep -c ^processor /proc/cpuinfo)

export HOME=/var/vcap
export LIBYAML_VERSION=`ls -r libyaml/yaml-* | sed 's/libyaml\/yaml-\(.*\)\.tar.gz/\1/' | head -1`

tar xfz libyaml/yaml-$LIBYAML_VERSION.tar.gz
cd yaml-$LIBYAML_VERSION
./configure --prefix=${BOSH_INSTALL_TARGET}
make -j${CPUS} && make install
ldconfig
