summaryrefslogtreecommitdiffstats
path: root/man/meson.build
blob: 501309363756ab3378dac1d802ea0e0262791672 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
fs = import('fs')

adocfiles_common = [
    'common_options.adoc',
    'common_footer.adoc',
]

manpage_tuples_to_build = []
manpage_tuples_all = []

# tuple with adoc file and generated aliases
cryptsetup_manpages = [
    [
        'cryptsetup.8.adoc',
        [],
    ],
    [
        'cryptsetup-open.8.adoc',
        [
            'cryptsetup-create.8',
            'cryptsetup-plainOpen.8',
            'cryptsetup-luksOpen.8',
            'cryptsetup-loopaesOpen.8',
            'cryptsetup-tcryptOpen.8',
            'cryptsetup-bitlkOpen.8',
        ],
    ],
    [
        'cryptsetup-close.8.adoc',
        [],
    ],
    [
        'cryptsetup-reencrypt.8.adoc',
        [],
    ],
    [
        'cryptsetup-status.8.adoc',
        [],
    ],
    [
        'cryptsetup-resize.8.adoc',
        [],
    ],
    [
        'cryptsetup-refresh.8.adoc',
        [],
    ],
    [
        'cryptsetup-luksFormat.8.adoc',
        [],
    ],
    [
        'cryptsetup-luksSuspend.8.adoc',
        [],
    ],
    [
        'cryptsetup-luksResume.8.adoc',
        [],
    ],
    [
        'cryptsetup-luksAddKey.8.adoc',
        [],
    ],
    [
        'cryptsetup-luksRemoveKey.8.adoc',
        [],
    ],
    [
        'cryptsetup-luksConvertKey.8.adoc',
        [],
    ],
    [
        'cryptsetup-luksKillSlot.8.adoc',
        [],
    ],
    [
        'cryptsetup-luksChangeKey.8.adoc',
        [],
    ],
    [
        'cryptsetup-erase.8.adoc',
        [
            'cryptsetup-luksErase.8',
        ],
    ],
    [
        'cryptsetup-luksUUID.8.adoc',
        [],
    ],
    [
        'cryptsetup-isLuks.8.adoc',
        [],
    ],
    [
        'cryptsetup-luksDump.8.adoc',
        [],
    ],
    [
        'cryptsetup-luksHeaderBackup.8.adoc',
        [],
    ],
    [
        'cryptsetup-luksHeaderRestore.8.adoc',
        [],
    ],
    [
        'cryptsetup-token.8.adoc',
        [],
    ],
    [
        'cryptsetup-convert.8.adoc',
        [],
    ],
    [
        'cryptsetup-config.8.adoc',
        [],
    ],
    [
        'cryptsetup-tcryptDump.8.adoc',
        [],
    ],
    [
        'cryptsetup-bitlkDump.8.adoc',
        [],
    ],
    [
        'cryptsetup-fvault2Dump.8.adoc',
        [],
    ],
    [
        'cryptsetup-repair.8.adoc',
        [],
    ],
    [
        'cryptsetup-benchmark.8.adoc',
        [],
    ],
]

veritysetup_manpages = [
    [
        'veritysetup.8.adoc',
        [],
    ],
]
integritysetup_manpages = [
    [
        'integritysetup.8.adoc',
        [],
    ],
]
sshplugin_manpages = [
    [
        'cryptsetup-ssh.8.adoc',
        [],
    ],
]

if get_option('cryptsetup')
    manpage_tuples_to_build += cryptsetup_manpages
endif
manpage_tuples_all += cryptsetup_manpages
if get_option('veritysetup')
    manpage_tuples_to_build += veritysetup_manpages
endif
manpage_tuples_all += veritysetup_manpages
if get_option('integritysetup')
    manpage_tuples_to_build += integritysetup_manpages
endif
manpage_tuples_all += integritysetup_manpages
if get_option('ssh-token')
    manpage_tuples_to_build += sshplugin_manpages
endif
manpage_tuples_all += sshplugin_manpages

adocfiles_all = []
foreach tuple : manpage_tuples_all
    adocfiles_all += tuple[0]
endforeach

prebuilt_manpages_exist = true
foreach manpage_tuple : manpage_tuples_to_build
    adocfile = manpage_tuple[0]
    aliases = manpage_tuple[1]
    manfile = fs.replace_suffix(adocfile, '')

    prebuilt_manpages_exist = prebuilt_manpages_exist and fs.exists(manfile)

    foreach alias : aliases
        prebuilt_manpages_exist = prebuilt_manpages_exist and fs.exists(alias)
    endforeach
endforeach

built_manpages = []

if use_asciidoc
    meson.add_dist_script(find_program('meson_dist_convert.sh'),
        asciidoc, meson.project_version(), adocfiles_all)

    foreach manpage_tuple : manpage_tuples_to_build
        adocfile = manpage_tuple[0]
        aliases = manpage_tuple[1]

        mandir = join_paths(get_option('prefix'), get_option('mandir'), 'man8')
        manfile = fs.replace_suffix(adocfile, '')

        built_manpages += custom_target(manfile,
            command: [
                asciidoc,
                '-b', 'manpage',
                '--failure-level', 'ERROR',
                '-a', 'release-version=@0@'.format(
                    meson.project_version(),
                ),
                '-o', '@BASENAME@',
                '@INPUT@',
                '--destination-dir=@0@'.format(
                    meson.current_build_dir(),
                ),
                '--base-dir=@SOURCE_ROOT@',
            ],
            input: adocfile,
            depend_files: adocfiles_common,
            install: true,
            install_dir: mandir,
            output: [
                manfile,
            ] + aliases,
        )
    endforeach
else
    # use_asciidoc == false
    if prebuilt_manpages_exist
        message('Using prebuilt manpages.')
        foreach manpage_tuple : manpage_tuples_to_build
            adocfile = manpage_tuple[0]
            aliases = manpage_tuple[1]
            manfile = fs.replace_suffix(adocfile, '')

            install_man(manfile)
            foreach alias : aliases
                install_man(alias)
            endforeach
        endforeach
    else
        warning('Neither asciidoctor nor prebuilt manual pages found. Skipping manpage installation')
    endif
endif

man = custom_target(
    'man',
    output: 'man',
    depends: built_manpages,
    command: [
        nop_command,
    ])