meson: Detect with-docs and with-man automatically

By default, only build man pages and gtk-doc if the build-deps were
found. To force-enable, pass -Dwith-docs=yes and -Dwith-man=yes.

Also use a foreach loop for man pages instead of listing them all
manually
This commit is contained in:
Nirbheek Chauhan 2017-03-21 16:38:47 +05:30 committed by Matthias Clasen
parent 5549a1d0c3
commit 88e437873a
5 changed files with 42 additions and 131 deletions

View File

@ -1,4 +1,4 @@
if get_option('with-docs')
if get_option('with-docs') != 'no'
subdir('xml')
ignore_headers = [
@ -146,76 +146,16 @@ if get_option('with-docs')
endif
if get_option('with-man')
custom_target('gapplication-man',
input: 'gapplication.xml',
output: 'gapplication.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
custom_target('gio-querymodules-man',
input: 'gio-querymodules.xml',
output: 'gio-querymodules.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
custom_target('glib-compile-schemas-man',
input: 'glib-compile-schemas.xml',
output: 'glib-compile-schemas.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
custom_target('glib-compile-resources-man',
input: 'glib-compile-resources.xml',
output: 'glib-compile-resources.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
custom_target('gsettings-man',
input: 'gsettings.xml',
output: 'gsettings.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
custom_target('gresource-man',
input: 'gresource.xml',
output: 'gresource.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
custom_target('gdbus-man',
input: 'gdbus.xml',
output: 'gdbus.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
custom_target('gio',
input: 'gio.xml',
output: 'gio.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
custom_target('gdbus-codegen-man',
input: 'gdbus-codegen.xml',
output: 'gdbus-codegen.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
if get_option('with-man') != 'no' and xsltproc.found()
manpages = ['gapplication', 'gio-querymodules', 'glib-compile-schemas',
'glib-compile-resources', 'gsettings', 'gresource', 'gdbus',
'gio', 'gdbus-codegen']
foreach page : manpages
custom_target(page + '-man',
input: page + '.xml',
output: page + '.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir)
endforeach
endif

View File

@ -1,4 +1,4 @@
if get_option('with-docs')
if get_option('with-docs') != 'no'
subdir('xml')
ignore_headers = [
@ -90,28 +90,14 @@ if get_option('with-docs')
install: true)
endif
if get_option('with-man')
custom_target('glib-gettextize-man',
input: 'glib-gettextize.xml',
output: 'glib-gettextize.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
custom_target('gtester-man',
input: 'gtester.xml',
output: 'gtester.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
custom_target('gtester-report-man',
input: 'gtester-report.xml',
output: 'gtester-report.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
if get_option('with-man') != 'no' and xsltproc.found()
manpages = ['glib-gettextize', 'gtester', 'gtester-report']
foreach page : manpages
custom_target(page + '-man',
input: page + '.xml',
output: page + '.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir)
endforeach
endif

View File

@ -1,4 +1,4 @@
if get_option('with-docs')
if get_option('with-docs') != 'no'
subdir('xml')
ignore_headers = [
@ -51,28 +51,14 @@ if get_option('with-docs')
)
endif
if get_option('with-man')
custom_target('glib-mkenums-man',
input: 'glib-mkenums.xml',
output: 'glib-mkenums.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
custom_target('glib-genmarshal-man',
input: 'glib-genmarshal.xml',
output: 'glib-genmarshal.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
custom_target('gobject-query-man',
input: 'gobject-query.xml',
output: 'gobject-query.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir,
)
if get_option('with-man') != 'no' and xsltproc.found()
manpages = ['glib-mkenums', 'glib-genmarshal', 'gobject-query']
foreach page : manpages
custom_target(page + '-man',
input: page + '.xml',
output: page + '.1',
command: xsltproc_command,
install: true,
install_dir: man1_dir)
endforeach
endif

View File

@ -1434,12 +1434,11 @@ configure_file(input : 'config.h.meson',
output : 'config.h',
configuration : glib_conf)
if get_option('with-docs') and not meson.version().version_compare('>= 0.37.0')
error('In order to build docs you must have Meson >= 0.37.0')
endif
if get_option('with-man')
xsltproc = find_program('xsltproc')
if get_option('with-man') != 'no'
xsltproc = find_program('xsltproc', required : false)
if not xsltproc.found() and get_option('with-man') == 'yes'
error('man pages enabled and xsltproc not found')
endif
xsltproc_command = [
xsltproc,
'--nonet',

View File

@ -1,5 +1,5 @@
option('with-docs', type : 'boolean', value : false)
option('with-man', type : 'boolean', value : true)
option('with-docs', type : 'combo', choices : ['auto', 'yes', 'no'], value : 'auto')
option('with-man', type : 'combo', choices : ['auto', 'yes', 'no'], value : 'auto')
option('enable-libmount', type : 'combo', choices : ['auto', 'yes', 'no'], value : 'yes')
option('enable-dtrace', type : 'boolean', value : false,
description : 'include tracing support for dtrace')