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 /%,%,$(patsubst $(BASEDIR)%,%,$(shell pwd -L)))
15 # BACK_TO_BASE: relative path from the current directory to BASEDIR
16 BACK_TO_BASE:=$(shell echo $(RELATIVEDIR)|sed -e 's/[^/]\+/../g')
17 ifeq ($(BACK_TO_BASE),)
21 # $(info BASEDIR=$(BASEDIR))
22 # $(info RELATIVEDIR=$(RELATIVEDIR))
23 # $(info BACK_TO_BASE=$(BACK_TO_BASE))
25 TARGETDIR:=$(BASEDIR)/www/$(RELATIVEDIR)
27 .PHONY: all clean local subdirs copy-links
38 $(Q)$(foreach d,$(SUBDIRS),$(MAKE) -C $(d) &&) true
42 WWW_ROOT ?= $(BACK_TO_BASE)
43 WWW_ROOT := $(WWW_ROOT:%/=%)
46 XMLS := $(wildcard *.xml)
48 htmls := $(if $(word 2,$(XMLS)),$(XMLS:%.xml=%.html),index.html)
51 default: $(htmls:%=$(TARGETDIR)/%)
54 ifeq ($(words $(XMLS)),1)
55 $(TARGETDIR)/$(htmls): $(XMLS)
57 $(TARGETDIR)/%.html: %.xml
59 $(Q)mkdir -p $(dir $@)
60 $(Q)echo " XSLTPROC $(RELATIVEDIR:%=%/)$(notdir $@)"
61 $(Q)xsltproc --stringparam www.root "$(WWW_ROOT)" $(XSLTPROCFLAGS) $(BASEDIR)/xsl/course.xsl $< > "$@"
63 $(Q)echo "$@" # Used by XXE macro to display the compiled page
67 links.mk: $(XMLS:%.xml=%.links)
68 $(Q)echo 'docbook_links = $(sort $(wildcard $(shell cat $^)))' > $@
72 copy-links: $(docbook_links:%=$(TARGETDIR)/%)
73 $(Q)rm links.mk $(XMLS:%.xml=%.links)
76 # $(Q)echo " XSLTPROC $@"
77 $(Q)xsltproc --stringparam www.root "$(WWW_ROOT)" $(XSLTPROCFLAGS) $(BASEDIR)/xsl/getlinks.xsl $< > $@
79 # For copying other file from source (images, pfd, ...)
81 $(Q)mkdir -p $(dir $@);\
82 if [ ! -d "$<" ]; then \