-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
108 lines (93 loc) · 2.35 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
##############
# parameters #
##############
# do you want to see the commands executed ?
DO_MKDBG:=0
# do you want dependency on the Makefile itself ?
DO_ALLDEP:=1
# do you want to check bash syntax?
DO_CHECK_SYNTAX:=1
# do you want to run mdl on md files?
DO_MD_MDL:=1
# do spell check on all?
DO_MD_ASPELL:=1
########
# code #
########
ALL:=
# silent stuff
ifeq ($(DO_MKDBG),1)
Q:=
# we are not silent in this branch
else # DO_MKDBG
Q:=@
#.SILENT:
endif # DO_MKDBG
ALL_SH:=$(shell find scripts -type f -and -name "*.bash")
ALL_STAMP:=$(addprefix out/, $(addsuffix .stamp, $(ALL_SH)))
MD_SRC:=$(shell find exercises -type f -and -name "*.md")
MD_BAS:=$(basename $(MD_SRC))
MD_MDL:=$(addprefix out/,$(addsuffix .mdl,$(MD_BAS)))
MD_ASPELL:=$(addprefix out/,$(addsuffix .aspell,$(MD_BAS)))
ifeq ($(DO_CHECK_SYNTAX),1)
ALL+=$(ALL_STAMP)
endif # DO_CHECK_SYNTAX
ifeq ($(DO_MD_MDL),1)
ALL+=$(MD_MDL)
endif # DO_MD_MDL
ifeq ($(DO_MD_ASPELL),1)
ALL+=$(MD_ASPELL)
endif # DO_MD_ASPELL
#########
# rules #
#########
.PHONY: all
all: $(ALL)
@true
.PHONY: check
check:
$(info doing [$@])
$(Q)git grep "<<" scripts | grep -v "'COMMENT'" | grep -v "<<<" | grep -v multi_line_comment.bash || exit 0
.PHONY: debug
debug:
$(info ALL_SH is $(ALL_SH))
$(info ALL_STAMP is $(ALL_STAMP))
$(info MD_SRC is $(MD_SRC))
$(info MD_BAS is $(MD_BAS))
$(info MD_ASPELL is $(MD_ASPELL))
$(info MD_MDL is $(MD_MDL))
.PHONY: first_line_stats
first_line_stats:
$(Q)head -1 -q $(ALL_SH) | sort | uniq -c
.PHONY: clean
clean:
$(Q)rm -f $(ALL)
.PHONY: clean_hard
clean_hard:
$(Q)git clean -qffxd
.PHONY: spell_many
spell_many:
$(info doing [$@])
$(Q)aspell_many.sh $(MD_SRC)
############
# patterns #
############
$(ALL_STAMP): out/%.stamp: % .shellcheckrc
$(info doing [$@])
$(Q)shellcheck --severity=error --shell=bash --external-sources --source-path="$$HOME" $<
$(Q)pymakehelper touch_mkdir $@
$(MD_MDL): out/%.mdl: %.md .mdlrc .mdl.style.rb
$(info doing [$@])
$(Q)GEM_HOME=gems gems/bin/mdl "$<"
$(Q)mkdir -p $(dir $@)
$(Q)touch "$@"
$(MD_ASPELL): out/%.aspell: %.md .aspell.conf .aspell.en.prepl .aspell.en.pws
$(info doing [$@])
$(Q)aspell --conf-dir=. --conf=.aspell.conf list < "$<" | pymakehelper error_on_print sort -u
$(Q)pymakehelper touch_mkdir $@
##########
# alldep #
##########
ifeq ($(DO_ALLDEP),1)
.EXTRA_PREREQS+=$(foreach mk, ${MAKEFILE_LIST},$(abspath ${mk}))
endif # DO_ALLDEP