#!/bin/sh
#
# Simple script to get started from a fresh git checkout.
#
# Copyright © 2011-2012, 2021-2025 Nick Bowler
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

scriptname=$0

err() {
        printf '%s: %s\n' "$scriptname" "$*" 1>&2
}

die() {
        err "$@"
        exit 1
}

: "${AUTORECONF=autoreconf}"
: "${AUTOMAKE=automake}"
: "${GIT=git}"

$GIT submodule update --init || err "Failed to update submodules from git."

# Punt some automake-generated files so that Gentoo's wrapper script doesn't
# try to detect the automake version in use.
rm -f Makefile.in aclocal.m4
$AUTORECONF -fis || exit

amdir=`$AUTOMAKE --print-libdir`
if test -f "$amdir/INSTALL"; then
  ln -sf "$amdir/INSTALL" INSTALL
fi
