
%.xml: %.cml
	# Protect HTML special chars in R code chunks
	Rscript -e 't <- readLines("$*.cml"); writeLines(gsub("<rcode ([^>]+)>", "<rcode \\1><![CDATA[", gsub("</rcode>", "]]></rcode>", t)), "$*.xml")'

%.Rhtml : %.xml
	# Transform to .Rhtml
	xsltproc knitr.xsl $*.xml > $*.Rhtml

%.html : %.Rhtml
	# Use knitr to produce HTML
	Rscript -e 'library(knitr); knit("$<")'

web:
	cp cpi-host-pipeline.html ~/Web/Reports/OpenAPI/CPI-host/
	cp -r figure/ ~/Web/Reports/OpenAPI/CPI-host/
	cp *.svg ~/Web/Reports/OpenAPI/CPI-host/
	cp conduit-form.html ~/Web/Reports/OpenAPI/CPI-host/
	cp conduit-run.php.txt ~/Web/Reports/OpenAPI/CPI-host/
	cp *.png ~/Web/Reports/OpenAPI/CPI-host/
	cp -r cpi/ ~/Web/Reports/OpenAPI/CPI-host/
	cp docker-R-conduit-apache-php.json ~/Web/Reports/OpenAPI/CPI-host/
	cp docker-R-conduit.sh ~/Web/Reports/OpenAPI/CPI-host/
	cp apache-php.sh ~/Web/Reports/OpenAPI/CPI-host/
	cp cpi-host-pipeline.cml ~/Web/Reports/OpenAPI/CPI-host/
	cp cpi-host-pipeline.xml ~/Web/Reports/OpenAPI/CPI-host/
	cp cpi-host-pipeline.Rhtml ~/Web/Reports/OpenAPI/CPI-host/
	cp Makefile ~/Web/Reports/OpenAPI/CPI-host/
	cp knitr.xsl ~/Web/Reports/OpenAPI/CPI-host/
	cp common.xsl ~/Web/Reports/OpenAPI/CPI-host/

