message("")
message(STATUS "${BoldGreen}Starting configuration for the doc material for ${CMAKE_PROJECT_NAME} ${ColourReset}")
message("")

# The UNIX man pages
if(UNIX AND NOT APPLE)

  message("\n${BoldYellow}Generating the man page.${ColourReset}\n")

	execute_process(COMMAND docbook-to-man ${PROJECT_NAME}.xml
		OUTPUT_FILE	${CMAKE_BINARY_DIR}/${PROJECT_NAME}.1
		WORKING_DIRECTORY	${CMAKE_CURRENT_SOURCE_DIR})

endif()


###############
# install stuff

# The history and licence files.

message("\n${BoldGreen}Installation directory for the doc files:
${PROJECT_INSTALL_DOC_DIR}${ColourReset}\n")

install(FILES history.html ../LICENSE
	DESTINATION ${PROJECT_INSTALL_DOC_DIR})

# The man page.
if(UNIX AND NOT APPLE)
	install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.1
		DESTINATION ${CMAKE_INSTALL_DATADIR}/man/man1)
endif()


#############################################################
###########################
# BUILD OF THE USER MANUAL

# The version of the program needs to be set in the user manual front
# matter. We need to make this configuration even if we do not build the
# user manual because when building debian packages the source tarball
# needs to have the right version in the file.
configure_file(
    ${CMAKE_SOURCE_DIR}/CMakeStuff/user-manual-version-entity.ent.cmake.in
    ${CMAKE_SOURCE_DIR}/doc/user-manual/xml/user-manual-version-entity.ent @ONLY
)

if(UNIX AND BUILD_USER_MANUAL)
	add_subdirectory(user-manual)
endif()

message("\n${BoldGreen}Ending configuration for subdirectory doc${ColourReset}\n")
