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