-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
48 lines (35 loc) · 1.19 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
# NOTE: in this file tab indentation is used.
# Otherwise .RECIPEPREFIX would have to be set.
#
# create variables
#
subscription_lists := official.json
# subscriptions are all json file except those in $(subscription_lists)
all_json_files := $(wildcard *.json)
subscriptions := $(filter-out $(subscription_lists),$(all_json_files))
#
# define targets
#
# set "check" to be the default target
.DEFAULT_GOAL := check
# all checks and their order of execution
checks := check_json_validity \
check_duplicate_lines
.PHONY: check test
.PHONY: $(checks)
check test: $(checks)
check_json_validity:
@for file in $(all_json_files) ; do \
echo -n "$$file: "; (cat official.json | python -m json.tool > /dev/null && echo "Valid JSON") || echo "Invalid JSON" ; \
done
# _________________________
# check for duplicate lines
#
duplicate_rules := $(shell egrep -ho '\{.*\}' $(subscriptions) | sort | uniq -d)
duplicate_rules_quoted := $(addprefix ',$(addsuffix ',$(duplicate_rules)))
check_duplicate_lines:
@# go through all duplicates and report in which subscription files they are
@for rule in $(duplicate_rules_quoted) ; do \
echo '___Duplicate rule___' ; \
fgrep -nHT $$rule $(subscriptions) ; \
done