diff --git a/configure.ac b/configure.ac
index 96265b30..0de147b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -326,6 +326,37 @@ AM_CONDITIONAL([ENABLE_GTK_DOC], [false])
])
AM_CONDITIONAL([ENABLE_GTK_DOC_CHECK], [test "x$enable_gtk_doc_check" = xyes])
+
+AC_ARG_ENABLE(docbook-docs,
+ [AS_HELP_STRING([--enable-docbook-docs],[build documentation (requires xmlto)])],
+ enable_docbook_docs=$enableval, enable_docbook_docs=auto)
+AC_PATH_PROG(XMLTO, xmlto, no)
+AC_MSG_CHECKING([whether to build DocBook documentation])
+if test x$XMLTO = xno ; then
+ have_docbook=no
+else
+ have_docbook=yes
+fi
+if test x$enable_docbook_docs = xauto ; then
+ if test x$have_docbook = xno ; then
+ enable_docbook_docs=no
+ else
+ enable_docbook_docs=yes
+ fi
+fi
+if test x$enable_docbook_docs = xyes; then
+ if test x$have_docbook = xno; then
+ AC_MSG_ERROR([Building DocBook docs explicitly required, but DocBook not found])
+ fi
+ AC_MSG_RESULT(yes)
+else
+ AC_MSG_RESULT(no)
+fi
+AM_CONDITIONAL(DOCBOOK_DOCS_ENABLED, test x$enable_docbook_docs = xyes)
+AC_ARG_VAR([XMLTO],[Define/override the 'xmlto' location.])
+AC_ARG_VAR([XMLTO_FLAGS],[Define/override 'xmlto' options, like '--skip-validation'.])
+
+
##################################################
# Visibility handling
##################################################
@@ -391,6 +422,7 @@ doc/reference/Makefile
flatpak.pc
lib/flatpak-version-macros.h
doc/reference/version.xml
+doc/flatpak-docs.xml
po/Makefile.in
])
AC_OUTPUT
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 0af2a9bb..fe05f9d9 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -51,6 +51,27 @@ man_MANS = \
xml_files = $(man_MANS:.1=.xml)
-EXTRA_DIST = $(xml_files)
+EXTRA_DIST = \
+ $(xml_files) \
+ docbook.css \
+ flatpak-docs.xml.in \
+ xmlto-config.xsl \
+ $(NULL)
+
+DISTCLEANFILES = \
+ $(man_MANS) \
+ flatpak-docs.xml \
+ $(NULL)
+
+if DOCBOOK_DOCS_ENABLED
+
+doc_DATA = \
+ flatpak-docs.html \
+ docbook.css \
+ $(NULL)
+
+flatpak-docs.html: flatpak-docs.xml $(xml_files) xmlto-config.xsl
+ $(AM_V_GEN) $(XMLTO) $(XMLTO_FLAGS) --skip-validation xhtml-nochunks -m $(srcdir)/xmlto-config.xsl $<
+
+endif # DOCBOOK_DOCS_ENABLED
-DISTCLEANFILES = $(man_MANS)
diff --git a/doc/docbook.css b/doc/docbook.css
new file mode 100644
index 00000000..6a7373e2
--- /dev/null
+++ b/doc/docbook.css
@@ -0,0 +1,78 @@
+body
+{
+ font-family: sans-serif;
+}
+h1.title
+{
+}
+.permission
+{
+ color: #ee0000;
+ text-decoration: underline;
+}
+.synopsis, .classsynopsis
+{
+ background: #eeeeee;
+ border: solid 1px #aaaaaa;
+ padding: 0.5em;
+}
+.programlisting
+{
+ background: #eeeeff;
+ border: solid 1px #aaaaff;
+ padding: 0.5em;
+}
+.variablelist
+{
+ padding: 4px;
+ margin-left: 3em;
+}
+.variablelist td:first-child
+{
+ vertical-align: top;
+}
+td.shortcuts
+{
+ color: #770000;
+ font-size: 80%;
+}
+div.refnamediv
+{
+ margin-top: 2em;
+}
+div.toc
+{
+ border: 2em;
+}
+a
+{
+ text-decoration: none;
+}
+a:hover
+{
+ text-decoration: underline;
+ color: #FF0000;
+}
+
+div.table table
+{
+ border-collapse: collapse;
+ border-spacing: 0px;
+ border-style: solid;
+ border-color: #777777;
+ border-width: 1px;
+}
+
+div.table table td, div.table table th
+{
+ border-style: solid;
+ border-color: #777777;
+ border-width: 1px;
+ padding: 3px;
+ vertical-align: top;
+}
+
+div.table table th
+{
+ background-color: #eeeeee;
+}
diff --git a/doc/flatpak-docs.xml.in b/doc/flatpak-docs.xml.in
new file mode 100644
index 00000000..d095c13a
--- /dev/null
+++ b/doc/flatpak-docs.xml.in
@@ -0,0 +1,44 @@
+
+
+]>
+
+
+ Version @VERSION@
+
+ Flatpak Command Reference
+
+
+ Flatpak comes with a rich commandline interface.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/xmlto-config.xsl b/doc/xmlto-config.xsl
new file mode 100644
index 00000000..7aa9defc
--- /dev/null
+++ b/doc/xmlto-config.xsl
@@ -0,0 +1,6 @@
+
+
+
+