-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMakefile
More file actions
68 lines (58 loc) · 2.2 KB
/
Makefile
File metadata and controls
68 lines (58 loc) · 2.2 KB
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
# Makefile for tutorials
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER = letter
BUILDDIR = _build
WORKDIR = _workdir
BASENAME = $${PWD\#\#*/}
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS)
.PHONY: help html clean latex pdf archive setup
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " pdf to make LaTeX files and run them through pdflatex"
clean:
-rm -rf $(BUILDDIR)/* $(BASENAME)_files.zip $(BASENAME)_files.tgz $(BASENAME).pdf
setup:
mkdir -p $(WORKDIR)
echo $(BASENAME)
cp -f $(BASENAME)_files/* $(WORKDIR)/ 2>/dev/null || :
ln -fs ../../_theme
ln -fs ../../_static
mkdir -p _static/figures
rm -f files.txt;
files=`ls $(BASENAME)_files`; \
if [ -z "$$files" ]; then echo "There are no required files." > files.txt; else \
ls -hgoL $(BASENAME)_files/ | tail -n +2 | cut -b 14-128 > files.txt; fi
html: setup
cd $(WORKDIR); $(SPHINXBUILD) -b html -d ../$(BUILDDIR)/doctrees ../ ../$(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
pdf: setup
cd $(WORKDIR); $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) -d ../$(BUILDDIR)/doctrees ../ ../$(BUILDDIR)/latex
@echo
@echo "LaTeX file is ready, see $(BUILDDIR)/latex."
@echo "Running LaTeX files through pdflatex..."
@echo
make -C $(BUILDDIR)/latex all-pdf
mv -f $(BUILDDIR)/latex/$(BASENAME).pdf .
@echo
@echo "PDF file is ready, see $(BASENAME).pdf."
archive:
rm -f $(BASENAME)_files.zip $(BASENAME)_files.tgz
files=`ls $(BASENAME)_files`; \
if [ -n "$$files" ]; then \
tar -chzf $(BASENAME)_files.tgz $(BASENAME)_files/*; \
zip $(BASENAME)_files.zip $(BASENAME)_files/*; \
echo "$(BASENAME)_files.zip and $(BASENAME)_files.tgz are created."; \
ls -hgoL $(BASENAME)_files/ | tail -n +2 | cut -b 14-128 > files.txt; \
else \
echo "There are no tutorial files." > files.txt; \
fi
build: archive pdf
copy: build
/bin/mv -f $(BASENAME).pdf ../../_build/html/tutorials/$(BASENAME)/
if [ -f "$(BASENAME)_files.tgz" ]; then /bin/mv -f $(BASENAME)_files.* ../../_build/html/tutorials/$(BASENAME)/; fi