#!/bin/bash
[% c("var/set_default_env") -%]
[% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
distdir=/var/tmp/dist/[% project %]
mkdir -p /var/tmp/build
tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.[% c('compress_tar') %]
cd /var/tmp/build/[% project %]-[% c('version') %]
[% IF c("var/windows") -%]
  export CC=[% c("arch") %]-w64-mingw32-cc
[% END -%]
./autogen.sh
./configure [% c("var/configure_opt") %] --disable-libevent-regress --disable-samples --disable-openssl --prefix=$distdir
[% IF c("var/macos") -%]
  [% c("var/faketime_setup") %]
[% END -%]
make -j[% c("num_procs") %]
make install
cp LICENSE $distdir/
cd /var/tmp/dist
[% c('tar', {
        tar_src => [ project ],
        tar_args => '-caf ' _ dest_dir _ '/' _ c('filename'),
    }) %]
