blob: 099db897c44f66868ef00080f988fcaf5917eb66 [file] [log] [blame]
Arkadiusz Hilereccae132018-05-15 14:07:50 +03001project('igt-gpu-tools', 'c',
Arkadiusz Hiler4b728a52018-07-18 00:21:44 +03002 version : '1.23',
Daniel Vetter9a7d8502017-09-05 14:36:14 +02003 default_options: [
4 'warning_level=2',
Lucas De Marchi523bc592018-06-06 15:27:39 -07005 'c_std=gnu11',
Daniel Vetter9a7d8502017-09-05 14:36:14 +02006 ],
Daniel Vetter866970a2017-09-05 14:36:24 +02007 license : 'MIT',
Arkadiusz Hilercc48c232019-02-19 12:51:42 +02008 meson_version : '>=0.46.0')
Daniel Vetter9a7d8502017-09-05 14:36:14 +02009
10cc = meson.get_compiler('c')
11
Daniel Vetterc4614fe2017-09-05 14:36:20 +020012cc_args = [
Petri Latvala7fd5da22018-10-29 16:30:54 +020013 '-Wbad-function-cast',
14 '-Wdeclaration-after-statement',
15 '-Wformat=2',
Eric Anholtcae05d92017-09-05 14:36:17 +020016# igt_assert(0) in switch statements triggers a bunch of this.
Daniel Vetterc4614fe2017-09-05 14:36:20 +020017 '-Wimplicit-fallthrough=0',
Petri Latvala7fd5da22018-10-29 16:30:54 +020018 '-Wlogical-op',
19 '-Wmissing-declarations',
20 '-Wmissing-format-attribute',
21 '-Wmissing-noreturn',
22 '-Wmissing-prototypes',
23 '-Wnested-externs',
24 '-Wold-style-definition',
25 '-Wpointer-arith',
26 '-Wredundant-decls',
27 '-Wshadow',
28 '-Wstrict-prototypes',
29 '-Wuninitialized',
30 '-Wunused',
31
32 '-Wno-clobbered',
33 '-Wno-maybe-uninitialized',
34 '-Wno-missing-field-initializers',
35 '-Wno-pointer-arith',
36 '-Wno-sign-compare',
37# Macros asserting on the range of their arguments triggers this.
38 '-Wno-type-limits',
39 '-Wno-unused-parameter',
40 '-Wno-unused-result',
41
42 '-Werror=address',
43 '-Werror=array-bounds',
44 '-Werror=implicit',
45 '-Werror=init-self',
46 '-Werror=int-to-pointer-cast',
47 '-Werror=main',
48 '-Werror=missing-braces',
49 '-Werror=nonnull',
50 '-Werror=pointer-to-int-cast',
51 '-Werror=return-type',
52 '-Werror=sequence-point',
53 '-Werror=trigraphs',
54 '-Werror=write-strings',
Daniel Vetterc4614fe2017-09-05 14:36:20 +020055]
56
57foreach cc_arg : cc_args
58 if cc.has_argument(cc_arg)
59 add_global_arguments(cc_arg, language : 'c')
60 endif
61endforeach
Eric Anholtcae05d92017-09-05 14:36:17 +020062
Petri Latvala0e98bf62018-06-21 14:06:25 +030063_build_overlay = false
64_overlay_required = false
65_build_man = false
66_man_required = false
67_build_audio = false
68_audio_required = false
69_build_chamelium = false
70_chamelium_required = false
71_build_docs = false
72_docs_required = false
73_build_tests = false
74_tests_required = false
Petri Latvala18c1e752018-08-08 14:07:00 +030075_build_runner = false
76_runner_required = false
Petri Latvala0e98bf62018-06-21 14:06:25 +030077
78build_overlay = get_option('build_overlay')
79overlay_backends = get_option('overlay_backends')
80build_man = get_option('build_man')
81with_valgrind = get_option('with_valgrind')
82build_audio = get_option('build_audio')
83build_chamelium = get_option('build_chamelium')
84build_docs = get_option('build_docs')
85build_tests = get_option('build_tests')
86with_libdrm = get_option('with_libdrm')
Daniel Vetter2908e4c2018-10-30 13:22:12 +010087with_libunwind = get_option('with_libunwind')
Petri Latvala18c1e752018-08-08 14:07:00 +030088build_runner = get_option('build_runner')
Petri Latvala0e98bf62018-06-21 14:06:25 +030089
90_build_overlay = build_overlay != 'false'
91_overlay_required = build_overlay == 'true'
92_build_man = build_man != 'false'
93_man_required = build_man == 'true'
94_build_audio = build_audio != 'false'
95_audio_required = build_audio == 'true'
96_build_chamelium = build_chamelium != 'false'
97_chamelium_required = build_chamelium == 'true'
98_build_docs = build_docs != 'false'
99_docs_required = build_docs == 'true'
100_build_tests = build_tests != 'false'
101_tests_required = build_tests == 'true'
Petri Latvala18c1e752018-08-08 14:07:00 +0300102_build_runner = build_runner != 'false'
103_runner_required = build_runner == 'true'
Petri Latvala0e98bf62018-06-21 14:06:25 +0300104
105build_info = []
106
Lucas De Marchi31ea7dd2018-07-24 15:20:23 -0700107inc = include_directories('include/drm-uapi', 'lib', 'lib/stubs/syscalls', '.')
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200108
Daniel Vetter491e8c12017-12-05 11:16:49 +0100109inc_for_gtkdoc = include_directories('lib')
110
Daniel Vetter6e262252017-09-08 17:14:48 +0200111config = configuration_data()
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200112
Petri Latvala0e98bf62018-06-21 14:06:25 +0300113null_dep = dependency('', required : false)
114
115libdrm_info = []
116libdrm_intel = null_dep
117libdrm_nouveau = null_dep
118libdrm_amdgpu = null_dep
119
Arkadiusz Hiler43d7c052018-03-08 13:25:44 +0200120libdrm_version = '>=2.4.82'
121libdrm = dependency('libdrm', version : libdrm_version)
Petri Latvala0e98bf62018-06-21 14:06:25 +0300122if with_libdrm.contains('auto') or with_libdrm.contains('intel')
123 libdrm_intel = dependency('libdrm_intel', version : libdrm_version, required : with_libdrm.contains('intel'))
124 libdrm_info += 'intel'
125endif
126if with_libdrm.contains('auto') or with_libdrm.contains('nouveau')
127 libdrm_nouveau = dependency('libdrm_nouveau', version : libdrm_version, required : with_libdrm.contains('nouveau'))
128 libdrm_info += 'nouveau'
129endif
130if with_libdrm.contains('auto') or with_libdrm.contains('amdgpu')
131 libdrm_amdgpu = dependency('libdrm_amdgpu', version : libdrm_version, required : with_libdrm.contains('amdgpu'))
132 libdrm_info += 'amdgpu'
133endif
134
135build_info += 'With libdrm: ' + ','.join(libdrm_info)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200136
137pciaccess = dependency('pciaccess', version : '>=0.10')
138libkmod = dependency('libkmod')
Arkadiusz Hiler643dc092017-11-24 17:17:48 +0200139libprocps = dependency('libprocps', required : true)
Daniel Vetter2908e4c2018-10-30 13:22:12 +0100140
141libunwind = null_dep
142libunwindinfo = 'No'
143if with_libunwind != 'false'
144 libunwind = dependency('libunwind', required : with_libunwind == 'true')
145 if libunwind.found()
146 libunwindinfo = 'Yes'
147 endif
148endif
149build_info += 'With libunwind: ' + libunwindinfo
150
Maarten Lankhorste39e0992018-08-28 14:04:25 +0200151libdw = dependency('libdw', required : true)
Maxime Ripardddb38282018-10-04 14:39:01 +0200152pixman = dependency('pixman-1', required : true)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200153
Petri Latvala0e98bf62018-06-21 14:06:25 +0300154valgrind = null_dep
155valgrindinfo = 'No'
156if with_valgrind != 'false'
157 valgrind = dependency('valgrind', required : with_valgrind == 'true')
158 if valgrind.found()
159 config.set('HAVE_VALGRIND', 1)
160 valgrindinfo = 'Yes'
161 endif
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200162endif
Petri Latvala0e98bf62018-06-21 14:06:25 +0300163build_info += 'Valgrind annotations: ' + valgrindinfo
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200164
Arkadiusz Hilerf9b6fd62018-02-20 11:00:22 +0200165cairo = dependency('cairo', version : '>1.12.0', required : true)
Antonio Argenzianod75e6762018-02-23 15:14:40 -0800166libudev = dependency('libudev', required : true)
Petri Latvala9bbfbb12018-06-21 14:06:24 +0300167glib = dependency('glib-2.0', required : true)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200168
Petri Latvala0e98bf62018-06-21 14:06:25 +0300169gsl = null_dep
170alsa = null_dep
Petri Latvala0e98bf62018-06-21 14:06:25 +0300171if _build_audio or _build_chamelium
172 gsl = dependency('gsl', required : _audio_required or _chamelium_required)
173endif
174if _build_audio
175 alsa = dependency('alsa', required : _audio_required)
176endif
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200177
Petri Latvala0e98bf62018-06-21 14:06:25 +0300178audioinfo = 'No'
179if _build_audio and alsa.found() and gsl.found()
180 audioinfo = 'Yes'
181else
182 if _audio_required
183 error('Cannot build audio test due to missing dependencies')
184 endif
185 _build_audio = false
186endif
187build_info += 'Build audio test: ' + audioinfo
188
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200189xmlrpc = dependency('xmlrpc', required : false)
190xmlrpc_util = dependency('xmlrpc_util', required : false)
191xmlrpc_client = dependency('xmlrpc_client', required : false)
192
Jani Nikula1ae18b02017-10-24 11:14:14 +0300193xmlrpc_cmd = find_program('xmlrpc-c-config', required : false)
194if not xmlrpc.found() and xmlrpc_cmd.found()
195 libs_cmd = run_command(xmlrpc_cmd, 'client', '--libs')
196 cflags_cmd = run_command(xmlrpc_cmd, 'client', '--cflags')
Arkadiusz Hiler892abc62017-10-17 15:05:41 +0300197
198 if libs_cmd.returncode() == 0 and cflags_cmd.returncode() == 0
199 xmlrpc = declare_dependency(compile_args: cflags_cmd.stdout().strip().split(),
200 link_args : libs_cmd.stdout().strip().split())
201 xmlrpc_util = declare_dependency()
202 xmlrpc_client = declare_dependency()
203 endif
204endif
205
Petri Latvala0e98bf62018-06-21 14:06:25 +0300206chamelium = null_dep
207chameliuminfo = 'No'
Maxime Ripardddb38282018-10-04 14:39:01 +0200208if _build_chamelium and gsl.found() and xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found()
209 chamelium = declare_dependency(dependencies : [ xmlrpc,
Petri Latvala0e98bf62018-06-21 14:06:25 +0300210 xmlrpc_util, xmlrpc_client])
Arkadiusz Hiler892abc62017-10-17 15:05:41 +0300211 config.set('HAVE_CHAMELIUM', 1)
Petri Latvala0e98bf62018-06-21 14:06:25 +0300212 chameliuminfo = 'Yes'
213elif _chamelium_required
214 error('Cannot build chamelium test due to missing dependencies')
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200215endif
Petri Latvala0e98bf62018-06-21 14:06:25 +0300216build_info += 'Build Chamelium test: ' + chameliuminfo
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200217
218pthreads = dependency('threads')
219math = cc.find_library('m')
220realtime = cc.find_library('rt')
221dlsym = cc.find_library('dl')
222zlib = cc.find_library('z')
223
224if cc.has_header('linux/kd.h')
Daniel Vetter6e262252017-09-08 17:14:48 +0200225 config.set('HAVE_LINUX_KD_H', 1)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200226endif
227if cc.has_header('sys/kd.h')
Daniel Vetter6e262252017-09-08 17:14:48 +0200228 config.set('HAVE_SYS_KD_H', 1)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200229endif
230if cc.has_header('libgen.h')
Daniel Vetter6e262252017-09-08 17:14:48 +0200231 config.set('HAVE_LIBGEN_H', 1)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200232endif
233if cc.has_header('sys/io.h')
Daniel Vetter6e262252017-09-08 17:14:48 +0200234 config.set('HAVE_SYS_IO_H', 1)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200235endif
236if cc.has_header('cpuid.h')
237 # FIXME: Do we need the example link test from configure.ac?
Daniel Vetter6e262252017-09-08 17:14:48 +0200238 config.set('HAVE_CPUID_H', 1)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200239endif
240
241if cc.has_member('struct sysinfo', 'totalram',
242 prefix : '#include <sys/sysinfo.h>')
Daniel Vetter6e262252017-09-08 17:14:48 +0200243 config.set('HAVE_STRUCT_SYSINFO_TOTALRAM', 1)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200244endif
245
Lucas De Marchibcb37a92018-07-24 15:20:24 -0700246have = cc.has_function('memfd_create', prefix : '''#include <sys/mman.h>''', args : '-D_GNU_SOURCE')
247config.set10('HAVE_MEMFD_CREATE', have)
248
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200249add_project_arguments('-D_GNU_SOURCE', language : 'c')
250add_project_arguments('-include', 'config.h', language : 'c')
251
Daniel Vetter6e262252017-09-08 17:14:48 +0200252config.set('PACKAGE_NAME', meson.project_name())
253config.set_quoted('PACKAGE_VERSION', meson.project_version())
254config.set_quoted('PACKAGE', meson.project_name())
255config.set('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version())
256config.set_quoted('TARGET_CPU_PLATFORM', host_machine.cpu_family())
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200257
Daniel Vetter6e262252017-09-08 17:14:48 +0200258configure_file(output: 'config.h', install: false, configuration: config)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200259
Petri Latvala4ebf6872018-01-15 13:14:56 +0200260prefix = get_option('prefix')
261bindir = get_option('bindir')
Arkadiusz Hilereccae132018-05-15 14:07:50 +0300262datadir = join_paths(get_option('datadir'), 'igt-gpu-tools')
Petri Latvala4ebf6872018-01-15 13:14:56 +0200263includedir = get_option('includedir')
264libdir = get_option('libdir')
Arkadiusz Hilereccae132018-05-15 14:07:50 +0300265libexecdir = join_paths(get_option('libexecdir'), 'igt-gpu-tools')
Arkadiusz Hiler6cc5ebf2018-08-13 13:16:22 +0300266amdgpudir = join_paths(libexecdir, 'amdgpu')
Petri Latvala4ebf6872018-01-15 13:14:56 +0200267mandir = get_option('mandir')
268pkgconfigdir = join_paths(libdir, 'pkgconfig')
269
Arkadiusz Hiler6cc5ebf2018-08-13 13:16:22 +0300270if get_option('use_rpath')
271 # Set up runpath for the test executables towards libigt.so.
272 # The path should be relative to $ORIGIN so the library is
273 # still found properly even if installed to a path other than
274 # prefix.
275
276 # libdir and bindir are pathnames relative to prefix. meson
277 # enforces this.
278
279 # 1. Start from the executable.
280 # 2. Executables are installed in certain dir. Add a .. for each
281 # directory name in it.
282 # 3. Add relative path to libdir.
283
284 bindir_rpathdir = '$ORIGIN'
285 foreach p : bindir.split('/')
286 bindir_rpathdir = join_paths(bindir_rpathdir, '..')
287 endforeach
288 bindir_rpathdir = join_paths(bindir_rpathdir, libdir)
289
290 libexecdir_rpathdir = '$ORIGIN'
291 foreach p : libexecdir.split('/')
292 libexecdir_rpathdir = join_paths(libexecdir_rpathdir, '..')
293 endforeach
294 libexecdir_rpathdir = join_paths(libexecdir_rpathdir, libdir)
295
296 amdgpudir_rpathdir = '$ORIGIN'
297 foreach p : amdgpudir.split('/')
298 amdgpudir_rpathdir = join_paths(amdgpudir_rpathdir, '..')
299 endforeach
300 amdgpudir_rpathdir = join_paths(amdgpudir_rpathdir, libdir)
301else
302 bindir_rpathdir = ''
303 libexecdir_rpathdir = ''
304 amdgpudir_rpathdir = ''
305endif
306
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200307subdir('lib')
Petri Latvala0e98bf62018-06-21 14:06:25 +0300308if _build_tests
309 subdir('tests')
310 build_info += 'Build tests: Yes'
311else
312 build_info += 'Build tests: No'
313endif
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200314subdir('benchmarks')
315subdir('tools')
Petri Latvala18c1e752018-08-08 14:07:00 +0300316subdir('runner')
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200317if libdrm_intel.found()
318 subdir('assembler')
Petri Latvala0e98bf62018-06-21 14:06:25 +0300319endif
320subdir('overlay')
321subdir('man')
322
323docs_info = 'No'
324if _build_docs
325 if _build_tests
326 subdir('docs')
327 docs_info = 'Yes'
328 elif _docs_required
329 error('Documentation requires building tests')
Eric Anholtb26e9182017-09-27 11:30:52 -0700330 endif
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200331endif
Petri Latvala0e98bf62018-06-21 14:06:25 +0300332build_info += 'Build documentation: ' + docs_info
333
334message('Build options')
335message('=============')
336foreach str : build_info
337 message(str)
338endforeach
Maarten Lankhorstcb8e45a2019-02-01 11:13:59 +0100339
340if cairo.version().version_compare('<1.17.2')
341 if pixman.version().version_compare('<0.36.0')
342 warning('Pixman < 0.36.0 found, cannot test HDR formats')
343 endif
344 warning('Cairo < 1.17.2 found, cannot test HDR formats')
345elif pixman.version().version_compare('<0.36.0')
346 # Cairo 1.17.2 requires 0.36.0 to compile, but somehow it went missing?
347 error('Cairo with floating point support found, but pixman version too old')
348endif