2014-04-19 22:39:48 -04:00
|
|
|
set (ASCIIDOC_MANS
|
|
|
|
man1/wsjtx.1.txt
|
2014-09-05 14:36:10 -04:00
|
|
|
man1/jt65code.1.txt
|
2014-09-25 10:45:36 -04:00
|
|
|
man1/rigctld-wsjtx.1.txt
|
2014-04-19 22:39:48 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
find_program (A2X_EXECUTABLE NAMES a2x a2x.py)
|
|
|
|
if (NOT A2X_EXECUTABLE)
|
2014-04-20 08:46:34 -04:00
|
|
|
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2014-04-21 07:49:20 -04:00
|
|
|
message (SEND_ERROR "Failed to find a2x which is an optional requirement for non-debug
|
2014-04-21 07:38:17 -04:00
|
|
|
builds on *nix platforms.
|
|
|
|
|
|
|
|
You can choose to skip manpage generation and this error by setting
|
|
|
|
the CMake option WSJT_SKIP_MANPAGES to ON. This option is designed for
|
2014-04-21 07:49:20 -04:00
|
|
|
those that are building for their own use, package builders should not
|
|
|
|
opt to skip manpage generation since package building requires the
|
2014-04-21 07:38:17 -04:00
|
|
|
manpages.")
|
|
|
|
|
2014-04-20 08:46:34 -04:00
|
|
|
else (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
|
|
message (WARNING "Failed to find a2x skipping manpage generation.")
|
|
|
|
endif (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2014-04-19 22:39:48 -04:00
|
|
|
endif ()
|
|
|
|
find_program (GZIP_EXECUTABLE NAMES gzip)
|
|
|
|
find_program (SED_EXECUTABLE NAMES sed)
|
|
|
|
|
|
|
|
set (XSLTPROC_OPTS
|
|
|
|
"-param man.endnotes.list.enabled 0 -param man.endnotes.are.numbered 0"
|
|
|
|
)
|
|
|
|
set (A2X_OPTS
|
|
|
|
--format=manpage
|
|
|
|
--xsltproc-opts=${XSLTPROC_OPTS}
|
|
|
|
--doctype=manpage
|
|
|
|
--no-xmllint
|
|
|
|
)
|
|
|
|
|
|
|
|
set (MANPAGES)
|
2014-04-20 08:46:34 -04:00
|
|
|
if (A2X_EXECUTABLE AND GZIP_EXECUTABLE AND SED_EXECUTABLE)
|
2014-04-19 22:39:48 -04:00
|
|
|
file (MAKE_DIRECTORY man)
|
|
|
|
foreach (f IN LISTS ASCIIDOC_MANS)
|
|
|
|
get_filename_component (d "${f}" PATH)
|
|
|
|
string (SUBSTRING "${d}" 3 -1 section)
|
|
|
|
if (NOT section MATCHES "[1-9]")
|
|
|
|
message (SEND_ERROR "Invalid man section ${section} in ${f}")
|
|
|
|
endif (NOT section MATCHES "[1-9]")
|
|
|
|
get_filename_component (filename "${f}" NAME_WE)
|
|
|
|
set (f "${CMAKE_CURRENT_SOURCE_DIR}/${f}")
|
|
|
|
set (d "man/${d}")
|
|
|
|
set (o "${d}/${filename}.${section}")
|
|
|
|
add_custom_command (OUTPUT "${o}.gz"
|
|
|
|
COMMAND ${CMAKE_COMMAND} ARGS -E make_directory "${d}"
|
|
|
|
COMMAND ${A2X_EXECUTABLE} ARGS ${A2X_OPTS} -D "${d}" "${f}"
|
2014-04-20 10:28:02 -04:00
|
|
|
COMMAND ${SED_EXECUTABLE} ARGS -e "'s@.so @&man${section}/@'" -i.orig "${d}/*.${section}"
|
2014-04-20 08:46:34 -04:00
|
|
|
COMMAND ${GZIP_EXECUTABLE} ARGS -f9 "${d}/*.${section}"
|
2014-04-19 22:39:48 -04:00
|
|
|
DEPENDS "${f}"
|
|
|
|
COMMENT "Generating ${o}.gz"
|
|
|
|
)
|
|
|
|
list (APPEND MANPAGES "${o}.gz")
|
|
|
|
endforeach ()
|
|
|
|
|
|
|
|
install (
|
|
|
|
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man
|
|
|
|
DESTINATION ${WSJT_MANPAGE_DESTINATION}
|
2014-04-20 10:28:02 -04:00
|
|
|
PATTERN "*.orig" EXCLUDE
|
2014-04-21 08:21:44 -04:00
|
|
|
#COMPONENT Runtime
|
2014-04-19 22:39:48 -04:00
|
|
|
)
|
2014-04-20 08:46:34 -04:00
|
|
|
endif (A2X_EXECUTABLE AND GZIP_EXECUTABLE AND SED_EXECUTABLE)
|
2014-04-19 22:39:48 -04:00
|
|
|
|
|
|
|
add_custom_target (manpages DEPENDS ${MANPAGES})
|