Skip to content
Permalink
Browse files

Use a2x for man page generation

  • Loading branch information...
kimwalisch committed Nov 3, 2019
1 parent 198520a commit 3e2af5b690a19a43d8ef8f33a23f9da79ac941f6
Showing with 47 additions and 41 deletions.
  1. +1 −1 .travis.yml
  2. +21 −6 BUILD.md
  3. +17 −28 CMakeLists.txt
  4. +8 −6 doc/README.md
@@ -86,7 +86,7 @@ install:
if [ "${TRAVIS_OS_NAME}" = "linux" ]
then
sudo apt-get install -y g++-multilib make cmake ninja-build cppcheck doxygen \
doxygen-latex help2man graphviz libqt4-dev qt4-qmake valgrind
doxygen-latex graphviz libqt4-dev qt4-qmake valgrind
fi
script:
@@ -70,12 +70,13 @@ built. The build options can be modified at the configure step using e.g.
```cmake . -DBUILD_TESTS=ON```.
```CMake
option(BUILD_PRIMESIEVE "Build primesieve binary" ON)
option(BUILD_SHARED_LIBS "Build shared libprimesieve" ON)
option(BUILD_STATIC_LIBS "Build static libprimesieve" ON)
option(BUILD_DOC "Build documentation" OFF)
option(BUILD_EXAMPLES "Build example programs" OFF)
option(BUILD_TESTS "Build test programs" OFF)
option(BUILD_PRIMESIEVE "Build primesieve binary" ON)
option(BUILD_SHARED_LIBS "Build shared libprimesieve" ON)
option(BUILD_STATIC_LIBS "Build static libprimesieve" ON)
option(BUILD_DOC "Build C/C++ API documentation" OFF)
option(BUILD_MANPAGE "Regenerate man page using a2x" OFF)
option(BUILD_EXAMPLES "Build example programs" OFF)
option(BUILD_TESTS "Build test programs" OFF)
```

## Run the tests
@@ -107,3 +108,17 @@ you need to have installed the ```doxygen```, ```doxygen-latex``` and
cmake -DBUILD_DOC=ON .
make doc
```

## Man page regeneration

primesieve includes an up to date man page at ```doc/primesieve.1```.
That man page has been generated from ```doc/primesieve.txt``` using
the ```a2x``` program from the ```asciidoc``` package. However when
packaging primesieve for e.g. a Linux distro it is recommended to
regenerate the man page.

```bash
# Build man page using a2x program (asciidoc package)
cmake -DBUILD_MANPAGE=ON .
make -j
```
@@ -5,12 +5,13 @@ set(PRIMESIEVE_SOVERSION "9.5.0")

# Build options ######################################################

option(BUILD_PRIMESIEVE "Build primesieve binary" ON)
option(BUILD_SHARED_LIBS "Build shared libprimesieve" ON)
option(BUILD_STATIC_LIBS "Build static libprimesieve" ON)
option(BUILD_DOC "Build documentation" OFF)
option(BUILD_EXAMPLES "Build example programs" OFF)
option(BUILD_TESTS "Build test programs" OFF)
option(BUILD_PRIMESIEVE "Build primesieve binary" ON)
option(BUILD_SHARED_LIBS "Build shared libprimesieve" ON)
option(BUILD_STATIC_LIBS "Build static libprimesieve" ON)
option(BUILD_DOC "Build C/C++ API documentation" OFF)
option(BUILD_MANPAGE "Regenerate man page using a2x" OFF)
option(BUILD_EXAMPLES "Build example programs" OFF)
option(BUILD_TESTS "Build test programs" OFF)

if(NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
message(FATAL_ERROR "One or both of BUILD_SHARED_LIBS or BUILD_STATIC_LIBS must be set to ON")
@@ -281,32 +282,20 @@ endif()

# Regenerate man page ################################################

if(BUILD_PRIMESIEVE AND NOT CMAKE_CROSSCOMPILING)
find_program(HELP2MAN help2man)
if(BUILD_MANPAGE)
find_program(A2X_EXECUTABLE a2x)

if(HELP2MAN)
message(STATUS "Found help2man: ${HELP2MAN}")

execute_process(COMMAND perl -e "use Locale::gettext;"
RESULT_VARIABLE LOCALE_RES
OUTPUT_QUIET ERROR_QUIET)

if(LOCALE_RES EQUAL 0)
message(STATUS "Found help2man option: --locale=C.UTF-8")
set(HELP2MAN_LOCALE "--locale=C.UTF-8")
endif()
if(NOT A2X_EXECUTABLE)
message(FATAL_ERROR "Missing a2x program (required for man page generation)!")
else()
message(STATUS "Found a2x: ${A2X_EXECUTABLE}")

add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${HELP2MAN}
ARGS -s 1
--manual="primesieve"
--source="primesieve ${PRIMESIEVE_VERSION}"
--no-info
${HELP2MAN_LOCALE}
-n "efficient prime number generator"
-o ${PROJECT_SOURCE_DIR}/doc/primesieve.1
$<TARGET_FILE:primesieve>
COMMAND ${A2X_EXECUTABLE}
ARGS --format=manpage
-D "${PROJECT_SOURCE_DIR}/doc"
"${PROJECT_SOURCE_DIR}/doc/primesieve.txt"
VERBATIM)
endif()
endif()
@@ -15,12 +15,14 @@ make doc
Build man page
==============

To regenerate the primesieve man page you need to have installed
the ```help2man``` program. Run the commands below from the parent
directory.
primesieve includes an up to date man page at ```doc/primesieve.1```.
That man page has been generated from ```doc/primesieve.txt``` using
the ```a2x``` program from the ```asciidoc``` package. However when
packaging primesieve for e.g. a Linux distro it is recommended to
regenerate the man page.

```bash
# Build man page
cmake .
make
# Build man page using a2x program (asciidoc package)
cmake -DBUILD_MANPAGE=ON .
make -j
```

0 comments on commit 3e2af5b

Please sign in to comment.
You can’t perform that action at this time.