33
44# Settings
55MAKEFILES =Makefile $(wildcard * .mk)
6- JEKYLL =bundle config --local set path .vendor/bundle && bundle install && bundle update && bundle exec jekyll
6+ JEKYLL =bundle config set --local path .vendor/bundle && bundle install && bundle update && bundle exec jekyll
77PARSER =bin/markdown_ast.rb
88DST =_site
99
@@ -12,7 +12,7 @@ DST=_site
1212PYTHON3_EXE := $(shell which python3 2>/dev/null)
1313ifneq (, $(PYTHON3_EXE ) )
1414 ifeq (,$(findstring Microsoft/WindowsApps/python3,$(subst \,/,$(PYTHON3_EXE))))
15- PYTHON := python3
15+ PYTHON := $( PYTHON3_EXE )
1616 endif
1717endif
1818
@@ -21,25 +21,25 @@ ifeq (,$(PYTHON))
2121 ifneq (, $(PYTHON_EXE))
2222 PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1) ) )
2323 PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL})
24- ifneq (3, ${PYTHON_VERSION_MAJOR})
25- $(error "Your system does not appear to have Python 3 installed.")
24+ ifeq (3, ${PYTHON_VERSION_MAJOR})
25+ PYTHON := $(PYTHON_EXE )
26+ else
27+ PYTHON_NOTE = "Your system does not appear to have Python 3 installed."
2628 endif
27- PYTHON := python
2829 else
29- $(error "Your system does not appear to have any Python installed.")
30+ PYTHON_NOTE = "Your system does not appear to have any Python installed."
3031 endif
3132endif
3233
3334
34- # Controls
35- .PHONY : commands clean files
36-
3735# Default target
3836.DEFAULT_GOAL := commands
3937
4038# # I. Commands for both workshop and lesson websites
4139# # =================================================
4240
41+ .PHONY : site docker-serve repo-check clean clean-rmd
42+
4343# # * serve : render website and run a local server
4444serve : lesson-md
4545 ${JEKYLL} serve
@@ -50,8 +50,8 @@ site : lesson-md
5050
5151# # * docker-serve : use Docker to serve the site
5252docker-serve :
53- docker pull carpentries/lesson-docker:latest
54- docker run --rm -it \
53+ @ docker pull carpentries/lesson-docker:latest
54+ @ docker run --rm -it \
5555 -v $$ {PWD}:/home/rstudio \
5656 -p 4000:4000 \
5757 -p 8787:8787 \
@@ -60,14 +60,17 @@ docker-serve :
6060 carpentries/lesson-docker:latest
6161
6262# # * repo-check : check repository settings
63- repo-check :
63+ repo-check : python
6464 @${PYTHON} bin/repo_check.py -s .
6565
6666# # * clean : clean up junk files
6767clean :
6868 @rm -rf ${DST}
6969 @rm -rf .sass-cache
7070 @rm -rf bin/__pycache__
71+ @rm -rf .vendor
72+ @rm -rf .bundle
73+ @rm -f Gemfile.lock
7174 @find . -name .DS_Store -exec rm {} \;
7275 @find . -name ' *~' -exec rm {} \;
7376 @find . -name ' *.pyc' -exec rm {} \;
@@ -85,7 +88,7 @@ clean-rmd :
8588.PHONY : workshop-check
8689
8790# # * workshop-check : check workshop homepage
88- workshop-check :
91+ workshop-check : python
8992 @${PYTHON} bin/workshop_check.py .
9093
9194
@@ -96,7 +99,7 @@ workshop-check :
9699.PHONY : lesson-check lesson-md lesson-files lesson-fixme install-rmd-deps
97100
98101# RMarkdown files
99- RMD_SRC = $(wildcard _episodes_rmd/??- * .Rmd)
102+ RMD_SRC = $(wildcard _episodes_rmd/* .Rmd)
100103RMD_DST = $(patsubst _episodes_rmd/% .Rmd,_episodes/% .md,$(RMD_SRC ) )
101104
102105# Lesson source files in the order they appear in the navigation menu.
@@ -115,7 +118,7 @@ HTML_DST = \
115118 ${DST}/conduct/index.html \
116119 ${DST}/setup/index.html \
117120 $(patsubst _episodes/% .md,${DST}/% /index.html,$(sort $(wildcard _episodes/* .md) ) ) \
118- ${DST}/reference/index .html \
121+ ${DST}/reference.html \
119122 $(patsubst _extras/% .md,${DST}/% /index.html,$(sort $(wildcard _extras/* .md) ) ) \
120123 ${DST}/license/index.html
121124
@@ -128,18 +131,18 @@ lesson-md : ${RMD_DST}
128131
129132_episodes/% .md : _episodes_rmd/% .Rmd install-rmd-deps
130133 @mkdir -p _episodes
131- @bin/knit_lessons.sh $< $@
134+ @$( SHELL ) bin/knit_lessons.sh $< $@
132135
133136# # * lesson-check : validate lesson Markdown
134- lesson-check : lesson-fixme
137+ lesson-check : python lesson-fixme
135138 @${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md
136139
137140# # * lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace
138- lesson-check-all :
141+ lesson-check-all : python
139142 @${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive
140143
141144# # * unittest : run unit tests on checking tools
142- unittest :
145+ unittest : python
143146 @${PYTHON} bin/test_lesson_check.py
144147
145148# # * lesson-files : show expected names of generated files for debugging
@@ -157,6 +160,15 @@ lesson-fixme :
157160# # IV. Auxililary (plumbing) commands
158161# # =================================================
159162
163+ .PHONY : commands python
164+
160165# # * commands : show all commands.
161166commands :
162167 @sed -n -e ' /^##/s|^##[[:space:]]*||p' $(MAKEFILE_LIST )
168+
169+ python :
170+ ifeq (, $(PYTHON ) )
171+ $(error $(PYTHON_NOTE))
172+ else
173+ @:
174+ endif
0 commit comments