mirror of
https://github.com/hendricius/the-sourdough-framework
synced 2025-11-09 12:41: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 removeMaxWidth = function(s) return s:gsub(' max-width: %d+px;', '') end
|
||||||
local removeFixedSettings = function(s) return removeMaxWidth(removeWidth(removeHeight(s))) end
|
local removeFixedSettings = function(s) return removeMaxWidth(removeWidth(removeHeight(s))) end
|
||||||
local process = filter{removeFixedSettings}
|
local process = filter{removeFixedSettings}
|
||||||
Make:htlatex()
|
Make:latexmk {}
|
||||||
Make:match("html$",process)
|
Make:match("html$",process)
|
||||||
|
|||||||
@@ -19,8 +19,10 @@
|
|||||||
\renewcommand\theadfont{\bfseries}
|
\renewcommand\theadfont{\bfseries}
|
||||||
|
|
||||||
% Fonts for accessibility
|
% Fonts for accessibility
|
||||||
%\usepackage{helvet}
|
\ifdefined\isaccessible
|
||||||
%\renewcommand{\familydefault}{\sfdefault}
|
\usepackage{helvet}
|
||||||
|
\renewcommand{\familydefault}{\sfdefault}
|
||||||
|
\fi
|
||||||
|
|
||||||
% References
|
% References
|
||||||
\usepackage[backend=biber]{biblatex}
|
\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
|
.PHONY: build_pdf
|
||||||
build_pdf: clean figures tables
|
build_pdf: build_serif_pdf build_sans_serif_pdf
|
||||||
pdflatex book.tex
|
|
||||||
biber book
|
|
||||||
pdflatex book.tex
|
|
||||||
|
|
||||||
# setup_default_build:
|
.PHONY: build_serif_pdf
|
||||||
# sed -i '.bak' 's#^\\usepackage{helvet}#%\\usepackage{helvet}#g' book.tex
|
build_serif_pdf: book_serif/book.pdf
|
||||||
# sed -i '.bak' 's#^\\renewcommand{\\familydefault}{\\sfdefault}#%\\renewcommand{\\familydefault}{\\sfdefault}#g' book.tex
|
|
||||||
|
|
||||||
|
.PHONY: build_sans_serif_pdf
|
||||||
|
build_sans_serif_pdf: book_sans_serif/book_sans_serif.pdf
|
||||||
|
|
||||||
.PHONY: clean_figures
|
.PHONY: build_ebook
|
||||||
clean_figures:
|
build_ebook: build_serif_ebook build_sans_serif_ebook
|
||||||
cd figures
|
|
||||||
rm -rf figures/*.aux
|
.PHONY: build_serif_ebook
|
||||||
rm -rf figures/*.fdb_latexmk
|
build_serif_ebook: $(TGT_FIGURES) book-epub/book.epub book-mobi/book.mobi book-azw3/book.azw3 | make_release_dir
|
||||||
rm -rf figures/*.fls
|
|
||||||
rm -rf figures/*.log
|
.PHONY: build_sans_serif_ebook
|
||||||
rm -rf figures/*.pdf
|
build_sans_serif_ebook: $(TGT_FIGURES) book_sans_serif-epub/book_sans_serif.epub \
|
||||||
rm -rf figures/*.png
|
book_sans_serif-mobi/book_sans_serif.mobi \
|
||||||
|
book_sans_serif-azw3/book_sans_serif.azw3 | make_release_dir
|
||||||
|
|
||||||
.PHONY: export_figures
|
.PHONY: export_figures
|
||||||
# Requires that you have docker running on your computer.
|
# Requires that you have docker running on your computer.
|
||||||
@@ -25,54 +117,70 @@ export_figures:
|
|||||||
cd figures/ && bash export_figures.sh
|
cd figures/ && bash export_figures.sh
|
||||||
|
|
||||||
.PHONY: figures
|
.PHONY: figures
|
||||||
figures: clean_figures
|
figures: $(SRC_FIGURES)
|
||||||
cd figures && find . -name "fig-*.tex" -exec pdflatex '{}' \;
|
$(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
|
.PHONY: clean
|
||||||
clean: clean_figures
|
clean: clean_ebook_build clean_figures
|
||||||
rm -f book.blg
|
$(CLEAN) -output-directory=book_serif book.tex
|
||||||
rm -f book.bbl
|
$(CLEAN) -output-directory=book_sans_serif book_sans_serif.tex
|
||||||
rm -f book.aux
|
-rm book*/*.bbl
|
||||||
rm -f book.out
|
-rm book*/*.run.xml
|
||||||
rm -f book.toc
|
-rm -rf book*-epub/META-INF
|
||||||
rm -f book.run.xml
|
-rm -rf book*-epub/OEBPS
|
||||||
rm -f book.bcf
|
-rm book*-epub/mimetype
|
||||||
rm -f book.pdf
|
-rm -rf book*-mobi/META-INF
|
||||||
rm -f book.log
|
-rm -rf book*-mobi/OEBPS
|
||||||
rm -f book.mobi
|
-rm book*-mobi/mimetype
|
||||||
rm -f book.4ct
|
-rm book*-mobi/book.epub
|
||||||
rm -f book.4tc
|
-rm -rf book*-mobi/META-INF
|
||||||
rm -f book.dvi
|
-rm -rf book*-azw3/OEBPS
|
||||||
rm -f book.epub
|
-rm -rf book*-azw3/META-INF
|
||||||
rm -f book.css
|
-rm book*-azw3/book.epub
|
||||||
rm -f book.fdb_latexmk
|
-rm book*-azw3/mimetype
|
||||||
rm -f book.fls
|
|
||||||
rm -f book.idv
|
.PHONY: mrproper
|
||||||
rm -f book.lg
|
mrproper: clean
|
||||||
rm -f book.ncx
|
$(CLEAN) -C $(SRC_FIGURES)
|
||||||
rm -f book.tmp
|
$(CLEAN) -C -output-directory=book_serif book.tex
|
||||||
rm -f book.xref
|
$(CLEAN) -C -output-directory=book_sans_serif book_sans_serif.tex
|
||||||
rm -f book*.svg
|
-rm figures/*.pdf
|
||||||
rm -f book*.html
|
-rm figures/*.png
|
||||||
rm -f book*.xhtml
|
rm -rf book*-mobi/
|
||||||
rm -rf book-epub/
|
rm -rf book*-azw3/
|
||||||
rm -rf book-epub3/
|
rm -rf book*-epub/
|
||||||
rm -rf book-mobi/
|
rm -rf release/
|
||||||
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
|
|
||||||
rm -rf release/
|
rm -rf release/
|
||||||
rm -rf release_sans_serif/
|
rm -rf release_sans_serif/
|
||||||
|
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
|
|
||||||
|
|
||||||
.PHONY: bake
|
.PHONY: bake
|
||||||
bake: release_default release_sans_serif
|
bake: release_default release_sans_serif
|
||||||
@@ -81,35 +189,16 @@ bake: release_default release_sans_serif
|
|||||||
make_release_dir:
|
make_release_dir:
|
||||||
mkdir -p release
|
mkdir -p release
|
||||||
|
|
||||||
.PHONY: release_sans_serif
|
.PHONY: release_default
|
||||||
release_sans_serif: make_release_dir
|
release_default: build_pdf build_ebook | make_release_dir
|
||||||
# For the sans serif version we are just going
|
cp book_serif/book.pdf release/TheBreadCode-The-Sourdough-Framework.pdf
|
||||||
# to copy all the files into a new folder and
|
cp book-mobi/book.mobi release/TheBreadCode-The-Sourdough-Framework.mobi
|
||||||
rm -rf release_sans_serif/
|
cp book-epub/book.epub release/TheBreadCode-The-Sourdough-Framework.epub
|
||||||
mkdir /tmp/release_sans_serif
|
cp book-azw3/book.azw3 release/TheBreadCode-The-Sourdough-Framework.azw3
|
||||||
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: build_ebook
|
.PHONY: release_sans_serif
|
||||||
build_ebook: make_release_dir
|
release_sans_serif: build_sans_serif_pdf build_sans_serif_ebook | make_release_dir
|
||||||
tex4ebook -c tex4ebook.cfg -f epub book.tex
|
cp book_sans_serif/book_sans_serif.pdf release/TheBreadCode-The-Sourdough-Framework-sans-serif.pdf
|
||||||
tex4ebook -c tex4ebook.cfg -f mobi book.tex
|
cp book_sans_serif-mobi/book_sans_serif.mobi release/TheBreadCode-The-Sourdough-Framework-sans-serif.mobi
|
||||||
# not sure why, but I hvae to generate the mobi twice for the
|
cp book_sans_serif-epub/book_sans_serif.epub release/TheBreadCode-The-Sourdough-Framework-sans-serif.epub
|
||||||
# release command to properly work.
|
cp book_sans_serif-azw3/book_sans_serif.azw3 release/TheBreadCode-The-Sourdough-Framework-sans-serif.azw3
|
||||||
tex4ebook -c tex4ebook.cfg -f mobi book.tex
|
|
||||||
tex4ebook -c tex4ebook.cfg -f azw3 book.tex
|
|
||||||
|
|||||||
Reference in New Issue
Block a user