Switching to GitHub-defined variables
[rnaseq-cwl-training.git] / Makefile
1 ## ========================================
2 ## Commands for both workshop and lesson websites.
3
4 # Settings
5 MAKEFILES=Makefile $(wildcard *.mk)
6 JEKYLL=jekyll
7 PARSER=bin/markdown_ast.rb
8 DST=_site
9
10 # Controls
11 .PHONY : commands clean files
12 all : commands
13
14 ## commands         : show all commands.
15 commands :
16         @grep -h -E '^##' ${MAKEFILES} | sed -e 's/## //g'
17
18 ## serve            : run a local server.
19 serve : lesson-rmd
20         ${JEKYLL} serve
21
22 ## site             : build files but do not run a server.
23 site : lesson-rmd
24         ${JEKYLL} build
25
26 # repo-check        : check repository settings.
27 repo-check :
28         @bin/repo_check.py -s .
29
30 ## clean            : clean up junk files.
31 clean :
32         @rm -rf ${DST}
33         @rm -rf .sass-cache
34         @rm -rf bin/__pycache__
35         @find . -name .DS_Store -exec rm {} \;
36         @find . -name '*~' -exec rm {} \;
37         @find . -name '*.pyc' -exec rm {} \;
38
39 ## clean-rmd        : clean intermediate R files (that need to be committed to the repo).
40 clear-rmd :
41         @rm -rf ${RMD_DST}
42         @rm -rf fig/rmd-*
43
44 ## ----------------------------------------
45 ## Commands specific to workshop websites.
46
47 .PHONY : workshop-check
48
49 ## workshop-check   : check workshop homepage.
50 workshop-check :
51         @bin/workshop_check.py .
52
53 ## ----------------------------------------
54 ## Commands specific to lesson websites.
55
56 .PHONY : lesson-check lesson-rmd lesson-files lesson-fixme
57
58 # RMarkdown files
59 RMD_SRC = $(wildcard _episodes_rmd/??-*.Rmd)
60 RMD_DST = $(patsubst _episodes_rmd/%.Rmd,_episodes/%.md,$(RMD_SRC))
61
62 # Lesson source files in the order they appear in the navigation menu.
63 MARKDOWN_SRC = \
64   index.md \
65   CONDUCT.md \
66   setup.md \
67   $(wildcard _episodes/*.md) \
68   reference.md \
69   $(wildcard _extras/*.md) \
70   LICENSE.md
71
72 # Generated lesson files in the order they appear in the navigation menu.
73 HTML_DST = \
74   ${DST}/index.html \
75   ${DST}/conduct/index.html \
76   ${DST}/setup/index.html \
77   $(patsubst _episodes/%.md,${DST}/%/index.html,$(wildcard _episodes/*.md)) \
78   ${DST}/reference/index.html \
79   $(patsubst _extras/%.md,${DST}/%/index.html,$(wildcard _extras/*.md)) \
80   ${DST}/license/index.html
81
82 ## lesson-rmd       : convert Rmarkdown files to markdown
83 lesson-rmd: $(RMD_SRC)
84         @bin/knit_lessons.sh $(RMD_SRC)
85
86 ## lesson-check     : validate lesson Markdown.
87 lesson-check :
88         @bin/lesson_check.py -s . -p ${PARSER}
89
90 ## lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace.
91 lesson-check-all :
92         @bin/lesson_check.py -s . -p ${PARSER} -l -w
93
94 ## lesson-figures   : re-generate inclusion displaying all figures.
95 lesson-figures :
96         @bin/extract_figures.py -p ${PARSER} ${MARKDOWN_SRC} > _includes/all_figures.html
97
98 ## unittest         : run unit tests on checking tools.
99 unittest :
100         python bin/test_lesson_check.py
101
102 ## lesson-files     : show expected names of generated files for debugging.
103 lesson-files :
104         @echo 'RMD_SRC:' ${RMD_SRC}
105         @echo 'RMD_DST:' ${RMD_DST}
106         @echo 'MARKDOWN_SRC:' ${MARKDOWN_SRC}
107         @echo 'HTML_DST:' ${HTML_DST}
108
109 ## lesson-fixme     : show FIXME markers embedded in source files.
110 lesson-fixme :
111         @fgrep -i -n FIXME ${MARKDOWN_SRC} || true
112
113 #-------------------------------------------------------------------------------
114 # Include extra commands if available.
115 #-------------------------------------------------------------------------------
116
117 -include commands.mk