if(BUILD_USER_MANUAL)

  if(UNIX AND NOT APPLE)

    message("")
    message(STATUS "${BoldGreen}Starting configuration for the user manual for ${CMAKE_PROJECT_NAME} ${ColourReset}")
    message("")

    # The version of the program needs to be set in the user manual front
    # matter.
    CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/CMakeStuff/user-manual-version-entity.ent.in
      ${CMAKE_SOURCE_DIR}/doc/user-manual/xml/user-manual-version-entity.ent @ONLY)

    # The location of the main user manual config file (set fop.xconf file
    # location)
    set(FOP_XCONF_DIR ${CMAKE_SOURCE_DIR}/doc/user-manual)
    CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/CMakeStuff/DC-user-manual.cmake.in
      ${CMAKE_SOURCE_DIR}/doc/user-manual/DC-user-manual @ONLY)

    # If the user asks that the JavaScript documentation be extracted from the
    # source code files, then do that:

    # Command:
    # make jsextract

    message("\tConfiguring the JavaScript-related documentation extraction")

    add_custom_target(jsextract

      COMMAND ${CMAKE_SOURCE_DIR}/doc/scripts/jsExtract.py -i src/nongui/js/TraceJs.cpp 
      -o ${CMAKE_SOURCE_DIR}/doc/user-manual/javascript-reference.txt
      WORKING_DIRECTORY	${CMAKE_SOURCE_DIR}
      COMMENT "Extraction of all the JavaScript source code documentation"
      )

    # Command:
    # make usermanual
    # Makes use of the local  Makefile file.
    # Will generate HTML and PDF documentation in the build directory

    message("\tConfiguring the user manual compilation")

    add_custom_target(usermanual
      COMMAND make all_f
      DEPENDS jsextract
      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
      COMMENT "Build of the DocBook-based user manual documentation")

    install(FILES
      ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}-doc.pdf
      DESTINATION ${DOC_DIR})

    message(STATUS "The pdf file: ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}-doc.pdf")

    install(DIRECTORY 
      ${CMAKE_CURRENT_SOURCE_DIR}/build/user-manual/html/user-manual/
      DESTINATION ${DOC_DIR}/html)

    message("")
    message(STATUS "${BoldGreen}Finished configuring the ${CMAKE_PROJECT_NAME} user manual.${ColourReset}")
    message("")

  else()

    message(STATUS "User manual build skipped")

  endif()

endif()
