summaryrefslogtreecommitdiff
path: root/doc/meson.build
blob: 7c9631cb6297739b9ef2f163ffbced885de5904f (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
manpages = [
  { 'name': 'alpm-hooks.5' },
  { 'name': 'pacman.8' },
  { 'name': 'makepkg.8' },
  { 'name': 'makepkg-template.1' },
  { 'name': 'repo-add.8' },
  { 'name': 'vercmp.8' },
  { 'name': 'pkgdelta.8' },
  { 'name': 'pacman-key.8' },
  { 'name': 'PKGBUILD.5', 'extra_depends' : [ 'PKGBUILD-example.txt' ] },
  { 'name': 'makepkg.conf.5' },
  { 'name': 'pacman.conf.5' },
  { 'name': 'libalpm.3' },
  { 'name': 'BUILDINFO.5' },
]

asciidoc_conf = join_paths(meson.current_source_dir(), 'asciidoc.conf')

asciidoc_opts = [
 '-f', asciidoc_conf,
 '-a', 'pacman_version="@0@"'.format(PACKAGE_VERSION),
 '-a', 'pacman_date=@0@'.format(run_command('date', '+%Y-%m-%d').stdout().strip()),
 '-a', 'pkgdatadir=@0@'.format(PKGDATADIR),
 '-a', 'localstatedir=@0@'.format(LOCALSTATEDIR),
 '-a', 'sysconfdir=@0@'.format(SYSCONFDIR),
 '-a', 'datarootdir=@0@'.format(DATAROOTDIR),
]

html_targets = []
html_files = []

foreach page : manpages
  manpage = page['name']
  htmlpage = '@0@.html'.format(manpage)
  input = '@0@.asciidoc'.format(manpage)

  section = page['name'].split('.')[-1]

  mandirn = join_paths(MANDIR, 'man' + section)

  custom_target(
    manpage,
    command : [
      A2X,
      '--no-xmllint',
      '-d', 'manpage',
      '-f', 'manpage',
      '--xsltproc-opts', '-param man.endnotes.list.enabled 0 -param man.endnotes.are.numbered 0',
      '-D', '@OUTDIR@',
      '--asciidoc-opts', ' '.join(asciidoc_opts),
      '@INPUT@',
    ],
    input : input,
    output : [manpage],
    depend_files : [
      asciidoc_conf,
    ] + page.get('extra_depends', []),
    install : true,
    install_dir : mandirn,
  )

  html = custom_target(
    htmlpage,
    command : [
      ASCIIDOC,
    ] + asciidoc_opts + [
      '-a', 'linkcss',
      '-a', 'toc',
      '-a', 'icons',
      '-a', 'max-width=960px',
      '-a', 'stylesheet=asciidoc-override.css',
      '-o', '@OUTPUT@',
      '@INPUT@',
    ],
    input : input,
    output : [htmlpage],
    depend_files : [
      asciidoc_conf,
      'asciidoc-override.css',
    ] + page.get('extra_depends', []),
    build_by_default : false,
    install : false,
  )
  html_targets += [html]
  html_files += [htmlpage]
endforeach

run_target('html',
           command : ['/bin/true'],
           depends : html_targets)

custom_target(
  'website.tar.gz',
  command : [
    'bsdtar', 'czf', '@OUTPUT@',
    '-C', meson.current_build_dir(),
  ] + html_files + [
    '-C', meson.current_source_dir(),
    'submitting-patches.html',
    'translation-help.html',
    'HACKING.html',
    'index.html',
    'asciidoc-override.css',
    '-C', '/etc/asciidoc/stylesheets/',
    'asciidoc.css',
    '-C', '/etc/asciidoc/javascripts/',
    'asciidoc.js',
    '-C', '/etc/asciidoc/',
    'images',
  ],
  output : ['website.tar.gz'],
  build_by_default : false,
  depends : html_targets,
)

meson.add_install_script(MESON_MAKE_SYMLINK,
                         'repo-add.8',
                         join_paths(MANDIR, 'man8/repo-remove.8'))

doxygen = find_program('doxygen', required : get_option('doxygen'))
if doxygen.found() and not get_option('doxygen').disabled()
  doxyconf = configuration_data()
  doxyconf.set('OUTPUT_DIRECTORY', meson.current_build_dir())
  doxyfile = configure_file(
    input : 'Doxyfile.in',
    output : 'Doxyfile',
    configuration : doxyconf,
    install : false)

  custom_target(
    'doxygen',
    input : doxyfile,
    output : ['man3'],
    command : [doxygen, doxyfile],
    build_by_default : true,
    install : true,
    install_dir : MANDIR)
endif