Debian Codegraph @

cleaners/Makefile

raw
1 # Copyright (C) 2008-2026 Andrew Ziem. All rights reserved.
2 # License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
3 # This is free software: You are free to change and redistribute it.
4 # There is NO WARRANTY, to the extent permitted by law.
5
6 # On some systems if not explicitly given, make uses /bin/sh, so 'make pretty' fails.
7 SHELL != command -v bash
8
9 .PHONY: pretty tests require-xmllint
10
11 require-xmllint:
12 command -v xmllint >/dev/null 2>&1 || { echo "ERROR: Missing xmllint. APT users, try: sudo apt install libxml2-utils"; exit 1; }
13
14 pretty: require-xmllint
15 shopt -s nullglob; \
16 for f in *xml; \
17 do \
18 xmllint --format "$$f" > "$$f.pretty"; \
19 diff=`diff -q "$$f" "$$f.pretty" | grep -o differ`; \
20 [[ "$$diff" != "differ" ]] && echo "$$f" unchanged && rm -- "$$f.pretty"; \
21 [[ -s "$$f.pretty" ]] && echo "$$f" is pretty now!!! && mv -- "$$f.pretty" "$$f"; \
22 done; \
23 exit 0
24
25 tests: require-xmllint
26 lintrc=0; \
27 shopt -s nullglob; \
28 for f in *.xml; \
29 do \
30 xmllint --noout --schema ../doc/cleaner_markup_language.xsd "$$f"; \
31 : 'In case of an error, delay exit, so we can see all errors.'; \
32 lintrc=$$(($$lintrc + $$?)); \
33 done; \
34 exit $$lintrc