1 # To be included in other Makefile
3 # This Makefile converts all XML files found in the current directory
4 # to HTML file under www directory and copies there the referenced
5 # files such as images or hyperlinked files.
8 BASEDIR := $(shell ( old_pwd="" ; while [ ! -e xsl/course.xsl ] ; do if [ "$$old_pwd" = `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
12 # RELATIVEDIR: relative path from BASEDIR to the current directory
13 RELATIVEDIR=$(patsubst $(BASEDIR)/%,%,$(shell pwd))
15 # BACK_TO_BASE: relative path from the current directory to BASEDIR
16 BACK_TO_BASE:=$(shell echo $(RELATIVEDIR)|sed -e 's/[^/]*/../g')
18 # Destination filename
23 TARGETDIR:=$(BASEDIR)/www/$(RELATIVEDIR)
25 .PHONY: all clean local subdirs copy-links
36 $(Q)$(foreach d,$(SUBDIRS),$(MAKE) -C $(d) &&) true
40 WWW_ROOT ?= $(BACK_TO_BASE)
41 WWW_ROOT := $(WWW_ROOT:%/=%)
44 XMLS := $(wildcard *.xml)
46 htmls := $(XMLS:%.xml=%.html)
49 default: $(htmls:%=$(TARGETDIR)/%)
51 $(TARGETDIR)/%.html: %.xml
52 $(Q)mkdir -p $(dir $@)
53 $(Q)echo " XSLTPROC $(notdir $@)"
54 $(Q)xsltproc --stringparam www.root $(WWW_ROOT) $(XSLTPROCFLAGS) $(BASEDIR)/xsl/course.xsl $< > "$@"
55 $(Q)$(MAKE) --no-print-directory copy-links XML=$<
57 links.mk: $(XML:%.xml=%.links)
58 $(Q)echo 'docbook_links = $(wildcard $(shell cat $^))' > $@
60 ifeq ($(MAKECMDGOALS),copy-links)
64 copy-links: $(docbook_links:%=$(TARGETDIR)/%)
65 $(Q)rm links.mk $(XML:%.xml=%.links)
68 $(Q)echo " XSLTPROC $@"
69 $(Q)xsltproc --stringparam www.root $(WWW_ROOT) $(XSLTPROCFLAGS) $(BASEDIR)/xsl/getlinks.xsl $< > $@
71 # For copying other file from source (images, pfd, ...)
73 $(Q)mkdir -p $(dir $@);\
74 if [ ! -d "$<" ]; then \