💾 Archived View for ew.srht.site › en › 2022 › 20221219-redo-4.gmi captured on 2023-11-14 at 07:53:42. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
Part 2: Automatic Recording of Dependencies on Header Files
Part 3: CFLAGS and friends, config.sh, compile.do
Part 4: CFLAGS and friends, env/VAR, default.run.do
Part 5: Auto-update BUILDDATE in version.h
Part 6: The yacc/bison problem: one call produces two artifacts
Part 7: Test: Generator for N source files
My code featured in this series can be found at
https://git.sr.ht/~ew/ew.redo/
In part 3 I detailed one option to deal with an equivalent of CFLAGS et al. makefile variables. I could have stopped there, but I did not like, that "compile" and all equivalent scripts sourcing config.sh were going to be rebuild, even if they didn't pick up on a given change. Variables may be used separately in different parts of the build. So I wanted to have each Variable in a separate file (which can be versioned), and compile is exactly dependant only on CC and CFLAGS and not on LIBS or other existing, but unused variables. Now the plan is quite different:
So let's look at CFLAGS and trace it's way through the build. The value of CFLAGS is the content of the file env/CFLAGS:
-O2 -g -Wpedantic -Wall
CFLAGS is referenced in the template compile.in
# compile.in %%CC%% %%CFLAGS%% -c -MMD -MF "$2.d" -o "$3" "$2.c" read DEPS < "$2.d" redo-ifchange ${DEPS#*:}
The "%%VAR%%" Notation is inspired from the documentation of Avery Pennaruns implementation of redo. This template is transformed into a .run script calling default.run.do:
#!/bin/bash # from $target.in create $target.run, using env/VAR files. if [ -e "$2.in" ] then # find out, which env/VARs are used by $2.in declare -g VARLIST="" for V in $( cd ./env || exit 99; ls -1 | grep -v '~