From 897eed184a4c79d75e2f04706e2f66d158d20d4e Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 20 Nov 2024 02:22:02 -0500 Subject: [PATCH 1/5] build: only demand an xsltproc program when it is used It's intrinsically used when building manpages, and also part of the introspection-specific parts of the documentation build. There's no particular guarantee either of those will actually be invoked during a build, so don't unconditionally look it up. This allows building with one fewer dependency in many cases. --- docs/api/meson.build | 2 ++ man/meson.build | 2 +- meson.build | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/api/meson.build b/docs/api/meson.build index 6dc4adc17b..aea7e5a9a6 100644 --- a/docs/api/meson.build +++ b/docs/api/meson.build @@ -1,6 +1,8 @@ # SPDX-License-Identifier: LGPL-2.1-or-later if enable_introspection + xsltproc = find_program('xsltproc') + settings = 'settings-spec' output = settings + '.xml' diff --git a/man/meson.build b/man/meson.build index 56f52bb4b3..502c36b08e 100644 --- a/man/meson.build +++ b/man/meson.build @@ -7,7 +7,7 @@ common_ent_file = configure_file( ) xsltproc_options = [ - xsltproc, + find_program('xsltproc'), '--output', '@OUTPUT@', '--path', meson.current_build_dir(), '--xinclude', diff --git a/meson.build b/meson.build index 1ee1fe35f9..078a13013c 100644 --- a/meson.build +++ b/meson.build @@ -89,7 +89,6 @@ po_dir = source_root / 'po' top_inc = include_directories('.') perl = find_program('perl') -xsltproc = find_program('xsltproc') check_exports = find_program(join_paths(source_root, 'tools', 'check-exports.sh')) From ee078be7457d0180f1e3a1650625f7461e7c06e8 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 20 Nov 2024 02:24:50 -0500 Subject: [PATCH 2/5] build: remove outdated, commented-out configure.ac snippet This was likely added during the port to meson. It's just a multiline string, so it has no effect in meson, and it appears to be entirely for things which are already implemented in meson, so there's no real point in keeping it any longer. --- meson.build | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/meson.build b/meson.build index 078a13013c..05fa16811a 100644 --- a/meson.build +++ b/meson.build @@ -963,38 +963,6 @@ data_conf.set('nmstatedir', nm_pkgstatedir) data_conf.set('sbindir', nm_sbindir) data_conf.set('sysconfdir', nm_sysconfdir) -# check if we can build setting property documentation -''' -build_docs=no -if test -n "$INTROSPECTION_MAKEFILE"; then - # If g-i is installed we know we have python, but we might not have pygobject - if ! "$PYTHON" -c 'from gi.repository import GObject' >& /dev/null; then - AC_MSG_ERROR(["--enable-introspection aims to build the settings documentation. This requires GObject introspection for python (pygobject)]) - fi - - AC_PATH_PROG(PERL, perl) - if test -z "$PERL"; then - AC_MSG_ERROR([--enable-introspection requires perl]) - fi - AC_PATH_PROG(XSLTPROC, xsltproc) - if test -z "$XSLTPROC"; then - AC_MSG_ERROR([--enable-introspection requires xsltproc]) - fi - - have_introspection=yes - if test "$enable_gtk_doc" = "yes"; then - build_docs=yes - fi -else - if test "$enable_gtk_doc" = "yes"; then - # large parts of the documentation require introspection/pygobject to extract - # the documentation out of the source files. You cannot enable gtk-doc without alone. - AC_MSG_ERROR(["--with-gtk-doc requires --enable-introspection"]) - fi - have_introspection=no -fi -''' - content_files = [] subdir('introspection') From f656675b57e26763f4afa1c4549d56ba75cbc049 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Mon, 18 Nov 2024 16:35:37 -0500 Subject: [PATCH 3/5] build: install pre-disted manpages if available When building from a release tarball of NetworkManager, `meson.add_dist_script()` has copied various prebuilt manpages into the tarball and building them again is not really necessary. We can just install those directly. This means that *all* manpages could be installed even without introspection, even though some of them can only be *built* when introspection is enabled. It also means that manpages can be installed even when xsltproc is not available at build time. --- man/meson.build | 67 ++++++++++++++++++++++++++++++++++--------------- meson.build | 3 ++- 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/man/meson.build b/man/meson.build index 502c36b08e..5a8e520429 100644 --- a/man/meson.build +++ b/man/meson.build @@ -1,5 +1,52 @@ # SPDX-License-Identifier: LGPL-2.1-or-later +mans = [ + ['NetworkManager', '8'], + ['NetworkManager-dispatcher', '8'], + ['NetworkManager-wait-online.service', '8'], + ['NetworkManager.conf', '5'], + ['nm-online', '1'], + ['nmcli-examples', '7'], + ['nmcli', '1'], + ['nmtui', '1'], + ['nm-initrd-generator', '8'], +] + +if enable_ovs + mans += [['nm-openvswitch', '7']] +endif + +if enable_nm_cloud_setup + mans += [['nm-cloud-setup', '8']] +endif + +introspection_mans = [ + ['nm-settings-keyfile', '5'], + ['nm-settings-dbus', '5'], + ['nm-settings-nmcli', '5'], +] + +if enable_ifcfg_rh + introspection_mans += [['nm-settings-ifcfg-rh', '5']] +endif + +built_mans = [] +foreach man: mans + introspection_mans + name = man[0] + '.' + man[1] + if not fs.exists(name) + built_mans = [] + break + endif + + built_mans += name +endforeach + +if built_mans.length() > 0 + install_man(built_mans) + subdir_done() +endif + + common_ent_file = configure_file( input: 'common.ent.in', output: '@BASENAME@', @@ -24,26 +71,6 @@ docbook_xls = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbo mans_xmls = [] -mans = [ - ['NetworkManager', '8'], - ['NetworkManager-dispatcher', '8'], - ['NetworkManager-wait-online.service', '8'], - ['NetworkManager.conf', '5'], - ['nm-online', '1'], - ['nmcli-examples', '7'], - ['nmcli', '1'], - ['nmtui', '1'], - ['nm-initrd-generator', '8'], -] - -if enable_ovs - mans += [['nm-openvswitch', '7']] -endif - -if enable_nm_cloud_setup - mans += [['nm-cloud-setup', '8']] -endif - foreach man: mans input = man[0] + '.xml' content_files += join_paths(meson.current_source_dir(), input) diff --git a/meson.build b/meson.build index 05fa16811a..c03d98c15b 100644 --- a/meson.build +++ b/meson.build @@ -12,7 +12,7 @@ project( 'c_std=gnu11', 'warning_level=2' # value "2" will add "-Wall" and "-Wextra" to the compiler flags ], - meson_version: '>= 0.51.0', + meson_version: '>= 0.53.0', ) nm_name = meson.project_name() @@ -77,6 +77,7 @@ libnm_version = '@0@.@1@.@2@'.format(current - age, age, revision) libnm_pkgincludedir = join_paths(nm_includedir, libnm_name) +fs = import('fs') gnome = import('gnome') i18n = import('i18n') pkg = import('pkgconfig') From a11760ef39629fd5f850b9a495e5b155c2cb120d Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 10 Nov 2024 17:59:55 -0500 Subject: [PATCH 4/5] build: make manpages a mandatory part of the build by default Currently, both man pages and gtk-doc HTML documentation are enabled by the same build option. It is common for users to want to choose whether to build HTML docs, as not everyone cares about HTML developer docs, but manpages are intended directly for end-user consumption and should always be available. At the very least, there should be a separate option to disable them to avoid accidentally disabling them while trying to disable HTML developer docs. Resolves: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1653 --- man/meson.build | 105 +++++++++++++++++++----------------- meson.build | 10 +++- meson_options.txt | 1 + tools/meson-post-install.sh | 5 +- 4 files changed, 68 insertions(+), 53 deletions(-) diff --git a/man/meson.build b/man/meson.build index 5a8e520429..d3310dc1de 100644 --- a/man/meson.build +++ b/man/meson.build @@ -41,54 +41,53 @@ foreach man: mans + introspection_mans built_mans += name endforeach -if built_mans.length() > 0 - install_man(built_mans) - subdir_done() +if enable_introspection or enable_docs + common_ent_file = configure_file( + input: 'common.ent.in', + output: '@BASENAME@', + configuration: data_conf, + ) endif +if enable_introspection and (enable_man or enable_docs) + xsltproc_options = [ + find_program('xsltproc'), + '--output', '@OUTPUT@', + '--path', meson.current_build_dir(), + '--xinclude', + '--nonet', + '--stringparam', 'man.output.quietly', '1', + '--stringparam', 'funcsynopsis.style', 'ansi', + '--stringparam', 'man.th.extra1.suppress', '1', + '--stringparam', 'man.authors.section.enabled', '0', + '--stringparam', 'man.copyright.section.enabled', '0', + '--stringparam', 'man.th.title.max.length', '30', + ] -common_ent_file = configure_file( - input: 'common.ent.in', - output: '@BASENAME@', - configuration: data_conf, -) + docbook_xls = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl' -xsltproc_options = [ - find_program('xsltproc'), - '--output', '@OUTPUT@', - '--path', meson.current_build_dir(), - '--xinclude', - '--nonet', - '--stringparam', 'man.output.quietly', '1', - '--stringparam', 'funcsynopsis.style', 'ansi', - '--stringparam', 'man.th.extra1.suppress', '1', - '--stringparam', 'man.authors.section.enabled', '0', - '--stringparam', 'man.copyright.section.enabled', '0', - '--stringparam', 'man.th.title.max.length', '30', -] + mans_xmls = [] -docbook_xls = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl' + foreach man: mans + input = man[0] + '.xml' + content_files += join_paths(meson.current_source_dir(), input) -mans_xmls = [] + output = '@0@.@1@'.format(man[0], man[1]) -foreach man: mans - input = man[0] + '.xml' - content_files += join_paths(meson.current_source_dir(), input) + # not needed if only html requested + if enable_man + custom_target( + output, + input: input, + output: output, + command: xsltproc_options + [docbook_xls, '@INPUT@'], + depend_files: common_ent_file, + install: true, + install_dir: join_paths(nm_mandir, 'man' + man[1]), + ) + endif + endforeach - output = '@0@.@1@'.format(man[0], man[1]) - - custom_target( - output, - input: input, - output: output, - command: xsltproc_options + [docbook_xls, '@INPUT@'], - depend_files: common_ent_file, - install: true, - install_dir: join_paths(nm_mandir, 'man' + man[1]), - ) -endforeach - -if enable_introspection merge_cmd = files(source_root / 'tools' / 'generate-docs-nm-settings-docs-merge.py') name = 'dbus' @@ -151,13 +150,23 @@ if enable_introspection output = '@0@.@1@'.format(man[0], man[1]) - custom_target( - output, - input: input, - output: output, - command: xsltproc_options + [docbook_xls, '@INPUT@'], - install: true, - install_dir: join_paths(nm_mandir, 'man' + man[1]), - ) + # not needed if only html requested + if enable_man + custom_target( + output, + input: input, + output: output, + command: xsltproc_options + [docbook_xls, '@INPUT@'], + install: true, + install_dir: join_paths(nm_mandir, 'man' + man[1]), + ) + endif endforeach +# not needed if only html requested +elif enable_man + if built_mans.length() > 0 + install_man(built_mans) + else + error('Building manpages requires xsltproc and -Dintrospection=true, and no prebuilt manpages were found. Try building from a release tarball or using -Dman=false.') + endif endif diff --git a/meson.build b/meson.build index c03d98c15b..1e28a72650 100644 --- a/meson.build +++ b/meson.build @@ -816,6 +816,7 @@ if enable_nm_cloud_setup assert(jansson_dep.found(), 'nm-cloud-setup requires jansson library. Use -Dnm_cloud_setup=false to disable it') endif +enable_man = get_option('man') enable_docs = get_option('docs') more_asserts = get_option('more_asserts') @@ -1001,9 +1002,14 @@ if enable_qt != 'false' endif endif +# The man/ directory builds a couple targets needed by the docs build too. +# If we build with docs but no man, then enter the subdir and only build +# some targets. +if enable_docs or enable_man + subdir('man') +endif if enable_docs assert(enable_introspection, '-Ddocs=true requires -Dintrospection=true') - subdir('man') subdir('docs') meson.add_dist_script( 'tools/meson-dist-data.sh', @@ -1054,7 +1060,7 @@ meson.add_install_script( nm_pkgstatedir, nm_mandir, nm_sysconfdir, - enable_docs ? '1' : '0', + enable_man ? '1' : '0', enable_ifcfg_rh ? '1' : '0', enable_nm_cloud_setup ? '1' : '0', install_systemdunitdir ? '1' : '0', diff --git a/meson_options.txt b/meson_options.txt index 18d8bfc44c..55762f65d5 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -67,6 +67,7 @@ option('config_dhcp_default', type: 'combo', choices: ['dhclient', 'dhcpcd', 'in option('introspection', type: 'boolean', value: true, description: 'Enable introspection for this build') option('vapi', type : 'combo', choices : ['auto', 'true', 'false'], description: 'build Vala bindings') option('docs', type: 'boolean', value: false, description: 'use to build documentation') +option('man', type: 'boolean', value: true, description: 'Install manpages') option('tests', type: 'combo', choices: ['yes', 'no', 'root'], value: 'yes', description: 'Build NetworkManager tests') option('firewalld_zone', type: 'boolean', value: true, description: 'Install and use firewalld zone for shared mode') option('more_asserts', type: 'string', value: 'auto', description: 'Enable more assertions for debugging (0 = no, 100 = all, default: auto)') diff --git a/tools/meson-post-install.sh b/tools/meson-post-install.sh index fe85d417ae..2560e3d16d 100755 --- a/tools/meson-post-install.sh +++ b/tools/meson-post-install.sh @@ -7,7 +7,7 @@ nm_pkglibdir="$4" nm_pkgstatedir="$5" nm_mandir="$6" nm_sysconfdir="$7" -enable_docs="$8" +enable_man="$8" enable_ifcfg_rh="$9" enable_nm_cloud_setup="${10}" install_systemdunitdir="${11}" @@ -40,7 +40,7 @@ done mkdir -p "${DESTDIR}${nm_pkgstatedir}" chmod 0700 "${DESTDIR}${nm_pkgstatedir}" -if [ "$enable_docs" = 1 ]; then +if [ "$enable_man" = 1 ]; then for alias in nmtui-connect nmtui-edit nmtui-hostname; do ln -fn "${DESTDIR}${nm_mandir}/man1/nmtui.1" "${DESTDIR}${nm_mandir}/man1/${alias}.1" @@ -58,4 +58,3 @@ if [ "$enable_nm_cloud_setup" = 1 -a "$install_systemdunitdir" = 1 ]; then ln -sfn '../pre-up.d/90-nm-cloud-setup.sh' "${DESTDIR}${nm_pkglibdir}/dispatcher.d/no-wait.d/90-nm-cloud-setup.sh" ln -sfn 'no-wait.d/90-nm-cloud-setup.sh' "${DESTDIR}${nm_pkglibdir}/dispatcher.d/90-nm-cloud-setup.sh" fi - From fe62ce6a4b8edae64b30d1bb54602a0c48c7f8f1 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 19 Feb 2025 16:43:54 -0500 Subject: [PATCH 5/5] ci: avoid building manpages on Fedora It appears that xsltproc is not installed there. It is generally needed for the docs build too, so as a crude CI heuristic, don't build anywhere that docs are disabled. --- contrib/scripts/nm-ci-run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/scripts/nm-ci-run.sh b/contrib/scripts/nm-ci-run.sh index 4881d110d3..ff9aadf898 100755 --- a/contrib/scripts/nm-ci-run.sh +++ b/contrib/scripts/nm-ci-run.sh @@ -167,6 +167,7 @@ meson setup build \ -D libpsl=false \ -D vapi=false \ -D introspection=$_WITH_DOCS \ + -D man=$_WITH_DOCS \ -D qt=false \ -D crypto=$_WITH_CRYPTO \ -D docs=$_WITH_DOCS \