aboutsummaryrefslogtreecommitdiff
path: root/doc/meson.build
blob: 26e5d6c79ca07349e813e56964fa5513bea123a6 (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
scdoc = find_program('scdoc', required: get_option('manpage'), disabler: true)
if scdoc.found()

sh = find_program('sh', required: true, native: true, disabler: true)

man_files = ['man/smolbote.1.scd', 'man/smolbote.5.scd']

foreach input : man_files
  topic = input.split('/')[-1].split('.')[-3]
  section = input.split('.')[-2]
  output = '@0@.@1@'.format(topic, section)

  message('creating manpage target ' + output)
  custom_target(output,
    build_by_default: true,

    input: input,
    output: output,

    # scdoc takes input from stdin, and prints its output to stdout
    # meson uses 'capture' to store stdout to output, but there is no stdin toggle
    #command: [scdoc],
    #capture: true,

    # workaround using sh
    command: [sh, '-c', '@0@ < @INPUT0@ > @OUTPUT0@'.format(scdoc.path())],

    install: true,
    install_dir: '@0@/man@1@'.format(get_option('mandir'), section)
  )
endforeach

endif # manpage