-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
176 lines (141 loc) · 5.79 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Location of build dir
BUILD_DIR=build
BUILD_DIR_IMAGES=$(BUILD_DIR)/images/chaps
# Location of website files
SITE_DIR=site
# Location of website images
SITE_IMAGES_DIR=$(SITE_DIR)/images
SITE_CHAP_IMAGES_DIR=$(SITE_IMAGES_DIR)/chaps
SITE_STYLE_DIR=$(SITE_DIR)/style
# List of targets that are not files
.PHONY: all quick clean web print pdf screen quickpdf cleantmp cleanpdf cleanimages html htmlimages cleansite
all: pdf cleantmp
quick: quickpdf cleantmp
clean: cleantmp cleanpdf
web: images html
# Generate a print version PDF (for lulu.com)
print:
xelatex '\def\mediaformat{print}\input{gitt}'
makeindex gitt
xelatex '\def\mediaformat{print}\input{gitt}'
xelatex '\def\mediaformat{print}\input{gitt}'
# Generate the PDF (on-screen version)
pdf:
xelatex '\def\mediaformat{screen}\input{gitt}'
makeindex gitt
xelatex '\def\mediaformat{screen}\input{gitt}'
xelatex '\def\mediaformat{screen}\input{gitt}'
# An alias for generated the PDF
screen: pdf
# Quickly update the PDF. Will not update the index or cross-references
quickpdf:
xelatex gitt
# Remove the temporary files generated by LaTeX
cleantmp:
rm -f *.aux *.log *.out *.toc *.idx *.ind *.ilg
# Remove the generated PDF
cleanpdf:
rm -f gitt.pdf
rm -f print.pdf
# Remove the generated website images
cleanimages:
@rm -f $(SITE_IMAGES_DIR)/*.png
# Clean up generated site files
cleansite:
@rm -fr $(SITE_DIR)
@rm html/nav.html
cleanbuild:
@rm -fr $(BUILD_DIR)
site: html htmlimages
baseconvert: $(BUILD_DIR) $(BUILD_DIR_IMAGES) htmlimages
@python scripts/htmlbuild.py alltex
@python scripts/htmlbuild.py baseconvert
@python scripts/htmlbuild.py baseconcat
@cp -r site/images $(BUILD_DIR)
@cp -r images/source/*.svg $(BUILD_DIR_IMAGES)
baseconvert-mobi: $(BUILD_DIR) $(BUILD_DIR_IMAGES) htmlimages
@python scripts/htmlbuild.py alltex
@python scripts/htmlbuild.py baseconvert mobi
@python scripts/htmlbuild.py baseconcat
@cp -r site/images $(BUILD_DIR)
@cp -r images/source/*.svg $(BUILD_DIR_IMAGES)
baseconvert-epub: $(BUILD_DIR) $(BUILD_DIR_IMAGES) htmlimages
@python scripts/htmlbuild.py alltex
@python scripts/htmlbuild.py baseconvert epub
@python scripts/htmlbuild.py baseconcat
@cp -r site/images $(BUILD_DIR)
@cp -r images/source/*.svg $(BUILD_DIR_IMAGES)
epub: baseconvert-epub
@ebook-convert build/complete.html build/complete.epub --chapter '//*[name()="h1"]' --authors 'Peter Savage' --title 'Git In The Trenches' --cover images/source/fcover-epub.png
epub-view: epub
@ebook-viewer build/complete.epub
mobi: baseconvert-mobi
@ebook-convert build/complete.html build/complete.mobi --chapter '//*[name()="h1"]' --authors 'Peter Savage' --title 'Git In The Trenches' --cover images/source/fcover-epub.png
mobi-view: mobi
@ebook-viewer build/complete.mobi
# Convert TeX to HTML
html: $(SITE_IMAGES_DIR)
@touch html/nav.html
@cp html/stylesheet.css $(SITE_DIR)/
@cp html/index.html $(SITE_DIR)/
@python scripts/htmlbuild.py simple index
@python scripts/htmlbuild.py simple feedback
@python scripts/htmlbuild.py simple download
@python scripts/htmlbuild.py simple legal
@python scripts/htmlbuild.py alltex
@python scripts/htmlbuild.py allchaps
@python scripts/htmlbuild.py allafterhours
@python scripts/htmlbuild.py intro
@python scripts/htmlbuild.py setup
# Get a list of all SVG images
IMAGES=$(shell ls images/source/*.svg)
# Generate list of images required for the website
SITEIMAGES=$(shell for IMAGE in $(IMAGES); do echo "$$(basename $${IMAGE} .svg).png"; done)
# Generate PNG file from SVG file
%.png: images/source/%.svg $(SITE_IMAGES_DIR) $(SITE_CHAP_IMAGES_DIR) $(BUILD_DIR_IMAGES)
inkscape -f $< -D -w 400 -e $(SITE_CHAP_IMAGES_DIR)/f-$(shell basename $< .svg).png >/dev/null
inkscape -f $< -D -l $(BUILD_DIR_IMAGES)/f-$(shell basename $<)
# Convert all images
htmlimages: $(SITEIMAGES) $(SITE_CHAP_IMAGES_DIR)
@cp images/f-w5-d1.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d1.png
@cp images/f-w5-d2.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d2.png
@cp images/f-w5-d3.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d3.png
@cp images/f-w5-d4.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d4.png
@cp images/f-w5-d5.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d5.png
@cp images/f-w5-d6.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d6.png
@cp images/f-w5-d7.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d7.png
@cp images/f-w5-d8.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d8.png
@cp images/f-w5-d9.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d9.png
@cp images/f-w5-d10.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d10.png
@cp images/f-w5-d11.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d11.png
@cp images/f-w5-d12.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d12.png
@cp images/f-w5-d13.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d13.png
@cp images/f-w5-d14.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d14.png
@cp images/f-w5-d15.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d15.png
@cp images/f-w5-d16.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d16.png
@cp images/f-w5-d17.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d17.png
@cp images/f-w5-d18.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d18.png
@cp images/f-w5-d19.png $(SITE_CHAP_IMAGES_DIR)/f-w5-d19.png
@cp images/f-af7-d1.png $(SITE_CHAP_IMAGES_DIR)/f-af7-d1.png
@cp images/f-af7-d2.png $(SITE_CHAP_IMAGES_DIR)/f-af7-d2.png
@cp images/f-af7-d3.png $(SITE_CHAP_IMAGES_DIR)/f-af7-d3.png
@cp images/f-af7-d4.png $(SITE_CHAP_IMAGES_DIR)/f-af7-d4.png
@cp images/f-af7-d5.png $(SITE_CHAP_IMAGES_DIR)/f-af7-d5.png
@cp images/f-af7-d6.png $(SITE_CHAP_IMAGES_DIR)/f-af7-d6.png
@cp images/f-af5-d1.png $(SITE_CHAP_IMAGES_DIR)/f-af5-d1.png
@cp images/f-af5-d2.png $(SITE_CHAP_IMAGES_DIR)/f-af5-d2.png
@cp images/f-af5-d3.png $(SITE_CHAP_IMAGES_DIR)/f-af5-d3.png
@cp html/images/* $(SITE_IMAGES_DIR)/
# Make directories
$(SITE_DIR):
@mkdir -p $(SITE_DIR)
$(SITE_STYLE_DIR):
@mkdir -p $(SITE_STYLE_DIR)
$(SITE_IMAGES_DIR):
@mkdir -p $(SITE_IMAGES_DIR)
$(SITE_CHAP_IMAGES_DIR):
@mkdir -p $(SITE_CHAP_IMAGES_DIR)
$(BUILD_DIR):
@mkdir -p $(BUILD_DIR)
$(BUILD_DIR_IMAGES):
@mkdir -p $(BUILD_DIR_IMAGES)