mirror of
https://github.com/hendricius/the-sourdough-framework
synced 2025-11-08 20:21:12 -06:00
improve makefiles (#113)
* Make headrow in tables bold
* Simplify tables markup
- Markup is definitely simpler.
- Will not be built separately in a pdf anymore.
- Fixed some typo as well
- Relatively coherent look
- Can be better, some sizes are relatively arbitrary
* Remove horizontal separation inside tables
Not very nice if you ask me..
* Fix some tables for the ebook
The alignement trick to have nicely alignment on = sign or on unit (g)
used broke the html. Reverting to a less optimal version on pdf while
not breaking the html.
* Simplify table for html output
* Revert "Simplify table for html output"
This reverts commit f85d65adb7.
* Revert pancake table
This way it builds ebook correctly.
* Use latexmk and dedicated build_directory
- Generic rule for building pdf from tex
- build the book in its own directory
- do not clean before
* Make accessible pdf a command line option
* Simplify accessible version generation
using the option in book.tex instead of copying files around.
TODO: figures/Tkiz still are with serif.
* Specify some dependencies as order only
We don't want to trigger a rebuild everytime the directory timestamp
changes
* Remove force rebuild
* Fix dependencies handling
- Explicit some dependencies
- Ebook must be handled manually as we don't have latexmk working with
latexmk or not sure how to do it...
* Improve clean
- Use latexmk to clean where possible
- clean the sans-serif as well
- failing rm will output a non-stopping error now
* Cleanup and comment makefile
For clarity, also move things around
* Add an mrproper target
clean now only removes intermediate files, keeps pdf and ebook in there.
Mr proper will remove evrything
* Add dependency of figures for ebook
* Add default rules you expect
make will build the pdf
make all will build all
* Add a make help command
Gives list of useful targets and their action
* Use latexmk to build TikZ pictures
* Use latexmk for building ebooks
* Let latexmk handle dependencies
would get it wrong otherwise...
* Add rule for sans serif ebook
* Add dependencies on TikZ figures for ebooks
* add mk4 file for the sans_serif version of ebook
symlink to the other one as they should be the same.
* Reorder the makefile variables declaration
Looks like I did not fully understood how it works..
Also added some PHONY targets and comments
* Add missing actions in clean target
Some file got forgotten... clean the makefile as well.
* Split the clean in a clean ebook section
* Clean the ebook before building the pdf
Not idel but I have no idea how to have the intermediate files in
another directory with tex4ebook
This commit is contained in:
@@ -4,5 +4,5 @@ local removeWidth = function(s) return s:gsub('width="%d+"', '') end
|
||||
local removeMaxWidth = function(s) return s:gsub(' max-width: %d+px;', '') end
|
||||
local removeFixedSettings = function(s) return removeMaxWidth(removeWidth(removeHeight(s))) end
|
||||
local process = filter{removeFixedSettings}
|
||||
Make:htlatex()
|
||||
Make:latexmk {}
|
||||
Make:match("html$",process)
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
\renewcommand\theadfont{\bfseries}
|
||||
|
||||
% Fonts for accessibility
|
||||
%\usepackage{helvet}
|
||||
%\renewcommand{\familydefault}{\sfdefault}
|
||||
\ifdefined\isaccessible
|
||||
\usepackage{helvet}
|
||||
\renewcommand{\familydefault}{\sfdefault}
|
||||
\fi
|
||||
|
||||
% References
|
||||
\usepackage[backend=biber]{biblatex}
|
||||
|
||||
1
book/book_sans_serif.mk4
Symbolic link
1
book/book_sans_serif.mk4
Symbolic link
@@ -0,0 +1 @@
|
||||
book.mk4
|
||||
2
book/book_sans_serif.tex
Normal file
2
book/book_sans_serif.tex
Normal file
@@ -0,0 +1,2 @@
|
||||
\def\isaccessible{1}
|
||||
\input{book.tex}
|
||||
271
book/makefile
271
book/makefile
@@ -1,23 +1,115 @@
|
||||
# Macros for commands
|
||||
LATEX := latexmk -cd -pdf -pdflatex="pdflatex -interaction=nonstopmode" -use-make
|
||||
EBOOK := tex4ebook -c tex4ebook.cfg
|
||||
CLEAN := latexmk -cd -c -use-make
|
||||
|
||||
# List all files that are dependencies
|
||||
SRC_FIGURES := $(wildcard figures/fig-*.tex)
|
||||
# List all files that are dependencies
|
||||
CHAPTERS = baking basics bread-types flour-types history intro\
|
||||
non-wheat-sourdough sourdough-starter storing-bread troubleshooting\
|
||||
wheat-sourdough
|
||||
|
||||
SRC_TABLES := $(wildcard tables/tables-*.tex)
|
||||
SRC_FIGURES := $(wildcard figures/fig-*.tex)
|
||||
|
||||
SRC_TEX := $(foreach directory, $(CHAPTERS), $(wildcard $(directory)/*.tex))
|
||||
SRC_TEX := $(SRC_TEX) book.tex book_sans_serif.tex references.bib
|
||||
|
||||
IMAGES := $(wildcard images/*/*.jpg)
|
||||
IMAGES := $(IMAGES) $(wildcard images/*/*.png)
|
||||
IMAGES := $(IMAGES) $(foreach directory, $(CHAPTERS), $(wildcard $(directory)/*.jpg))
|
||||
IMAGES := $(IMAGES) $(foreach directory, $(CHAPTERS), $(wildcard $(directory)/*.png))
|
||||
|
||||
TGT_FIGURES := $(patsubst %.tex, %.pdf,$(SRC_FIGURES))
|
||||
SRC_ALL := $(SRC_TEX) $(SRC_FIGURES) $(SRC_TABLES) tex4ebook.cfg book.mk4 $(IMAGES)
|
||||
|
||||
# Default rules for pdf and ebooks, getting overwritten when built in a
|
||||
# sub-directory
|
||||
%.pdf: %.tex
|
||||
$(LATEX) $<
|
||||
|
||||
book_serif/book.pdf: clean_ebook_build $(SRC_ALL)
|
||||
$(LATEX) -output-directory=book_serif book.tex
|
||||
|
||||
book_sans_serif/book_sans_serif.pdf: clean_ebook_build $(SRC_ALL)
|
||||
$(LATEX) -output-directory=book_sans_serif book_sans_serif.tex
|
||||
|
||||
book-epub/%.epub: %.tex $(SRC_ALL)
|
||||
$(EBOOK) -f epub $<
|
||||
|
||||
book-mobi/%.mobi: %.tex $(SRC_ALL)
|
||||
# not sure why, but I have to generate the mobi twice for the release
|
||||
# command to properly work.
|
||||
$(EBOOK) -f mobi $<
|
||||
$(EBOOK) -f mobi $<
|
||||
|
||||
book-azw3/%.azw3: %.tex $(SRC_ALL)
|
||||
$(EBOOK) -f azw3 $<
|
||||
|
||||
# Not sure if there is a better way with a wildcard?
|
||||
book_sans_serif-epub/%.epub: %.tex $(SRC_ALL)
|
||||
$(EBOOK) -f epub $<
|
||||
|
||||
book_sans_serif-mobi/%.mobi: %.tex $(SRC_ALL)
|
||||
# not sure why, but I have to generate the mobi twice for the release
|
||||
# command to properly work.
|
||||
$(EBOOK) -f mobi $<
|
||||
$(EBOOK) -f mobi $<
|
||||
|
||||
book_sans_serif-azw3/%.azw3: %.tex $(SRC_ALL)
|
||||
$(EBOOK) -f azw3 $<
|
||||
|
||||
# Now with the rules
|
||||
# Expected usual rules first
|
||||
|
||||
.PHONY: default
|
||||
default: build_pdf
|
||||
|
||||
.PHONY: all
|
||||
all: bake
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@echo ""
|
||||
@echo "default: builds the book in pdf format (serif)"
|
||||
@echo ""
|
||||
@echo "all: pdf and ebooks serif and sans-serif accessible version, same as build release"
|
||||
@echo "bake: same as build all"
|
||||
@echo "release_default: same as build all"
|
||||
@echo ""
|
||||
@echo "clean: delete all intermediate files keep targets (pdf/ebook)"
|
||||
@echo "mrproper: delete all generated files intermediate and pdf/ebooks"
|
||||
@echo "clean_figures: delete intermediate TikZ files"
|
||||
@echo ""
|
||||
@echo "build_ebook: builds only the ebook serif and accessible version"
|
||||
@echo "build_pdf:builds both serif and accessible pdf"
|
||||
@echo ""
|
||||
@echo "build_sans_serif_ebook: build accessible ebook only"
|
||||
@echo "build_sans_serif_pdf: build accessible pdf only"
|
||||
@echo ""
|
||||
@echo "figures: build TikZ figures"
|
||||
|
||||
# Finally project specif targets
|
||||
.PHONY: build_pdf
|
||||
build_pdf: clean figures tables
|
||||
pdflatex book.tex
|
||||
biber book
|
||||
pdflatex book.tex
|
||||
build_pdf: build_serif_pdf build_sans_serif_pdf
|
||||
|
||||
# setup_default_build:
|
||||
# sed -i '.bak' 's#^\\usepackage{helvet}#%\\usepackage{helvet}#g' book.tex
|
||||
# sed -i '.bak' 's#^\\renewcommand{\\familydefault}{\\sfdefault}#%\\renewcommand{\\familydefault}{\\sfdefault}#g' book.tex
|
||||
.PHONY: build_serif_pdf
|
||||
build_serif_pdf: book_serif/book.pdf
|
||||
|
||||
.PHONY: build_sans_serif_pdf
|
||||
build_sans_serif_pdf: book_sans_serif/book_sans_serif.pdf
|
||||
|
||||
.PHONY: clean_figures
|
||||
clean_figures:
|
||||
cd figures
|
||||
rm -rf figures/*.aux
|
||||
rm -rf figures/*.fdb_latexmk
|
||||
rm -rf figures/*.fls
|
||||
rm -rf figures/*.log
|
||||
rm -rf figures/*.pdf
|
||||
rm -rf figures/*.png
|
||||
.PHONY: build_ebook
|
||||
build_ebook: build_serif_ebook build_sans_serif_ebook
|
||||
|
||||
.PHONY: build_serif_ebook
|
||||
build_serif_ebook: $(TGT_FIGURES) book-epub/book.epub book-mobi/book.mobi book-azw3/book.azw3 | make_release_dir
|
||||
|
||||
.PHONY: build_sans_serif_ebook
|
||||
build_sans_serif_ebook: $(TGT_FIGURES) book_sans_serif-epub/book_sans_serif.epub \
|
||||
book_sans_serif-mobi/book_sans_serif.mobi \
|
||||
book_sans_serif-azw3/book_sans_serif.azw3 | make_release_dir
|
||||
|
||||
.PHONY: export_figures
|
||||
# Requires that you have docker running on your computer.
|
||||
@@ -25,54 +117,70 @@ export_figures:
|
||||
cd figures/ && bash export_figures.sh
|
||||
|
||||
.PHONY: figures
|
||||
figures: clean_figures
|
||||
cd figures && find . -name "fig-*.tex" -exec pdflatex '{}' \;
|
||||
figures: $(SRC_FIGURES)
|
||||
$(LATEX) $<
|
||||
|
||||
.PHONY: clean_figures
|
||||
clean_figures:
|
||||
$(CLEAN) $(SRC_FIGURES)
|
||||
|
||||
.PHONY: clean_ebook_build
|
||||
clean_ebook_build:
|
||||
-rm book*.aux
|
||||
-rm book*.run.xml
|
||||
-rm book*.bcf
|
||||
-rm book*.blg
|
||||
-rm book*.log
|
||||
-rm book*.4tc
|
||||
-rm book*.4ct
|
||||
-rm book*.dvi
|
||||
-rm book*.epub
|
||||
-rm book.css
|
||||
-rm book_sans_serif.css
|
||||
-rm book*.idv
|
||||
-rm book*.lg
|
||||
-rm book*.ncx
|
||||
-rm book*.tmp
|
||||
-rm book*.xref
|
||||
-rm book*.html
|
||||
-rm book*.fls
|
||||
-rm book*.fdb_latexmk
|
||||
-rm book*.bbl
|
||||
-rm content.opf
|
||||
|
||||
.PHONY: clean
|
||||
clean: clean_figures
|
||||
rm -f book.blg
|
||||
rm -f book.bbl
|
||||
rm -f book.aux
|
||||
rm -f book.out
|
||||
rm -f book.toc
|
||||
rm -f book.run.xml
|
||||
rm -f book.bcf
|
||||
rm -f book.pdf
|
||||
rm -f book.log
|
||||
rm -f book.mobi
|
||||
rm -f book.4ct
|
||||
rm -f book.4tc
|
||||
rm -f book.dvi
|
||||
rm -f book.epub
|
||||
rm -f book.css
|
||||
rm -f book.fdb_latexmk
|
||||
rm -f book.fls
|
||||
rm -f book.idv
|
||||
rm -f book.lg
|
||||
rm -f book.ncx
|
||||
rm -f book.tmp
|
||||
rm -f book.xref
|
||||
rm -f book*.svg
|
||||
rm -f book*.html
|
||||
rm -f book*.xhtml
|
||||
rm -rf book-epub/
|
||||
rm -rf book-epub3/
|
||||
rm -rf book-mobi/
|
||||
rm -rf book-azw3/
|
||||
rm -rf book.azw3
|
||||
rm -f *.pdf
|
||||
rm -f output.log
|
||||
rm -f content.opf
|
||||
find . -name "*.xbb" | xargs rm -f
|
||||
clean: clean_ebook_build clean_figures
|
||||
$(CLEAN) -output-directory=book_serif book.tex
|
||||
$(CLEAN) -output-directory=book_sans_serif book_sans_serif.tex
|
||||
-rm book*/*.bbl
|
||||
-rm book*/*.run.xml
|
||||
-rm -rf book*-epub/META-INF
|
||||
-rm -rf book*-epub/OEBPS
|
||||
-rm book*-epub/mimetype
|
||||
-rm -rf book*-mobi/META-INF
|
||||
-rm -rf book*-mobi/OEBPS
|
||||
-rm book*-mobi/mimetype
|
||||
-rm book*-mobi/book.epub
|
||||
-rm -rf book*-mobi/META-INF
|
||||
-rm -rf book*-azw3/OEBPS
|
||||
-rm -rf book*-azw3/META-INF
|
||||
-rm book*-azw3/book.epub
|
||||
-rm book*-azw3/mimetype
|
||||
|
||||
.PHONY: mrproper
|
||||
mrproper: clean
|
||||
$(CLEAN) -C $(SRC_FIGURES)
|
||||
$(CLEAN) -C -output-directory=book_serif book.tex
|
||||
$(CLEAN) -C -output-directory=book_sans_serif book_sans_serif.tex
|
||||
-rm figures/*.pdf
|
||||
-rm figures/*.png
|
||||
rm -rf book*-mobi/
|
||||
rm -rf book*-azw3/
|
||||
rm -rf book*-epub/
|
||||
rm -rf release/
|
||||
rm -rf release/
|
||||
rm -rf release_sans_serif/
|
||||
|
||||
.PHONY: release_default
|
||||
release_default: clean build_pdf make_release_dir build_ebook
|
||||
cp book.pdf release/TheBreadCode-The-Sourdough-Framework.pdf
|
||||
cp book-mobi/book.mobi release/TheBreadCode-The-Sourdough-Framework.mobi
|
||||
cp book-epub/book.epub release/TheBreadCode-The-Sourdough-Framework.epub
|
||||
cp book-azw3/book.azw3 release/TheBreadCode-The-Sourdough-Framework.azw3
|
||||
rm -rf release_sans_serif/
|
||||
|
||||
.PHONY: bake
|
||||
bake: release_default release_sans_serif
|
||||
@@ -81,35 +189,16 @@ bake: release_default release_sans_serif
|
||||
make_release_dir:
|
||||
mkdir -p release
|
||||
|
||||
.PHONY: release_sans_serif
|
||||
release_sans_serif: make_release_dir
|
||||
# For the sans serif version we are just going
|
||||
# to copy all the files into a new folder and
|
||||
rm -rf release_sans_serif/
|
||||
mkdir /tmp/release_sans_serif
|
||||
cp -R * /tmp/release_sans_serif
|
||||
mv /tmp/release_sans_serif .
|
||||
# The next part will uncomment the sans serif font in the book.tex
|
||||
#
|
||||
# Note that the OS X sed behaves a little different
|
||||
# than the gnu sed. If you are on OS X you might
|
||||
# have to install gnu sed for this to work. Or you can
|
||||
# use sed -i '.bak' restofcommand. OS X wants to have
|
||||
# a backup file listed before replacing the contents
|
||||
# of a file.
|
||||
sed -i 's#%\\usepackage{helvet}#\\usepackage{helvet}#g' release_sans_serif/book.tex
|
||||
sed -i 's#%\\renewcommand{\\familydefault}{\\sfdefault}#\\renewcommand{\\familydefault}{\\sfdefault}#g' release_sans_serif/book.tex
|
||||
cd release_sans_serif && $(MAKE) release_default
|
||||
cp release_sans_serif/release/TheBreadCode-The-Sourdough-Framework.pdf release/TheBreadCode-The-Sourdough-Framework-sans-serif.pdf
|
||||
cp release_sans_serif/release/TheBreadCode-The-Sourdough-Framework.mobi release/TheBreadCode-The-Sourdough-Framework-sans-serif.mobi
|
||||
cp release_sans_serif/release/TheBreadCode-The-Sourdough-Framework.epub release/TheBreadCode-The-Sourdough-Framework-sans-serif.epub
|
||||
cp release_sans_serif/release/TheBreadCode-The-Sourdough-Framework.azw3 release/TheBreadCode-The-Sourdough-Framework-sans-serif.azw3
|
||||
.PHONY: release_default
|
||||
release_default: build_pdf build_ebook | make_release_dir
|
||||
cp book_serif/book.pdf release/TheBreadCode-The-Sourdough-Framework.pdf
|
||||
cp book-mobi/book.mobi release/TheBreadCode-The-Sourdough-Framework.mobi
|
||||
cp book-epub/book.epub release/TheBreadCode-The-Sourdough-Framework.epub
|
||||
cp book-azw3/book.azw3 release/TheBreadCode-The-Sourdough-Framework.azw3
|
||||
|
||||
.PHONY: build_ebook
|
||||
build_ebook: make_release_dir
|
||||
tex4ebook -c tex4ebook.cfg -f epub book.tex
|
||||
tex4ebook -c tex4ebook.cfg -f mobi book.tex
|
||||
# not sure why, but I hvae to generate the mobi twice for the
|
||||
# release command to properly work.
|
||||
tex4ebook -c tex4ebook.cfg -f mobi book.tex
|
||||
tex4ebook -c tex4ebook.cfg -f azw3 book.tex
|
||||
.PHONY: release_sans_serif
|
||||
release_sans_serif: build_sans_serif_pdf build_sans_serif_ebook | make_release_dir
|
||||
cp book_sans_serif/book_sans_serif.pdf release/TheBreadCode-The-Sourdough-Framework-sans-serif.pdf
|
||||
cp book_sans_serif-mobi/book_sans_serif.mobi release/TheBreadCode-The-Sourdough-Framework-sans-serif.mobi
|
||||
cp book_sans_serif-epub/book_sans_serif.epub release/TheBreadCode-The-Sourdough-Framework-sans-serif.epub
|
||||
cp book_sans_serif-azw3/book_sans_serif.azw3 release/TheBreadCode-The-Sourdough-Framework-sans-serif.azw3
|
||||
|
||||
Reference in New Issue
Block a user