1 Commits

Author SHA1 Message Date
Hendrik Kleinwaechter
95c3a91bee Merge 4160557857 into 6b1d2c3de6 2025-02-24 17:20:46 +00:00

View File

@@ -7,8 +7,8 @@ CHECK_1 := lacheck
CHECK_2 := chktex CHECK_2 := chktex
CONVERT_PIC := convert CONVERT_PIC := convert
REDUCE_PIC := -resize '800x800>' \ REDUCE_PIC := -resize '800x800>' \
-strip -interlace Plane -gaussian-blur 0.05 -quality 85\% \ -strip -interlace Plane -gaussian-blur 0.05 -quality 85\% \
-set colorspace Gray -separate -evaluate-sequence Mean -set colorspace Gray -separate -evaluate-sequence Mean
REDUCE_PIC_COLOR := -quality 80\% REDUCE_PIC_COLOR := -quality 80\%
RSYNC := rsync -au --exclude 'book.epub' --exclude '*.jpg' RSYNC := rsync -au --exclude 'book.epub' --exclude '*.jpg'
GIT := git --no-pager GIT := git --no-pager
@@ -30,7 +30,7 @@ endif
# and building everything take a long time. # and building everything take a long time.
.DEFAULT_GOAL := serif .DEFAULT_GOAL := serif
# Dependencies {{{ # List all files that are dependencies {{{
chapters = baking basics bread-types cover flour-types history intro mix-ins\ chapters = baking basics bread-types cover flour-types history intro mix-ins\
non-wheat-sourdough sourdough-starter storing-bread troubleshooting\ non-wheat-sourdough sourdough-starter storing-bread troubleshooting\
wheat-sourdough glossary wheat-sourdough glossary
@@ -75,17 +75,15 @@ low_res_images := $(filter-out %.png, $(low_res_images))
# All together. # All together.
src_all := $(src_tex) $(src_figures) $(src_tables) $(images) $(src_plots) src_all := $(src_tex) $(src_figures) $(src_tables) $(images) $(src_plots)
# Format specific configuration files # And format specific configurations
ebook_src := $(src_all) tex4ebook.cfg book.mk4 book-ebook.css ebook_src := $(src_all) tex4ebook.cfg book.mk4 book-ebook.css
website_src := $(src_all) website.cfg style.css website_src := $(src_all) website.cfg style.css
website_dir := static_website_html website_dir := static_website_html
website_assets := $(wildcard ../website/assets/*) website_assets := $(wildcard ../website/assets/*)
ruby_src := ../website/modify_build.rb $(website_assets) ruby_src := ../website/modify_build.rb $(website_assets)
ruby_pkg := ../website/Gemfile ../website/Gemfile.lock ruby_pkg := ../website/Gemfile ../website/Gemfile.lock
# }}}
# Internal build rules {{{
# Flowcharts {{{ # Flowcharts {{{
# TODO: check if it works on github CI # TODO: check if it works on github CI
%.png: %.tex %.png: %.tex
@@ -100,7 +98,7 @@ ruby_pkg := ../website/Gemfile ../website/Gemfile.lock
ebb -x $< ebb -x $<
# }}} # }}}
# Pdf {{{ # pdf {{{
# Default rules for pdf, getting overwritten when built in a sub-directory # Default rules for pdf, getting overwritten when built in a sub-directory
%.pdf: %.tex %.pdf: %.tex
$(LATEX) $< $(LATEX) $<
@@ -118,15 +116,15 @@ book_sans_serif/book_sans_serif.pdf: $(src_all)
epub/%.epub: %.tex $(ebook_src) cover/cover-page.xbb epub/%.epub: %.tex $(ebook_src) cover/cover-page.xbb
$(EBOOK) $< $(EBOOK) $<
copy_ebook_files: ebook copy_ebook_files: build_ebook
$(RSYNC) --exclude '*.png' epub_build/book-epub/ bw-book-epub/ $(RSYNC) --exclude '*.png' epub_build/book-epub/ bw-book-epub/
# Now that we have built the ebook we will generate 2 more versions # Now that we have built the ebook we will generate 2 more versions
# #
# 1) With kindle app on phone we want a colour version with size < 50 MB # 1) With kindle app on phone we want a colour version with size < 50 MB
# 2) A black-white version for actual eink readers # 2) A black-white version for actual eink readers
# #
# In both cases we just convert images and repack the ebpub # In both cases we just convert images and repack the ebpub
# We do not convert SVG to B&W or lower res for now as they are super small # We do not convert SVG to B&W or lower res for now as they are super small
# anyway # anyway
@@ -153,7 +151,7 @@ low-res-book-epub/OEBPS/%.jpg: %.jpg
epub/low_res_book.epub: copy_ebook_files_low_res $(low_res_images) epub/low_res_book.epub: copy_ebook_files_low_res $(low_res_images)
cd low-res-book-epub; zip -q0X ../epub/low_res_book.epub mimetype cd low-res-book-epub; zip -q0X ../epub/low_res_book.epub mimetype
cd low-res-book-epub; zip -q9XrD ../epub/low_res_book.epub ./ cd low-res-book-epub; zip -q9XrD ../epub/low_res_book.epub ./
# }}} #}}}
# Website {{{ # Website {{{
################################### ###################################
@@ -183,47 +181,33 @@ website: html ../website/_bundle_install_done $(ruby_src)
export_figures: pdf $(tgt_figures) export_figures: pdf $(tgt_figures)
cd figures/ && bash export_figures.sh cd figures/ && bash export_figures.sh
# }}} # }}}
# }}}
# User level targets {{{ # Now with the targets {{{
# Build targets {{{ # Expected usual targets first
.PHONY: all .PHONY: all
all: bake all: bake
# Finally actual project targets (i.e. build pdf and ebooks) # Finally actual project targets (i.e. build pdf and ebooks)
.PHONY: pdf serif sans_serif ebook .PHONY: pdf serif sans_serif ebook
pdf: serif sans_serif pdf: serif sans_serif
serif: book_serif/book.pdf serif: book_serif/book.pdf
sans_serif: book_sans_serif/book_sans_serif.pdf sans_serif: book_sans_serif/book_sans_serif.pdf
ebook: epub/book.epub ebook: epub/book.epub
bw_ebook: epub/bw_book.epub bw_ebook: epub/bw_book.epub
low_res_ebook: epub/low_res_book.epub low_res_ebook: epub/low_res_book.epub
# }}}
# Old target names are disabled with helpful help message {{{ # We keep the old target names for backward compatibility
build_pdf: build_pdf: pdf
@echo "build_pdf target is not supported anymore, please use make pdf" build_serif_pdf: serif
@exit build_sans_serif_pdf: sans_serif
build_serif_pdf: build_ebook: ebook
@echo "build_serif_pdf target is not supported anymore, please use make serif" build_bw_ebook: bw_ebook
@exit build_low_res_ebook: low_res_ebook
build_sans_serif_pdf:
@echo "build_sans_serif_pdf target is not supported anymore, please use make sans_serif"
@exit
build_ebook:
@echo "build_ebook target is not supported anymore, please use make ebook"
@exit
build_bw_ebook:
@echo "build_bw_ebook target is not supported anymore, please use make bw_ebook"
@exit
build_low_res_ebook:
@echo "build_low_res_ebook target is not supported anymore, please use make low_res_ebook"
@exit
# }}}
# Top level releases rules {{{ # top level releases rules
.PHONY: bake release_serif release_sans_serif .PHONY: bake release_serif release_sans_serif
bake: release_serif release_sans_serif website bake: release_serif release_sans_serif website
@@ -241,7 +225,7 @@ release_serif: serif ebook bw_ebook low_res_ebook | release
fi fi
release_sans_serif: sans_serif | release release_sans_serif: sans_serif | release
cp book_sans_serif/book_sans_serif.pdf release/TheBreadCode-The-Sourdough-Framework-sans-serif.pdf cp book_sans_serif/book_sans_serif.pdf release/TheBreadCode-The-Sourdough-Framework-sans-serif.pdf
# }}} # }}}
# Clean up {{{ # Clean up {{{
@@ -259,9 +243,12 @@ clean_figures:
clean_ebook_build: clean_ebook_build:
-rm epub_build/book*.{4ct,4tc,aux,bbl,bcf,blg,dvi,fdb_latexmk,fls,html} -rm epub_build/book*.{4ct,4tc,aux,bbl,bcf,blg,dvi,fdb_latexmk,fls,html}
-rm epub_build/book*.{idv,lg,loc,log,ncx,run.xml,tmp,xref} -rm epub_build/book*.{idv,lg,loc,log,ncx,run.xml,tmp,xref}
-rm epub_build/{book.css,content.opf} epub_build/book-epub/mimetype
-rm epub_build/book*x.svg -rm epub_build/book*x.svg
-rm -rf epub_build/book-epub/META-INF epub_build/book-epub/OEBPS -rm epub_build/book.css
-rm epub_build/content.opf
-rm epub_build/book-epub/mimetype
-rm -rf epub_build/book-epub/META-INF
-rm -rf epub_build/book-epub/OEBPS
clean_website_build: clean_website_build:
-rm website_build/book*.{4ct,4tc,aux,bbl,bcf,blg,dvi,fdb_latexmk,fls,html} -rm website_build/book*.{4ct,4tc,aux,bbl,bcf,blg,dvi,fdb_latexmk,fls,html}
@@ -278,11 +265,15 @@ mrproper: clean
$(CLEAN) -C -output-directory=book_serif book.tex $(CLEAN) -C -output-directory=book_serif book.tex
$(CLEAN) -C -output-directory=book_sans_serif book_sans_serif.tex $(CLEAN) -C -output-directory=book_sans_serif book_sans_serif.tex
-rm figures/*.png -rm figures/*.png
-rm -rf epub/
-rm -rf release/ -rm -rf release/
-rm -rf book_serif/ book_sans_serif/ -rm -rf book_serif/
-rm -rf epub/ epub_build/ bw-book-epub/ low-res-book-epub/ -rm -rf book_sans_serif/
-rm -rf website_build/ $(website_dir) -rm -rf *book-epub/
# }}} -rm -rf epub_build/
-rm -rf website_build/
-rm -rf $(website_dir)
#}}}
# Help {{{ # Help {{{
################################### ###################################
@@ -342,9 +333,8 @@ help:
@echo "" @echo ""
@echo "set DEBUG i.e make DEBUG=1 ebook to add debug flags to commands" @echo "set DEBUG i.e make DEBUG=1 ebook to add debug flags to commands"
# }}} # }}}
# }}}
# Debug Stuff {{{ # Debug Stuff from now on {{{
################################### ###################################
# Verify your spelling and TeX warnings {{{ # Verify your spelling and TeX warnings {{{
@@ -370,54 +360,54 @@ spell-check: $(src_tex) spelling_exceptions.txt
.PHONY: quick quick_ebook show_tools_version printvars .PHONY: quick quick_ebook show_tools_version printvars
# Those 2 targets allow fast debug cycles but not resolving references etc # Those 2 targets allow fast debug cycles but not resolving references etc
# They also ignore dependencies and run each time you call them. # They also ignore dependencies and run each time you call them.
quick: # run latex only once no biber, no references etc... quick: # run latex only once no biber, no references etc...
$(LATEX) -e '$$max_repeat=1' -halt-on-error -output-directory=book_serif book.tex $(LATEX) -e '$$max_repeat=1' -halt-on-error -output-directory=book_serif book.tex
quick_ebook: cover/cover-page.xbb # run latex only once no biber, ref etc... quick_ebook: cover/cover-page.xbb # run latex only once no biber, ref etc...
$(EBOOK) --mode draft book.tex $(EBOOK) --mode draft book.tex
show_tools_version: # Show version of tools used on the build machine {{{ show_tools_version: # Show version of tools used on the build machine {{{
-$(GIT) log -5 --pretty="%h: %s by %an on %as" - $(GIT) log -1 --pretty=%B
@echo "" @echo ""
-uname -a - uname -a
@echo "" @echo ""
-$(SHELL) --version - $(SHELL) --version
@echo "" @echo ""
-@echo "PATH:" - @echo "PATH:"
-@echo $(PATH) | tr ':' '\n' - @echo $(PATH) | tr ':' '\n'
@echo "" @echo ""
-latexmk --version - latexmk --version
@echo "" @echo ""
-lualatex --version - lualatex --version
@echo "" @echo ""
-tex4ebook --version - tex4ebook --version
@echo "" @echo ""
-make4ht --version - make4ht --version
@echo "" @echo ""
-tidy -version - tidy -version
@echo "" @echo ""
-dvisvgm --version - dvisvgm --version
@echo "" @echo ""
-lacheck | head -5 | tail -1 - lacheck | head -5 | tail -1
@echo "" @echo ""
-chktex --version - chktex --version
@echo "" @echo ""
-make --version - make --version
@echo "" @echo ""
-biber -version - biber -version
@echo "" @echo ""
-ruby --version - ruby --version
@echo "" @echo ""
-$(CONVERT_PIC) --version - $(CONVERT_PIC) --version
@echo "" @echo ""
-rsync --version - rsync --version
# }}} # }}}
# You can find the value of variable X with the following command: # You can find the value of variable X with the following command:
# make print-X # make print-X
print-%: ; @echo $* = $($*) # Print a makefile variable print-%: ; @echo $* = $($*) # Print a makefile variable
printvars: # Print all variables in the makefile printvars: # Print all variables in the makefile
@$(foreach V,$(sort $(.VARIABLES)), \ @$(foreach V,$(sort $(.VARIABLES)), \
$(if $(filter-out environ% default automatic, \ $(if $(filter-out environ% default automatic, \
$(origin $V)),$(info $V=$($V) ($(value $V))))) $(origin $V)),$(info $V=$($V) ($(value $V)))))