Makefile
author fabien
Mon, 03 Jul 2006 11:47:57 -0400
branchecjdr
changeset 90 9803b2ef6621
parent 87 bbe189163a7a
child 95 6e24ee2b02ff
permissions -rw-r--r--
[svn] r2127@freebird: fabien | 2006-07-02 18:02:06 -0400 Revision et ajout des index. PrĂȘt pour une soumission.

#!/usr/bin/make

# No final slash here!
# It will mess up rsync behavior.
TOP=`pwd`
SRC_DIR=`pwd`
INSTALL_DIR=$(TOP)/install
FR_ARTICLES=couleurs jjch credo systemes resolution mecanique
EN_ARTICLES=colors
UNPUBLISHED=dri-aido jdrdef jdrl scenarios
BOOKS=jeuderologie rpgtheory
TARGETS=$(BOOKS) $(FR_ARTICLES) $(EN_ARTICLES) $(UNPUBLISHED)
HTML_FILES=index.en.html index.fr.html
SGML_CATALOG_FILES=/etc/sgml/catalog
export SGML_CATALOG_FILES
xml_validate=xmllint --valid --noout $(1)
xml_post_validate=xmllint --postvalid --xinclude --noout $(1)
html_validate=$(xml_validate)

make_subdir=						\
	[ -d $(2) ] || mkdir -p $(2) ;			\
	$(MAKE) SRC_DIR=$(SRC_DIR) VPATH=$(SRC_DIR)	\
		-C $(2) -f $(SRC_DIR)/Makefile $(1)

all: $(addsuffix -do,$(TARGETS))

jeuderologie.xml: $(addsuffix .xml, $(FR_ARTICLES))

rpgtheory.xml: $(addsuffix .xml, $(EN_ARTICLES))

validate-jeuderologie: $(addsuffix -validate, $(FR_ARTICLES))

validate-rpgtheory: $(addsuffix -validate, $(EN_ARTICLES))

%-post-validate: %.xml
	$(call xml_post_validate,$<)

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

%.html-validate: %.html
	$(call html_validate,$<)

validate: $(addsuffix -validate,$(TARGETS) $(HTML_FILES)) post-validate

post-validate: $(addsuffix -post-validate,$(BOOKS)) 

install: $(addsuffix -do,$(TARGETS)) $(HTML_FILES)
	mkdir -p $(INSTALL_DIR)
	cp -a $(HTML_FILES) $(TARGETS) $(INSTALL_DIR)
	ln -sf index.fr.html $(INSTALL_DIR)/index.html

$(addsuffix -do,$(TARGETS)):
	$(call make_subdir,$(patsubst %-do,%,$@),$(patsubst %-do,%,$@))

clean:
	rm -rf *~ *.fo *.aux *.log *.out

purge:
	rm -rf $(TARGETS)

$(TARGETS):
	$(MAKE) -f $(SRC_DIR)/Makefile $@.pdf $@.txt $@/index.html $@.html

%.fo: %.xml $(SRC_DIR)/print.xsl $(SRC_DIR)/common.xsl
	xsltproc --xinclude -o $@ $(SRC_DIR)/print.xsl $< 

TEX_OPTIONS=-interaction=errorstopmode -file-line-error-style
TEXERRORLEVEL=2
MAX_TEX_RECURSION=4
%.pdf: %.fo
# 	-cp -pf prior.aux pprior.aux
# 	-cp -pf $(basename $<).aux prior.aux
# 	pdfxmltex $(TEX_OPTIONS) $< || [ $$? -lt $(TEXERRORLEVEL) ]
# 	if ! cmp $(basename $<).aux prior.aux &&		\
# 	   ! cmp $(basename $<).aux pprior.aux &&		\
# 	   expr $(MAKELEVEL) '<' $(MAX_TEX_RECURSION); then	\
# 		rm -f $@ ;					\
# 		$(MAKE) -f $(SRC_DIR)/Makefile $@ ;		\
# 	fi
# 	rm -f prior.aux pprior.aux
# 	xmlto pdf $<
	fop $< $@

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

%/index.html: %.xml $(SRC_DIR)/chunk.xsl $(SRC_DIR)/common.xsl
	rm -rf $(dir $@)
	xsltproc --xinclude -o $(dir $@) $(SRC_DIR)/chunk.xsl $<

%.html: %.xml $(SRC_DIR)/html.xsl $(SRC_DIR)/common.xsl
	xsltproc --xinclude -o $@ $(SRC_DIR)/html.xsl $<

.PHONY: $(TARGETS) $(addsuffix -do,$(TARGETS))
.PHONY: update clean all install validate