From 06ec2066442f15e570fae56310545be9b208cced Mon Sep 17 00:00:00 2001 From: Gustav Eek Date: Tue, 20 Aug 2024 09:30:45 +0200 Subject: [PATCH] [tools] Create makefiles for installation and testing --- tools/Makefile | 46 ++++++++++++++++++++++++++++++++++++++++++++ tools/tests/Makefile | 0 2 files changed, 46 insertions(+) create mode 100644 tools/Makefile create mode 100644 tools/tests/Makefile diff --git a/tools/Makefile b/tools/Makefile new file mode 100644 index 0000000..0bd8595 --- /dev/null +++ b/tools/Makefile @@ -0,0 +1,46 @@ +SRC = a2cho cho2tex +TRG = $(HOME)/.local/bin + +.PHONY: all install uninstall test clean + +all: + +# Installation + +install: $(SRC) + /usr/bin/install -m 755 -t "$(TRG)" $^ + +uninstall: + /usr/bin/rm -f $(addprefix $(TRG)/, $(SRC)) + /usr/bin/rmdir --ignore-fail-on-non-empty $(TRG) + +# Tests + +ifdef XDG_RUNTIME_DIR + RUN = $(XDG_RUNTIME_DIR) +else + RUN = /tmp +endif + +TXT = $(notdir $(basename $(wildcard tests/*.txt))) +CHO = $(notdir $(basename $(wildcard tests/*.cho))) + +print: + echo $(RUN) + echo $(TXT) + echo $(join $(TXT), $(CHO)) + + +test: + sts=0; \ + for f in $(TXT); do \ + echo a2cho: $$f ; \ + bash a2cho < tests/$$f.txt > $(RUN)/$$f.cho; \ + diff tests/$$f.cho $(RUN)/$$f.cho; \ + sts=$$(( $$sts + $$? )); \ + done; \ + exit $$sts + +# Cleaning + +clean: diff --git a/tools/tests/Makefile b/tools/tests/Makefile new file mode 100644 index 0000000..e69de29 -- 2.39.2