-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
78 lines (66 loc) · 2.38 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# GNU Make syntax used below
OUTFILE = latest.json
PRODUCT = ipm
CONVERT = ./tools/convert.sh
JSONSH_PATH = ./JSON.sh/
JSONSH = JSON.sh
INPUTS = $(shell ls -1 "$(PRODUCT)"/*.md)
CURRENT_VERSION= ""
EGREP = grep -E
ASPELL = aspell
ASPELL_LANG_ARG = en
ASPELL_LANG_ENV = en_US.UTF-8
# Must have a path component, goes to homedir otherwise
ASPELL_DICT = ./relnotes.dict
ASPELL_OUT_NOTERRORS = (^[ \t]*[\*\@]|^$$)
all: $(OUTFILE)
check: spellcheck check-json
clean-checked:
rm -f $(addsuffix .spellchecked, $(INPUTS)) $(OUTFILE).checkedvalid
clean: clean-checked
rm -f $(OUTFILE)
# Interactive aspell leaves older copies of checked files; with Git we do not need them:
rm -f $(addsuffix .bak, $(INPUTS))
$(OUTFILE): $(INPUTS)
$(CONVERT) "$(CURRENT_VERSION)" "$(PRODUCT)" "$(OUTFILE)"
check-json: $(OUTFILE).checkedvalid
$(OUTFILE).checkedvalid: $(OUTFILE)
@rm -f "$@"
@PATH="$(JSONSH_PATH):/usr/share/fty/scripts:$$PATH" ; export PATH; \
command -v JSON.sh \
&& { echo "INFO: Will use the copy of JSON.sh in the PATH found above to check '$<' file structure"; } \
|| { echo "WARNING: Seems you have no JSON.sh in the PATH; is the submodule checked out?" >&2; } ; \
$(JSONSH) -N -P < "$<" >/dev/null \
&& echo " JSON-OK $<" >&2 \
|| { echo " JSON-FAIL $<" >&2 ; exit 1; }
@touch "$@"
spellcheck: $(addsuffix .spellchecked, $(INPUTS))
# Ported from NUT
%.spellchecked: %
@rm -f "$@"
@test -s "$<"
@echo " SPELLCHECK $<" ; \
OUT="`(sed 's,^\(.*\)$$, \1,' | \
LANG=$(ASPELL_LANG_ENV) LC_ALL=$(ASPELL_LANG_ENV) \
$(ASPELL) -a -M -p "$(ASPELL_DICT)" \
-d "$(ASPELL_LANG_ARG)" --lang="$(ASPELL_LANG_ARG)" \
--ignore-accents --encoding=utf-8 \
) < "$<"`" \
&& { if test -n "$$OUT" ; then OUT="`echo "$$OUT" | $(EGREP) -b -v '$(ASPELL_OUT_NOTERRORS)' `" ; fi; \
test -z "$$OUT" ; } \
|| { RES=$$? ; \
echo "FAILED : Aspell reported errors here:" >&2 \
&& echo "----- vvv" >&2 \
&& echo "$$OUT" >&2 \
&& echo "----- ^^^" >&2 ; \
exit $$RES; }
@touch "$@"
# Note: here we do not touch any files
spellcheck-interactive: $(INPUTS)
@for F in $^ ; do \
echo " SPELLCHECK-INTERACTIVE $$F" ; \
LANG=$(ASPELL_LANG_ENV) LC_ALL=$(ASPELL_LANG_ENV) \
$(ASPELL) -c -M -p "$(ASPELL_DICT)" \
-d "$(ASPELL_LANG_ARG)" --lang="$(ASPELL_LANG_ARG)" \
--ignore-accents --encoding=utf-8 "$$F" ; \
done