commit 5210648cb2884e0211bebbfdc780df590d425a0c (patch)
parent 7855d37e65d51d3449ea02d86ded49be66ff5d6a
Author: Alex Karle <alex@alexkarle.com>
Date: Thu, 2 Dec 2021 10:18:53 -0500
make: Add recipe to run individual/all days
This makes it _much_ easier to verify that changes are the same between
the python and C solutions.
Diffstat:
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,4 +1,15 @@
+# Makefile
+#
+# Targets:
+#
+# build: builds all C executables
+#
+# run: runs all found solutions for $DAY
+# (default all, example: make DAY=1 run)
+#
+# clean: removes all C executables
CFLAGS = -g -O2 -Wall -Wpedantic -Wextra
+DAY = *
TARGETS = \
1/c/a \
@@ -6,8 +17,16 @@ TARGETS = \
2/c/a \
2/c/b \
-.PHONY: all
-all: $(TARGETS)
+.PHONY: build
+build: $(TARGETS)
+
+.PHONY: run
+run: build
+ @for d in $(DAY)/; do \
+ for sol in $${d}py/a.py $${d}c/a $${d}py/b.py $${d}c/b; do \
+ [ -e $$sol ] && printf "%-10s %s\n" "$$sol:" `$$sol < $$d/input`; \
+ done; \
+ done
.PHONY: clean
clean:
diff --git a/README.md b/README.md
@@ -1,5 +1,5 @@
Advent of Code 2021
--------------------
+===================
This year I'm attempting at least some of the earlier problems
in C as well as Python (need the dynamic language to get that
super speedy private leaderboard time!).
@@ -10,3 +10,13 @@ If you want to discuss any of my solutions, shoot me an email
at my public inbox: [~akarle/public-inbox@lists.sr.ht][mail]
[mail]: mailto:~akarle/public-inbox@lists.sr.ht
+
+Running
+-------
+The GNU Makefile builds the C code and runs both C and Python
+solutions via the `build` and `run` targets respectively. `run`
+takes an optional parameter `DAY` that can limit the solutions
+run:
+
+ make run # runs all
+ make DAY=1 run # runs day 1