1bb3a541cSmrg# And some files that are a straight install
2bb3a541cSmrginstall_data('README', 'xkb.dtd', 'xfree98',
3bb3a541cSmrg             install_dir: dir_xkb_rules)
4bb3a541cSmrg
5bb3a541cSmrg# the actual rules files are generated from a list of parts in a very
6bb3a541cSmrg# specific order
7bb3a541cSmrgparts = [
8bb3a541cSmrg    '0000-hdr.part',
9bb3a541cSmrg    '0001-lists.part',
10bb3a541cSmrg    '0002-@0@.lists.part',
11bb3a541cSmrg    '0004-@0@.m_k.part',
12bb3a541cSmrg    '0005-l1_k.part',
13bb3a541cSmrg    '0006-l_k.part',
14bb3a541cSmrg    '0007-o_k.part',
15bb3a541cSmrg    '0008-ml_g.part',
16bb3a541cSmrg    '0009-m_g.part',
17bb3a541cSmrg    '0011-mlv_s.part',
18bb3a541cSmrg    '0013-ml_s.part',
19bb3a541cSmrg    '0015-ml1_s.part',
20bb3a541cSmrg    '0018-ml2_s.part',
21bb3a541cSmrg    '0020-ml3_s.part',
22bb3a541cSmrg    '0022-ml4_s.part',
23bb3a541cSmrg    '0026-@0@.m_s.part',
24bb3a541cSmrg    '0027-@0@.ml_s1.part',
25bb3a541cSmrg    '0033-ml_c.part',
26bb3a541cSmrg    '0034-ml1_c.part',
27bb3a541cSmrg    '0035-m_t.part',
28bb3a541cSmrg    '0036-lo_s.part',
29bb3a541cSmrg    '0037-l1o_s.part',
30bb3a541cSmrg    '0038-l2o_s.part',
31bb3a541cSmrg    '0039-l3o_s.part',
32bb3a541cSmrg    '0040-l4o_s.part',
33bb3a541cSmrg    '0042-o_s.part',
34bb3a541cSmrg    '0043-o_c.part',
35bb3a541cSmrg    '0044-o_t.part',
36bb3a541cSmrg]
37bb3a541cSmrg
38bb3a541cSmrg# generated compat parts
39bb3a541cSmrgrules_compat_generated = []
40bb3a541cSmrg
41bb3a541cSmrgif get_option('compat-rules')
42bb3a541cSmrg  # non-generated compat parts
43bb3a541cSmrg  parts += [
44bb3a541cSmrg      'compat/0028-lv_c.part',
45bb3a541cSmrg      'compat/0029-l1v1_c.part',
46bb3a541cSmrg      'compat/0030-l2v2_c.part',
47bb3a541cSmrg      'compat/0031-l3v3_c.part',
48bb3a541cSmrg      'compat/0032-l4v4_c.part',
49bb3a541cSmrg      'compat/0041-o_s.part',
50bb3a541cSmrg  ]
51bb3a541cSmrg
52bb3a541cSmrg  layout_mappings = files('compat/layoutsMapping.lst')
53bb3a541cSmrg  variant_mappings = files('compat/variantsMapping.lst')
54bb3a541cSmrg  map_variants_py = find_program('compat/map-variants.py')
55bb3a541cSmrg
56bb3a541cSmrg  # two sets of files are generated: ml_s.part and mlv_s.part
57bb3a541cSmrg  # each with the level name in the filename
58bb3a541cSmrg  lvl_ml_s = {
59bb3a541cSmrg    '0': '0012-ml_s.part',
60bb3a541cSmrg    '1': '0014-ml1_s.part',
61bb3a541cSmrg    '2': '0017-ml2_s.part',
62bb3a541cSmrg    '3': '0019-ml3_s.part',
63bb3a541cSmrg    '4': '0021-ml4_s.part',
64bb3a541cSmrg  }
65bb3a541cSmrg
66bb3a541cSmrg  lvl_mlv_s = {
67bb3a541cSmrg    '0': '0010-mlv_s.part',
68bb3a541cSmrg    '1': '0016-ml1v1_s.part',
69bb3a541cSmrg    '2': '0023-ml2v2_s.part',
70bb3a541cSmrg    '3': '0024-ml3v3_s.part',
71bb3a541cSmrg    '4': '0025-ml4v4_s.part',
72bb3a541cSmrg  }
73bb3a541cSmrg
74bb3a541cSmrg  foreach lvl: [0, 1, 2, 3, 4]
75bb3a541cSmrg      ml_s_file = lvl_ml_s['@0@'.format(lvl)]
76bb3a541cSmrg      ml_s = custom_target(ml_s_file,
77bb3a541cSmrg                           build_by_default: true,
78bb3a541cSmrg                           command: [
79bb3a541cSmrg                               map_variants_py,
80bb3a541cSmrg                               '--want=mls',
81bb3a541cSmrg                               '--number=@0@'.format(lvl),
82bb3a541cSmrg                               '@OUTPUT@',
83bb3a541cSmrg                               layout_mappings,
84bb3a541cSmrg                               variant_mappings,
85bb3a541cSmrg                           ],
86bb3a541cSmrg                           output: ml_s_file,
87bb3a541cSmrg                           install: false)
88bb3a541cSmrg      rules_compat_generated += [ml_s]
89bb3a541cSmrg
90bb3a541cSmrg      mlv_s_file = lvl_mlv_s['@0@'.format(lvl)]
91bb3a541cSmrg      mlv_s = custom_target(mlv_s_file,
92bb3a541cSmrg                           build_by_default: true,
93bb3a541cSmrg                           command: [
94bb3a541cSmrg                               map_variants_py,
95bb3a541cSmrg                               '--want=mlvs',
96bb3a541cSmrg                               '--number=@0@'.format(lvl),
97bb3a541cSmrg                               '@OUTPUT@',
98bb3a541cSmrg                               variant_mappings,
99bb3a541cSmrg                           ],
100bb3a541cSmrg                           output: mlv_s_file,
101bb3a541cSmrg                           install: false)
102bb3a541cSmrg      rules_compat_generated += [mlv_s]
103bb3a541cSmrg  endforeach
104bb3a541cSmrgendif # compat-rules
105bb3a541cSmrg
106bb3a541cSmrgmerge_py = find_program('merge.py')
107bb3a541cSmrgxml2lst = find_program('xml2lst.pl')
108bb3a541cSmrgforeach ruleset: ['base', 'evdev']
109bb3a541cSmrg    # generate the "evdev" and "base" rules files
110bb3a541cSmrg    #
111bb3a541cSmrg    # First: copy all the parts over to the build directory, replacing
112bb3a541cSmrg    # RULESET with the rulename (evdev or base) and prefix it with the
113bb3a541cSmrg    # ruleset name. So 0000-hdr.part becomes 0000-hdr.part.evdev and
114bb3a541cSmrg    # 0000-hdr.part.base
115bb3a541cSmrg    rules_parts = []
116bb3a541cSmrg    foreach part: parts
117bb3a541cSmrg      infile = part.format(ruleset)
118bb3a541cSmrg      p = configure_file(output: '@PLAINNAME@.@0@'.format(ruleset),
119bb3a541cSmrg                         input: infile,
120bb3a541cSmrg                         copy: true,
121bb3a541cSmrg                         install: false)
122bb3a541cSmrg      rules_parts += p
123bb3a541cSmrg    endforeach
124bb3a541cSmrg
125bb3a541cSmrg    # Second: merge those parts together into the actual rules file
126bb3a541cSmrg    custom_target('rules-@0@'.format(ruleset),
127bb3a541cSmrg                  build_by_default: true,
128bb3a541cSmrg                  command: [
129bb3a541cSmrg                      merge_py,
130bb3a541cSmrg                      rules_parts + rules_compat_generated,
131bb3a541cSmrg                  ],
132bb3a541cSmrg                  depends: rules_compat_generated,
133bb3a541cSmrg                  output: ruleset,
134bb3a541cSmrg                  capture: true,
135bb3a541cSmrg                  install: true,
136bb3a541cSmrg                  install_dir: dir_xkb_rules)
137bb3a541cSmrg
138bb3a541cSmrg    # Third: the xml files, simply copied from the base*.xml files
139bb3a541cSmrg    ruleset_xml = configure_file(output: '@0@.xml'.format(ruleset),
140bb3a541cSmrg                       input: 'base.xml',
141bb3a541cSmrg                       copy: true,
142bb3a541cSmrg                       install: true,
143bb3a541cSmrg                       install_dir: dir_xkb_rules)
144bb3a541cSmrg
145bb3a541cSmrg    # This is used by the man page's meson.build
146bb3a541cSmrg    if ruleset == 'evdev'
147bb3a541cSmrg      evdev_ruleset = ruleset_xml
148bb3a541cSmrg    endif
149bb3a541cSmrg
150bb3a541cSmrg    configure_file(output: '@0@.extras.xml'.format(ruleset),
151bb3a541cSmrg                   input: 'base.extras.xml',
152bb3a541cSmrg                   copy: true,
153bb3a541cSmrg                   install: true,
154bb3a541cSmrg                   install_dir: dir_xkb_rules)
155bb3a541cSmrg
156bb3a541cSmrg    # Fourth: generate the evdev.lst and base.lst files
157bb3a541cSmrg    lst_file = '@0@.lst'.format(ruleset)
158bb3a541cSmrg    custom_target(lst_file,
159bb3a541cSmrg                  build_by_default: true,
160bb3a541cSmrg                  command: [xml2lst, ruleset_xml],
161bb3a541cSmrg                  capture: true,
162bb3a541cSmrg                  output: lst_file,
163bb3a541cSmrg                  install: true,
164bb3a541cSmrg                  install_dir: dir_xkb_rules)
1659ea7388fSmrg
166bb3a541cSmrgendforeach
167bb3a541cSmrg
1689ea7388fSmrgif get_option('xorg-rules-symlinks')
1699ea7388fSmrg	foreach suffix: ['', '.lst', '.xml']
1709ea7388fSmrg		meson.add_install_script('sh', '-c',
1719ea7388fSmrg			'ln -s base@0@ $DESTDIR@1@/xorg@0@'.format(suffix, dir_xkb_rules))
1729ea7388fSmrg	endforeach
1739ea7388fSmrgendif
174bb3a541cSmrg# Copy the DTD to the build directory, the man page generation expects it in
175bb3a541cSmrg# the same directory as the input XML file.
176bb3a541cSmrgconfigure_file(output: 'xkb.dtd',
177bb3a541cSmrg               input: 'xkb.dtd',
178bb3a541cSmrg               copy: true,
179bb3a541cSmrg               install: false)
180