diff --git a/doc/Makefile b/doc/Makefile
new file mode 100644
index 00000000..43d82b8e
--- /dev/null
+++ b/doc/Makefile
@@ -0,0 +1,45 @@
+FOP = /opt/fop/fop.sh
+XALAN = /opt/fop/xalan.sh
+JAVA_HOME = /usr/lib/jvm/java-6-sun
+
+ALLDOCS = modsecurity2-apache-reference.pdf modsecurity2-data-formats.pdf modsecurity2-apache-reference.html modsecurity2-data-formats.html html-multipage/index.html index.html
+
+all: $(ALLDOCS)
+
+modsecurity2-apache-reference.pdf: modsecurity2-apache-reference.xml
+ JAVA_HOME=$(JAVA_HOME); export JAVA_HOME; \
+ $(FOP) -q -xsl pdf.xsl -xml modsecurity2-apache-reference.xml -pdf modsecurity2-apache-reference.pdf;
+
+modsecurity2-data-formats.pdf: modsecurity2-data-formats.xml
+ JAVA_HOME=$(JAVA_HOME); export JAVA_HOME; \
+ $(FOP) -q -xsl pdf.xsl -xml modsecurity2-data-formats.xml -pdf modsecurity2-data-formats.pdf;
+
+modsecurity2-apache-reference.html: modsecurity2-apache-reference.xml
+ JAVA_HOME=$(JAVA_HOME); export JAVA_HOME; \
+ $(XALAN) -q -xsl html.xsl -in modsecurity2-apache-reference.xml -param base.dir ./; \
+ mv index.html modsecurity2-apache-reference.html;
+
+modsecurity2-data-formats.html: modsecurity2-data-formats.xml
+ JAVA_HOME=$(JAVA_HOME); export JAVA_HOME; \
+ $(XALAN) -q -xsl html.xsl -in modsecurity2-data-formats.xml -param base.dir ./; \
+ mv index.html modsecurity2-data-formats.html;
+
+html-multipage/index.html: modsecurity2-apache-reference.xml
+ JAVA_HOME=$(JAVA_HOME); export JAVA_HOME; \
+ mkdir html-multipage/; \
+ $(XALAN) -q -xsl html-chunked.xsl -in modsecurity2-apache-reference.xml -param base.dir html-multipage/; \
+ cp modsecurity-reference.css html-multipage/; \
+ cp modsecurity.gif html-multipage/; \
+ cp breach-logo-small.gif html-multipage/; \
+ cp apache_request_cycle-modsecurity.jpg html-multipage/
+
+index.html: main-index.html
+ (cp main-index.html index.html && \
+ VERSION=`grep ".*" modsecurity2-apache-reference.xml | sed 's/[ \t]*<\/\?releaseinfo>[ \t]*//g'` && \
+ perl -pi -e "s/\\\$$version/$$VERSION/" index.html)
+
+clean:
+ rm -rf docindex.html $(ALLDOCS) html-multipage
+
+.PHONY: setup cleanup
+
diff --git a/doc/html-chunked.xsl b/doc/html-chunked.xsl
index 739ca0e1..2c42ecf1 100644
--- a/doc/html-chunked.xsl
+++ b/doc/html-chunked.xsl
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/doc/html.xsl b/doc/html.xsl
index b1cd6183..a3b50930 100644
--- a/doc/html.xsl
+++ b/doc/html.xsl
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/doc/index.html b/doc/main-index.html
similarity index 97%
rename from doc/index.html
rename to doc/main-index.html
index 85c74eed..321caa01 100644
--- a/doc/index.html
+++ b/doc/main-index.html
@@ -18,7 +18,7 @@ height="36" width="100" border="0">
ModSecurity for Apache Documentation
- Version $version
+ $version
- HTML, one page per chapter
diff --git a/doc/pdf.xsl b/doc/pdf.xsl
index b0ace8a3..b7b70c17 100644
--- a/doc/pdf.xsl
+++ b/doc/pdf.xsl
@@ -5,8 +5,8 @@
version="1.0"
>
-
-
+
+