From 7872785bfc0c0e34b2bd8d964da5b19ce0da4eee Mon Sep 17 00:00:00 2001 From: lbonn Date: Tue, 5 Mar 2024 12:23:22 +0100 Subject: [PATCH] [Doc] New installation with autoconf and meson - autoconf: * generate in source directory if pandoc found * install from source directory - meson: * generate and install with build directory if pandoc found * try to install from source directory if pandoc not found * bail otherwise --- .github/actions/setup/action.yml | 1 + Makefile.am | 57 ++++++++++++++++++++++---------- configure.ac | 12 +++++++ doc/meson.build | 42 +++++++++++++++++------ meson-dist-script | 16 +++++++++ meson.build | 2 ++ 6 files changed, 101 insertions(+), 29 deletions(-) create mode 100644 meson-dist-script diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 0181bafaf..16871dc52 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -34,6 +34,7 @@ runs: libxkbcommon-dev \ libxkbcommon-x11-dev \ ninja-build \ + pandoc \ python3-pip \ python3-setuptools \ python3-wheel \ diff --git a/Makefile.am b/Makefile.am index 98881b77e..adcda08c1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -172,19 +172,52 @@ rofi_LDADD=\ $(LIBS) ## -# Manpage +# Manpages ## + +.PHONY: generate-manpage + +if FOUND_PANDOC + +generate-manpage: doc/rofi.1\ + doc/rofi-sensible-terminal.1\ + doc/rofi-theme-selector.1\ + doc/rofi-debugging.5\ + doc/rofi-dmenu.5\ + doc/rofi-keys.5\ + doc/rofi-script.5\ + doc/rofi-theme.5 + +doc/rofi.1: doc/rofi.1.markdown + pandoc --standalone --to=man --lua-filter=$(top_srcdir)/doc/man_filter.lua -f markdown-tex_math_dollars -o ./$@ ./$< +doc/rofi-sensible-terminal.1: doc/rofi-sensible-terminal.1.markdown + pandoc --standalone --to=man --lua-filter=$(top_srcdir)/doc/man_filter.lua -f markdown-tex_math_dollars -o ./$@ ./$< +doc/rofi-theme-selector.1: doc/rofi-theme-selector.1.markdown + pandoc --standalone --to=man --lua-filter=$(top_srcdir)/doc/man_filter.lua -f markdown-tex_math_dollars -o ./$@ ./$< +doc/rofi-debugging.5: doc/rofi-debugging.5.markdown + pandoc --standalone --to=man --lua-filter=$(top_srcdir)/doc/man_filter.lua -f markdown-tex_math_dollars -o ./$@ ./$< +doc/rofi-dmenu.5: doc/rofi-dmenu.5.markdown + pandoc --standalone --to=man --lua-filter=$(top_srcdir)/doc/man_filter.lua -f markdown-tex_math_dollars -o ./$@ ./$< +doc/rofi-keys.5: doc/rofi-keys.5.markdown + pandoc --standalone --to=man --lua-filter=$(top_srcdir)/doc/man_filter.lua -f markdown-tex_math_dollars -o ./$@ ./$< +doc/rofi-script.5: doc/rofi-script.5.markdown + pandoc --standalone --to=man --lua-filter=$(top_srcdir)/doc/man_filter.lua -f markdown-tex_math_dollars -o ./$@ ./$< +doc/rofi-theme.5: doc/rofi-theme.5.markdown + pandoc --standalone --to=man --lua-filter=$(top_srcdir)/doc/man_filter.lua -f markdown-tex_math_dollars -o ./$@ ./$< + +endif + dist_man1_MANS=\ doc/rofi.1\ - doc/rofi-theme-selector.1\ - doc/rofi-sensible-terminal.1 + doc/rofi-sensible-terminal.1\ + doc/rofi-theme-selector.1 dist_man5_MANS=\ - doc/rofi-theme.5\ doc/rofi-debugging.5\ - doc/rofi-keys.5\ doc/rofi-dmenu.5\ - doc/rofi-script.5 + doc/rofi-keys.5\ + doc/rofi-script.5\ + doc/rofi-theme.5 EXTRA_DIST += \ doc/rofi-theme.5.markdown \ @@ -254,19 +287,7 @@ EXTRA_DIST+=\ doc/default_configuration.rasi\ doc/default_theme.rasi\ Changelog -## -# Indent -## -generate-manpage: $(top_srcdir)/doc/rofi-theme-selector.1.markdown $(top_srcdir)/doc/rofi.1.markdown $(top_srcdir)/doc/rofi-theme.5.markdown $(top_srcdir)/doc/rofi-script.5.markdown ${top_srcdir}/doc/rofi-sensible-terminal.1.markdown ${top_srcdir}/doc/rofi-keys.5.markdown ${top_srcdir}/doc/rofi-dmenu.5.markdown $(top_srcdir)/doc/rofi-debugging.5.markdown - pandoc --standalone --to=man -f markdown-tedxt_math_dollars $(top_srcdir)/doc/rofi.1.markdown -o $(top_srcdir)/doc/rofi.1 - pandoc --standalone --to=man -f markdown-tedxt_math_dollars $(top_srcdir)/doc/rofi-theme-selector.1.markdown -o $(top_srcdir)/doc/rofi-theme-selector.1 - pandoc --standalone --to=man -f markdown-tedxt_math_dollars $(top_srcdir)/doc/rofi-theme.5.markdown -o $(top_srcdir)/doc/rofi-theme.5 - pandoc --standalone --to=man -f markdown-tedxt_math_dollars $(top_srcdir)/doc/rofi-debugging.5.markdown -o $(top_srcdir)/doc/rofi-debugging.5 - pandoc --standalone --to=man -f markdown-tedxt_math_dollars $(top_srcdir)/doc/rofi-keys.5.markdown -o $(top_srcdir)/doc/rofi-keys.5 - pandoc --standalone --to=man -f markdown-tedxt_math_dollars $(top_srcdir)/doc/rofi-script.5.markdown -o $(top_srcdir)/doc/rofi-script.5 - pandoc --standalone --to=man -f markdown-tedxt_math_dollars $(top_srcdir)/doc/rofi-dmenu.5.markdown -o $(top_srcdir)/doc/rofi-dmenu.5 - pandoc --standalone --to=man -f markdown-tedxt_math_dollars $(top_srcdir)/doc/rofi-sensible-terminal.1.markdown -o $(top_srcdir)/doc/rofi-sensible-terminal.1 ## # Rofi test program diff --git a/configure.ac b/configure.ac index 2b97e3662..c658aed9d 100644 --- a/configure.ac +++ b/configure.ac @@ -169,6 +169,13 @@ AC_ARG_ENABLE([check], AS_HELP_STRING([--disable-check], [Build with checks usin AS_IF([test "x${enable_check}" != "xno"], [ PKG_CHECK_MODULES([check],[check >= 0.11.0], [HAVE_CHECK=1]) ]) AM_CONDITIONAL([USE_CHECK], [test "x${enable_check}" != "xno" && test "$HAVE_CHECK" -eq 1]) +dnl --------------------------------------------------------------------- +dnl Build man pages +dnl --------------------------------------------------------------------- +AC_ARG_ENABLE([man], AS_HELP_STRING([--disable-man], [Build man pages (default: enabled)])) + +AS_IF([test "x$enable_man" != "xno" ], [ AC_CHECK_PROG([pandoc], pandoc, [yes])]) +AM_CONDITIONAL([FOUND_PANDOC], [test "x$pandoc" = xyes]) dnl --------------------------------------------------------------------- dnl Gets the resource compile tool path. @@ -210,6 +217,11 @@ echo "Check based tests Enabled" else echo "Check based tests Disabled" fi +if test "x${enable_man}" != "xno" && test "x$pandoc" = "xyes"; then +echo "Build man pages Enabled" +else +echo "Build man pages Disabled" +fi echo "-------------------------------------" echo "Now type 'make' to build" echo "" diff --git a/doc/meson.build b/doc/meson.build index 3d6919aef..17df2da65 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -1,16 +1,22 @@ -pandoc = find_program('pandoc', required: false) +man_files = [ + 'rofi.1', + 'rofi-sensible-terminal.1', + 'rofi-theme-selector.1', + 'rofi-debugging.5', + 'rofi-dmenu.5', + 'rofi-keys.5', + 'rofi-script.5', + 'rofi-theme.5', +] + +fs = import('fs') + +pandoc = find_program('pandoc', required: false, version: '>=2.17') + if pandoc.found() man_targets = [] - foreach f: [ - 'rofi.1', - 'rofi-sensible-terminal.1', - 'rofi-debugging.5', - 'rofi-dmenu.5', - 'rofi-keys.5', - 'rofi-script.5', - 'rofi-theme-selector.1', - 'rofi-theme.5', - ] + cp_cmds = [] + foreach f: man_files section_number = f.split('.')[1] install_dest = join_paths(get_option('prefix'), get_option('mandir'), 'man' + section_number) @@ -26,7 +32,21 @@ if pandoc.found() build_by_default: true, ) endforeach + run_target('generate-manpage', command: ['true'], depends: man_targets) +else + man_missing = false + foreach f: man_files + if not fs.is_file(f) + man_missing = true + endif + endforeach + + if man_missing + warning('Man files cannot be generated and not present in source directory, they will not be installed') + else + install_man(man_files) + endif endif doxy_conf = configuration_data() diff --git a/meson-dist-script b/meson-dist-script new file mode 100644 index 000000000..05e126f06 --- /dev/null +++ b/meson-dist-script @@ -0,0 +1,16 @@ +#!/bin/sh + +set -eu + +cd "${MESON_DIST_ROOT}" + +# deploy docs +mkdir build +meson setup build -Dprefix=/usr +ninja -C build +cp build/doc/*.1 doc +cp build/doc/*.5 doc +rm -rf build + +# configure script +autoreconf -i diff --git a/meson.build b/meson.build index d69cf6704..f5fc1ec04 100644 --- a/meson.build +++ b/meson.build @@ -17,6 +17,8 @@ add_project_arguments( language: 'c' ) +meson.add_dist_script('meson-dist-script') + flags = [ '-Wparentheses', '-Winline',