This adds the lines for the cmake build files to build manpages from the
docbook XML files. The same must still be done for the autotools build
files.

---
 CMakeLists.txt     |   16 ++++++-
 doc/CMakeLists.txt |  126 +++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 134 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 160bb45..ba01757 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -157,9 +157,21 @@ add_subdirectory ( ircp )
 #
 # build the documentation
 #
-option ( BUILD_DOCUMENTATION "Build the glib binding library" ON)
+option ( BUILD_DOCUMENTATION "Build library and application documentation" ON)
 if ( BUILD_DOCUMENTATION )
-add_subdirectory ( doc )
+  if ( NOT DOCUMENTATION_INSTALL_DIR )
+    set ( DOCUMENTATION_INSTALL_DIR share/doc/openobex
+      CACHE PATH "Where to install generic documentation files to" FORCE )
+  endif ( NOT DOCUMENTATION_INSTALL_DIR )
+  mark_as_advanced ( DOCUMENTATION_INSTALL_DIR )
+
+  if ( NOT MANPAGE_INSTALL_DIR )
+    set ( MANPAGE_INSTALL_DIR share/man
+      CACHE PATH "Where to install manpage files to" FORCE )
+  endif ( NOT MANPAGE_INSTALL_DIR )
+  mark_as_advanced ( MANPAGE_INSTALL_DIR )
+
+  add_subdirectory ( doc )
 endif ( BUILD_DOCUMENTATION )
 
 
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index a075ca8..caceefb 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -1,5 +1,5 @@
 
-add_custom_target ( doc ALL )
+add_custom_target ( doc )
 
 set ( SOURCES
   "${CMAKE_SOURCE_DIR}/lib/obex.c"
@@ -40,19 +40,133 @@ if ( DOXYGEN_FOUND )
           VERBATIM
       )
 
-      add_custom_target ( ${type_low}
-        DEPENDS "${DOC_${type}_OUTPUT_FILE_ABS}"
-      )
+      add_custom_target ( apidoc_${type_low} DEPENDS 
${DOC_${type}_OUTPUT_FILE_ABS} )
     endif ( DOC_${type}_OUTPUT_FILE )
   endforeach ( type )
 
   set_directory_properties ( PROPERTIES
     ADDITIONAL_MAKE_CLEAN_FILES "html;latex"
   )
+  add_dependencies ( openobex apidoc_html )
+  add_dependencies ( doc apidoc_html )
 
-  add_dependencies ( doc html )
   install ( DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html"
-    DESTINATION share/doc/openobex
+    DESTINATION ${DOCUMENTATION_INSTALL_DIR}
     COMPONENT documentation
   )
 endif ( DOXYGEN_FOUND )
+
+#
+# xsltproc is preferred because it creates better output and is faster.
+#
+# xalan2 can also be used by adding xalan2.jar, xml-apis.jar, xercesImpl.jar
+# and maybe docbook saxon extension jar file to the classpath, then runinng
+# org.apache.xalan.xslt.Process
+# There is also a xalan (1.10) binary of that name that did not work.
+#
+# Saxon-6.5.5 can also be used by adding saxon.jar to classpath, then running
+# com.icl.saxon.StyleSheet
+# Debian has wrapper shell scripts for saxon-6.5.5, called saxon-xslt.
+# Saxon-B 9.1 did not work, Saxon-SA was not tested.
+#
+# Sablotron (1.0.3) does not work.
+#
+find_program ( XSLT_PROCESSOR
+  NAMES xsltproc saxon-xslt
+  DOC   "XSLT processor command (xsltproc, xalan2 or saxon are usable)"
+)
+mark_as_advanced ( XSLT_PROCESSOR )
+
+#
+# call as XSLT_TRANSFORM(<.xsl file URL> <input file> <output file...>)
+#
+macro ( XSL_TRANSFORM xslurl infile )
+  if ( XSLT_PROCESSOR MATCHES ".*xsltproc.*" )
+    set ( XSL_TRANSFORM_COMMAND ${XSLT_PROCESSOR} ${xslurl} ${infile} )
+  elseif ( XSLT_PROCESSOR MATCHES ".*xalan2.*" )
+    set ( XSL_TRANSFORM_COMMAND ${XSLT_PROCESSOR} -in ${infile} -xsl ${xslurl} 
)
+  elseif ( XSLT_PROCESSOR MATCHES ".*saxon.*" )
+    set ( XSL_TRANSFORM_COMMAND ${XSLT_PROCESSOR} ${infile} ${xslurl} )
+  else ( XSLT_PROCESSOR MATCHES ".*xsltproc.*" )
+    message ( FATAL_ERROR "Unsupported XSLT processor" )
+  endif ( XSLT_PROCESSOR MATCHES ".*xsltproc.*" )
+  add_custom_command(
+    OUTPUT ${ARGN}
+    COMMAND ${XSL_TRANSFORM_COMMAND}
+    DEPENDS openobex-apps.xml
+    VERBATIM
+  )
+endmacro ( XSL_TRANSFORM )
+
+if ( XSLT_PROCESSOR )
+  if ( UNIX )
+    option (BUILD_APPS_HELP_MAN "Build manpage application help files" ON)
+    option (BUILD_APPS_HELP_HTML "Build HTML application help files" OFF)
+  else ( UNIX )
+    option (BUILD_APPS_HELP_HTML "Build HTML application help files" ON)
+  endif ( UNIX )
+
+  SET ( DOCBOOK_XSL_PREFIX "http://docbook.sourceforge.net/release/xsl/current";
+        CACHE STRING "prefix to locate the docbook-XSL release files" )
+  mark_as_advanced ( DOCBOOK_XSL_PREFIX )
+
+  file ( READ "${CMAKE_CURRENT_SOURCE_DIR}/openobex-apps.xml" 
XML_FILE_CONTENTS )
+  string ( REGEX MATCHALL "<refentrytitle>[^<]*" XML_REFENTRYTITLE 
"${XML_FILE_CONTENTS}" )
+  foreach ( file ${XML_REFENTRYTITLE} )
+    string ( REGEX REPLACE "^<refentrytitle>" "" file "${file}" )
+    string ( REGEX REPLACE "[[:space:]]" "" file "${file}" )
+    list ( APPEND XSLT_FILES ${file} )
+  endforeach ( file )
+  set ( XML_FILE_CONTENTS )
+  set ( XML_REFENTRYTITLE )
+
+  if ( BUILD_APPS_HELP_MAN )
+    foreach ( file  ${XSLT_FILES} )
+      list ( APPEND XSLT_FILES_MAN ${file}.1 )
+    endforeach ( file )
+    xsl_transform (
+      "${DOCBOOK_XSL_PREFIX}/manpages/docbook.xsl"
+      "${CMAKE_CURRENT_SOURCE_DIR}/openobex-apps.xml"
+      ${XSLT_FILES_MAN}
+    )
+    foreach ( file ${XSLT_FILES_MAN} )
+      list ( APPEND OPENOBEX_HELP_FILES ${file} )
+      get_filename_component ( fileExt ${file} EXT )
+      string ( REGEX REPLACE "^[.]" "" fileExt ${fileExt} )
+      install (
+       FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}
+       DESTINATION ${MANPAGE_INSTALL_DIR}/man${fileExt}
+       PERMISSIONS OWNER_READ OWNER_WRITE
+                    GROUP_READ
+                    WORLD_READ
+        COMPONENT documentation
+      )
+    endforeach ( file )
+  endif ( BUILD_APPS_HELP_MAN )
+
+  if ( BUILD_APPS_HELP_HTML )
+    foreach ( file  ${XSLT_FILES} )
+      list ( APPEND XSLT_FILES_HTML ${file}.html )
+    endforeach ( file )
+    xsl_transform (
+      "${DOCBOOK_XSL_PREFIX}/xhtml/docbook.xsl"
+      "${CMAKE_CURRENT_SOURCE_DIR}/openobex-apps.xml"
+      ${XSLT_FILES_HTML}
+    )
+    foreach ( file ${XSLT_FILES_HTML} )
+      list ( APPEND OPENOBEX_HELP_FILES ${file} )
+      INSTALL (
+       FILES ${file}
+        DESTINATION ${DOCUMENTATION_INSTALL_DIR}
+        PERMISSIONS OWNER_READ OWNER_WRITE
+                    GROUP_READ
+                    WORLD_READ
+        COMPONENT documentation
+      )
+    endforeach ( file )
+  endif ( BUILD_APPS_HELP_HTML )
+
+  add_custom_target ( openobex-apps-doc DEPENDS ${OPENOBEX_HELP_FILES} )
+  add_dependencies ( openobex-apps openobex-apps-doc )
+  add_dependencies ( doc openobex-apps-doc )
+endif ( XSLT_PROCESSOR )
-- 
1.5.6.5


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Openobex-users mailing list
Openobex-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/openobex-users

Reply via email to