blob: 469723dc46330edff3c9b95668eb39734a8ff8a0 [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',
Petri Latvala779d2d42018-07-27 15:40:06 +03008 meson_version : '>=0.44.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)
Chris Wilsoncaea9c52018-05-30 22:44:56 +0100152ssl = dependency('openssl', required : true)
Maxime Ripardddb38282018-10-04 14:39:01 +0200153pixman = dependency('pixman-1', required : true)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200154
Petri Latvala0e98bf62018-06-21 14:06:25 +0300155valgrind = null_dep
156valgrindinfo = 'No'
157if with_valgrind != 'false'
158 valgrind = dependency('valgrind', required : with_valgrind == 'true')
159 if valgrind.found()
160 config.set('HAVE_VALGRIND', 1)
161 valgrindinfo = 'Yes'
162 endif
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200163endif
Petri Latvala0e98bf62018-06-21 14:06:25 +0300164build_info += 'Valgrind annotations: ' + valgrindinfo
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200165
Arkadiusz Hilerf9b6fd62018-02-20 11:00:22 +0200166cairo = dependency('cairo', version : '>1.12.0', required : true)
Antonio Argenzianod75e6762018-02-23 15:14:40 -0800167libudev = dependency('libudev', required : true)
Petri Latvala9bbfbb12018-06-21 14:06:24 +0300168glib = dependency('glib-2.0', required : true)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200169
Petri Latvala0e98bf62018-06-21 14:06:25 +0300170gsl = null_dep
171alsa = null_dep
Petri Latvala0e98bf62018-06-21 14:06:25 +0300172if _build_audio or _build_chamelium
173 gsl = dependency('gsl', required : _audio_required or _chamelium_required)
174endif
175if _build_audio
176 alsa = dependency('alsa', required : _audio_required)
177endif
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200178
Petri Latvala0e98bf62018-06-21 14:06:25 +0300179audioinfo = 'No'
180if _build_audio and alsa.found() and gsl.found()
181 audioinfo = 'Yes'
182else
183 if _audio_required
184 error('Cannot build audio test due to missing dependencies')
185 endif
186 _build_audio = false
187endif
188build_info += 'Build audio test: ' + audioinfo
189
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200190xmlrpc = dependency('xmlrpc', required : false)
191xmlrpc_util = dependency('xmlrpc_util', required : false)
192xmlrpc_client = dependency('xmlrpc_client', required : false)
193
Jani Nikula1ae18b02017-10-24 11:14:14 +0300194xmlrpc_cmd = find_program('xmlrpc-c-config', required : false)
195if not xmlrpc.found() and xmlrpc_cmd.found()
196 libs_cmd = run_command(xmlrpc_cmd, 'client', '--libs')
197 cflags_cmd = run_command(xmlrpc_cmd, 'client', '--cflags')
Arkadiusz Hiler892abc62017-10-17 15:05:41 +0300198
199 if libs_cmd.returncode() == 0 and cflags_cmd.returncode() == 0
200 xmlrpc = declare_dependency(compile_args: cflags_cmd.stdout().strip().split(),
201 link_args : libs_cmd.stdout().strip().split())
202 xmlrpc_util = declare_dependency()
203 xmlrpc_client = declare_dependency()
204 endif
205endif
206
Petri Latvala0e98bf62018-06-21 14:06:25 +0300207chamelium = null_dep
208chameliuminfo = 'No'
Maxime Ripardddb38282018-10-04 14:39:01 +0200209if _build_chamelium and gsl.found() and xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found()
210 chamelium = declare_dependency(dependencies : [ xmlrpc,
Petri Latvala0e98bf62018-06-21 14:06:25 +0300211 xmlrpc_util, xmlrpc_client])
Arkadiusz Hiler892abc62017-10-17 15:05:41 +0300212 config.set('HAVE_CHAMELIUM', 1)
Petri Latvala0e98bf62018-06-21 14:06:25 +0300213 chameliuminfo = 'Yes'
214elif _chamelium_required
215 error('Cannot build chamelium test due to missing dependencies')
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200216endif
Petri Latvala0e98bf62018-06-21 14:06:25 +0300217build_info += 'Build Chamelium test: ' + chameliuminfo
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200218
219pthreads = dependency('threads')
220math = cc.find_library('m')
221realtime = cc.find_library('rt')
222dlsym = cc.find_library('dl')
223zlib = cc.find_library('z')
224
225if cc.has_header('linux/kd.h')
Daniel Vetter6e262252017-09-08 17:14:48 +0200226 config.set('HAVE_LINUX_KD_H', 1)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200227endif
228if cc.has_header('sys/kd.h')
Daniel Vetter6e262252017-09-08 17:14:48 +0200229 config.set('HAVE_SYS_KD_H', 1)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200230endif
231if cc.has_header('libgen.h')
Daniel Vetter6e262252017-09-08 17:14:48 +0200232 config.set('HAVE_LIBGEN_H', 1)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200233endif
234if cc.has_header('sys/io.h')
Daniel Vetter6e262252017-09-08 17:14:48 +0200235 config.set('HAVE_SYS_IO_H', 1)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200236endif
237if cc.has_header('cpuid.h')
238 # FIXME: Do we need the example link test from configure.ac?
Daniel Vetter6e262252017-09-08 17:14:48 +0200239 config.set('HAVE_CPUID_H', 1)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200240endif
241
242if cc.has_member('struct sysinfo', 'totalram',
243 prefix : '#include <sys/sysinfo.h>')
Daniel Vetter6e262252017-09-08 17:14:48 +0200244 config.set('HAVE_STRUCT_SYSINFO_TOTALRAM', 1)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200245endif
246
Lucas De Marchibcb37a92018-07-24 15:20:24 -0700247have = cc.has_function('memfd_create', prefix : '''#include <sys/mman.h>''', args : '-D_GNU_SOURCE')
248config.set10('HAVE_MEMFD_CREATE', have)
249
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200250add_project_arguments('-D_GNU_SOURCE', language : 'c')
251add_project_arguments('-include', 'config.h', language : 'c')
252
Daniel Vetter6e262252017-09-08 17:14:48 +0200253config.set('PACKAGE_NAME', meson.project_name())
254config.set_quoted('PACKAGE_VERSION', meson.project_version())
255config.set_quoted('PACKAGE', meson.project_name())
256config.set('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version())
257config.set_quoted('TARGET_CPU_PLATFORM', host_machine.cpu_family())
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200258
Daniel Vetter6e262252017-09-08 17:14:48 +0200259configure_file(output: 'config.h', install: false, configuration: config)
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200260
Petri Latvala4ebf6872018-01-15 13:14:56 +0200261prefix = get_option('prefix')
262bindir = get_option('bindir')
Arkadiusz Hilereccae132018-05-15 14:07:50 +0300263datadir = join_paths(get_option('datadir'), 'igt-gpu-tools')
Petri Latvala4ebf6872018-01-15 13:14:56 +0200264includedir = get_option('includedir')
265libdir = get_option('libdir')
Arkadiusz Hilereccae132018-05-15 14:07:50 +0300266libexecdir = join_paths(get_option('libexecdir'), 'igt-gpu-tools')
Arkadiusz Hiler6cc5ebf2018-08-13 13:16:22 +0300267amdgpudir = join_paths(libexecdir, 'amdgpu')
Petri Latvala4ebf6872018-01-15 13:14:56 +0200268mandir = get_option('mandir')
269pkgconfigdir = join_paths(libdir, 'pkgconfig')
270
Arkadiusz Hiler6cc5ebf2018-08-13 13:16:22 +0300271if get_option('use_rpath')
272 # Set up runpath for the test executables towards libigt.so.
273 # The path should be relative to $ORIGIN so the library is
274 # still found properly even if installed to a path other than
275 # prefix.
276
277 # libdir and bindir are pathnames relative to prefix. meson
278 # enforces this.
279
280 # 1. Start from the executable.
281 # 2. Executables are installed in certain dir. Add a .. for each
282 # directory name in it.
283 # 3. Add relative path to libdir.
284
285 bindir_rpathdir = '$ORIGIN'
286 foreach p : bindir.split('/')
287 bindir_rpathdir = join_paths(bindir_rpathdir, '..')
288 endforeach
289 bindir_rpathdir = join_paths(bindir_rpathdir, libdir)
290
291 libexecdir_rpathdir = '$ORIGIN'
292 foreach p : libexecdir.split('/')
293 libexecdir_rpathdir = join_paths(libexecdir_rpathdir, '..')
294 endforeach
295 libexecdir_rpathdir = join_paths(libexecdir_rpathdir, libdir)
296
297 amdgpudir_rpathdir = '$ORIGIN'
298 foreach p : amdgpudir.split('/')
299 amdgpudir_rpathdir = join_paths(amdgpudir_rpathdir, '..')
300 endforeach
301 amdgpudir_rpathdir = join_paths(amdgpudir_rpathdir, libdir)
302else
303 bindir_rpathdir = ''
304 libexecdir_rpathdir = ''
305 amdgpudir_rpathdir = ''
306endif
307
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200308subdir('lib')
Petri Latvala0e98bf62018-06-21 14:06:25 +0300309if _build_tests
310 subdir('tests')
311 build_info += 'Build tests: Yes'
312else
313 build_info += 'Build tests: No'
314endif
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200315subdir('benchmarks')
316subdir('tools')
Petri Latvala18c1e752018-08-08 14:07:00 +0300317subdir('runner')
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200318if libdrm_intel.found()
319 subdir('assembler')
Petri Latvala0e98bf62018-06-21 14:06:25 +0300320endif
321subdir('overlay')
322subdir('man')
323
324docs_info = 'No'
325if _build_docs
326 if _build_tests
327 subdir('docs')
328 docs_info = 'Yes'
329 elif _docs_required
330 error('Documentation requires building tests')
Eric Anholtb26e9182017-09-27 11:30:52 -0700331 endif
Daniel Vetter9a7d8502017-09-05 14:36:14 +0200332endif
Petri Latvala0e98bf62018-06-21 14:06:25 +0300333build_info += 'Build documentation: ' + docs_info
334
335message('Build options')
336message('=============')
337foreach str : build_info
338 message(str)
339endforeach