#!/bin/bash
[% c("var/set_default_env") -%]
distdir=/var/tmp/dist/[% project %]
[% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]

mkdir -p /var/tmp/dist

tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
export PATH="/var/tmp/dist/binutils/bin:$PATH"

mkdir -p /var/tmp/build
tar -C /var/tmp/build -xf $rootdir/[% c('input_files_by_name/elfutils') %]

cd /var/tmp/build/[% project %]-[% c("version") %]
./configure --prefix="$distdir"
make -j[% c("buildconf/num_procs") %]
make install

cd /var/tmp/dist
[% c('tar', {
        tar_src => [ project ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
        }) %]
