From 990a5d5e79b7f30abda864286a5a7307912a75ee Mon Sep 17 00:00:00 2001 From: huntedbytheirs Date: Fri, 28 Aug 2026 20:34:50 -0400 Subject: [PATCH] build: add release/debug profiles (-O2 / -g2) --- Makefile.am | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Makefile.am b/Makefile.am index 7672d04..239821d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,3 +13,25 @@ EXTRA_DIST = tests/run.sh scripts/build-static.sh .PHONY: static static: $(SHELL) "$(srcdir)/scripts/build-static.sh" + +# Release/debug build profiles (explicit opt-in; `make` alone is unchanged). +# +# Mechanism: CFLAGS is passed on the recursive make COMMAND LINE. Automake's +# compile rule ends with `$(AM_CFLAGS) $(CFLAGS)`, so a command-line CFLAGS +# overrides configure's `-g -O2` default while AM_CFLAGS (-std=c23 -Wall +# -Wextra -Wpedantic) is always kept. No configure.ac churn, no default +# build impact. Both targets clean first so a previous profile's objects +# can never be reused as a fresh build. +# +# release: -O2 -DNDEBUG, no -g, then the binary is stripped (needs binutils +# `strip` on PATH). +# debug: -g2 only, no -O/-O2, no NDEBUG (default CFLAGS are overridden). +.PHONY: release debug +release: + $(MAKE) clean + $(MAKE) CFLAGS="-O2 -DNDEBUG" + strip src/stupidtools + +debug: + $(MAKE) clean + $(MAKE) CFLAGS="-g2"