Skip to content

Commit 04134ed

Browse files
committed
CMake: added manual page generation
1 parent a83cb2a commit 04134ed

22 files changed

+398
-11
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ if (${BUILD_TYPE_UPPER} STREQUAL "COVERAGE")
5454
set(TESTS_DEFAULT ON)
5555
endif()
5656

57-
option(ENABLE_DOC "Enable documentation building" OFF)
57+
option(ENABLE_DOC_MANPAGE "Enable manual page building" ON)
58+
option(ENABLE_DOC_DOXYGEN "Enable code documentation building" OFF)
5859
option(ENABLE_TESTS "Build Unit tests (make test)" ${TESTS_DEFAULT})
5960
option(ENABLE_TESTS_VALGRIND "Build Unit tests with Valgrind Memcheck" OFF)
6061
option(PACKAGE_BUILDER_RPM "Enable RPM package builder (make rpm)" OFF)

CMakeModules/FindRst2Man.cmake

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# RST2MAN_FOUND - true if the program was found
2+
# RST2MAN_VERSION - version of rst2man
3+
# RST2MAN_EXECUTABLE - path to the rst2man program
4+
5+
find_program(RST2MAN_EXECUTABLE
6+
NAMES rst2man rst2man.py rst2man-3 rst2man-3.py
7+
DOC "The Python Docutils generator of Unix Manpages from reStructuredText"
8+
)
9+
10+
if (RST2MAN_EXECUTABLE)
11+
# Get the version string
12+
execute_process(
13+
COMMAND ${RST2MAN_EXECUTABLE} --version
14+
OUTPUT_VARIABLE rst2man_version_str
15+
)
16+
# Expected format: rst2man (Docutils 0.13.1 [release], Python 2.7.15, on linux2)
17+
string(REGEX REPLACE "^rst2man[\t ]+\\(Docutils[\t ]+([^\t ]*).*" "\\1"
18+
RST2MAN_VERSION "${rst2man_version_str}")
19+
unset(rst2man_version_str)
20+
endif()
21+
22+
# handle the QUIETLY and REQUIRED arguments and set RST2MAN_FOUND to TRUE
23+
# if all listed variables are set
24+
include(FindPackageHandleStandardArgs)
25+
find_package_handle_standard_args(Rst2Man
26+
REQUIRED_VARS RST2MAN_EXECUTABLE
27+
VERSION_VAR RST2MAN_VERSION
28+
)
29+
30+
mark_as_advanced(RST2MAN_EXECUTABLE RST2MAN_VERSION)

doc/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Build documentation
2-
if (ENABLE_DOC)
1+
# Build code documentation
2+
if (ENABLE_DOC_DOXYGEN)
33
find_package(Doxygen)
44
if (NOT DOXYGEN_FOUND)
55
message(FATAL_ERROR "Doxygen is not available.")
@@ -28,4 +28,4 @@ if (ENABLE_DOC)
2828
COMMENT "Generating API documentation with Doxygen to ${DOXYGEN_DIRECTORY}"
2929
VERBATIM
3030
)
31-
endif(ENABLE_DOC)
31+
endif(ENABLE_DOC_DOXYGEN)

extra_plugins/output/lnfstore/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ if (NOT CMAKE_BUILD_TYPE)
4141
CACHE STRING "Choose type of build (Release/Debug/Coverage)." FORCE)
4242
endif()
4343

44+
option(ENABLE_DOC_MANPAGE "Enable manual page building" ON)
45+
4446
# Hard coded definitions
4547
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -std=gnu11")
4648
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
@@ -87,3 +89,25 @@ install(
8789
TARGETS lnfstore-output
8890
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/ipfixcol2/"
8991
)
92+
93+
if (ENABLE_DOC_MANPAGE)
94+
find_package(Rst2Man)
95+
if (NOT RST2MAN_FOUND)
96+
message(FATAL_ERROR "rst2man is not available. Install python-docutils or disable manual page generation (-DENABLE_DOC_MANPAGE=False)")
97+
endif()
98+
99+
# Build a manual page
100+
set(SRC_FILE "${CMAKE_CURRENT_SOURCE_DIR}/doc/ipfixcol2-lnfstore-output.7.rst")
101+
set(DST_FILE "${CMAKE_CURRENT_BINARY_DIR}/ipfixcol2-lnfstore-output.7")
102+
103+
add_custom_command(TARGET lnfstore-output PRE_BUILD
104+
COMMAND ${RST2MAN_EXECUTABLE} --syntax-highlight=none ${SRC_FILE} ${DST_FILE}
105+
DEPENDS ${SRC_FILE}
106+
VERBATIM
107+
)
108+
109+
install(
110+
FILES "${DST_FILE}"
111+
DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man7"
112+
)
113+
endif()
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# RST2MAN_FOUND - true if the program was found
2+
# RST2MAN_VERSION - version of rst2man
3+
# RST2MAN_EXECUTABLE - path to the rst2man program
4+
5+
find_program(RST2MAN_EXECUTABLE
6+
NAMES rst2man rst2man.py rst2man-3 rst2man-3.py
7+
DOC "The Python Docutils generator of Unix Manpages from reStructuredText"
8+
)
9+
10+
if (RST2MAN_EXECUTABLE)
11+
# Get the version string
12+
execute_process(
13+
COMMAND ${RST2MAN_EXECUTABLE} --version
14+
OUTPUT_VARIABLE rst2man_version_str
15+
)
16+
# Expected format: rst2man (Docutils 0.13.1 [release], Python 2.7.15, on linux2)
17+
string(REGEX REPLACE "^rst2man[\t ]+\\(Docutils[\t ]+([^\t ]*).*" "\\1"
18+
RST2MAN_VERSION "${rst2man_version_str}")
19+
unset(rst2man_version_str)
20+
endif()
21+
22+
# handle the QUIETLY and REQUIRED arguments and set RST2MAN_FOUND to TRUE
23+
# if all listed variables are set
24+
include(FindPackageHandleStandardArgs)
25+
find_package_handle_standard_args(Rst2Man
26+
REQUIRED_VARS RST2MAN_EXECUTABLE
27+
VERSION_VAR RST2MAN_VERSION
28+
)
29+
30+
mark_as_advanced(RST2MAN_EXECUTABLE RST2MAN_VERSION)

extra_plugins/output/lnfstore/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ files and provide query results faster.
1414
How to build
1515
------------
1616

17-
By default, the plugin is not distributed with the IPFIXcol itself due to extra dependencies.
17+
By default, the plugin is not distributed with IPFIXcol due to extra dependencies.
1818
To build the plugin, IPFIXcol (and its header files) and the following dependencies must be
1919
installed on your system:
2020

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
===========================
2+
ipfixcol2-lnfstore-output
3+
===========================
4+
5+
------------------------
6+
lnfstore (output plugin)
7+
------------------------
8+
9+
:Author: Lukáš Huták ([email protected])
10+
:Author: Pavel Krobot ([email protected])
11+
:Date: 2018-09-20
12+
:Copyright: Copyright © 2018 CESNET, z.s.p.o.
13+
:Version: 2.0
14+
:Manual section: 7
15+
:Manual group: IPFIXcol collector
16+
17+
Description
18+
-----------
19+
20+
.. include:: ../README.rst
21+
:start-line: 3
22+
:end-before: How to build
23+
24+
.. include:: ../README.rst
25+
:start-after: make install

extra_plugins/output/unirec/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ if (NOT CMAKE_BUILD_TYPE)
2929
CACHE STRING "Choose type of build (Release/Debug)." FORCE)
3030
endif()
3131

32+
option(ENABLE_DOC_MANPAGE "Enable manual page building" ON)
33+
3234
# Hard coded definitions
3335
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -std=gnu11")
3436
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
@@ -72,3 +74,24 @@ install(
7274
DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/ipfixcol2/"
7375
)
7476

77+
if (ENABLE_DOC_MANPAGE)
78+
find_package(Rst2Man)
79+
if (NOT RST2MAN_FOUND)
80+
message(FATAL_ERROR "rst2man is not available. Install python-docutils or disable manual page generation (-DENABLE_DOC_MANPAGE=False)")
81+
endif()
82+
83+
# Build a manual page
84+
set(SRC_FILE "${CMAKE_CURRENT_SOURCE_DIR}/doc/ipfixcol2-unirec-output.7.rst")
85+
set(DST_FILE "${CMAKE_CURRENT_BINARY_DIR}/ipfixcol2-unirec-output.7")
86+
87+
add_custom_command(TARGET unirec-output PRE_BUILD
88+
COMMAND ${RST2MAN_EXECUTABLE} --syntax-highlight=none ${SRC_FILE} ${DST_FILE}
89+
DEPENDS ${SRC_FILE}
90+
VERBATIM
91+
)
92+
93+
install(
94+
FILES "${DST_FILE}"
95+
DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man7"
96+
)
97+
endif()
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# RST2MAN_FOUND - true if the program was found
2+
# RST2MAN_VERSION - version of rst2man
3+
# RST2MAN_EXECUTABLE - path to the rst2man program
4+
5+
find_program(RST2MAN_EXECUTABLE
6+
NAMES rst2man rst2man.py rst2man-3 rst2man-3.py
7+
DOC "The Python Docutils generator of Unix Manpages from reStructuredText"
8+
)
9+
10+
if (RST2MAN_EXECUTABLE)
11+
# Get the version string
12+
execute_process(
13+
COMMAND ${RST2MAN_EXECUTABLE} --version
14+
OUTPUT_VARIABLE rst2man_version_str
15+
)
16+
# Expected format: rst2man (Docutils 0.13.1 [release], Python 2.7.15, on linux2)
17+
string(REGEX REPLACE "^rst2man[\t ]+\\(Docutils[\t ]+([^\t ]*).*" "\\1"
18+
RST2MAN_VERSION "${rst2man_version_str}")
19+
unset(rst2man_version_str)
20+
endif()
21+
22+
# handle the QUIETLY and REQUIRED arguments and set RST2MAN_FOUND to TRUE
23+
# if all listed variables are set
24+
include(FindPackageHandleStandardArgs)
25+
find_package_handle_standard_args(Rst2Man
26+
REQUIRED_VARS RST2MAN_EXECUTABLE
27+
VERSION_VAR RST2MAN_VERSION
28+
)
29+
30+
mark_as_advanced(RST2MAN_EXECUTABLE RST2MAN_VERSION)

extra_plugins/output/unirec/README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ flow records that consist of HTTP fields.
2121
How to build
2222
------------
2323

24-
By default, the plugin is not distributed with the IPFIXcol itself due to extra dependencies.
24+
By default, the plugin is not distributed with IPFIXcol due to extra dependencies.
2525
To build the plugin, IPFIXcol (and its header files) and the following dependencies must be
2626
installed on your system:
2727

@@ -245,7 +245,7 @@ with increased verbosity level i.e. ``ipfixcol2 -v``.
245245
Note
246246
----
247247

248-
Bidirectional flows are now currently supported by UniRec, therefore, biflow records are
248+
Bidirectional flows are not currently supported by UniRec, therefore, biflow records are
249249
automatically split into two unidirectional flow records during conversion.
250250

251251
When multiple IPFIX Information Elements are mapped to the same UniRec field and those IPFIX fields

0 commit comments

Comments
 (0)