]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/meson.build
Merge pull request #5164 from Werkov/ordering-for-_netdev-devices
[thirdparty/systemd.git] / man / meson.build
1 # This is lame, I know, but meson has no other include mechanism
2 subdir('rules')
3
4 want_man = get_option('man')
5 want_html = get_option('html')
6 xsltproc = find_program('xsltproc',
7 required : want_man == 'true' or want_html == 'true')
8 want_man = want_man != 'false' and xsltproc.found()
9 want_html = want_html != 'false' and xsltproc.found()
10
11 xsltproc_flags = [
12 '--nonet',
13 '--xinclude',
14 '--stringparam', 'man.output.quietly', '1',
15 '--stringparam', 'funcsynopsis.style', 'ansi',
16 '--stringparam', 'man.authors.section.enabled', '0',
17 '--stringparam', 'man.copyright.section.enabled', '0',
18 '--stringparam', 'systemd.version', '@0@'.format(meson.project_version()),
19 '--path',
20 '@0@:@1@'.format(meson.current_build_dir(), meson.current_source_dir())]
21
22 custom_man_xsl = files('custom-man.xsl')
23 custom_html_xsl = files('custom-html.xsl')
24 xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags
25
26 custom_entities_ent = configure_file(
27 input : 'custom-entities.ent.in',
28 output : 'custom-entities.ent',
29 configuration : conf)
30
31 man_pages = []
32 html_pages = []
33 source_xml_files = []
34 foreach tuple : manpages
35 stem = tuple[0]
36 section = tuple[1]
37 aliases = tuple[2]
38 condition = tuple[3]
39
40 xml = stem + '.xml'
41 html = stem + '.html'
42 man = stem + '.' + section
43
44 manaliases = []
45 htmlaliases = []
46 foreach alias : aliases
47 manaliases += [alias + '.' + section]
48 htmlaliases += [alias + '.html']
49 endforeach
50
51 mandirn = join_paths(get_option('mandir'), 'man' + section)
52
53 if condition == '' or conf.get(condition, 0) == 1
54 p1 = custom_target(
55 man,
56 input : xml,
57 output : [man] + manaliases,
58 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
59 depend_files : custom_entities_ent,
60 install : want_man,
61 install_dir : mandirn)
62 man_pages += [p1]
63
64 p2 = custom_target(
65 html,
66 input : xml,
67 output : [html] + htmlaliases,
68 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
69 depend_files : custom_entities_ent,
70 install : want_html,
71 install_dir : join_paths(docdir, 'html'))
72 html_pages += [p2]
73
74 source_xml_files += files(tuple[0] + '.xml')
75 else
76 message('Skipping @0@.@1@ because @2@ is false'.format(stem, section, condition))
77 endif
78 endforeach
79
80 ############################################################
81
82 have_lxml = run_command(xml_helper_py).returncode() == 0
83 if not have_lxml
84 message('python-lxml not available, not making man page indices')
85 endif
86
87 systemd_directives_xml = custom_target(
88 'systemd.directives.xml',
89 input : source_xml_files,
90 output : 'systemd.directives.xml',
91 command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
92
93 nonindex_xml_files = source_xml_files + [systemd_directives_xml]
94 systemd_index_xml = custom_target(
95 'systemd.index.xml',
96 input : nonindex_xml_files,
97 output : 'systemd.index.xml',
98 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
99
100 foreach tuple : [['systemd.directives', '7', systemd_directives_xml],
101 ['systemd.index', '7', systemd_index_xml]]
102 stem = tuple[0]
103 section = tuple[1]
104 xml = tuple[2]
105
106 html = stem + '.html'
107 man = stem + '.' + section
108
109 mandirn = join_paths(get_option('mandir'), 'man' + section)
110
111 p1 = custom_target(
112 man,
113 input : xml,
114 output : man,
115 command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
116 install : want_man and have_lxml,
117 install_dir : mandirn)
118 man_pages += [p1]
119
120 p2 = custom_target(
121 html,
122 input : xml,
123 output : html,
124 command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
125 install : want_html and have_lxml,
126 install_dir : join_paths(docdir, 'html'))
127 html_pages += [p2]
128 endforeach
129
130 # cannot use run_target until https://github.com/mesonbuild/meson/issues/1644 is resolved
131 man = custom_target(
132 'man',
133 output : 'man',
134 depends : man_pages,
135 command : ['echo'])
136
137 html = run_target(
138 'html',
139 depends : html_pages,
140 output : 'html',
141 command : ['echo'])
142
143 run_target(
144 'doc-sync',
145 depends : man_pages + html_pages,
146 command : ['rsync', '-rlv',
147 '--delete-excluded',
148 '--include=man',
149 '--include=*.html',
150 '--exclude=*',
151 '--omit-dir-times',
152 meson.current_build_dir(),
153 get_option('www-target')])
154
155 ############################################################
156
157 if git.found()
158 run_target(
159 'update-man-rules',
160 # slightly strange syntax because of
161 # https://github.com/mesonbuild/meson/issues/1643
162 # and https://github.com/mesonbuild/meson/issues/1512
163 command : ['sh', '-c',
164 'cd @0@ && '.format(meson.build_root()) +
165 'python3 @0@/tools/make-man-rules.py --meson `git ls-files ":/man/*.xml"` >t && '.format(meson.source_root()) +
166 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
167 depend_files : custom_entities_ent)
168 endif