1 # This file is meant to be included from the
2 # makefiles in the individual books' directories.
7 DIST_ARCHIVE
= $(BOOK
).
tar.gz
11 CLS_FILES
= "lmseries.cls","lmcommon.sty","lmfigs.sty","lmlayout.sty","lmmath.sty","lm.make","mytocloft.sty","lmlanguage.sty","lmenvironments.sty","fullembed.map","learn-cmd-syntax.sty","custom_html.yaml","shaddap.sty"
12 # ... a list of files that's assumed to exist in the parent dir, which we
13 # copy into the working dir when building the book; "CLS_" is really a misnomer
14 GET_CLS
= perl
-e
'foreach $$f($(CLS_FILES)) {$$cmd="cp $(FILE_PREFIX)../$$f ."; system $$cmd}'
15 RM_CLS
= perl
-e
'foreach $$f($(CLS_FILES)) {system "rm -f $$f"}'
16 RM_TEMP
= rm -f
*.pos
*/*temp.
* */*.bak eruby_complaints
17 RUN_ERUBY
= $(NICE
) perl
-I..
/scripts ..
/scripts
/run_eruby.pl
18 HARVEST_AUX_FILES
= ..
/scripts
/harvest_aux_files.rb
19 SPLIT_BOOK
= ..
/scripts
/split_book.pl
20 HANDHELD_TEMP
= handheld_temp
21 GENERIC_OPTIONS_FOR_CALIBRE
= --authors
"Benjamin Crowell" --language en
--toc-filter
="[0-9]\.[0-9]"
22 PROBLEMS_CSV
= ..
/data
/problems.csv
24 MAKEINDEX
= makeindex
$(BOOK
).idx
>/dev
/null
26 TEX_INTERPRETER
= pdflatex
27 #TEX_INTERPRETER = lualatex
28 # ... lualatex sometimes segfaults on Mechanics, but not always reproducible
29 DO_PDFLATEX_RAW
= $(NICE
) $(TEX_INTERPRETER
) -shell-escape
-interaction
=$(MODE
) $(BOOK
) >$(TERMINAL_OUTPUT
)
30 # -shell-escape is so that write18 will be allowed
31 # environment variable openout_any=a is so that we can write to ../share/end
33 system
("../scripts/filter_latex_messages.rb <$(TERMINAL_OUTPUT) >a.a && mv a.a $(TERMINAL_OUTPUT)")
34 print "========error========\n"; \
35 open
(F
,"$(TERMINAL_OUTPUT)"); \
36 while
($$line = <F
>) { \
37 if
($$line=~m
/^\
! / ||
$$line=~m
/^l.\d
+ /) { \
43 DO_PDFLATEX
= echo
"$(DO_PDFLATEX_RAW)" ; perl
-e
'if (system("$(DO_PDFLATEX_RAW)")) {$(SHOW_ERRORS)};'
44 DO_MAKEFILEPREAMBLE
= perl
-e
'open(F,">makefilepreamble.tex"); if ("$(POPT)"=~/only(\d+)/) {print F "\\includeonly{ch$$1/ch$$1temp}"} close F'
46 # Since book1 comes first, it's the default target --- you can just do ``make'' to make it.
48 export GIT_DIR
= "~/Git_LM/$(BOOK_LABEL)"
49 # export makes it set the actual environment variable (not just the makefile macro) for all processes run by the makefile
53 @..
/scripts
/before_each.rb
54 @..
/scripts
/translate_to_html.rb
--write_config_and_exit
55 #@rm -f marg.pos ### might want to do this the very first time, or just make a habit of doing a make clean
56 $(RUN_ERUBY
) - $(FIRST_CHAPTER
) $(DIRECTORIES
)
57 @..
/scripts
/harvest_code_listings.pl
59 @
$(DO_MAKEFILEPREAMBLE
)
61 @..
/scripts
/translate_to_html.rb
--util
="learn_commands:$(BOOK).cmd"
63 @
rm -f
$(TERMINAL_OUTPUT
) # If pdflatex has a nonzero exit code, we don't get here, so the output file is available for inspection.
64 @..
/process_geom_file.pl
<geom.pos
>temp.pos
67 @perl
-e
'if (-e "eruby_complaints") {system "cat eruby_complaints"}'
74 @..
/scripts
/before_each.rb
76 @..
/scripts
/translate_to_html.rb
--write_config_and_exit
79 @
$(RUN_ERUBY
) - $(FIRST_CHAPTER
) $(DIRECTORIES
)
80 @..
/scripts
/harvest_code_listings.pl
82 @
$(DO_MAKEFILEPREAMBLE
)
84 @..
/scripts
/translate_to_html.rb
--util
="learn_commands:$(BOOK).cmd"
86 @..
/process_geom_file.pl
<geom.pos
>temp.pos
88 @
$(RUN_ERUBY
) - $(FIRST_CHAPTER
) $(DIRECTORIES
)
89 @
$(DO_MAKEFILEPREAMBLE
)
90 @..
/scripts
/before_each.rb
93 @..
/process_geom_file.pl
<geom.pos
>temp.pos
95 @
$(RUN_ERUBY
) - $(FIRST_CHAPTER
) $(DIRECTORIES
)
97 @
$(DO_MAKEFILEPREAMBLE
)
98 @..
/scripts
/before_each.rb
100 @
$(HARVEST_AUX_FILES
)
101 @perl
-e
'open(F,"<$(TERMINAL_OUTPUT)"); while ($$l=<F>) {if ($$l=~/LaTeX Warning: Reference/) {print "****** $$l"}}; close F'
102 @..
/process_geom_file.pl
<geom.pos
>temp.pos
103 @mv temp.pos geom.pos
104 @..
/check_for_colliding_figures.rb
105 @..
/scripts
/before_each.rb
106 @
$(DO_PDFLATEX
) # a fourth time, because otherwise some references don't work, e.g., ref. in EM 1-2 to back of book
107 @
$(HARVEST_AUX_FILES
)
108 @
rm -f
$(TERMINAL_OUTPUT
) # If pdflatex has a nonzero exit code, we don't get here, so the output file is available for inspection.
110 @perl
-e
'if (-e "eruby_complaints") {system "cat eruby_complaints"}'
113 @
[ `which footex` ] || echo
"******** footex is not installed, so html cannot be generated; get footex from http://www.lightandmatter.com/footex/footex.html"
114 @
[ `which footex` ] || exit
1
116 @cp ..
/custom_html.yaml .
117 @..
/scripts
/translate_to_html.rb
--write_config_and_exit
118 WOPT
='$(WOPT) --html5' $(RUN_ERUBY
) w
$(FIRST_CHAPTER
) $(DIRECTORIES
) #... html 5 with mathml
119 WOPT
='$(WOPT) --mathjax' $(RUN_ERUBY
) w
$(FIRST_CHAPTER
) $(DIRECTORIES
) #... html 4 with mathjax
120 # To set options, do, e.g., "WOPT='--no_write' make web". Options are documented in translate_to_html.rb.
123 WOPT
='$(WOPT) --wiki' $(RUN_ERUBY
) w
127 # Filtering through gs used to be necessary to convince Lulu not to complain about missing fonts.
128 # Now that should no longer be necessary, because recent versions of pdftex embed all fonts, and fullembed.map prevents subsetting.
129 # See meki:computer:apps:ghostscript, scripts/create_fullembed_file, and http://tex.stackexchange.com/questions/24002/turning-off-font-subsetting-in-pdftex
130 ..
/scripts
/preflight_pdf.pl
$(BOOK
).pdf
131 cd ..
; make preflight_figs
; cd
-
132 perl
-e
'if ("$(BOOK)" eq 'cp
' || "$(BOOK)" eq 'me
') {system("make prepress_single_vol")} else {system("make prepress_splits")}'
135 # Don't use this directly; just do a 'make prepress'.
136 pdftk
$(BOOK
).pdf cat
3-end output lulu_
$(BOOK
).pdf
140 # Don't use this directly; just do a 'make prepress'.
141 $(NICE
) ..
/scripts
/splits.pl
$(BOOK
).pdf
1 lulu_
$(BOOK
)_v1.pdf
142 $(NICE
) ..
/scripts
/splits.pl
$(BOOK
).pdf
2 lulu_
$(BOOK
)_v2.pdf
146 perl
-e
'if (system("pdflatex -interaction=$(MODE) $(BOOK) >$(TERMINAL_OUTPUT)")) {print "error\n"} else {print "no error\n"}'
149 rm -f
$(BOOK
).pdf lulu
*.pdf
*.epub
*.mobi
*.postm4
*.temp ch
*.csv ch
*temp.
tex brief-toc.
tex brief-toc-new.
tex
150 rm -Rf
$(HANDHELD_TEMP
)
151 rm -f learned_commands.json custom_html.yaml declaregraphicsextensions.
tex
158 @
rm -f bk
*lulu.pdf simple1.pdf simple2.pdf
# lulu files
159 @
rm -f
*/*.pos geom.pos report.pos marg.pos makefilepreamble
161 @
rm -f
*/*temp_new
*/*.postm4
*/*.wiki
*/*temp.
tex
162 @
rm -f code_listing_
* code_listings
/* code_listings.zip
163 @
rm -Rf code_listings
164 @
rm -f temp.
* temp_mathml.
*
165 @
# Sometimes we get into a state where LaTeX is unhappy, and erasing these cures it:
166 @
rm -f
*aux
*idx
*ilg
*ind
*log
*toc
168 @
# Shouldn't exist in subdirectories:
170 @
# Emacs backup files:
176 @
rm -Rf
*/figs
/.xvpics
186 cp
$(BOOK
).pdf save.pdf
# save unwatermarked version, so, e.g., if we do a make prepress, we won't inadvertently use the watermarked version
187 # pdftk $(BOOK).pdf background ../watermark/watermark.pdf output temp.pdf
188 # mv temp.pdf $(BOOK).pdf
189 $(SPLIT_BOOK
) $(BOOK
).pdf
190 # move, e.g., bk1.pdf, bk1a.pdf, ..., but don't move simple1.pdf or simple2.pdf if they exist:
191 perl
-e
'foreach $$f(<$(BOOK)?.pdf>) {if ($$f=~/$(BOOK)[a-z].pdf/) {$$c="mv -v $$f $(HOME)/Lightandmatter"; system $$c}}'
192 mv save.pdf
$(BOOK
).pdf
193 cp
$(BOOK
).pdf
$(HOME
)/Lightandmatter
194 perl
-e
'if (-e "code_listings.zip") {system("cp code_listings.zip $(HOME)/Lightandmatter/$(BOOK)_code_listings.zip")}'
197 @perl
-e
'foreach $$g("scripts/check_ruby_version.rb","scripts/run_eruby.pl","fruby","mv_silent","scripts/translate_to_html.rb","process_geom_file.pl","scripts/harvest_aux_files.rb","scripts/latex_table_to_html.pl","scripts/equation_to_image.pl","check_for_colliding_figures.rb","scripts/harvest_code_listings.pl") {$$f="../$$g"; die "file $$g is not executable; fix this with chmod +x $$g" unless -e $$f && -x $$f}'
198 @..
/scripts
/check_ruby_version.rb
199 @perl
-e
'if (-e "../scripts/custom/enable") {system("chmod +x ../scripts/custom/*"); foreach $$f(<../scripts/custom/*.pl>) {$$c="$$f $(BOOK) $(PROBLEMS_CSV)"; system($$c)}}'
200 @
[ `which footex` ] || echo
"******** warning: footex is not installed, so html cannot be generated; get footex from http://www.lightandmatter.com/footex/footex.html"
203 # see meki/zzz_misc/publishing for notes on how far I've progressed with this
205 @cp ..
/custom_html.yaml .
206 ..
/scripts
/translate_to_html.rb
--write_config_and_exit
--modern
--override_config_with
="../config/handheld.config"
207 rm -f
$(HANDHELD_TEMP
)/ch
*/*html
$(HANDHELD_TEMP
)/index.
*html
208 mkdir
-p
$(HANDHELD_TEMP
)
209 WOPT
='$(WOPT) --modern --override_config_with="../config/handheld.config"' $(RUN_ERUBY
) w
$(FIRST_CHAPTER
) $(DIRECTORIES
) #... xhtml
210 cp ..
/standalone.css
$(HANDHELD_TEMP
)
213 @echo
"To post the books, do 'make post_handheld'."
216 cp
$(BOOK
).epub
$(HOME
)/Lightandmatter
217 cp
$(BOOK
).mobi
$(HOME
)/Lightandmatter
220 # Before doing this, do a "make handheld".
221 ebook-convert
$(HANDHELD_TEMP
)/index.html
$(BOOK
).epub
$(GENERIC_OPTIONS_FOR_CALIBRE
) --no-default-epub-cover
224 # Before doing this, do a "make handheld".
225 ebook-convert
$(HANDHELD_TEMP
)/index.html
$(BOOK
).mobi
$(GENERIC_OPTIONS_FOR_CALIBRE
) --rescale-images
228 java
-jar
/usr
/bin
/epubcheck
/epubcheck.jar
$(BOOK
).epub
2>err