-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WiP reworked makefile for web version
Issue #4
- Loading branch information
Showing
4 changed files
with
164 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# | ||
# Rules for converting TikZ figures to PNG images, invoked by 'epub_html.gosh' | ||
# | ||
|
||
img/%.tikz: ../img/%.tikz | ||
cd img; ln -s ../../img/$*.tikz | ||
|
||
img/%.pdf: img/%.tikz | ||
make -C img $*.pdf | ||
|
||
GS_DPI := 200 | ||
|
||
img/%-unscaled.png: img/%.pdf | ||
gs -dNOPAUSE -dBATCH -sDEVICE=pngalpha -r$(GS_DPI) -sOutputFile=$@ $< | ||
|
||
img/%.png: img/%-unscaled.png | ||
convert -filter lanczos -resize 80% $< $@ | ||
|
||
GENERATED_IMGS_LOG := $(wildcard img/*.log) | ||
GENERATED_IMGS := $(GENERATED_IMGS_LOG:.log=) | ||
|
||
clean_generated_imgs: | ||
rm -f $(foreach suffix,.png .log .tikz .aux,$(addsuffix $(suffix),$(GENERATED_IMGS))) | ||
|
||
clean: clean_generated_imgs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
SHELL := bash | ||
|
||
PWD := $(shell pwd) | ||
|
||
CHAPTERS := introduction \ | ||
getting_started \ | ||
architecture \ | ||
components \ | ||
development \ | ||
system_configuration \ | ||
under_the_hood | ||
|
||
# return list of sections for given basename of chapter | ||
sections = $(shell ../epub/splitter/filter-sec.sh list < ../$1.txt) | ||
|
||
# return Nth path element | ||
second_elem = $(word 2,$(subst /, ,$1)) | ||
third_elem = $(word 3,$(subst /, ,$1)) | ||
|
||
# populate 'SECTIONS(i)' variables, using the chapter as index | ||
$(foreach C,$(CHAPTERS),$(eval SECTIONS($C) := $(call sections,$C))) | ||
|
||
ALL_SECTIONS := $(foreach C,$(CHAPTERS),\ | ||
$(foreach S,${SECTIONS($C)},\ | ||
$C/$S)) | ||
|
||
ALL_SECTIONS_TXT := $(addprefix sections/,$(addsuffix .txt,$(ALL_SECTIONS))) | ||
ALL_CHAPTERS_TXT := $(addprefix chapters/,$(addsuffix .txt,$(CHAPTERS))) | ||
ALL_SECTIONS_HTML := $(addprefix html/,$(addsuffix .html,$(ALL_SECTIONS))) | ||
ALL_CHAPTERS_INDEX_HTML := $(addprefix html/,$(addsuffix /index.html,$(CHAPTERS))) | ||
ALL_HTML := $(ALL_SECTIONS_HTML) $(ALL_CHAPTERS_INDEX_HTML) html/index.html | ||
|
||
# gosh arguments used for all html documents | ||
GOSH_DOC_ARGS := --style ../epub/epub_html \ | ||
--web-build \ | ||
--html-xrefs xrefs \ | ||
--stylesheet style.css \ | ||
|
||
default: html/style.css $(ALL_HTML) | ||
|
||
# | ||
# Create img directory before generating html documents to allow epub_html.gosh | ||
# to create the individual images as side effects of creating the html | ||
# documents. | ||
# | ||
IMG_DIR_CONTENT := Makefile \ | ||
tikz-common.tex tikz-preamble.tex tikz-standalone.tex \ | ||
qt_avplay_screen.png | ||
|
||
$(ALL_HTML): $(addprefix img/,$(IMG_DIR_CONTENT)) | ||
$(addprefix img/,$(IMG_DIR_CONTENT)): | ||
mkdir -p img | ||
ln -sf ../../img/$(notdir $@) $@ | ||
|
||
# generate cross-reference index | ||
xrefs: $(ALL_SECTIONS_TXT) $(ALL_CHAPTERS_TXT) | ||
( $(foreach C,$(CHAPTERS),\ | ||
gosh --style html_xrefs --html-path '$C/index.html' \ | ||
'chapters/$C.txt'; \ | ||
$(foreach S,${SECTIONS($C)},\ | ||
gosh --style html_xrefs --html-path '$C/$S.html' \ | ||
'sections/$C/$S.txt' | grep -v FAKE-CHAPTER; )) \ | ||
)> $@ | ||
|
||
# install images generated during the creation of the html documents | ||
default: html/img | ||
html/img: $(ALL_HTML) | ||
.PHONY: html/img | ||
html/img: | ||
mkdir -p $@ | ||
cp img/*.png $@ | ||
|
||
# install CSS file | ||
html/style.css: ../epub/style.css | ||
mkdir -p $(dir $@) | ||
cp $< $@ | ||
|
||
# | ||
# Main index.html file | ||
# | ||
|
||
html/index.html : xrefs | ||
mkdir -p $(dir $@) | ||
gosh $(GOSH_DOC_ARGS) --basepath "." --main-index <(echo '') > $@ | ||
|
||
# | ||
# Chapter index.html files | ||
# | ||
|
||
# rule to extract only the intro of a chapter | ||
chapters/%.txt: | ||
mkdir -p $(dir $@) | ||
../epub/splitter/filter-sec.sh chapter < ../$*.txt > $@ | ||
|
||
# let each chapter index.html file depend from its corresponding chapter text | ||
$(foreach C,$(CHAPTERS),$(eval html/$C/index.html : ../$C.txt)) | ||
|
||
# rule to generate index.html for a chapter | ||
$(ALL_CHAPTERS_INDEX_HTML) : xrefs | ||
mkdir -p $(dir $@) | ||
gosh $(GOSH_DOC_ARGS) \ | ||
--basepath ".." --unique-name '$(call second_elem,$@)' \ | ||
'chapters/$(call second_elem,$@).txt' > '$@' | ||
|
||
# | ||
# Sections | ||
# | ||
|
||
# let each section text depend on its original chapter text | ||
$(foreach C,$(CHAPTERS),\ | ||
$(eval $(addprefix sections/$C/,$(addsuffix .txt,${SECTIONS($C)})) : ../$C.txt)) | ||
|
||
# rule to extract a section txt from a chapter, | ||
# called with the pattern '<chapter>/<section>' | ||
sections/%.txt: | ||
mkdir -p $(dir $@) | ||
../epub/splitter/filter-sec.sh get '$(notdir $*)' \ | ||
< ../$(firstword $(subst /, ,$*)).txt \ | ||
> '$@' | ||
|
||
# let each section HTML file depend from its corresponding section text | ||
$(foreach S,$(ALL_SECTIONS),$(eval html/$S.html : sections/$S.txt)) | ||
|
||
# rule to generate HTML from a section txt | ||
$(ALL_SECTIONS_HTML) : xrefs | ||
mkdir -p $(dir $@) | ||
chapter='$(call second_elem,$@)'; \ | ||
section='$(call third_elem,$(basename $@))'; \ | ||
gosh $(GOSH_DOC_ARGS) \ | ||
--basepath ".." --unique-name "$$section" \ | ||
--style ../epub/splitter/skip-chapter.gosh \ | ||
"sections/$$chapter/$$section.txt" > '$@' | ||
|
||
include ../epub/img.mk | ||
|
||
clean: | ||
rm -rf sections chapters html xrefs img |