#!/bin/bash
[% c("var/set_default_env") -%]
mkdir /var/tmp/dist
distdir=/var/tmp/dist/[% c("var/distdir") %]
[% IF c("var/linux"); GET c("var/set_hardened_build_flags"); END %]

tar xf [% project %]-[% c("version") %].tar.xz
cd [% project %]-[% c("version") %]
./configure --prefix=$distdir [% c('var/configure_opt') %]
# Jessie's makeinfo is too old, and it makes the build fail even if installed.
# So we replace the makeinfo calls with `true`.
# Trick from https://stackoverflow.com/a/56159871
make -j[% c("num_procs") %] MAKEINFO=true
make install MAKEINFO=true

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