#!/usr/bin/env bash
# $Id: bootstrap 2 2026-07-28 13:27:06Z peter $
#
# bootstrap --- regenerate the autotools machinery for dudhya.
#
# Copyright (C) 2026 Péter Felecan
# Assisted by Claude Sonnet 5 (Anthropic)
#
# 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.
#
# Run this once after a fresh checkout (or after editing configure.ac
# / Makefile.am files) to produce 'configure' and the 'Makefile.in'
# files. Then run ./configure as usual.

set -euo pipefail

# Refuse to run from anywhere other than the project root.
if [[ ! -f configure.ac ]]
then
{
	echo "bootstrap: must be run from the project root (configure.ac not found)" >&2
	exit 1
}
fi

# --install copies (or symlinks) auxiliary build files; --symlink
# uses symlinks during development so that updates to system-wide
# autotools data are picked up without re-bootstrapping. --force is
# required: configure.ac reads VERSION via m4_esyscmd_s at
# regeneration time, but autoreconf's own staleness check only looks
# at configure.ac/aclocal.m4 timestamps, not at VERSION --- without
# --force, a VERSION bump with no other configure.ac change would
# leave a stale PACKAGE_VERSION baked into an unchanged 'configure'.
exec autoreconf --install --symlink --force --verbose
