Skip to content

Commit 6272878

Browse files
barakliuxinyu95
authored andcommitted
major build system tweaking:
- use latexmk, which + tracks dependencies itself + does some included-file conversion automatically + runs all necessary commands (xelatex, bibtex, makeindex, etc) + runs repeatedly until output stabilizes fixedpoint: no more guesswork - simplify top-level Makefile to process all .dot files into .pdf files - set up "chapters" target for all individual chapters - Makefiles in per-chapter subdirs are links, allowing "make" there to work
1 parent c545de0 commit 6272878

File tree

39 files changed

+54
-1342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

39 files changed

+54
-1342
lines changed

Makefile

Lines changed: 21 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,29 @@
1-
BOOK = algoxy
2-
BOOK_EN = $(BOOK)-en
3-
BOOK_CN = $(BOOK)-zh-cn
4-
OBJ_EN = $(BOOK_EN).pdf
5-
OBJ_CN = $(BOOK_CN).pdf
6-
XELATEX = $(shell which xelatex > /dev/null)
7-
8-
ifdef XELATEX
9-
LATEX = xelatex
10-
DVIPDFM = echo
11-
else
12-
LATEX = latex
13-
DVIPDFM = dvipdfmx
14-
endif
15-
16-
SRC = algoxy
17-
SRC_EN = $(foreach file, $(SRC), $(file)-en.tex)
18-
SRC_CN = $(foreach file, $(SRC), $(file)-zh-cn.tex)
19-
CHAPTERS = others/preface/preface \
20-
datastruct/tree/binary-search-tree/bstree \
21-
sorting/insertion-sort/isort \
22-
datastruct/tree/red-black-tree/rbtree datastruct/tree/AVL-tree/avltree \
23-
datastruct/tree/trie/trie \
24-
datastruct/tree/suffix-tree/stree datastruct/tree/B-tree/btree \
25-
datastruct/heap/binary-heap/bheap sorting/select-sort/ssort \
26-
datastruct/heap/other-heaps/kheap \
27-
datastruct/elementary/queue/queue \
28-
datastruct/elementary/sequence/sequence \
29-
sorting/dc-sort/dcsort \
30-
search/search \
31-
others/appendix/list/list \
32-
others/appendix/rbt-del/rbt-del \
33-
others/appendix/avltree/avl-proof \
34-
others/appendix/bib
35-
CHAPTER_OBJ_EN = $(foreach file, $(CHAPTERS), $(file)-en.pdf)
36-
CHAPTER_OBJ_CN = $(foreach file, $(CHAPTERS), $(file)-zh-cn.pdf)
37-
CHAPTER_SRC_EN = $(foreach file, $(CHAPTERS), $(file)-en.tex)
38-
CHAPTER_SRC_EN = $(foreach file, $(CHAPTERS), $(file)-zh-cn.tex)
39-
401
all: cn en
412

42-
cn: $(OBJ_CN)
43-
44-
en: $(OBJ_EN)
45-
46-
# only build the dependant images, but not the PDF for performance consideration
47-
%.pdf : %.tex
48-
$(MAKE) -C $(@D) image
3+
BOOK-CN := $(wildcard *-zh-cn.tex)
4+
BOOK-EN := $(wildcard *-en.tex)
495

50-
image:
51-
$(MAKE) -C img
6+
cn en: pdf
7+
cn: $(BOOK-CN:.tex=.pdf)
8+
en: $(BOOK-EN:.tex=.pdf)
529

53-
index:
54-
makeindex $(BOOK)
10+
DOTS = $(shell find -name '*.dot')
11+
FIGS = $(shell find -name '*.fig')
12+
PDFS = $(DOTS:.dot=.pdf) $(FIGS:.fig=.pdf)
5513

56-
$(OBJ_CN): image $(SRC_CN) $(CHAPTER_OBJ_CN)
57-
$(LATEX) $(BOOK_CN).tex
58-
makeindex $(BOOK_CN).idx
59-
$(LATEX) $(BOOK_CN).tex
60-
$(DVIPDFM) $(BOOK_CN)
14+
pdf: $(PDFS)
6115

62-
$(OBJ_EN): image $(SRC_EN) $(CHAPTER_OBJ_EN)
63-
$(LATEX) $(BOOK_EN).tex
64-
makeindex $(BOOK_EN).idx
65-
$(LATEX) $(BOOK_EN).tex
66-
$(DVIPDFM) $(BOOK_EN)
16+
%.ps: %.dot; dot -Tps -o $@ $<
17+
%.eps: %.dot; dot -Teps -o $@ $<
18+
%.pdf: %.dot; dot -Tpdf -o $@ $<
19+
%.pdf: %.fig; fig2dev -L pdf $< $@
20+
%.pdf: %.tex; latexmk -cd -xelatex $<
6721

68-
clean:
69-
rm -f *.aux *.toc *.lon *.lor *.lof *.ilg *.idx *.ind *.out *.log *.exa
22+
CHAPTERS-CN := $(shell egrep -l documentclass $$(find -name '*-zh-cn.tex' -a \! -name 'algoxy-*.tex'))
23+
CHAPTERS-EN := $(shell egrep -l documentclass $$(find -name '*-en.tex' -a \! -name 'algoxy-*.tex'))
24+
chapters: chapters-cn chapters-en
25+
chapters-cn chapters-en: pdf
26+
chapters-cn: $(CHAPTERS-CN:.tex=.pdf)
27+
chapters-en: $(CHAPTERS-EN:.tex=.pdf)
7028

71-
distclean: clean
72-
rm -f *.pdf *.dvi *~
73-
rm -f $(CHAPTER_OBJS)
29+
.PHONY: all cn en pdf chapters chapters-cn chapters-en

datastruct/elementary/queue/Makefile

Lines changed: 0 additions & 25 deletions
This file was deleted.

datastruct/elementary/queue/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../Makefile

datastruct/elementary/queue/img/Makefile

Lines changed: 0 additions & 56 deletions
This file was deleted.

datastruct/elementary/sequence/Makefile

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../Makefile

datastruct/elementary/sequence/img/Makefile

Lines changed: 0 additions & 57 deletions
This file was deleted.

datastruct/heap/binary-heap/Makefile

Lines changed: 0 additions & 25 deletions
This file was deleted.

datastruct/heap/binary-heap/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../Makefile

datastruct/heap/binary-heap/img/Makefile

Lines changed: 0 additions & 46 deletions
This file was deleted.

datastruct/heap/other-heaps/Makefile

Lines changed: 0 additions & 25 deletions
This file was deleted.

datastruct/heap/other-heaps/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../Makefile

0 commit comments

Comments
 (0)