| 1 |
# |
| 2 |
# Copyright (C) 2008-2025 Alexis Bienvenüe <[email protected]> |
| 3 |
# |
| 4 |
# This file is part of Auto-Multiple-Choice |
| 5 |
# |
| 6 |
# Auto-Multiple-Choice is free software: you can redistribute it |
| 7 |
# and/or modify it under the terms of the GNU General Public License |
| 8 |
# as published by the Free Software Foundation, either version 2 of |
| 9 |
# the License, or (at your option) any later version. |
| 10 |
# |
| 11 |
# Auto-Multiple-Choice is distributed in the hope that it will be |
| 12 |
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
| 13 |
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
# General Public License for more details. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU General Public License |
| 17 |
# along with Auto-Multiple-Choice. If not, see |
| 18 |
# <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
SHELL=/bin/sh |
| 21 |
|
| 22 |
include ../Makefile-all.conf |
| 23 |
|
| 24 |
ALL_DOCBOOKS = $(filter-out $(wildcard *.in.xml),$(wildcard auto-multiple-choice.*.xml)) |
| 25 |
DOC_LANG ?= $(patsubst auto-multiple-choice.%.xml,%,$(ALL_DOCBOOKS)) |
| 26 |
SELECTED_DOCBOOKS = $(foreach onelang,$(DOC_LANG),auto-multiple-choice.$(onelang).xml) |
| 27 |
|
| 28 |
IMAGES=$(addprefix html/images/,$(notdir $(wildcard img_src/*.svg))) $(addprefix html/images/callouts/,$(notdir $(wildcard img_src/callouts/*.svg))) |
| 29 |
BLOCK_IMAGES=$(addprefix img_pdf/,$(notdir $(wildcard img_src/*.svg))) |
| 30 |
|
| 31 |
MODELS=$(wildcard modeles/*/*.d) |
| 32 |
|
| 33 |
all: $(SELECTED_DOCBOOKS:.xml=.pdf) $(SELECTED_DOCBOOKS:.xml=.x) $(IMAGES:.svg=.png) $(MODELS:.d=.tgz) html/index.html; |
| 34 |
|
| 35 |
show_doc_lang: |
| 36 |
@echo "DOC_LANG = $(DOC_LANG)" |
| 37 |
|
| 38 |
images: $(IMAGES:.svg=.png) |
| 39 |
|
| 40 |
clean: |
| 41 |
rm -f $(foreach ext,1 aux cb cb2 glo idx log out toc tex html pdf ext man,*.$(ext)) |
| 42 |
rm -f modeles/*.tgz |
| 43 |
rm -f modeles/**/*.tgz |
| 44 |
rm -f html/auto-multiple-choice.**/*.html |
| 45 |
rm -f html/images/callouts/*.png html/images/*.png img_pdf/*.pdf |
| 46 |
rm -f *~ |
| 47 |
|
| 48 |
html/images/callouts/%.png: img_src/callouts/%.svg |
| 49 |
rsvg-convert -w 12 -h 12 $< -o $@ |
| 50 |
|
| 51 |
html/images/%.png: img_src/%.svg |
| 52 |
rsvg-convert -w 24 -h 24 $< -o $@ |
| 53 |
|
| 54 |
img_pdf/%.pdf: img_src/%.svg |
| 55 |
rsvg-convert -f pdf $< -o $@ |
| 56 |
|
| 57 |
html/index.html: FORCE |
| 58 |
$(PERLPATH) ./index.pl $(SELECTED_DOCBOOKS:.xml=) > $@ |
| 59 |
|
| 60 |
%.tex: %.xml amcdocstyle.sty |
| 61 |
dblatex -P latex.encoding=utf8 -b xetex -t tex -p custom.xsl --texstyle=amcdocstyle --xslt-opts="--nonet" --xslt-opts="--catalogs" $(DBLATEX_OPT) $< -o $@ |
| 62 |
# dblatex bug workaround (python3 writes b'<:' instead of <:) |
| 63 |
perl -pi -e "s,b'<:',<:,g ; s,b':>',:>,g " $@ |
| 64 |
|
| 65 |
XELATEX=xelatex -halt-on-error -interaction=nonstopmode |
| 66 |
|
| 67 |
%.pdf: export SOURCE_DATE_EPOCH=$(PACKAGE_V_EPOCH) |
| 68 |
%.pdf: export SOURCE_DATE_EPOCH_TEX_PRIMITIVES=1 |
| 69 |
%.pdf: export FORCE_SOURCE_DATE=1 |
| 70 |
%.pdf: export TEXINPUTS=./img_pdf/: |
| 71 |
|
| 72 |
%.pdf: %.tex $(BLOCK_IMAGES:.svg=.pdf) |
| 73 |
set -e ; $(XELATEX) $<; $(XELATEX) $< |
| 74 |
rm -f $(foreach ext,aux cb cb2 glo idx log out toc,$*.$(ext)) |
| 75 |
|
| 76 |
%.x: %.ext %.man %.html ; |
| 77 |
|
| 78 |
%.ext: %.xml |
| 79 |
$(PERLPATH) extrait-fichiers.pl --liste $@ $< |
| 80 |
|
| 81 |
%.man: %.xml |
| 82 |
xsltproc --nonet --catalogs --param man.charmap.use.subset "0" --param make.year.ranges "1" --param make.single.year.ranges "1" --param man.output.lang.in.name.enabled "1" $(DOCBOOK_MAN_XSL) $< |
| 83 |
date > $@ |
| 84 |
|
| 85 |
%.html: %.xml doc-xhtml.xsl |
| 86 |
rm -f html/$*/*.html |
| 87 |
xsltproc --nonet --catalogs --stringparam base.dir html/$*/ doc-xhtml.xsl $< |
| 88 |
date > $@ |
| 89 |
|
| 90 |
%.tgz: %.d |
| 91 |
find $< -type d -exec chmod 0755 '{}' \; |
| 92 |
find $< -type f -exec chmod 0644 '{}' \; |
| 93 |
ifeq ($(TAR_REPRODUCIBLE_ARGS),nonreproducible) |
| 94 |
tar -cz -f $@ -C $< . |
| 95 |
else |
| 96 |
tar cn -C $< $(TAR_REPRODUCIBLE_ARGS) -O . | gzip $(GZIP_REPRODUCIBLE_ARGS) -c > $@ |
| 97 |
endif |
| 98 |
|
| 99 |
check: FORCE |
| 100 |
./check_xml |
| 101 |
|
| 102 |
FORCE: ; |
| 103 |
|
| 104 |
.PHONY: FORCE all images clean check |