From 238db8b484db638311ffdba039d7e6979a1f9881 Mon Sep 17 00:00:00 2001 From: huntedbytheirs Date: Fri, 28 Aug 2026 19:42:33 -0400 Subject: [PATCH] build: add autotools bootstrap skeleton with C23 flags --- .gitignore | 24 +++++++++++++++++++ Makefile.am | 8 +++++++ configure.ac | 27 ++++++++++++++++++++++ examples/.gitkeep | 0 include/.gitkeep | 0 src/Makefile.am | 6 +++++ src/main.c | 24 +++++++++++++++++++ tests/run.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++ thirdparty/.gitkeep | 0 9 files changed, 145 insertions(+) create mode 100644 Makefile.am create mode 100644 configure.ac create mode 100644 examples/.gitkeep create mode 100644 include/.gitkeep create mode 100644 src/Makefile.am create mode 100644 src/main.c create mode 100755 tests/run.sh create mode 100644 thirdparty/.gitkeep diff --git a/.gitignore b/.gitignore index cd531cf..b3bfb8a 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,27 @@ Module.symvers Mkfile.old dkms.conf +# ---> Autotools (all generated by autoreconf/configure; only the .am/.ac +# inputs are tracked in git) +configure +config.log +config.status +aclocal.m4 +autom4te.cache/ +Makefile +Makefile.in +compile +depcomp +install-sh +missing +test-driver +.deps/ +.dirstamp +test-suite.log +*.trs +*.log + +# ---> stupidtools binaries (built, never committed) +/stupidtools +/src/stupidtools + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..d010198 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,8 @@ +# Top-level Makefile.am: recursion into src/ plus the test harness. +# `make check` runs tests/run.sh through automake's parallel test harness +# (genuinely executed - the harness propagates the script's exit code). + +SUBDIRS = src + +TESTS = tests/run.sh +EXTRA_DIST = tests/run.sh diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..21db21a --- /dev/null +++ b/configure.ac @@ -0,0 +1,27 @@ +# configure.ac - stupidtools bootstrap (autotools, C23). +# +# This is the *bootstrap* build only: stupidtools will later generate its +# own ./configure (self-hosting, todo 23). Only Makefile.am inputs are +# tracked in git; configure/Makefile* are generated and gitignored. + +AC_PREREQ([2.71]) +AC_INIT([stupidtools], [1.0.0], [huntedbytheirs@example.com]) +AM_INIT_AUTOMAKE([foreign subdir-objects]) +AC_CONFIG_SRCDIR([src/main.c]) +AC_PROG_CC + +# Require a compiler that actually accepts C23 (ISO/IEC 9899:2024). +# -std=c23: GCC >= 14, Clang >= 18. Never -std=c2y (next draft, not ratified). +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -std=c23 -Werror" +AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L +#error "C23 (__STDC_VERSION__ >= 202311L) required" +#endif]], + [[_Static_assert(1, "ok");]])], + [], + [AC_MSG_ERROR([a C compiler with C23 support (GCC >= 14 or Clang >= 18) is required])]) +CFLAGS="$save_CFLAGS" + +AC_CONFIG_FILES([Makefile src/Makefile]) +AC_OUTPUT diff --git a/examples/.gitkeep b/examples/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/include/.gitkeep b/include/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..79c6d78 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,6 @@ +# src/Makefile.am - build the stupidtools binary (C23, strict warnings). + +AM_CFLAGS = -std=c23 -Wall -Wextra -Wpedantic + +bin_PROGRAMS = stupidtools +stupidtools_SOURCES = main.c diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..68906bd --- /dev/null +++ b/src/main.c @@ -0,0 +1,24 @@ +/* + * stupidtools - the GNU AutoTools replacement for the moronic. + * + * Copyright (c) 2026 huntedbytheirs + * SPDX-License-Identifier: BSD-3-Clause + * + * Minimal skeleton: reports the version. Real CLI parsing (todo 4) + * replaces this stub. + */ + +#include + +/* Must match AC_INIT version in configure.ac (todo 1: 1.0.0). */ +#define STUPIDTOOLS_VERSION "1.0.0" + +int +main(int argc, char **argv) +{ + (void)argc; + (void)argv; + + printf("stupidtools %s\n", STUPIDTOOLS_VERSION); + return 0; +} diff --git a/tests/run.sh b/tests/run.sh new file mode 100755 index 0000000..90a3ea8 --- /dev/null +++ b/tests/run.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# tests/run.sh - test runner for stupidtools (skeleton). +# +# Grows with the project; today it proves the toolchain works end to end: +# the binary must exist, run, and report its version. +# +# POSIX sh only (dash/bash/zsh safe). Fails fast on the first failed check. + +TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) || { + echo "FAIL: cannot resolve project root" >&2 + exit 1 +} +BIN="$TOP_DIR/src/stupidtools" + +TESTS_RUN=0 +TESTS_FAILED=0 + +pass() { + TESTS_RUN=$((TESTS_RUN + 1)) + printf 'ok %d - %s\n' "$TESTS_RUN" "$1" +} + +fail() { + TESTS_RUN=$((TESTS_RUN + 1)) + TESTS_FAILED=$((TESTS_FAILED + 1)) + printf 'not ok %d - %s\n' "$TESTS_RUN" "$1" >&2 +} + +# --- 1. the built binary must exist and be executable ------------------- +if [ -x "$BIN" ]; then + pass "binary exists and is executable: $BIN" +else + fail "binary missing: $BIN (run 'make' first)" + printf 'FAILED: %d/%d checks failed\n' "$TESTS_FAILED" "$TESTS_RUN" >&2 + exit 1 +fi + +# --- 2. --version must exit 0 and print exactly 'stupidtools ' - +version_out= +if version_out=$("$BIN" --version 2>&1); then + if [ "$version_out" = "stupidtools 1.0.0" ]; then + pass "--version reports: $version_out" + else + fail "--version output unexpected: '$version_out' (want 'stupidtools 1.0.0')" + fi +else + rc=$? + fail "--version exited non-zero (rc=$rc): $version_out" +fi + +# --- summary ------------------------------------------------------------- +if [ "$TESTS_FAILED" -ne 0 ]; then + printf 'FAILED: %d/%d checks failed\n' "$TESTS_FAILED" "$TESTS_RUN" >&2 + exit 1 +fi +printf 'All %d checks passed.\n' "$TESTS_RUN" diff --git a/thirdparty/.gitkeep b/thirdparty/.gitkeep new file mode 100644 index 0000000..e69de29