summaryrefslogtreecommitdiff
path: root/meson.build
blob: f5cddf3d0bb4bb7bacc98db2221fdcb0a1ce3e5f (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
# Copyright © 2019 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

project(
  'X Test Suite',
  ['c'],
  version : '0.99.1',
  license : ['MIT', 'Artistic'],
  meson_version : '>=0.49.1',  # Arbitrary
  default_options : ['buildtype=debugoptimized', 'warning_level=0'],
)


# TODO: Does anyone even compile this code with these?

# The C and ObjC compilers take the same set of arguments
# cc = meson.get_compiler('c')
# add_project_arguments(
#   cc.get_supported_arguments(
#     [
#       '-Werror=unknown-warning-option',
#       '-Werror=unused-command-line-argument',
#       '-Wpointer-arith',
#       '-Wmissing-declarations',
#       '-Wformat2',
#       '-Wstrict-prototypes',
#       '-Wmissing-prototypes',
#       '-Wnested-externs',
#       '-Wbad-function-cast',
#       '-Wold-style-definition',
#       '-Wdeclaration-after-statement',
#       '-Wunused',
#       '-Wuninitialized',
#       '-Wshadow',
#       '-Wmissing-noreturn',
#       '-Wmissing-format-attribute',
#       '-Wredundant-decls',
#       '-Wlogical-op',
#       '-Werror=implicit',
#       '-Werror=nonnull',
#       '-Werror=init-self',
#       '-Werror=main',
#       '-Werror=missing-braces',
#       '-Werror=sequence-point',
#       '-Werror=return-type',
#       '-Werror=trigraphs',
#       '-Werror=array-bounds',
#       '-Werror=write-strings',
#       '-Werror=address',
#       '-Werror=int-to-pointer-cast',
#       '-Werror=attributes',
#     ],
#   ),
#   language : ['c'],
# )

# This code is such a pile of shit that we just don't want any warnings, and
# setting warn_level=0 at the meson level is not enough, we need to just set -w
# or /w to make it shut up.
cc = meson.get_compiler('c')
add_project_arguments(cc.first_supported_argument(['-w', '/w']), language: ['c'])

conf = configuration_data()
conf.set_quoted('DEFAULT_TET_ROOT', get_option('datadir'))
conf.set_quoted('DEFAULT_TET_EXEC_ROOT', get_option('libexecdir'))
conf.set('TET_LITE', 1)
conf.set('XT_X_RELEASE', 6)
conf.set('XTESTEXTENSION', 1)
conf.set('INPUTEXTENSION', 1)

dep_x11 = dependency('x11')
dep_xext = dependency('xext')
dep_xi = dependency('xi')
dep_xtst = dependency('xtst')
dep_xau = dependency('xau')
dep_xtrans = dependency('xtrans')
dep_xmu = dependency('xmu')
dep_xaw7 = dependency('xaw7')

deps_xts = [dep_x11, dep_xext, dep_xi, dep_xtst, dep_xau]
deps_xt = [dep_x11, dep_xext, dep_xi, dep_xtst, dep_xtrans]
deps_xaw = [dep_x11, dep_xext, dep_xi, dep_xtst, dep_xmu, dep_xaw7]

# Get just the compiler/preprocessor args and includes for each dependency
# they well be written to a variable called deps_<foo>_args
foreach t : ['xts', 'xt', 'xaw']
  _f = []
  foreach d : get_variable('deps_' + t)
    _f += d.partial_dependency(compile_args : true, includes : true)
  endforeach
  set_variable('deps_@0@_args'.format(t), _f)
endforeach

_trans = []
foreach t : get_option('transport-order')
  _trans += '@0@_TRANS'.format(t.to_upper())
endforeach
conf.set('LOCAL_TRANSPORT_LIST', ','.join(_trans))
conf.set('UNIXCONN', 1)
conf.set('TCPCONN', 1)

# Needed for generating fonts
prog_bdftopcf = find_program('bdftopcf')
prog_mkfontdir = find_program('mkfontdir')

# Needed for generating tetexec.cfg with xts-config
prog_sed = find_program('sed')
prog_perl = find_program('perl')
prog_xset = find_program('xset')
prog_xdpyinfo = find_program('xdpyinfo')
prog_python = import('python').find_installation('python3')

# For generating man pages
prog_asciidoc = find_program('asciidoc', required : get_option('manpages'))
prog_xmlto = find_program('xmlto', required : get_option('manpages'))

# TODO: putting config.h in the root is kinda a bad idea
config_h = configure_file(
  configuration : conf,
  output : 'config.h',
)
add_project_arguments('-DHAVE_CONFIG_H', language : ['c'])

inc_include = include_directories('include', '.') # Add . for config.h

# This could be made to depend on every .m file and then wouldn't need to be
# always stale. However, that would be tedious or involve a script, which
# would need to be always stale...
custom_target(
  'piglit-profile',
  command : [
    prog_python, '@INPUT@', meson.source_root(),
    join_paths(get_option('prefix'), get_option('libexecdir')),
    '@OUTPUT@',
    ],
  input : ['piglit-profile.py'],
  output : ['xts.xml.gz'],
  build_always_stale : true,
  install : true,
  install_dir : get_option('libexecdir'),
)

subdir('src/tet3')
subdir('xts5')

if prog_asciidoc.found() and prog_xmlto.found()
  # XXX: Meson dones't currently support sunos/solaris, so free pass!
  man_suffix = host_machine.system() == 'sunos' ? '5' : '7'

  xts_txt_xml = custom_target(
    'xts.txt.xml',
    command : [
      prog_asciidoc, '-b', 'docbook', '-d', 'manpage', '-o', '@OUTPUT@', '@INPUT@'
    ],
    input : files('README'),
    output : 'xts.txt.xml',
  )

  xts_xml_man = custom_target(
    'XTS.miscmansuffix',
    command : [prog_xmlto, 'man', '-o', '@OUTDIR@', '@INPUT@'],
    input : [xts_txt_xml],
    output : 'XTS.miscmansuffix',
  )

  xts_man = custom_target(
    'XTS.@0@'.format(man_suffix),
    command : [
      'sed', '-e', 's|miscmansuffix|@0@|'.format(man_suffix), '@INPUT@'
    ],
    input : [xts_xml_man],
    output : 'XTS.@0@'.format(man_suffix),
    install : true,
    install_dir : get_option('prefix') / get_option('mandir') / man_suffix,
    capture : true,
  )
endif