Makefile
author Fabien Ninoles <fabien@tzone.org>
Mon, 21 Sep 2015 22:16:41 -0400
branchpoesie
changeset 40 cf6fae3b8dd7
parent 39 839dbac5a671
child 41 99a12e640577
permissions -rw-r--r--
Ajout de l'Amour arriva un jour.

#/usr/bin/make

targets=$(addprefix $(1), .html .pdf .txt /index.html)
output=$(addprefix $(1), .html .pdf .txt) $(1)/

TOP=$(shell pwd)
INSTALL_DIR=$(TOP)/install
SRCS=poetry.xml 

# Currently, those sections doesn't compiled because of an invalid
# link references.  I have a similar problem with the nargir source
# book and ecjdr.  I should find a solution for this kind of "mixed"
# (internal|external) links when using xinclude.  Better would be to
# not used xinclude at all.

SECTIONS=\
    alpha.xml \
	themes.xml \
	chronology.xml
SRC_DEPS=\
	abzoodre.xml \
	amoureux.xml \
	amourunjour.xml \
	apprends.xml \
	belle.xml \
	coeur.xml \
	democratie.xml \
	desert.xml \
	ecrire.xml \
	ecrivain.xml \
	espoir.xml \
	flocons.xml \
	hiver.xml \
	horloge.xml \
	idees.xml \
	instrument.xml \
	jaime.xml \
	jugement.xml \
	lamourarriva.xml \
	langue.xml \
	lettreseule.xml \
	louve.xml \
	nature.xml \
	oiseau.xml \
	ondes.xml \
	orchidee.xml \
	paysage.xml \
	plonger.xml \
	poeme.xml \
	pomme.xml \
	prince.xml \
	renaissance.xml \
	reverie.xml \
	reveries.xml \
	serrure.xml \
	si_tu_maimais.xml \
	sombrespensees.xml \
	tempete.xml \
	testament.xml \
	ton_rire.xml \
	valentin.xml \
	voix.xml \
	wolf.xml
STYLES_DIR=$(TOP)/styles
DTD_DIR=$(TOP)/dtd
STYLES=$(addprefix $(STYLES_DIR)/,common.xsl)
HTML_STYLES=$(STYLES) $(addprefix $(STYLES_DIR)/,html.xsl poetry_html.xsl)
PRINT_STYLES=$(STYLES) $(addprefix $(STYLES_DIR)/,print.xsl poetry_print.xsl masters_print.xsl)
DTD=$(addprefix $(DTD_DIR)/,poetry.dtd)
SGML_CATALOG_FILES=$(TOP)/catalog
export SGML_CATALOG_FILES
XML_CATALOG_FILES=$(TOP)/catalog.xml
export XML_CATALOG_FILES
xml_validate=xmllint -nonet --valid --noout $(1)
xml_post_validate=xmllint -nonet --xinclude --postvalid --noout $(1)
html_validate=xmllint --xinclude --valid --noout $(1)

#REMOTE_DIR=o:public_html/poesie
# FOP=xmlto pdf
FOP=fop

#OUTPUT=$(foreach target,$(basename $(SRCS)),$(call output,$(target)))
OUTPUT=poetry.pdf poetry/

all: $(OUTPUT)

#poetry: $(call targets,poetry) $(SRC_DEPS)
poetry/: poetry/index.html

update: $(OUTPUT)
	rsync -avz -P $(OUTPUT) $(REMOTE_DIR)

install: $(OUTPUT)
	[ -d $(INSTALL_DIR) ] || mkdir -p $(INSTALL_DIR)
	cp -a $(OUTPUT)* $(INSTALL_DIR)

validate: $(SRCS) $(SECTIONS) $(addsuffix -validate,$(SRC_DEPS))
	$(call xml_post_validate,$<)

post-validate: $(SRCS) $(SECTIONS) $(SRC_DEPS)
	$(call xml_post_validate,$<)

%-validate: %
	$(call xml_validate,$<)

clean:
	rm -f *~ *.fo

purge: clean
	rm -rf $(OUTPUT)

debug:
	echo $(PRINT_STYLES)

%.fo: %.xml $(PRINT_STYLES) $(SRC_DEPS) $(SECTIONS)
	xsltproc -nonet --xinclude			\
		-o $@ $(STYLES_DIR)/poetry_print.xsl $<

%.pdf: %.fo
#	xsltproc -o $@.tmp.fo strip-attributes.xsl $<
#	xmlto pdf -o $(dir $@) $<
	fop $< $@
#	rm $@.tmp.fo

%.html: %.xml $(HTML_STYLES) $(SRC_DEPS) $(SECTIONS)
	xsltproc -nonet --xinclude				\
		--stringparam css-base-dir '/~fabien/styles/'	\
		-o $@ $(STYLES_DIR)/poetry_html.xsl $<

%/index.html: %.xml $(HTML_STYLES) $(SRC_DEPS) $(SECTIONS)
	rm -rf $(dir $@)
	mkdir -p $(dir $@)
	xsltproc -nonet --xinclude				\
		--stringparam css-base-dir '/~fabien/styles/'	\
		-o $@ $(STYLES_DIR)/poetry_html.xsl $<

%.txt: %.html
	w3m -dump $< > $@