]> granicus.if.org Git - p11-kit/commitdiff
meson: Build and install man pages
authorJan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Tue, 10 Sep 2019 18:08:25 +0000 (18:08 +0000)
committerDaiki Ueno <ueno@gnu.org>
Wed, 11 Sep 2019 08:57:10 +0000 (10:57 +0200)
doc/manual/meson.build
meson.build
meson_options.txt

index 0c83699a3be50f313c2cafd06921be903be5573c..5a249cfa128c5f89a5cd57ec1fd8294dba0154c8 100644 (file)
-ignore_headers = [
-  'private.h',
-  'pkcs11.h',
-  'conf.h',
-  'debug.h',
-  'dict.h',
-  'filter.h',
-  'log.h',
-  'mock.h',
-  'modules.h',
-  'pkcs11.h',
-  'pkcs11i.h',
-  'pkcs11x.h',
-  'private.h',
-  'client.h',
-  'proxy.h',
-  'rpc.h',
-  'rpc-message.h',
-  'util.h',
-  'virtual.h',
-  'virtual-fixed.h',
-  'array.h',
-  'compat.h'
-]
+if get_option('gtk_doc')
+  ignore_headers = [
+    'private.h',
+    'pkcs11.h',
+    'conf.h',
+    'debug.h',
+    'dict.h',
+    'filter.h',
+    'log.h',
+    'mock.h',
+    'modules.h',
+    'pkcs11.h',
+    'pkcs11i.h',
+    'pkcs11x.h',
+    'private.h',
+    'client.h',
+    'proxy.h',
+    'rpc.h',
+    'rpc-message.h',
+    'util.h',
+    'virtual.h',
+    'virtual-fixed.h',
+    'array.h',
+    'compat.h'
+  ]
 
-content_files = [
-  'p11-kit-config.xml',
-  'p11-kit-sharing.xml',
-  'p11-kit-devel.xml',
-  'p11-kit-proxy.xml',
-  'p11-kit-trust.xml',
-  'p11-kit-remoting.xml',
-  'p11-kit.xml',
-  'pkcs11.conf.xml',
-  'trust.xml',
-  'annotation-glossary.xml'
-]
+  content_files = [
+    'p11-kit-config.xml',
+    'p11-kit-sharing.xml',
+    'p11-kit-devel.xml',
+    'p11-kit-proxy.xml',
+    'p11-kit-trust.xml',
+    'p11-kit-remoting.xml',
+    'p11-kit.xml',
+    'pkcs11.conf.xml',
+    'trust.xml',
+    'annotation-glossary.xml'
+  ]
 
-configure_file(
-  input: 'version.xml.in',
-  output: '@BASENAME@',
-  configuration: {'VERSION': meson.project_version()})
+  configure_file(
+    input: 'version.xml.in',
+    output: '@BASENAME@',
+    configuration: {'VERSION': meson.project_version()})
 
-configure_file(
-  input: 'userdir.xml.in',
-  output: '@BASENAME@',
-  configuration: {'p11_user_config': p11_user_config})
+  configure_file(
+    input: 'userdir.xml.in',
+    output: '@BASENAME@',
+    configuration: {'p11_user_config': p11_user_config})
 
-configure_file(
-  input: 'sysdir.xml.in',
-  output: '@BASENAME@',
-  configuration: {'p11_system_config': p11_system_config})
+  configure_file(
+    input: 'sysdir.xml.in',
+    output: '@BASENAME@',
+    configuration: {'p11_system_config': p11_system_config})
 
-glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix')
-fixxref_args = [
-  '--html-dir=' + (prefix / gnome.gtkdoc_html_dir(meson.project_name())),
-  '--extra-dir=' + (glib_prefix / gnome.gtkdoc_html_dir('glib')),
-]
+  glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix')
+  fixxref_args = [
+    '--html-dir=' + (prefix / gnome.gtkdoc_html_dir(meson.project_name())),
+    '--extra-dir=' + (glib_prefix / gnome.gtkdoc_html_dir('glib')),
+  ]
 
-gnome.gtkdoc('p11-kit',
-             main_xml: 'p11-kit-docs.xml',
-             namespace: 'p11_kit',
-             src_dir: 'p11-kit',
-             dependencies: libffi_deps + dlopen_deps,
-             scan_args: [
-               '--ignore-headers=' + ' '.join(ignore_headers),
-               '--rebuild-types',
-               '--deprecated-guards="P11_KIT_DISABLE_DEPRECATED"'
-             ],
-             scanobjs_args: [
-               '--version'
-             ],
-             content_files: content_files,
-             fixxref_args: fixxref_args,
-             install: true)
+  gnome.gtkdoc('p11-kit',
+              main_xml: 'p11-kit-docs.xml',
+              namespace: 'p11_kit',
+              src_dir: 'p11-kit',
+              dependencies: libffi_deps + dlopen_deps,
+              scan_args: [
+                '--ignore-headers=' + ' '.join(ignore_headers),
+                '--rebuild-types',
+                '--deprecated-guards="P11_KIT_DISABLE_DEPRECATED"'
+              ],
+              scanobjs_args: [
+                '--version'
+              ],
+              content_files: content_files,
+              fixxref_args: fixxref_args,
+              install: true)
+endif
+
+if get_option('man')
+  xsltproc = find_program('xsltproc')
+  xsltproc_xsl = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
+  if run_command([xsltproc, '--nonet', xsltproc_xsl]).returncode() != 0
+    error('Docbook stylesheet for manpages is missing')
+  endif
+
+  xsltproc_flags = [
+    '--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',
+    '--path', meson.current_build_dir(),
+  ]
+
+  man_pages = {
+    '1': ['trust'],
+    '5': ['pkcs11.conf'],
+    '8': ['p11-kit'],
+  }
+
+  foreach section, pages: man_pages
+    foreach page: pages
+      man_src = '@0@.xml'.format(page)
+      man_dst = '@0@.@1@'.format(page, section)
+      man_section = 'man@0@'.format(section)
+      custom_target(man_dst,
+                    command: [
+                      xsltproc,
+                      xsltproc_flags,
+                      '-o', '@OUTPUT@',
+                      xsltproc_xsl,
+                      '@INPUT@',
+                    ],
+                    input: man_src,
+                    output: man_dst,
+                    install: true,
+                    install_dir: join_paths(mandir, man_section),
+                    build_be_default: true)
+    endforeach
+  endforeach
+endif
index 6bd70578812267efeda0e3a2b128210da1bd7320..8d2297198aa36eee914f3f8a5ec4411c45293d99 100644 (file)
@@ -56,6 +56,7 @@ bindir = get_option('bindir')
 libdir = get_option('libdir')
 libexecdir = get_option('libexecdir')
 sysconfdir = get_option('sysconfdir')
+mandir = get_option('mandir')
 pkgdatadir = datadir / meson.project_name()
 privatedir = libexecdir / meson.project_name()
 
@@ -358,7 +359,5 @@ subdir('p11-kit')
 if with_trust_module
   subdir('trust')
 endif
-if get_option('gtk_doc')
-  subdir('doc/manual')
-endif
+subdir('doc/manual')
 subdir('po')
index deda646abf34dbe6ffb5e4c811a36496a807db4b..bc7966599d6934c3d6e3baea3a3f5c5b3fc85b70 100644 (file)
@@ -45,3 +45,7 @@ option('systemd', type : 'feature',
 option('gtk_doc', type : 'boolean',
        value : false,
        description : 'Build documentation using gtk-doc')
+
+option('man', type : 'boolean',
+       value : false,
+       description : 'Build manpages using xsltproc')