]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/meson.build
more portable python shebangs (#5816)
[thirdparty/systemd.git] / man / meson.build
CommitLineData
5c23128d
ZJS
1# This is lame, I know, but meson has no other include mechanism
2subdir('rules')
3
527d43d7
ZJS
4want_man = get_option('man')
5want_html = get_option('html')
6xsltproc = find_program('xsltproc',
4390be30
ZJS
7 required : want_man == 'true' or want_html == 'true')
8want_man = want_man != 'false' and xsltproc.found()
9want_html = want_html != 'false' and xsltproc.found()
527d43d7 10
5c23128d 11xsltproc_flags = [
37efbbd8
ZJS
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())]
5c23128d
ZJS
21
22custom_man_xsl = files('custom-man.xsl')
527d43d7 23custom_html_xsl = files('custom-html.xsl')
37efbbd8 24xslt_cmd = [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags
04e3eb46
ZJS
25
26custom_entities_ent = configure_file(
37efbbd8
ZJS
27 input : 'custom-entities.ent.in',
28 output : 'custom-entities.ent',
29 configuration : conf)
5c23128d 30
527d43d7
ZJS
31man_pages = []
32html_pages = []
33source_xml_files = []
5c23128d 34foreach tuple : manpages
37efbbd8
ZJS
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
5c23128d
ZJS
78endforeach
79
80############################################################
81
b184e8fe
ZJS
82have_lxml = run_command(xml_helper_py).returncode() == 0
83if not have_lxml
37efbbd8 84 message('python-lxml not available, not making man page indices')
b184e8fe
ZJS
85endif
86
5c23128d 87systemd_directives_xml = custom_target(
37efbbd8
ZJS
88 'systemd.directives.xml',
89 input : source_xml_files,
90 output : 'systemd.directives.xml',
91 command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
5c23128d
ZJS
92
93nonindex_xml_files = source_xml_files + [systemd_directives_xml]
94systemd_index_xml = custom_target(
37efbbd8
ZJS
95 'systemd.index.xml',
96 input : nonindex_xml_files,
97 output : 'systemd.index.xml',
98 command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
5c23128d
ZJS
99
100foreach tuple : [['systemd.directives', '7', systemd_directives_xml],
101 ['systemd.index', '7', systemd_index_xml]]
37efbbd8
ZJS
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]
5c23128d 128endforeach
527d43d7 129
9c84bb78
ZJS
130# cannot use run_target until https://github.com/mesonbuild/meson/issues/1644 is resolved
131man = custom_target(
a923e085 132 'man',
9c84bb78 133 output : 'man',
a923e085
ZJS
134 depends : man_pages,
135 command : ['echo'])
136
137html = run_target(
138 'html',
139 depends : html_pages,
140 output : 'html',
141 command : ['echo'])
142
143run_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')])
18af8932
ZJS
154
155############################################################
156
157if 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)
168endif