#!/usr/bin/env bash
# $Id: bootstrap 82 2026-08-15 11:13:33Z peter $
#
# Copyright (C) 2026 Peter 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.
#
# bootstrap — regenerate autotools infrastructure for the svah project.
#
# Run this script once after extracting a fresh source archive, or
# whenever configure.ac or Makefile.am has changed and the autotools
# generated files (configure, Makefile.in, config.guess, ...) are
# absent or out of date.
#
# Typical usage:
#
#   After cloning or extracting a new archive:
#     ./bootstrap
#     ./configure
#     make
#     make check
#
#   Clean rebuild from scratch:
#     make maintainer-clean   (only if a Makefile exists already)
#     ./bootstrap
#     ./configure
#     make check
#
#   Integrating a new delivery archive into an existing build tree:
#     tar xJf svah-X.Y.Z.tar.xz
#     ./bootstrap             ← always run bootstrap first
#     make maintainer-clean
#     ./bootstrap
#     ./configure
#     make check
#
# Rationale for "bootstrap before maintainer-clean" when integrating:
#   make maintainer-clean triggers a Makefile remake. If configure.ac
#   or Makefile.am changed (new archive), make attempts to regenerate
#   Makefile.in via automake, which requires config.guess, config.sub,
#   depcomp and test-driver. If those files were removed by a previous
#   maintainer-clean, the remake fails. Running bootstrap first
#   reinstates these files so that make maintainer-clean can proceed.

set -e

autoreconf --install --symlink

echo ""
echo "Bootstrap complete. Next steps:"
echo "  ./configure"
echo "  make"
echo "  make check"
