Fix of cmake xmldoc dependencies chain.
[platform/upstream/dbus.git] / cmake / doc / CMakeLists.txt
index 13f81e0..bd1af17 100644 (file)
@@ -15,60 +15,78 @@ endif (DBUS_ENABLE_DOXYGEN_DOCS)
 #
 # find docbook generator
 # 
-find_program(MEINPROC_EXECUTABLE meinproc4)
+find_program(MEINPROC4_EXECUTABLE meinproc4)
 
 find_program(XMLTO_EXECUTABLE xmlto)
 
-if (MEINPROC_EXECUTABLE OR XMLTO_EXECUTABLE)
+if (MEINPROC4_EXECUTABLE OR XMLTO_EXECUTABLE)
   OPTION(DBUS_ENABLE_XML_DOCS "build XML  documentation (requires xmlto or meinproc4)" ON)
-endif (MEINPROC_EXECUTABLE OR XMLTO_EXECUTABLE)
+  ADD_CUSTOM_TARGET(xmldoc ALL)
+endif (MEINPROC4_EXECUTABLE OR XMLTO_EXECUTABLE)
 
-if (MEINPROC_EXECUTABLE)
+if (XMLTO_EXECUTABLE)
+       set (DOCBOOK_GENERATOR_NAME "xmlto" PARENT_SCOPE)
+       set(DBUS_XML_DOCS_ENABLED 1)
+       set(MEINPROC4_EXECUTABLE 0)
+       MESSAGE(STATUS "xmlto docbook generator found")
+       set(STYLESHEET_MAN "${DOCBOOKXSL_DIR}/manpages/docbook.xsl")
+       set(STYLESHEET_HTML "${DOCBOOKXSL_DIR}/html/docbook.xsl")
+
+elseif (MEINPROC4_EXECUTABLE)
        set(DOCBOOK_GENERATOR_NAME "meinproc4" PARENT_SCOPE)
        set(DBUS_XML_DOCS_ENABLED 1)
        if(WIN32)
-               get_filename_component(_a ${MEINPROC_EXECUTABLE} PATH)
+               get_filename_component(_a ${MEINPROC4_EXECUTABLE} PATH)
                get_filename_component(_meinproc_install_path ${_a} PATH)
+               set(STYLESHEET_HTML "${_meinproc_install_path}/share/apps/ksgmltools2/docbook/xsl/html/docbook.xsl")
        else(WIN32)
-               set(_meinproc_install_path ${CMAKE_INSTALL_PREFIX})
+               set(STYLESHEET_HTML file:///usr/share/kde4/apps/ksgmltools2/customization/kde-nochunk.xsl)
        endif(WIN32)
-       set(STYLESHEET "${_meinproc_install_path}/share/apps/ksgmltools2/docbook/xsl/html/docbook.xsl")
-endif (MEINPROC_EXECUTABLE)
-  
-if (XMLTO_EXECUTABLE)
-       set (DOCBOOK_GENERATOR_NAME "xmlto" PARENT_SCOPE)
-       set(DBUS_XML_DOCS_ENABLED 0)
-       MESSAGE(STATUS "xmlto docbook generator found, but xmlto doc generating needs validation")
-endif (XMLTO_EXECUTABLE)
+endif ()
 
 if (DBUS_ENABLE_XML_DOCS)
 
-macro (DOCBOOK _sources _options)
-  get_filename_component(_infile ${_sources} REALPATH)
-  get_filename_component(_basename ${_infile} NAME_WE)
-  set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.html)
+macro (DOCBOOK _sources _format)
+  get_filename_component(_infile ${_sources} ABSOLUTE)
+  get_filename_component(_name ${_infile} NAME)
+  set(_deps ${CMAKE_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt)
+
+  if (${_format} STREQUAL "man")
+    string(REPLACE ".xml" "" _outname ${_name})
+    set(STYLESHEET ${STYLESHEET_MAN})
+  else()
+    string(REPLACE ".xml" ".html" _outname ${_name})
+    set(STYLESHEET ${STYLESHEET_HTML})
+  endif ()
 
+  set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_outname})
   if (EXISTS ${_sources})
-         if (MEINPROC_EXECUTABLE)
-                 ADD_CUSTOM_TARGET(${_basename}.html ALL
-                       meinproc4 --stylesheet ${STYLESHEET} -o ${_outfile} ${_infile} 
-                       DEPENDS ${_infile} 
+         if (MEINPROC4_EXECUTABLE)
+                   ADD_CUSTOM_COMMAND(
+                       OUTPUT ${_outfile}
+                       COMMAND ${MEINPROC4_EXECUTABLE} --stylesheet ${STYLESHEET} -o ${_outfile} ${_infile}
+                       DEPENDS ${_infile} ${STYLESHEET} ${_deps}
                        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
                )
          endif ()
          if (XMLTO_EXECUTABLE)
-                 ADD_CUSTOM_TARGET(${_basename}.html ALL
-                       xmlto.bat ${_options} ${_infile} 
-                       DEPENDS ${_infile} 
+                   ADD_CUSTOM_COMMAND(
+                       OUTPUT ${_outfile}
+                       COMMAND ${XMLTO_EXECUTABLE} -vv ${_format} ${_infile}
+                       DEPENDS ${_infile} ${_deps}
                        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
                )
          endif ()
-         install(FILES ${_outfile} DESTINATION share/doc/dbus)
+         if (${_format} STREQUAL "man")
+                 install(FILES ${_outfile} DESTINATION share/man/man1)
+         else ()
+                 install(FILES ${_outfile} DESTINATION share/doc/dbus)
+         endif ()
   else ()
          MESSAGE(STATUS "skipping xml doc generating for ${_infile}, file not found")
   endif ()
-         
+  ADD_CUSTOM_TARGET(${_outname} DEPENDS ${_outfile})
+  ADD_DEPENDENCIES(xmldoc ${_outname})
 endmacro (DOCBOOK)
 
 ### copy tests to builddir so that generated tests and static tests 
@@ -98,11 +116,26 @@ DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-test-plan.xml html-nochunks)
 DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-tutorial.xml html-nochunks)
 DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-specification.xml html-nochunks)
 DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-faq.xml html-nochunks)
-DOCBOOK(${CMAKE_SOURCE_DIR}/bus/dbus-daemon.xml html-nochunks)
-DOCBOOK(${CMAKE_SOURCE_DIR}/tools/dbus-monitor.xml html-nochunks)
-DOCBOOK(${CMAKE_SOURCE_DIR}/tools/dbus-send.xml html-nochunks)
-DOCBOOK(${CMAKE_SOURCE_DIR}/tools/dbus-launch.xml html-nochunks)
-
+configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-cleanup-sockets.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-cleanup-sockets.1.xml)
+configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-daemon.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml)
+configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-launch.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-launch.1.xml)
+configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-monitor.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-monitor.1.xml)
+configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-send.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-send.1.xml)
+configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-uuidgen.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-uuidgen.1.xml)
+DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-cleanup-sockets.1.xml html-nochunks)
+DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml html-nochunks)
+DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-launch.1.xml html-nochunks)
+DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-monitor.1.xml html-nochunks)
+DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-send.1.xml html-nochunks)
+DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-uuidgen.1.xml html-nochunks)
+if (UNIX)
+  DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml man)
+  DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-monitor.1.xml man)
+  DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-send.1.xml man)
+  DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-launch.1.xml man)
+  DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-uuidgen.1.xml man)
+  DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-cleanup-sockets.1.xml man)
+endif()
 #
 # handle html index file
 #