meson.build 10 KB
Newer Older
1
project('igt-gpu-tools', 'c',
2
	version : '1.23',
3 4
        default_options: [
          'warning_level=2',
5
          'c_std=gnu11',
6
        ],
7
	license : 'MIT',
8
	meson_version : '>=0.46.0')
9 10 11

cc = meson.get_compiler('c')

Daniel Vetter's avatar
Daniel Vetter committed
12
cc_args = [
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
	'-Wbad-function-cast',
	'-Wdeclaration-after-statement',
	'-Wformat=2',
# igt_assert(0) in switch statements triggers a bunch of this.
	'-Wimplicit-fallthrough=0',
	'-Wlogical-op',
	'-Wmissing-declarations',
	'-Wmissing-format-attribute',
	'-Wmissing-noreturn',
	'-Wmissing-prototypes',
	'-Wnested-externs',
	'-Wold-style-definition',
	'-Wpointer-arith',
	'-Wredundant-decls',
	'-Wshadow',
	'-Wstrict-prototypes',
	'-Wuninitialized',
	'-Wunused',

Daniel Vetter's avatar
Daniel Vetter committed
32
	'-Wno-clobbered',
33 34 35 36
	'-Wno-maybe-uninitialized',
	'-Wno-missing-field-initializers',
	'-Wno-pointer-arith',
	'-Wno-sign-compare',
37
# Macros asserting on the range of their arguments triggers this.
Daniel Vetter's avatar
Daniel Vetter committed
38
	'-Wno-type-limits',
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
	'-Wno-unused-parameter',
	'-Wno-unused-result',

	'-Werror=address',
	'-Werror=array-bounds',
	'-Werror=implicit',
	'-Werror=init-self',
	'-Werror=int-to-pointer-cast',
	'-Werror=main',
	'-Werror=missing-braces',
	'-Werror=nonnull',
	'-Werror=pointer-to-int-cast',
	'-Werror=return-type',
	'-Werror=sequence-point',
	'-Werror=trigraphs',
	'-Werror=write-strings',
Daniel Vetter's avatar
Daniel Vetter committed
55 56 57 58 59 60 61
]

foreach cc_arg : cc_args
  if cc.has_argument(cc_arg)
    add_global_arguments(cc_arg, language : 'c')
  endif
endforeach
62

63 64 65 66 67 68 69 70 71 72 73 74
_build_overlay = false
_overlay_required = false
_build_man = false
_man_required = false
_build_audio = false
_audio_required = false
_build_chamelium = false
_chamelium_required = false
_build_docs = false
_docs_required = false
_build_tests = false
_tests_required = false
Petri Latvala's avatar
Petri Latvala committed
75 76
_build_runner = false
_runner_required = false
77 78 79 80 81 82 83 84 85 86

build_overlay = get_option('build_overlay')
overlay_backends = get_option('overlay_backends')
build_man = get_option('build_man')
with_valgrind = get_option('with_valgrind')
build_audio = get_option('build_audio')
build_chamelium = get_option('build_chamelium')
build_docs = get_option('build_docs')
build_tests = get_option('build_tests')
with_libdrm = get_option('with_libdrm')
87
with_libunwind = get_option('with_libunwind')
Petri Latvala's avatar
Petri Latvala committed
88
build_runner = get_option('build_runner')
89 90 91 92 93 94 95 96 97 98 99 100 101

_build_overlay = build_overlay != 'false'
_overlay_required = build_overlay == 'true'
_build_man = build_man != 'false'
_man_required = build_man == 'true'
_build_audio = build_audio != 'false'
_audio_required = build_audio == 'true'
_build_chamelium = build_chamelium != 'false'
_chamelium_required = build_chamelium == 'true'
_build_docs = build_docs != 'false'
_docs_required = build_docs == 'true'
_build_tests = build_tests != 'false'
_tests_required = build_tests == 'true'
Petri Latvala's avatar
Petri Latvala committed
102 103
_build_runner = build_runner != 'false'
_runner_required = build_runner == 'true'
104 105 106

build_info = []

107
inc = include_directories('include/drm-uapi', 'lib', 'lib/stubs/syscalls', '.')
108

Daniel Vetter's avatar
Daniel Vetter committed
109 110
inc_for_gtkdoc = include_directories('lib')

111
config = configuration_data()
112

113 114 115 116 117 118 119
null_dep = dependency('', required : false)

libdrm_info = []
libdrm_intel = null_dep
libdrm_nouveau = null_dep
libdrm_amdgpu = null_dep

120 121
libdrm_version = '>=2.4.82'
libdrm = dependency('libdrm', version : libdrm_version)
122 123 124 125 126 127 128 129 130 131 132 133 134 135
if with_libdrm.contains('auto') or with_libdrm.contains('intel')
	libdrm_intel = dependency('libdrm_intel', version : libdrm_version, required : with_libdrm.contains('intel'))
	libdrm_info += 'intel'
endif
if with_libdrm.contains('auto') or with_libdrm.contains('nouveau')
	libdrm_nouveau = dependency('libdrm_nouveau', version : libdrm_version, required : with_libdrm.contains('nouveau'))
	libdrm_info += 'nouveau'
endif
if with_libdrm.contains('auto') or with_libdrm.contains('amdgpu')
	libdrm_amdgpu = dependency('libdrm_amdgpu', version : libdrm_version, required : with_libdrm.contains('amdgpu'))
	libdrm_info += 'amdgpu'
endif

build_info += 'With libdrm: ' + ','.join(libdrm_info)
136 137 138

pciaccess = dependency('pciaccess', version : '>=0.10')
libkmod = dependency('libkmod')
139
libprocps = dependency('libprocps', required : true)
140 141 142 143 144 145 146 147 148 149 150

libunwind = null_dep
libunwindinfo = 'No'
if with_libunwind != 'false'
	libunwind = dependency('libunwind', required : with_libunwind == 'true')
	if libunwind.found()
		libunwindinfo = 'Yes'
	endif
endif
build_info += 'With libunwind: ' + libunwindinfo

151
libdw = dependency('libdw', required : true)
152
pixman = dependency('pixman-1', required : true)
153

154 155 156 157 158 159 160 161
valgrind = null_dep
valgrindinfo = 'No'
if with_valgrind != 'false'
	valgrind = dependency('valgrind', required : with_valgrind == 'true')
	if valgrind.found()
		config.set('HAVE_VALGRIND', 1)
		valgrindinfo = 'Yes'
	endif
162
endif
163
build_info += 'Valgrind annotations: ' + valgrindinfo
164

165
cairo = dependency('cairo', version : '>1.12.0', required : true)
166
libudev = dependency('libudev', required : true)
Petri Latvala's avatar
Petri Latvala committed
167
glib = dependency('glib-2.0', required : true)
168

169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
gsl = null_dep
alsa = null_dep
if _build_audio or _build_chamelium
	gsl = dependency('gsl', required : _audio_required or _chamelium_required)
endif
if _build_audio
	alsa = dependency('alsa', required : _audio_required)
endif

audioinfo = 'No'
if _build_audio and alsa.found() and gsl.found()
	audioinfo = 'Yes'
else
	if _audio_required
		error('Cannot build audio test due to missing dependencies')
	endif
	_build_audio = false
endif
build_info += 'Build audio test: ' + audioinfo
188 189 190 191 192

xmlrpc = dependency('xmlrpc', required : false)
xmlrpc_util = dependency('xmlrpc_util', required : false)
xmlrpc_client = dependency('xmlrpc_client', required : false)

193 194 195 196
xmlrpc_cmd = find_program('xmlrpc-c-config', required : false)
if not xmlrpc.found() and xmlrpc_cmd.found()
	libs_cmd = run_command(xmlrpc_cmd, 'client', '--libs')
	cflags_cmd = run_command(xmlrpc_cmd, 'client', '--cflags')
197 198 199 200 201 202 203 204 205

	if libs_cmd.returncode() == 0 and cflags_cmd.returncode() == 0
		xmlrpc = declare_dependency(compile_args: cflags_cmd.stdout().strip().split(),
					   link_args : libs_cmd.stdout().strip().split())
		xmlrpc_util = declare_dependency()
		xmlrpc_client = declare_dependency()
	endif
endif

206 207
chamelium = null_dep
chameliuminfo = 'No'
208 209
if _build_chamelium and gsl.found() and xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found()
	chamelium = declare_dependency(dependencies : [ xmlrpc,
210
							xmlrpc_util, xmlrpc_client])
211
	config.set('HAVE_CHAMELIUM', 1)
212 213 214
	chameliuminfo = 'Yes'
elif _chamelium_required
	error('Cannot build chamelium test due to missing dependencies')
215
endif
216
build_info += 'Build Chamelium test: ' + chameliuminfo
217 218 219 220 221 222 223 224

pthreads = dependency('threads')
math = cc.find_library('m')
realtime = cc.find_library('rt')
dlsym = cc.find_library('dl')
zlib = cc.find_library('z')

if cc.has_header('linux/kd.h')
225
	config.set('HAVE_LINUX_KD_H', 1)
226 227
endif
if cc.has_header('sys/kd.h')
228
	config.set('HAVE_SYS_KD_H', 1)
229 230
endif
if cc.has_header('libgen.h')
231
	config.set('HAVE_LIBGEN_H', 1)
232 233
endif
if cc.has_header('sys/io.h')
234
	config.set('HAVE_SYS_IO_H', 1)
235 236 237
endif
if cc.has_header('cpuid.h')
	# FIXME: Do we need the example link test from configure.ac?
238
	config.set('HAVE_CPUID_H', 1)
239 240 241 242
endif

if cc.has_member('struct sysinfo', 'totalram',
		prefix : '#include <sys/sysinfo.h>')
243
	config.set('HAVE_STRUCT_SYSINFO_TOTALRAM', 1)
244 245
endif

246 247 248
have = cc.has_function('memfd_create', prefix : '''#include <sys/mman.h>''', args : '-D_GNU_SOURCE')
config.set10('HAVE_MEMFD_CREATE', have)

249 250 251
add_project_arguments('-D_GNU_SOURCE', language : 'c')
add_project_arguments('-include', 'config.h', language : 'c')

252 253 254 255 256
config.set('PACKAGE_NAME', meson.project_name())
config.set_quoted('PACKAGE_VERSION', meson.project_version())
config.set_quoted('PACKAGE', meson.project_name())
config.set('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version())
config.set_quoted('TARGET_CPU_PLATFORM', host_machine.cpu_family())
257

258
configure_file(output: 'config.h', install: false, configuration: config)
259

260 261
prefix = get_option('prefix')
bindir = get_option('bindir')
262
datadir = join_paths(get_option('datadir'), 'igt-gpu-tools')
263 264
includedir = get_option('includedir')
libdir = get_option('libdir')
265
libexecdir = join_paths(get_option('libexecdir'), 'igt-gpu-tools')
266
amdgpudir = join_paths(libexecdir, 'amdgpu')
267 268 269
mandir = get_option('mandir')
pkgconfigdir = join_paths(libdir, 'pkgconfig')

270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
if get_option('use_rpath')
	# Set up runpath for the test executables towards libigt.so.
	# The path should be relative to $ORIGIN so the library is
	# still found properly even if installed to a path other than
	# prefix.

	# libdir and bindir are pathnames relative to prefix. meson
	# enforces this.

	# 1. Start from the executable.
	# 2. Executables are installed in certain dir. Add a .. for each
	#    directory name in it.
	# 3. Add relative path to libdir.

	bindir_rpathdir = '$ORIGIN'
	foreach p : bindir.split('/')
		bindir_rpathdir = join_paths(bindir_rpathdir, '..')
	endforeach
	bindir_rpathdir = join_paths(bindir_rpathdir, libdir)

	libexecdir_rpathdir = '$ORIGIN'
	foreach p : libexecdir.split('/')
		libexecdir_rpathdir = join_paths(libexecdir_rpathdir, '..')
	endforeach
	libexecdir_rpathdir = join_paths(libexecdir_rpathdir, libdir)

	amdgpudir_rpathdir = '$ORIGIN'
	foreach p : amdgpudir.split('/')
		amdgpudir_rpathdir = join_paths(amdgpudir_rpathdir, '..')
	endforeach
	amdgpudir_rpathdir = join_paths(amdgpudir_rpathdir, libdir)
else
	bindir_rpathdir = ''
	libexecdir_rpathdir = ''
	amdgpudir_rpathdir = ''
endif

307
subdir('lib')
308 309 310 311 312 313
if _build_tests
	subdir('tests')
	build_info += 'Build tests: Yes'
else
	build_info += 'Build tests: No'
endif
314 315
subdir('benchmarks')
subdir('tools')
Petri Latvala's avatar
Petri Latvala committed
316
subdir('runner')
317 318 319
if libdrm_intel.found()
	subdir('assembler')
endif
320
subdir('overlay')
321
subdir('man')
322 323 324 325 326 327 328 329 330

docs_info = 'No'
if _build_docs
	if _build_tests
		subdir('docs')
		docs_info = 'Yes'
	elif _docs_required
		error('Documentation requires building tests')
	endif
331
endif
332 333 334 335 336 337 338
build_info += 'Build documentation: ' + docs_info

message('Build options')
message('=============')
foreach str : build_info
	message(str)
endforeach
339 340 341 342 343 344 345 346 347 348

if cairo.version().version_compare('<1.17.2')
	if pixman.version().version_compare('<0.36.0')
		warning('Pixman < 0.36.0 found, cannot test HDR formats')
	endif
	warning('Cairo < 1.17.2 found, cannot test HDR formats')
elif pixman.version().version_compare('<0.36.0')
	# Cairo 1.17.2 requires 0.36.0 to compile, but somehow it went missing?
	error('Cairo with floating point support found, but pixman version too old')
endif