forked from cloudmesh-community/book
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.book
225 lines (172 loc) · 6.42 KB
/
Makefile.book
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# -*- makefile -*-
OS=$(shell ..//bin/sysinfo.py)
DOCKER=$(shell ../bin/isdocker.py)
IMAGE_DIRS=$(shell ../bin/find-image-dirs.py)
#MARKUPALL=../bin/markup-all.py
#
# removing mermaid filter from linux as we do not yet know how to use it in docker
#
COPY=rsync
ifeq ($(OS), osx)
OPEN_EPUB=open
MERMAID=-F mermaid-filter
endif
ifeq ($(OS), linux)
OPEN_EPUB=xdg-open
MERMAID=-F mermaid-filter
endif
ifeq ($(OS), windows)
OPEN_EPUB=open
MERMAID=-F mermaid-filter.cmd
endif
ifeq ($(DOCKER), True)
MERMAID=
endif
all: splash prepare epub
echo done
splash:
@echo "# ======================================================================"
@echo "# Creating:", $(BOOK)
@echo "# Epub :", $(FILENAME)
@echo "# ======================================================================"
new: clean update images issues all
echo done
missing:
../bin/manifest-parser.py info no $(BOOK)
update: Makefile
python ../bin/manifest-parser.py dep $(BOOK) > ../Makefile.$(BOOK)
tree: Makefile
../bin/manifest-parser.py tree $(BOOK)
include ../Makefile.$(BOOK)
test:
echo $(INDEX)
MARKDOWN-OPTIONS=--verbose $(MERMAID) --filter pandoc-fignos -f markdown+header_attributes -f markdown+smart -f markdown+emoji --indented-code-classes=bash,python,yaml
#MARKDOWN-OPTIONS=--verbose -f IncludeFilter $(MERMAID) --filter pandoc-fignos -f markdown+header_attributes -f markdown+smart -f markdown+emoji --indented-code-classes=bash,python,yaml
CSL=--csl=template/ieee-with-url.csl
FORMAT=--toc --number-sections
FONTS=--epub-embed-font='fonts/*.ttf'
BIB=--bibliography references.bib
CSS=--css=template/epub.css
RESOURCE=--resource-path=$(IMAGE_DIRS)
draft: prepare epubdraft
echo done
images:
mkdir -p dest
rsync -v -r --include='*.jpeg' --include='*.jpg' --include='*.png' --include='*.JPG' --include='*.PNG' --exclude=".DS_Store" --exclude="*.md" --exclude="*.tex" --exclude="*.txt" ../chapters dest
destination:
mkdir -p dest
$(COPY) metadata.txt dest
$(COPY) -r cover dest
$(COPY) -r ../template dest
$(COPY) -r ../template/fonts dest
authors:
../bin/authors.py > ../chapters/authors.md
version:
../bin/date.py > ../chapters/version.md
generateimages:
ifeq (,$(wildcard dest/chapters/images/penguin.jpg))
make -f Makefile images
endif
prepare: generateimages version authors destination chapterlist references todo index
echo "\n\nThis document can be downloaded from\n\n" >> dest/chapters/version.md
echo "<https://github.com/cloudmesh-community/book/blob/master/$(FILENAME).epub?raw=true>\n\n" >> dest/chapters/version.md
bibtex: bibtex-duplicate bibtex-cat bibtex-error bibtex-datamodel
bibtex-issues:
cd dest: rm -f *.blg *_bibertool.bib
cd dest; cat -n references.bib
cd dest; biber -V --tool references.bib | fgrep -v Datamodel | fgrep -v INFO | fgrep -v Duplicate | fgrep -v Overwriting | fgrep -v ISBN
bibtex-duplicate: refrerences
cd dest; biber -V --tool references.bib | fgrep Duplicate
bibtex-cat:
cd dest; cat -n references.bib
bibtex-ERROR:
cd dest; biber -V --tool references.bib | fgrep ERROR
bibtex-datamodel:
cd dest; biber -V --tool references.bib | fgrep Datamodel
bibtex-other:
cd dest; biber -V --tool references.bib | fgrep -v Datamodel
bibtex-junk:
cd dest; biber -V --tool references.bib | fgrep junk
epub: prepare
cd dest; touch chapters/index.md
ifeq ($(OS), osx)
cd dest; iconv -t utf-8 $(INDEX) > all.md
endif
ifeq ($(OS), linux)
cd dest; cat $(INDEX) > all.md
endif
make -f Makefile index
cd dest; pandoc $(RESOURCE) $(MARKDOWN-OPTIONS) $(FORMAT) $(FONTS) $(BIB) $(CSL) $(CSS) -o $(FILENAME).epub metadata.txt all.md
epub-all: prepare
ifeq ($(OS), osx)
cd dest; iconv -t utf-8 $(INDEX) > all.md
endif
ifeq ($(OS), linux)
cd dest; cat $(INDEX) > all.md
endif
make -f Makefile fixemoji
cd dest; pandoc $(RESOURCE) $(MARKDOWN-OPTIONS) $(FORMAT) $(FONTS) $(BIB) $(CSL) $(CSS) -o $(FILENAME).epub metadata.txt $(INDEX)
find:
cd ..; grep -R -n "$(FIND)" $(INDEX)
nolanguage:
cd ..; grep -R -n "\`\`\`" $(INDEX)
epubdraft: prepare
ifeq ($(OS), osx)
# cd dest; iconv -t utf-8 $(DRAFT) > all.md
cd dest; cat $(DRAFT) > all.md
endif
ifeq ($(OS), linux)
cd dest; cat $(DRAFT) > all.md
endif
cd dest; pandoc $(RESOURCE) $(MARKDOWN-OPTIONS) $(FORMAT) $(FONTS) $(BIB) $(CSL) $(CSS) -o $(FILENAME).epub metadata.txt all.md
references:
mkdir -p dest
cat ../bib/*.bib > dest/references.bib
html:
cd dest; pandoc $(MARKDOWN-OPTIONS) $(FORMAT) $(FONTS) $(BIB) $(CSL) $(CSS) -o $(FILENAME).html metadata.txt $(INDEX)
pdf:
cd dest; pandoc $(RESOURCE) -V pagestyle:headings -V secnumdepth:5 -V geometry:margin=1in --pdf-engine=xelatex -f markdown+smart --toc --epub-embed-font='fonts/*.ttf' -V geometry:margin=1in --bibliography references.bib --csl=../../template/ieee.csl -o $(FILENAME).pdf metadata.txt $(INDEX)
tex:
cd dest; pandoc -f markdown+smart -f markdown+emoji --toc --epub-embed-font='fonts/*.ttf' --bibliography references.bib --csl=../../template/ieee.csl -o $(FILENAME).tex metadata.txt $(INDEX)
cd dest; pdflatex content.tex
#
bootstrap:
cd dest; pandoc $(RESOURCE) --template ../../template/bootstrap/template.html --css ../../template/bootstrap/template.css --self-contained --toc --toc-depth 2 $(MARKDOWN-OPTIONS) $(FORMAT) $(FONTS) $(BIB) $(CSL) $(CSS) -o $(FILENAME).html metadata.txt $(INDEX)
clean:
rm -rf $(FILENAME).*
rm -rf dest
list:
@echo "----"
@find . -name "*.md"
@echo "----"
@echo "Markdown Files": `find . -name "*.md" | wc -l`
@echo "----"
@find . -name "*.md" | sed -e 's/^/ /' | sed 's/$$/\\/'
view:
$(OPEN_EPUB) dest/$(FILENAME).epub
todo:
../bin/todo.py > dest/todo.md
cat dest/todo.md
issues:
python ../bin/issues.py > /tmp/issues.tex
pandoc /tmp/issues.tex -o ../chapters/preface/issues.md
@echo "# Github Issues\n" > /tmp/issues.md
@echo "---\n" >> /tmp/issues.md
@echo ":warning: The issues are automatically created from Github Issues. Please change them directly in github." >> /tmp/issues.md
@echo "Do not modify the table.\n" >> /tmp/issues.md
@echo "---\n" >> /tmp/issues.md
echo ".<div class=\"smalltable\">\n" >> /tmp/issues.md
tail -n +3 ../chapters/preface/issues.md >> /tmp/issues.md
echo >> /tmp/issues.md
echo ".</div>\n" >> /tmp/issues.md
echo "\n\n\n\n" >> /tmp/issues.md
cp /tmp/issues.md ../chapters/preface/issues.md
publish: epub
cp dest/$(FILENAME).epub ..
git add ../$(FILENAME).epub
git commit -m "update epub" ../$(FILENAME).epub
git push
index:
cd dest; pandoc -o chapters/index.json $(INDEX)
cd dest; pandoc-index chapters/index
echo "\n" >> dest/chapters/index.md