forked from yochju/general_relativity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
140 lines (123 loc) · 5.02 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
RUN_ERUBY = perl -Iscripts scripts/run_eruby.pl
TEX_INTERPRETER = pdflatex
#TEX_INTERPRETER = lualatex
DO_PDFLATEX_RAW = $(TEX_INTERPRETER) -shell-escape -interaction=nonstopmode genrel >err
# -shell-escape is so that write18 will be allowed
SHOW_ERRORS = \
print "========error========\n"; \
open(F,"err"); \
while ($$line = <F>) { \
if ($$line=~m/^\! / || $$line=~m/^l.\d+ /) { \
print $$line \
} \
} \
close F; \
exit(1)
DO_PDFLATEX = echo "$(DO_PDFLATEX_RAW)" ; perl -e 'if (system("$(DO_PDFLATEX_RAW)")) {$(SHOW_ERRORS)}'
HANDHELD_TEMP = handheld_temp
BOOK = genrel
GENERIC_OPTIONS_FOR_CALIBRE = --authors "Benjamin Crowell" --language en --title "Calculus" --toc-filter="[0-9]\.[0-9]" --title="General Relativity"
PROBLEMS_CSV = problems.csv
default:
@make preflight
@scripts/before_each.rb
$(RUN_ERUBY)
# perl -e 'foreach $$f(<ch*>) {if (-d $$f) {$$f=~/ch(\d\d)/; $$n=$$1; $$c = "cd ch$$n && ../fruby ch$$n.rbtex >ch$${n}temp.tex && cd -"; print "$$c\n"; system $$c}}'
$(DO_PDFLATEX)
@scripts/translate_to_html.rb --util="learn_commands:$(BOOK).cmd"
@process_geom_file.pl <geom.pos >temp.pos
@mv temp.pos geom.pos
makeindex genrel.idx >/dev/null
book:
@make preflight
make clean
make && make
@scripts/translate_to_html.rb --util="learn_commands:$(BOOK).cmd"
@scripts/check_for_colliding_figures.rb
@scripts/harvest_aux_files.rb
make
web:
@make preflight
scripts/translate_to_html.rb --write_config_and_exit
WOPT='$(WOPT) --html5' $(RUN_ERUBY) w #... html 5 with mathml
WOPT='$(WOPT) --mathjax' $(RUN_ERUBY) w #... html 4 with mathjax
# To set options, do, e.g., "WOPT='--no_write' make web". Options are documented in translate_to_html.rb.
clean:
# Cleaning...
@rm -f genrel.pdf genrel_lulu.pdf
@rm -f temp.tex
@rm -f ch*/ch*temp.tex
@rm -f bk*lulu.pdf simple1.pdf simple2.pdf # lulu files
@rm -f ch*.pos geom.pos report.pos marg.pos makefilepreamble
@rm -f figfeedback*
@rm -f ch*/ch*temp_new ch*/*.postm4 ch*/*.wiki
@rm -f code_listing_* code_listings/* code_listings.zip
@rm -Rf code_listings
@rm -f temp.* temp_mathml.*
@# Sometimes we get into a state where LaTeX is unhappy, and erasing these cures it:
@rm -f *aux *idx *ilg *ind *log *toc
@rm -f ch*/*aux
@# Shouldn't exist in subdirectories:
@rm -f */*.log
@# Emacs backup files:
@rm -f *~
@rm -f */*~
@rm -f */*/*~
@rm -f */ch*.temp
@# Misc:
@rm -Rf ch*/figs/.xvpics
@rm -f a.a
@rm -f */a.a
@rm -f */*/a.a
@rm -f junk
@rm -f err
@rm -f temp_mathml.html temp_mathml.tex temp.html
@# ... done.
very_clean:
make clean
rm -f brief-toc.tex brief-toc-new.tex
preflight:
@@chmod +x scripts/custom/*
@chmod +x mv_silent fruby process_geom_file.pl scripts/*.rb scripts/create_fullembed_file scripts/custom/*.pl
@perl -e 'if (-e "scripts/custom/enable") {foreach $$f(<scripts/custom/*.pl>) {$$c="$$f $(BOOK) $(PROBLEMS_CSV)"; system($$c)}}'
@perl -e 'foreach $$f("scripts/run_eruby.pl","scripts/equation_to_image.pl","scripts/latex_table_to_html.pl","scripts/harvest_aux_files.rb","scripts/check_for_colliding_figures.rb","scripts/translate_to_html.rb","mv_silent") {die "file $$f is not executable; fix this with chmod +x $$f" unless -e $$f && -x $$f}'
post:
cp genrel.pdf ~/Lightandmatter/genrel
prepress:
PREPRESS=1 make book
make preflight_figs
scripts/pdf_extract_pages.rb genrel.pdf 3-end genrel_lulu.pdf
# Filtering through gs used to be necessary to convince Lulu not to complain about missing fonts.
# Now that should no longer be necessary, because recent versions of pdftex embed all fonts, and fullembed.map prevents subsetting.
# See meki:computer:apps:ghostscript, scripts/create_fullembed_file, and http://tex.stackexchange.com/questions/24002/turning-off-font-subsetting-in-pdftex
@rm -f temp.pdf
preflight_figs:
@echo "checking all figures in all books for transparency, embedded fonts, bad structure..."
scripts/preflight_figs.pl
@echo "...done"
all_figures:
# The following requires Inkscape 0.47 or later.
perl -e 'foreach my $$f(<ch*/figs/*.svg>) {system("scripts/render_one_figure.pl $$f")}'
handheld:
# see meki/zzz_misc/publishing for notes on how far I've progressed with this
scripts/translate_to_html.rb --write_config_and_exit --modern --override_config_with="config/handheld.config"
make preflight
@rm -Rf $(HANDHELD_TEMP)
mkdir $(HANDHELD_TEMP)
pwd
WOPT='$(WOPT) --modern --override_config_with="config/handheld.config"' $(RUN_ERUBY) w $(FIRST_CHAPTER) $(DIRECTORIES) #... xhtml
cp standalone.css $(HANDHELD_TEMP)
make epub
make mobi
@echo "To post the books, do 'make post_handheld'."
post_handheld:
cp $(BOOK).epub $(HOME)/Lightandmatter
cp $(BOOK).mobi $(HOME)/Lightandmatter
epub:
# Before doing this, do a "make handheld".
ebook-convert $(HANDHELD_TEMP)/index.html $(BOOK).epub $(GENERIC_OPTIONS_FOR_CALIBRE) --no-default-epub-cover
mobi:
# Before doing this, do a "make handheld".
ebook-convert $(HANDHELD_TEMP)/index.html $(BOOK).mobi $(GENERIC_OPTIONS_FOR_CALIBRE) --rescale-images
epubcheck:
java -jar /usr/bin/epubcheck/epubcheck.jar $(BOOK).epub 2>err