Template
build: add autotools bootstrap skeleton with C23 flags
This commit is contained in:
+24
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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], [[email protected]])
|
||||
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
|
||||
@@ -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
|
||||
+24
@@ -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 <stdio.h>
|
||||
|
||||
/* 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;
|
||||
}
|
||||
Executable
+56
@@ -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>' -
|
||||
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"
|
||||
Vendored
Reference in New Issue
Block a user