export BASEDIR
# RELATIVEDIR: relative path from BASEDIR to the current directory
-RELATIVEDIR=$(patsubst $(BASEDIR)/%,%,$(shell pwd))
+RELATIVEDIR=$(patsubst /%,%,$(patsubst $(BASEDIR)%,%,$(shell pwd)))
# BACK_TO_BASE: relative path from the current directory to BASEDIR
-BACK_TO_BASE:=$(shell echo $(RELATIVEDIR)|sed -e 's/[^/]*/../g')
+BACK_TO_BASE:=$(shell echo $(RELATIVEDIR)|sed -e 's/[^/]\+/../g')
-# Destination filename
-ifndef FNAME
-FNAME=index.html
-endif
+# $(info BASEDIR=$(BASEDIR))
+# $(info RELATIVEDIR=$(RELATIVEDIR))
+# $(info BACK_TO_BASE=$(BACK_TO_BASE))
TARGETDIR:=$(BASEDIR)/www/$(RELATIVEDIR)
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)/%)
+ifeq ($(words $(XMLS)),1)
+$(TARGETDIR)/$(htmls): $(XMLS)
+else
$(TARGETDIR)/%.html: %.xml
+endif
$(Q)mkdir -p $(dir $@)
- $(Q)echo " XSLTPROC $(notdir $@)"
+ $(Q)echo " XSLTPROC $(RELATIVEDIR:%=%/)$(notdir $@)"
$(Q)xsltproc --stringparam www.root $(WWW_ROOT) $(XSLTPROCFLAGS) $(BASEDIR)/xsl/course.xsl $< > "$@"
$(Q)$(MAKE) --no-print-directory copy-links XML=$<