Documentation:
- Added options to specify URLs to the ReadMe file and the license directory. This is used on the main documentation page.
- Working directory for doxygen documentation generation is now "${CMAKE_BINARY_DIR}/doc/etc" instead of "${CMAKE_BINARY_DIR}/doc". This is necessary to work around bug 646319 in doxygen (see https://bugzilla.gnome.org/show_bug.cgi?id=646319).
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 53af430..43961ac 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -2,8 +2,17 @@
 # MADlib Documentation
 # ------------------------------------------------------------------------------
 
+set(DOXYGEN_README_FILE "../ReadMe.txt" CACHE STRING
+    "Path to ReadMe file relative to the doc directory after installation")
+set(DOXYGEN_LICENSE_DIR "../../license" CACHE STRING
+    "Path to license directory relative to the doc directory after installation")
+configure_file(
+    mainpage.dox.in
+    "${CMAKE_CURRENT_BINARY_DIR}/mainpage.dox"
+    @ONLY
+)
 set(_DOXYGEN_INPUT_USER
-    "\"${CMAKE_SOURCE_DIR}/doc/mainpage.dox\""
+    "\"${CMAKE_CURRENT_BINARY_DIR}/mainpage.dox\""
     "\"${CMAKE_SOURCE_DIR}/src/dbal\""
     "\"${CMAKE_SOURCE_DIR}/src/modules\""
     "\"${CMAKE_SOURCE_DIR}/src/ports\""
@@ -32,11 +41,11 @@
 set(DOXYGEN_MATHJAX_RELPATH "../../../third_party/downloads/mathjax" CACHE STRING
     "Path to MathJax installation (used by Doxygen; absolute or relative to \${DOXYGEN_HTML_OUTPUT})"
 )
-set(DOXYGEN_OUTPUT_DEVELOPER developer CACHE PATH
-    "Base path where the documentation generated by Doxygen will be put (abolsute or relative to \${CMAKE_BINARY_DIR}/doc)"
+set(DOXYGEN_OUTPUT_DEVELOPER "../developer" CACHE PATH
+    "Base path where the documentation generated by Doxygen will be put (abolsute or relative to \${CMAKE_BINARY_DIR}/doc/etc)"
 )
-set(DOXYGEN_OUTPUT_USER user CACHE PATH
-    "Base path where the documentation generated by Doxygen will be put (abolsute or relative to \${CMAKE_BINARY_DIR}/doc)"
+set(DOXYGEN_OUTPUT_USER "../user" CACHE PATH
+    "Base path where the documentation generated by Doxygen will be put (abolsute or relative to \${CMAKE_BINARY_DIR}/doc/etc)"
 )
 set(DOXYGEN_HTML_OUTPUT html CACHE STRING
     "Path (relative to \${DOXYGEN_OUTPUT_<config>} where HTML docs will be put."
@@ -97,16 +106,16 @@
         "warning:.*\\(@param is not found in the argument list.*kwargs\\)\$|The following parameters.*kwargs\\) are not documented\\)|parameter 'kwargs'\$")
 
     add_custom_target(doc
-        COMMAND ${DOXYGEN_EXECUTABLE} etc/user.doxyfile | ${_DOXYGEN_UNNEEDED_WARNINGS_FILTER}
-        WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+        COMMAND ${DOXYGEN_EXECUTABLE} user.doxyfile | ${_DOXYGEN_UNNEEDED_WARNINGS_FILTER}
+        WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/etc"
         DEPENDS doxysql doxyBinFiles doxygen_css ${_MATHJAX_DEPENDENCY_USER}
         COMMENT "Generating user-level documentation..."
         VERBATIM
     )
     
     add_custom_target(devdoc
-        COMMAND ${DOXYGEN_EXECUTABLE} etc/developer.doxyfile | ${_DOXYGEN_UNNEEDED_WARNINGS_FILTER}
-        WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+        COMMAND ${DOXYGEN_EXECUTABLE} developer.doxyfile | ${_DOXYGEN_UNNEEDED_WARNINGS_FILTER}
+        WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/etc"
         DEPENDS doxysql doxyBinFiles doxygen_css update_mathjax
         COMMENT "Generating developer documentation..."
         VERBATIM
diff --git a/doc/bin/py_filter.sh.in b/doc/bin/py_filter.sh.in
index 651a83e..887ec05 100755
--- a/doc/bin/py_filter.sh.in
+++ b/doc/bin/py_filter.sh.in
@@ -1,4 +1,4 @@
 #!/bin/sh
-FILTER="bin/doxypy.py /dev/stdin"
+FILTER="../bin/doxypy.py /dev/stdin"
 
 @M4_BINARY@ @_M4_ARGUMENTS@ $1 | ${FILTER}
diff --git a/doc/bin/sql_filter.sh.in b/doc/bin/sql_filter.sh.in
index 371939c..6bedbd5 100755
--- a/doc/bin/sql_filter.sh.in
+++ b/doc/bin/sql_filter.sh.in
@@ -1,4 +1,4 @@
 #!/bin/sh
-FILTER="bin/doxysql"
+FILTER="../bin/doxysql"
 
 @M4_BINARY@ @_M4_ARGUMENTS@ $1 | ${FILTER} -f '$(@M4_BINARY@ @_M4_ARGUMENTS@'"$1)"
diff --git a/doc/etc/developer.doxyfile.in b/doc/etc/developer.doxyfile.in
index e5339fa..862be3a 100644
--- a/doc/etc/developer.doxyfile.in
+++ b/doc/etc/developer.doxyfile.in
@@ -784,10 +784,10 @@
 # info on how filters are used. If FILTER_PATTERNS is empty or if
 # non of the patterns match the file name, INPUT_FILTER is applied.
 
-FILTER_PATTERNS        = "*.py=bin/doxypy.py" \
-                         "*.py_in=bin/py_filter.sh" \
-                         "*.sql=bin/doxysql" \
-                         "*.sql_in=bin/sql_filter.sh"
+FILTER_PATTERNS        = "*.py=../bin/doxypy.py" \
+                         "*.py_in=../bin/py_filter.sh" \
+                         "*.sql=../bin/doxysql" \
+                         "*.sql_in=../bin/sql_filter.sh"
 
 # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
 # INPUT_FILTER) will be used to filter the input files when producing source
@@ -929,7 +929,7 @@
 # the style sheet file to the HTML output directory, so don't put your own
 # stylesheet in the HTML output directory as well, or it will be erased!
 
-HTML_STYLESHEET        = @CMAKE_CURRENT_BINARY_DIR@/doxygen.css
+HTML_STYLESHEET        = doxygen.css
 
 # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
 # other source files which should be copied to the HTML output directory. Note
diff --git a/doc/etc/user.doxyfile.in b/doc/etc/user.doxyfile.in
index 10fbe9f..b82f5d4 100644
--- a/doc/etc/user.doxyfile.in
+++ b/doc/etc/user.doxyfile.in
@@ -10,7 +10,7 @@
 #       TAG += value [value, ...]
 # Values that contain spaces should be placed between quotes (" ")
 
-@INCLUDE               = etc/developer.doxyfile
+@INCLUDE               = developer.doxyfile
 
 
 #---------------------------------------------------------------------------
diff --git a/doc/mainpage.dox b/doc/mainpage.dox.in
similarity index 94%
rename from doc/mainpage.dox
rename to doc/mainpage.dox.in
index c11f47d..f5f60a9 100644
--- a/doc/mainpage.dox
+++ b/doc/mainpage.dox.in
@@ -10,10 +10,10 @@
 <li>MADlib bug reporting site: http://jira.madlib.net/ and quick guide: https://github.com/madlib/madlib/wiki/Bug-reporting</li>
 </ul>
 
-Please refer to the <a href="../ReadMe.txt">Read-Me</a> file for information
+Please refer to the <a href="@DOXYGEN_README_FILE@">Read-Me</a> file for information
 about incorporated third-party material. License information regarding MADlib
 and included third-party libraries can be found inside the
-<a href="../../license">license</a> directory.
+<a href="@DOXYGEN_LICENSE_DIR@">license</a> directory.
 
 @defgroup grp_modeling Data Modeling