forked from mongodb/specifications
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
64 lines (54 loc) · 2.1 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
BUILD = build
SOURCE = source
EXTENSION = rst
MAKEFLAGS += -j
SOURCE_FILES := $(shell find $(SOURCE) -name "*.$(EXTENSION)")
OUTPUT_PDF_FILES = $(subst $(EXTENSION),pdf,$(subst $(SOURCE),$(BUILD),$(SOURCE_FILES)))
OUTPUT_HTML_FILES = $(subst $(EXTENSION),html,$(subst $(SOURCE),$(BUILD),$(SOURCE_FILES)))
HTMLCMD = rst2html.py
LATEXCMD = rst2latex.py --latex-preamble="\usepackage{fullpage} \usepackage{parskip} \usepackage{fancyhdr} \usepackage{graphicx} \pagestyle{fancy} \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt}" --documentoptions=letter --documentclass=article
PDFCMD = pdflatex --interaction batchmode --output-directory $(BUILD)/
.PHONY: all clean cleanup builds setup
.DEFAULT_GOAL := help
.SECONDARY:
help:
@echo "PDF, LaTeX and rST generator generator."
@echo "Targets:"
@echo ""
@echo " setup - builds targets for all files in source directory or directories."
@echo " (see bin/builder.py)"
@echo " all - rebuild all PDFs from files in the '$(SOURCE)' directory with"
@echo " the '.$(EXTENSION)' extension."
@echo ""
@echo " (other) - use 'make [filename-without-extension]' to rebuild only this file,"
@echo " after running 'make setup'"
setup:$(BUILD) makefile.generated logo.png
$(BUILD)/makefile.generated:bin/builder.py $(SOURCE_FILES)
@./$<
@echo [builder]: \(re\)generated \"makefile.generated\"
-include $(BUILD)/makefile.generated
all: logo.png $(BUILD) $(OUTPUT_PDF_FILES) $(OUTPUT_HTML_FILES)
logo.png:
curl http://docs.mongodb.org/logo-print.png >| $@
$(BUILD):
@mkdir -p $@
@echo [setup]: '$@' directory created.
$(BUILD)/%.html:$(SOURCE)/%.$(EXTENSION)
@$(HTMLCMD) $< >$@
@echo [rst2html]: converted $<
$(BUILD)/%.tex:$(SOURCE)/%.$(EXTENSION)
@$(LATEXCMD) $< >$@
@echo [rst2latex]: converted $<
$(BUILD)/%.pdf:$(BUILD)/%.tex
@$(PDFCMD) '$<' >|$@.log
@echo [pdflatex]: \(1/3\) built '$@'
@$(PDFCMD) '$<' >>$@.log
@echo [pdflatex]: \(2/3\) built '$@'
@$(PDFCMD) '$<' >>$@.log
@echo [pdflatex]: \(3/3\) built '$@'
cleanup:
rm -f $(BUILD)/*.{aux,log,out}
clean:
rm -rf $(BUILD)/
clean-logo:
rm -f logo.png