export BASEDIR
# RELATIVEDIR: relative path from BASEDIR to the current directory
-RELATIVEDIR=$(patsubst $(BASEDIR)/%,%,$(shell pwd))
+RELATIVEDIR=$(patsubst /%,%,$(patsubst $(BASEDIR)%,%,$(shell pwd -L)))
# BACK_TO_BASE: relative path from the current directory to BASEDIR
-BACK_TO_BASE:=$(shell echo $(RELATIVEDIR)|sed -e 's/[^/]*/../g')
-
-# Destination filename
-ifndef FNAME
-FNAME=index.html
+BACK_TO_BASE:=$(shell echo $(RELATIVEDIR)|sed -e 's/[^/]\+/../g')
+ifeq ($(BACK_TO_BASE),)
+BACK_TO_BASE=.
endif
+# $(info BASEDIR=$(BASEDIR))
+# $(info RELATIVEDIR=$(RELATIVEDIR))
+# $(info BACK_TO_BASE=$(BACK_TO_BASE))
+
TARGETDIR:=$(BASEDIR)/www/$(RELATIVEDIR)
.PHONY: all clean local subdirs copy-links
ifndef XMLS
XMLS := $(wildcard *.xml)
endif
-htmls := $(XMLS:%.xml=%.html)
+htmls := $(if $(word 2,$(XMLS)),$(XMLS:%.xml=%.html),index.html)
default: subdirs
default: $(htmls:%=$(TARGETDIR)/%)
+default: copy-links
+ifeq ($(words $(XMLS)),1)
+$(TARGETDIR)/$(htmls): $(XMLS)
+else
$(TARGETDIR)/%.html: %.xml
+endif
$(Q)mkdir -p $(dir $@)
- $(Q)echo " XSLTPROC $(notdir $@)"
- $(Q)xsltproc --stringparam www.root $(WWW_ROOT) $(XSLTPROCFLAGS) $(BASEDIR)/xsl/course.xsl $< > "$@"
- $(Q)$(MAKE) --no-print-directory copy-links XML=$<
+ $(Q)echo " XSLTPROC $(RELATIVEDIR:%=%/)$(notdir $@)"
+ $(Q)xsltproc --stringparam www.root "$(WWW_ROOT)" $(XSLTPROCFLAGS) $(BASEDIR)/xsl/course.xsl $< > "$@"
+ifdef SHOW_HTML_PATH
+ $(Q)echo "$@" # Used by XXE macro to display the compiled page
+endif
+
-links.mk: $(XML:%.xml=%.links)
- $(Q)echo 'docbook_links = $(wildcard $(shell cat $^))' > $@
+links.mk: $(XMLS:%.xml=%.links)
+ $(Q)echo 'docbook_links = $(sort $(wildcard $(shell cat $^)))' > $@
-ifeq ($(MAKECMDGOALS),copy-links)
-include links.mk
-endif
copy-links: $(docbook_links:%=$(TARGETDIR)/%)
- $(Q)rm links.mk $(XML:%.xml=%.links)
+ $(Q)rm links.mk $(XMLS:%.xml=%.links)
%.links: %.xml
- $(Q)echo " XSLTPROC $@"
- $(Q)xsltproc --stringparam www.root $(WWW_ROOT) $(XSLTPROCFLAGS) $(BASEDIR)/xsl/getlinks.xsl $< > $@
+# $(Q)echo " XSLTPROC $@"
+ $(Q)xsltproc --stringparam www.root "$(WWW_ROOT)" $(XSLTPROCFLAGS) $(BASEDIR)/xsl/getlinks.xsl $< > $@
# For copying other file from source (images, pfd, ...)
$(TARGETDIR)/%: %