diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8a5e77b03..c32165b8f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -758,14 +758,14 @@ endif()
 ########### next target ###############
 
 if(ENABLE_DOC AND DOXYGEN_FOUND)
-	add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/doc/doxygen/index.html
-		COMMAND ${DOXYGEN_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/doc/doxygen.cfg
-		DEPENDS doc/doxygen*.cfg ${stratagus_SRCS}
-		WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+	configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
+	add_custom_command(OUTPUT doxygen/index.html
+		COMMAND ${DOXYGEN_EXECUTABLE}
+		DEPENDS doc/Doxyfile* ${stratagus_SRCS} ${stratagus_HDRS} ${metaserver_SRCS} ${metaserver_HDRS}
 		COMMENT "Generating Stratagus souce code documentation with Doxygen" VERBATIM
 	)
-	add_custom_target(doc ALL DEPENDS doc/doxygen/index.html)
-	set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_SOURCE_DIR}/doc/doxygen/)
+	add_custom_target(doc ALL DEPENDS doxygen/index.html)
+	set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES doxygen)
 endif()
 
 ########### next target ###############
@@ -810,3 +810,21 @@ install(TARGETS png2stratagus DESTINATION bin)
 if(SQLITE_FOUND)
 	install(TARGETS metaserver DESTINATION sbin)
 endif()
+
+if(ENABLE_DOC AND DOXYGEN_FOUND)
+	install(FILES doc/stratagus.6 DESTINATION share/man/man6)
+	install(FILES
+		doc/development.html
+		doc/faq.html
+		doc/gpl.html
+		doc/guichan-copyright.txt
+		doc/ChangeLog.html
+		doc/index.html
+		doc/install.html
+		doc/media.html
+		doc/metaserver_protocol.txt
+		doc/README-SDL.txt
+		DESTINATION share/doc/stratagus
+	)
+	install(DIRECTORY doc/graphics doc/scripts ${CMAKE_CURRENT_BINARY_DIR}/doxygen DESTINATION share/doc/stratagus)
+endif(ENABLE_DOC AND DOXYGEN_FOUND)
diff --git a/debian/rules b/debian/rules
index c429199d8..794b47751 100755
--- a/debian/rules
+++ b/debian/rules
@@ -71,8 +71,8 @@ binary-fixup/stratagus-dbg::
 
 binary-fixup/stratagus-doc::
 	mkdir -p debian/stratagus-doc/opt/stratagus
-	mv debian/stratagus-doc/usr/share/doc/stratagus-doc debian/stratagus-doc/opt/stratagus/doc
-	ln -s /opt/stratagus/doc debian/stratagus-doc/usr/share/doc/stratagus-doc
+	mv debian/stratagus-doc/usr/share/doc/stratagus debian/stratagus-doc/opt/stratagus/doc
+	ln -s /opt/stratagus/doc debian/stratagus-doc/usr/share/doc/stratagus
 
 binary-predeb/stratagus::
 	if test -f debian/control.orig; then mv debian/control.orig debian/control; fi
diff --git a/debian/stratagus-doc.doc.base b/debian/stratagus-doc.doc.base
index 6fa8524bb..7f140a4a9 100644
--- a/debian/stratagus-doc.doc.base
+++ b/debian/stratagus-doc.doc.base
@@ -7,6 +7,6 @@ Abstract: This manual describes what Stratagus is
 Section: games
 
 Format: HTML
-Index: /usr/share/doc/stratagus-doc/index.html
-Files: /usr/share/doc/stratagus-doc/*.html
+Index: /usr/share/doc/stratagus/index.html
+Files: /usr/share/doc/stratagus/*.html
 
diff --git a/debian/stratagus-doc.docs b/debian/stratagus-doc.docs
deleted file mode 100644
index 24ecdc519..000000000
--- a/debian/stratagus-doc.docs
+++ /dev/null
@@ -1,3 +0,0 @@
-doc/*.html
-doc/*.txt
-doc/doxygen
diff --git a/doc/doxygen-footer.cfg b/doc/Doxyfile-footer.html
similarity index 100%
rename from doc/doxygen-footer.cfg
rename to doc/Doxyfile-footer.html
diff --git a/doc/doxygen-header.cfg b/doc/Doxyfile-header.html
similarity index 100%
rename from doc/doxygen-header.cfg
rename to doc/Doxyfile-header.html
diff --git a/doc/doxygen.cfg b/doc/Doxyfile.in
similarity index 99%
rename from doc/doxygen.cfg
rename to doc/Doxyfile.in
index 9fec1617d..37874bce7 100644
--- a/doc/doxygen.cfg
+++ b/doc/Doxyfile.in
@@ -38,7 +38,7 @@ PROJECT_NUMBER         = 2.2.5.5
 # If a relative path is entered, it will be relative to the location
 # where doxygen was started. If left blank the current directory will be used.
 
-OUTPUT_DIRECTORY       = doc/doxygen
+OUTPUT_DIRECTORY       = ${CMAKE_CURRENT_BINARY_DIR}/doxygen
 
 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
 # 4096 sub-directories (in 2 levels) under the output directory of each output
@@ -568,7 +568,9 @@ WARN_LOGFILE           =
 # directories like "/usr/src/myproject". Separate the files or directories
 # with spaces.
 
-INPUT                  = metaserver src tools
+INPUT                  = ${CMAKE_CURRENT_SOURCE_DIR}/metaserver \
+                         ${CMAKE_CURRENT_SOURCE_DIR}/src \
+                         ${CMAKE_CURRENT_SOURCE_DIR}/tools
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
@@ -779,13 +781,13 @@ HTML_FILE_EXTENSION    = .html
 # each generated HTML page. If it is left blank doxygen will generate a
 # standard header.
 
-HTML_HEADER            = doc/doxygen-header.cfg
+HTML_HEADER            = ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile-header.html
 
 # The HTML_FOOTER tag can be used to specify a personal HTML footer for
 # each generated HTML page. If it is left blank doxygen will generate a
 # standard footer.
 
-HTML_FOOTER            = doc/doxygen-footer.cfg
+HTML_FOOTER            = ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile-footer.html
 
 # The HTML_STYLESHEET tag can be used to specify a user-defined cascading
 # style sheet that is used by each HTML page. It can be used to