]> git.proxmox.com Git - mirror_qemu.git/blame - meson.build
meson: move pixman detection to meson
[mirror_qemu.git] / meson.build
CommitLineData
a5665051
PB
1project('qemu', ['c'], meson_version: '>=0.55.0',
2 default_options: ['warning_level=1', 'c_std=gnu99', 'cpp_std=gnu++11', 'b_lundef=false'],
3 version: run_command('head', meson.source_root() / 'VERSION').stdout().strip())
4
5not_found = dependency('', required: false)
b29b40f4
PB
6if meson.version().version_compare('>=0.56.0')
7 keyval = import('keyval')
8else
9 keyval = import('unstable-keyval')
10endif
a81df1b6
PB
11ss = import('sourceset')
12
ce1c1e7a 13sh = find_program('sh')
a81df1b6 14cc = meson.get_compiler('c')
a5665051 15config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
2becc36a 16config_all_disas = keyval.load(meson.current_build_dir() / 'config-all-disas.mak')
3154fee4 17enable_modules = 'CONFIG_MODULES' in config_host
35be72ba 18enable_static = 'CONFIG_STATIC' in config_host
f8aa24ea 19build_docs = 'BUILD_DOCS' in config_host
859aef02
PB
20config_host_data = configuration_data()
21genh = []
a5665051
PB
22
23add_project_arguments(config_host['QEMU_CFLAGS'].split(),
24 native: false, language: ['c', 'objc'])
25add_project_arguments(config_host['QEMU_CXXFLAGS'].split(),
26 native: false, language: 'cpp')
27add_project_link_arguments(config_host['QEMU_LDFLAGS'].split(),
28 native: false, language: ['c', 'cpp', 'objc'])
29add_project_arguments(config_host['QEMU_INCLUDES'].split(),
30 language: ['c', 'cpp', 'objc'])
31
fc929892
MAL
32python = import('python').find_installation()
33
34link_language = meson.get_external_property('link_language', 'cpp')
35if link_language == 'cpp'
36 add_languages('cpp', required: true, native: false)
37endif
a5665051
PB
38if host_machine.system() == 'darwin'
39 add_languages('objc', required: false, native: false)
40endif
41
968b4db3
PB
42if 'SPARSE_CFLAGS' in config_host
43 run_target('sparse',
44 command: [find_program('scripts/check_sparse.py'),
45 config_host['SPARSE_CFLAGS'].split(),
46 'compile_commands.json'])
47endif
48
a5665051
PB
49configure_file(input: files('scripts/ninjatool.py'),
50 output: 'ninjatool',
51 configuration: config_host)
f9332757
PB
52
53supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
54supported_cpus = ['ppc', 'ppc64', 's390x', 'sparc64', 'riscv32', 'riscv64', 'x86', 'x86_64',
55 'arm', 'aarch64', 'mips', 'mips64', 'sparc', 'sparc64']
56
57cpu = host_machine.cpu_family()
58targetos = host_machine.system()
59
a81df1b6
PB
60m = cc.find_library('m', required: false)
61util = cc.find_library('util', required: false)
4a96337d 62winmm = []
a81df1b6 63socket = []
04c6f1e7 64version_res = []
d92989aa
MAL
65coref = []
66iokit = []
67cocoa = []
68hvf = []
a81df1b6
PB
69if targetos == 'windows'
70 socket = cc.find_library('ws2_32')
4a96337d 71 winmm = cc.find_library('winmm')
04c6f1e7
MAL
72
73 win = import('windows')
74 version_res = win.compile_resources('version.rc',
75 depend_files: files('pc-bios/qemu-nsis.ico'),
76 include_directories: include_directories('.'))
d92989aa
MAL
77elif targetos == 'darwin'
78 coref = dependency('appleframeworks', modules: 'CoreFoundation')
79 iokit = dependency('appleframeworks', modules: 'IOKit')
80 cocoa = dependency('appleframeworks', modules: 'Cocoa')
81 hvf = dependency('appleframeworks', modules: 'Hypervisor')
cfad62f1
PB
82elif targetos == 'sunos'
83 socket = [cc.find_library('socket'),
84 cc.find_library('nsl'),
85 cc.find_library('resolv')]
86elif targetos == 'haiku'
87 socket = [cc.find_library('posix_error_mapper'),
88 cc.find_library('network'),
89 cc.find_library('bsd')]
a81df1b6
PB
90endif
91glib = declare_dependency(compile_args: config_host['GLIB_CFLAGS'].split(),
92 link_args: config_host['GLIB_LIBS'].split())
93gio = not_found
94if 'CONFIG_GIO' in config_host
95 gio = declare_dependency(compile_args: config_host['GIO_CFLAGS'].split(),
96 link_args: config_host['GIO_LIBS'].split())
97endif
98lttng = not_found
99if 'CONFIG_TRACE_UST' in config_host
100 lttng = declare_dependency(link_args: config_host['LTTNG_UST_LIBS'].split())
101endif
102urcubp = not_found
103if 'CONFIG_TRACE_UST' in config_host
104 urcubp = declare_dependency(link_args: config_host['URCU_BP_LIBS'].split())
105endif
106nettle = not_found
107if 'CONFIG_NETTLE' in config_host
108 nettle = declare_dependency(compile_args: config_host['NETTLE_CFLAGS'].split(),
109 link_args: config_host['NETTLE_LIBS'].split())
110endif
111gnutls = not_found
112if 'CONFIG_GNUTLS' in config_host
113 gnutls = declare_dependency(compile_args: config_host['GNUTLS_CFLAGS'].split(),
114 link_args: config_host['GNUTLS_LIBS'].split())
115endif
b7612f45
PB
116pixman = not_found
117if have_system or have_tools
118 pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8',
119 static: enable_static)
120endif
5e7fbd25
MAL
121pam = not_found
122if 'CONFIG_AUTH_PAM' in config_host
123 pam = cc.find_library('pam')
124endif
5e5733e5
MAL
125libaio = cc.find_library('aio', required: false)
126zlib = not_found
127if 'CONFIG_ZLIB' in config_host
128 zlib = declare_dependency(compile_args: config_host['ZLIB_CFLAGS'].split(),
129 link_args: config_host['ZLIB_LIBS'].split())
130endif
131linux_io_uring = not_found
132if 'CONFIG_LINUX_IO_URING' in config_host
133 linux_io_uring = declare_dependency(compile_args: config_host['LINUX_IO_URING_CFLAGS'].split(),
134 link_args: config_host['LINUX_IO_URING_LIBS'].split())
135endif
136libxml2 = not_found
137if 'CONFIG_LIBXML2' in config_host
138 libxml2 = declare_dependency(compile_args: config_host['LIBXML2_CFLAGS'].split(),
139 link_args: config_host['LIBXML2_LIBS'].split())
140endif
141libnfs = not_found
142if 'CONFIG_LIBNFS' in config_host
143 libnfs = declare_dependency(link_args: config_host['LIBNFS_LIBS'].split())
144endif
ec0d5893
MAL
145libattr = not_found
146if 'CONFIG_ATTR' in config_host
147 libattr = declare_dependency(link_args: config_host['LIBATTR_LIBS'].split())
148endif
3f99cf57
PB
149seccomp = not_found
150if 'CONFIG_SECCOMP' in config_host
151 seccomp = declare_dependency(compile_args: config_host['SECCOMP_CFLAGS'].split(),
152 link_args: config_host['SECCOMP_LIBS'].split())
153endif
154libcap_ng = not_found
155if 'CONFIG_LIBCAP_NG' in config_host
156 libcap_ng = declare_dependency(link_args: config_host['LIBCAP_NG_LIBS'].split())
157endif
4113f4cf
LV
158xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'), static: enable_static,
159 include_type: 'system')
160if xkbcommon.found()
161 xkbcommon = declare_dependency(dependencies: xkbcommon)
ade60d4f 162endif
cdaf0722
MAL
163slirp = not_found
164if config_host.has_key('CONFIG_SLIRP')
165 slirp = declare_dependency(compile_args: config_host['SLIRP_CFLAGS'].split(),
166 link_args: config_host['SLIRP_LIBS'].split())
167endif
168vde = not_found
169if config_host.has_key('CONFIG_VDE')
170 vde = declare_dependency(link_args: config_host['VDE_LIBS'].split())
171endif
478e943f
PB
172pulse = not_found
173if 'CONFIG_LIBPULSE' in config_host
174 pulse = declare_dependency(compile_args: config_host['PULSE_CFLAGS'].split(),
175 link_args: config_host['PULSE_LIBS'].split())
176endif
177alsa = not_found
178if 'CONFIG_ALSA' in config_host
179 alsa = declare_dependency(compile_args: config_host['ALSA_CFLAGS'].split(),
180 link_args: config_host['ALSA_LIBS'].split())
181endif
182jack = not_found
183if 'CONFIG_LIBJACK' in config_host
184 jack = declare_dependency(link_args: config_host['JACK_LIBS'].split())
185endif
2634733c
PB
186spice = not_found
187if 'CONFIG_SPICE' in config_host
188 spice = declare_dependency(compile_args: config_host['SPICE_CFLAGS'].split(),
189 link_args: config_host['SPICE_LIBS'].split())
190endif
5ee24e78 191rt = cc.find_library('rt', required: false)
897b5afa
MAL
192libmpathpersist = not_found
193if config_host.has_key('CONFIG_MPATH')
194 libmpathpersist = cc.find_library('mpathpersist')
195endif
99650b62
PB
196libiscsi = not_found
197if 'CONFIG_LIBISCSI' in config_host
198 libiscsi = declare_dependency(compile_args: config_host['LIBISCSI_CFLAGS'].split(),
199 link_args: config_host['LIBISCSI_LIBS'].split())
200endif
5e5733e5
MAL
201zstd = not_found
202if 'CONFIG_ZSTD' in config_host
203 zstd = declare_dependency(compile_args: config_host['ZSTD_CFLAGS'].split(),
204 link_args: config_host['ZSTD_LIBS'].split())
205endif
ea458960
MAL
206gbm = not_found
207if 'CONFIG_GBM' in config_host
208 gbm = declare_dependency(compile_args: config_host['GBM_CFLAGS'].split(),
209 link_args: config_host['GBM_LIBS'].split())
210endif
211virgl = not_found
212if 'CONFIG_VIRGL' in config_host
213 virgl = declare_dependency(compile_args: config_host['VIRGL_CFLAGS'].split(),
214 link_args: config_host['VIRGL_LIBS'].split())
215endif
1d7bb6ab
MAL
216curl = not_found
217if 'CONFIG_CURL' in config_host
218 curl = declare_dependency(compile_args: config_host['CURL_CFLAGS'].split(),
219 link_args: config_host['CURL_LIBS'].split())
220endif
f15bff25
PB
221libudev = not_found
222if 'CONFIG_LIBUDEV' in config_host
223 libudev = declare_dependency(link_args: config_host['LIBUDEV_LIBS'].split())
224endif
2634733c
PB
225brlapi = not_found
226if 'CONFIG_BRLAPI' in config_host
227 brlapi = declare_dependency(link_args: config_host['BRLAPI_LIBS'].split())
228endif
35be72ba
PB
229
230sdl = dependency('sdl2', required: get_option('sdl'), static: enable_static,
231 include_type: 'system')
232sdl_image = not_found
233if sdl.found()
234 # work around 2.0.8 bug
235 sdl = declare_dependency(compile_args: '-Wno-undef',
236 dependencies: sdl)
237 sdl_image = dependency('sdl-image', required: get_option('sdl_image'),
238 static: enable_static)
239else
240 if get_option('sdl_image').enabled()
241 error('sdl-image required, but SDL was @0@',
242 get_option('sdl').disabled() ? 'disabled' : 'not found')
243 endif
244 sdl_image = not_found
2634733c 245endif
35be72ba 246
5e5733e5
MAL
247rbd = not_found
248if 'CONFIG_RBD' in config_host
249 rbd = declare_dependency(link_args: config_host['RBD_LIBS'].split())
250endif
251glusterfs = not_found
252if 'CONFIG_GLUSTERFS' in config_host
253 glusterfs = declare_dependency(compile_args: config_host['GLUSTERFS_CFLAGS'].split(),
254 link_args: config_host['GLUSTERFS_LIBS'].split())
255endif
256libssh = not_found
257if 'CONFIG_LIBSSH' in config_host
258 libssh = declare_dependency(compile_args: config_host['LIBSSH_CFLAGS'].split(),
259 link_args: config_host['LIBSSH_LIBS'].split())
260endif
261libbzip2 = not_found
262if 'CONFIG_BZIP2' in config_host
263 libbzip2 = declare_dependency(link_args: config_host['BZIP2_LIBS'].split())
264endif
265liblzfse = not_found
266if 'CONFIG_LZFSE' in config_host
267 liblzfse = declare_dependency(link_args: config_host['LZFSE_LIBS'].split())
268endif
478e943f
PB
269oss = not_found
270if 'CONFIG_AUDIO_OSS' in config_host
271 oss = declare_dependency(link_args: config_host['OSS_LIBS'].split())
272endif
273dsound = not_found
274if 'CONFIG_AUDIO_DSOUND' in config_host
275 dsound = declare_dependency(link_args: config_host['DSOUND_LIBS'].split())
276endif
277coreaudio = not_found
278if 'CONFIG_AUDIO_COREAUDIO' in config_host
279 coreaudio = declare_dependency(link_args: config_host['COREAUDIO_LIBS'].split())
2b1ccdf4
MAL
280endif
281opengl = not_found
282if 'CONFIG_OPENGL' in config_host
283 opengl = declare_dependency(link_args: config_host['OPENGL_LIBS'].split())
284else
285endif
286gtk = not_found
287if 'CONFIG_GTK' in config_host
288 gtk = declare_dependency(compile_args: config_host['GTK_CFLAGS'].split(),
289 link_args: config_host['GTK_LIBS'].split())
290endif
291vte = not_found
292if 'CONFIG_VTE' in config_host
293 vte = declare_dependency(compile_args: config_host['VTE_CFLAGS'].split(),
294 link_args: config_host['VTE_LIBS'].split())
295endif
296x11 = not_found
297if 'CONFIG_X11' in config_host
298 x11 = declare_dependency(compile_args: config_host['X11_CFLAGS'].split(),
299 link_args: config_host['X11_LIBS'].split())
300endif
301curses = not_found
302if 'CONFIG_CURSES' in config_host
303 curses = declare_dependency(compile_args: config_host['CURSES_CFLAGS'].split(),
304 link_args: config_host['CURSES_LIBS'].split())
305endif
306iconv = not_found
307if 'CONFIG_ICONV' in config_host
308 iconv = declare_dependency(compile_args: config_host['ICONV_CFLAGS'].split(),
309 link_args: config_host['ICONV_LIBS'].split())
310endif
311gio = not_found
312if 'CONFIG_GIO' in config_host
313 gio = declare_dependency(compile_args: config_host['GIO_CFLAGS'].split(),
314 link_args: config_host['GIO_LIBS'].split())
315endif
a0b93237 316vnc = not_found
2b1ccdf4 317png = not_found
2b1ccdf4 318jpeg = not_found
2b1ccdf4 319sasl = not_found
a0b93237
PB
320if get_option('vnc').enabled()
321 vnc = declare_dependency() # dummy dependency
322 png = dependency('libpng', required: get_option('vnc_png'),
323 static: enable_static)
324 jpeg = cc.find_library('jpeg', has_headers: ['jpeglib.h'],
325 required: get_option('vnc_jpeg'),
326 static: enable_static)
327 sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'],
328 required: get_option('vnc_sasl'),
329 static: enable_static)
330 if sasl.found()
331 sasl = declare_dependency(dependencies: sasl,
332 compile_args: '-DSTRUCT_IOVEC_DEFINED')
333 endif
478e943f 334endif
4a96337d
PB
335fdt = not_found
336if 'CONFIG_FDT' in config_host
337 fdt = declare_dependency(compile_args: config_host['FDT_CFLAGS'].split(),
338 link_args: config_host['FDT_LIBS'].split())
339endif
708eab42
MAL
340snappy = not_found
341if 'CONFIG_SNAPPY' in config_host
342 snappy = declare_dependency(link_args: config_host['SNAPPY_LIBS'].split())
343endif
344lzo = not_found
345if 'CONFIG_LZO' in config_host
346 lzo = declare_dependency(link_args: config_host['LZO_LIBS'].split())
347endif
55166230
MAL
348rdma = not_found
349if 'CONFIG_RDMA' in config_host
350 rdma = declare_dependency(link_args: config_host['RDMA_LIBS'].split())
351endif
ab318051
MAL
352numa = not_found
353if 'CONFIG_NUMA' in config_host
354 numa = declare_dependency(link_args: config_host['NUMA_LIBS'].split())
355endif
582ea95f
MAL
356xen = not_found
357if 'CONFIG_XEN_BACKEND' in config_host
358 xen = declare_dependency(compile_args: config_host['XEN_CFLAGS'].split(),
359 link_args: config_host['XEN_LIBS'].split())
360endif
06677ce1
PB
361cacard = not_found
362if 'CONFIG_SMARTCARD' in config_host
363 cacard = declare_dependency(compile_args: config_host['SMARTCARD_CFLAGS'].split(),
364 link_args: config_host['SMARTCARD_LIBS'].split())
365endif
366usbredir = not_found
367if 'CONFIG_USB_REDIR' in config_host
368 usbredir = declare_dependency(compile_args: config_host['USB_REDIR_CFLAGS'].split(),
369 link_args: config_host['USB_REDIR_LIBS'].split())
370endif
371libusb = not_found
372if 'CONFIG_USB_LIBUSB' in config_host
373 libusb = declare_dependency(compile_args: config_host['LIBUSB_CFLAGS'].split(),
374 link_args: config_host['LIBUSB_LIBS'].split())
375endif
c9322ab5
MAL
376capstone = not_found
377if 'CONFIG_CAPSTONE' in config_host
378 capstone = declare_dependency(compile_args: config_host['CAPSTONE_CFLAGS'].split(),
379 link_args: config_host['CAPSTONE_LIBS'].split())
380endif
381libpmem = not_found
382if 'CONFIG_LIBPMEM' in config_host
383 libpmem = declare_dependency(compile_args: config_host['LIBPMEM_CFLAGS'].split(),
384 link_args: config_host['LIBPMEM_LIBS'].split())
385endif
c7c91a74
BR
386libdaxctl = not_found
387if 'CONFIG_LIBDAXCTL' in config_host
388 libdaxctl = declare_dependency(link_args: config_host['LIBDAXCTL_LIBS'].split())
389endif
a81df1b6 390
859aef02
PB
391# Create config-host.h
392
35be72ba
PB
393config_host_data.set('CONFIG_SDL', sdl.found())
394config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
a0b93237
PB
395config_host_data.set('CONFIG_VNC', vnc.found())
396config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
397config_host_data.set('CONFIG_VNC_PNG', png.found())
398config_host_data.set('CONFIG_VNC_SASL', sasl.found())
4113f4cf 399config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
859aef02
PB
400config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
401config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0])
402config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1])
403config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('.')[2])
404
405arrays = ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
406strings = ['HOST_DSOSUF', 'CONFIG_IASL', 'qemu_confdir', 'qemu_datadir',
407 'qemu_moddir', 'qemu_localstatedir', 'qemu_helperdir', 'qemu_localedir',
408 'qemu_icondir', 'qemu_desktopdir', 'qemu_firmwarepath']
409foreach k, v: config_host
410 if arrays.contains(k)
411 if v != ''
412 v = '"' + '", "'.join(v.split()) + '", '
413 endif
414 config_host_data.set(k, v)
415 elif k == 'ARCH'
416 config_host_data.set('HOST_' + v.to_upper(), 1)
417 elif strings.contains(k)
418 if not k.startswith('CONFIG_')
419 k = 'CONFIG_' + k.to_upper()
420 endif
421 config_host_data.set_quoted(k, v)
422 elif k.startswith('CONFIG_') or k.startswith('HAVE_') or k.startswith('HOST_')
423 config_host_data.set(k, v == 'y' ? 1 : v)
424 endif
425endforeach
426genh += configure_file(output: 'config-host.h', configuration: config_host_data)
427
2becc36a 428minikconf = find_program('scripts/minikconf.py')
a81df1b6
PB
429target_dirs = config_host['TARGET_DIRS'].split()
430have_user = false
431have_system = false
2becc36a
PB
432config_devices_mak_list = []
433config_devices_h = {}
859aef02 434config_target_h = {}
2becc36a
PB
435config_target_mak = {}
436kconfig_external_symbols = [
437 'CONFIG_KVM',
438 'CONFIG_XEN',
439 'CONFIG_TPM',
440 'CONFIG_SPICE',
441 'CONFIG_IVSHMEM',
442 'CONFIG_OPENGL',
443 'CONFIG_X11',
444 'CONFIG_VHOST_USER',
445 'CONFIG_VHOST_KERNEL',
446 'CONFIG_VIRTFS',
447 'CONFIG_LINUX',
448 'CONFIG_PVRDMA',
449]
859aef02 450ignored = ['TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_DIRS']
a81df1b6
PB
451foreach target : target_dirs
452 have_user = have_user or target.endswith('-user')
859aef02
PB
453 config_target = keyval.load(meson.current_build_dir() / target / 'config-target.mak')
454
455 config_target_data = configuration_data()
456 foreach k, v: config_target
457 if not k.startswith('TARGET_') and not k.startswith('CONFIG_')
458 # do nothing
459 elif ignored.contains(k)
460 # do nothing
461 elif k == 'TARGET_BASE_ARCH'
462 config_target_data.set('TARGET_' + v.to_upper(), 1)
463 elif k == 'TARGET_NAME'
464 config_target_data.set_quoted(k, v)
465 elif v == 'y'
466 config_target_data.set(k, 1)
467 else
468 config_target_data.set(k, v)
469 endif
470 endforeach
471 config_target_h += {target: configure_file(output: target + '-config-target.h',
472 configuration: config_target_data)}
2becc36a
PB
473
474 if target.endswith('-softmmu')
475 have_system = true
476
477 base_kconfig = []
478 foreach sym : kconfig_external_symbols
859aef02 479 if sym in config_target or sym in config_host
2becc36a
PB
480 base_kconfig += '@0@=y'.format(sym)
481 endif
482 endforeach
483
484 config_devices_mak = target + '-config-devices.mak'
485 config_devices_mak = configure_file(
486 input: ['default-configs' / target + '.mak', 'Kconfig'],
487 output: config_devices_mak,
488 depfile: config_devices_mak + '.d',
489 capture: true,
490 command: [minikconf, config_host['CONFIG_MINIKCONF_MODE'],
491 config_devices_mak, '@DEPFILE@', '@INPUT@',
492 base_kconfig])
859aef02
PB
493
494 config_devices_data = configuration_data()
495 config_devices = keyval.load(config_devices_mak)
496 foreach k, v: config_devices
497 config_devices_data.set(k, 1)
498 endforeach
2becc36a 499 config_devices_mak_list += config_devices_mak
859aef02
PB
500 config_devices_h += {target: configure_file(output: target + '-config-devices.h',
501 configuration: config_devices_data)}
502 config_target += config_devices
2becc36a
PB
503 endif
504 config_target_mak += {target: config_target}
a81df1b6
PB
505endforeach
506have_tools = 'CONFIG_TOOLS' in config_host
507have_block = have_system or have_tools
508
2becc36a
PB
509grepy = find_program('scripts/grepy.sh')
510# This configuration is used to build files that are shared by
511# multiple binaries, and then extracted out of the "common"
512# static_library target.
513#
514# We do not use all_sources()/all_dependencies(), because it would
515# build literally all source files, including devices only used by
516# targets that are not built for this compilation. The CONFIG_ALL
517# pseudo symbol replaces it.
518
519if have_system
520 config_all_devices_mak = configure_file(
521 output: 'config-all-devices.mak',
522 input: config_devices_mak_list,
523 capture: true,
524 command: [grepy, '@INPUT@'],
525 )
526 config_all_devices = keyval.load(config_all_devices_mak)
527else
528 config_all_devices = {}
529endif
530config_all = config_all_devices
531config_all += config_host
532config_all += config_all_disas
533config_all += {
534 'CONFIG_XEN': config_host.has_key('CONFIG_XEN_BACKEND'),
535 'CONFIG_SOFTMMU': have_system,
536 'CONFIG_USER_ONLY': have_user,
537 'CONFIG_ALL': true,
538}
539
a81df1b6
PB
540# Generators
541
3f885659 542hxtool = find_program('scripts/hxtool')
650b5d54 543shaderinclude = find_program('scripts/shaderinclude.pl')
a81df1b6
PB
544qapi_gen = find_program('scripts/qapi-gen.py')
545qapi_gen_depends = [ meson.source_root() / 'scripts/qapi/__init__.py',
546 meson.source_root() / 'scripts/qapi/commands.py',
547 meson.source_root() / 'scripts/qapi/common.py',
548 meson.source_root() / 'scripts/qapi/doc.py',
549 meson.source_root() / 'scripts/qapi/error.py',
550 meson.source_root() / 'scripts/qapi/events.py',
551 meson.source_root() / 'scripts/qapi/expr.py',
552 meson.source_root() / 'scripts/qapi/gen.py',
553 meson.source_root() / 'scripts/qapi/introspect.py',
554 meson.source_root() / 'scripts/qapi/parser.py',
555 meson.source_root() / 'scripts/qapi/schema.py',
556 meson.source_root() / 'scripts/qapi/source.py',
557 meson.source_root() / 'scripts/qapi/types.py',
558 meson.source_root() / 'scripts/qapi/visit.py',
559 meson.source_root() / 'scripts/qapi/common.py',
560 meson.source_root() / 'scripts/qapi/doc.py',
561 meson.source_root() / 'scripts/qapi-gen.py'
562]
563
564tracetool = [
565 python, files('scripts/tracetool.py'),
566 '--backend=' + config_host['TRACE_BACKENDS']
567]
568
2c273f32
MAL
569qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
570 meson.current_source_dir(),
859aef02 571 config_host['PKGVERSION'], meson.project_version()]
2c273f32
MAL
572qemu_version = custom_target('qemu-version.h',
573 output: 'qemu-version.h',
574 command: qemu_version_cmd,
575 capture: true,
576 build_by_default: true,
577 build_always_stale: true)
578genh += qemu_version
579
3f885659
MAL
580hxdep = []
581hx_headers = [
582 ['qemu-options.hx', 'qemu-options.def'],
583 ['qemu-img-cmds.hx', 'qemu-img-cmds.h'],
584]
585if have_system
586 hx_headers += [
587 ['hmp-commands.hx', 'hmp-commands.h'],
588 ['hmp-commands-info.hx', 'hmp-commands-info.h'],
589 ]
590endif
591foreach d : hx_headers
b7c70bf2 592 hxdep += custom_target(d[1],
3f885659
MAL
593 input: files(d[0]),
594 output: d[1],
595 capture: true,
596 build_by_default: true, # to be removed when added to a target
597 command: [hxtool, '-h', '@INPUT0@'])
598endforeach
599genh += hxdep
600
a81df1b6
PB
601# Collect sourcesets.
602
603util_ss = ss.source_set()
604stub_ss = ss.source_set()
605trace_ss = ss.source_set()
3154fee4 606block_ss = ss.source_set()
4a96337d 607blockdev_ss = ss.source_set()
ff219dca 608qmp_ss = ss.source_set()
2becc36a
PB
609common_ss = ss.source_set()
610softmmu_ss = ss.source_set()
611user_ss = ss.source_set()
612bsd_user_ss = ss.source_set()
613linux_user_ss = ss.source_set()
614specific_ss = ss.source_set()
64ed6f92 615specific_fuzz_ss = ss.source_set()
2becc36a 616
3154fee4 617modules = {}
2becc36a
PB
618hw_arch = {}
619target_arch = {}
620target_softmmu_arch = {}
a81df1b6
PB
621
622###############
623# Trace files #
624###############
625
c9322ab5
MAL
626# TODO: add each directory to the subdirs from its own meson.build, once
627# we have those
a81df1b6
PB
628trace_events_subdirs = [
629 'accel/kvm',
630 'accel/tcg',
631 'crypto',
632 'monitor',
633]
634if have_user
635 trace_events_subdirs += [ 'linux-user' ]
636endif
637if have_block
638 trace_events_subdirs += [
639 'authz',
640 'block',
641 'io',
642 'nbd',
643 'scsi',
644 ]
645endif
646if have_system
647 trace_events_subdirs += [
648 'audio',
649 'backends',
650 'backends/tpm',
651 'chardev',
652 'hw/9pfs',
653 'hw/acpi',
654 'hw/alpha',
655 'hw/arm',
656 'hw/audio',
657 'hw/block',
658 'hw/block/dataplane',
659 'hw/char',
660 'hw/display',
661 'hw/dma',
662 'hw/hppa',
663 'hw/hyperv',
664 'hw/i2c',
665 'hw/i386',
666 'hw/i386/xen',
667 'hw/ide',
668 'hw/input',
669 'hw/intc',
670 'hw/isa',
671 'hw/mem',
672 'hw/mips',
673 'hw/misc',
674 'hw/misc/macio',
675 'hw/net',
676 'hw/nvram',
677 'hw/pci',
678 'hw/pci-host',
679 'hw/ppc',
680 'hw/rdma',
681 'hw/rdma/vmw',
682 'hw/rtc',
683 'hw/s390x',
684 'hw/scsi',
685 'hw/sd',
686 'hw/sparc',
687 'hw/sparc64',
688 'hw/ssi',
689 'hw/timer',
690 'hw/tpm',
691 'hw/usb',
692 'hw/vfio',
693 'hw/virtio',
694 'hw/watchdog',
695 'hw/xen',
696 'hw/gpio',
697 'hw/riscv',
698 'migration',
699 'net',
700 'ui',
701 ]
702endif
703trace_events_subdirs += [
704 'hw/core',
705 'qapi',
706 'qom',
707 'target/arm',
708 'target/hppa',
709 'target/i386',
710 'target/mips',
711 'target/ppc',
712 'target/riscv',
713 'target/s390x',
714 'target/sparc',
715 'util',
716]
717
a81df1b6
PB
718subdir('qapi')
719subdir('qobject')
720subdir('stubs')
721subdir('trace')
722subdir('util')
5582c58f
MAL
723subdir('qom')
724subdir('authz')
a81df1b6 725subdir('crypto')
2d78b56e 726subdir('ui')
a81df1b6 727
3154fee4
MAL
728
729if enable_modules
730 libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO')
731 modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
732endif
733
a81df1b6
PB
734# Build targets from sourcesets
735
2becc36a 736stub_ss = stub_ss.apply(config_all, strict: false)
a81df1b6
PB
737
738util_ss.add_all(trace_ss)
2becc36a 739util_ss = util_ss.apply(config_all, strict: false)
a81df1b6
PB
740libqemuutil = static_library('qemuutil',
741 sources: util_ss.sources() + stub_ss.sources() + genh,
742 dependencies: [util_ss.dependencies(), m, glib, socket])
743qemuutil = declare_dependency(link_with: libqemuutil,
04c6f1e7 744 sources: genh + version_res)
a81df1b6 745
abff1abf
PB
746decodetree = generator(find_program('scripts/decodetree.py'),
747 output: 'decode-@BASENAME@.c.inc',
748 arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@'])
749
478e943f 750subdir('audio')
7fcfd456 751subdir('io')
848e8ff6 752subdir('chardev')
ec0d5893 753subdir('fsdev')
abff1abf 754subdir('libdecnumber')
d3b18480 755subdir('target')
708eab42 756subdir('dump')
ec0d5893 757
5e5733e5
MAL
758block_ss.add(files(
759 'block.c',
760 'blockjob.c',
761 'job.c',
762 'qemu-io-cmds.c',
763))
764block_ss.add(when: 'CONFIG_REPLICATION', if_true: files('replication.c'))
765
766subdir('nbd')
767subdir('scsi')
768subdir('block')
769
4a96337d
PB
770blockdev_ss.add(files(
771 'blockdev.c',
772 'blockdev-nbd.c',
773 'iothread.c',
774 'job-qmp.c',
775))
776
777# os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
778# os-win32.c does not
779blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
780softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
781
782softmmu_ss.add_all(blockdev_ss)
783softmmu_ss.add(files(
784 'bootdevice.c',
785 'dma-helpers.c',
786 'qdev-monitor.c',
787), sdl)
788
789softmmu_ss.add(when: 'CONFIG_TPM', if_true: files('tpm.c'))
790softmmu_ss.add(when: 'CONFIG_SECCOMP', if_true: [files('qemu-seccomp.c'), seccomp])
791softmmu_ss.add(when: ['CONFIG_FDT', fdt], if_true: [files('device_tree.c')])
792
793common_ss.add(files('cpus-common.c'))
794
5d3ea0e1 795subdir('softmmu')
c9322ab5 796
c7c91a74 797specific_ss.add(files('disas.c', 'exec.c', 'gdbstub.c'), capstone, libpmem, libdaxctl)
c9322ab5
MAL
798specific_ss.add(files('exec-vary.c'))
799specific_ss.add(when: 'CONFIG_TCG', if_true: files(
800 'fpu/softfloat.c',
801 'tcg/optimize.c',
802 'tcg/tcg-common.c',
803 'tcg/tcg-op-gvec.c',
804 'tcg/tcg-op-vec.c',
805 'tcg/tcg-op.c',
806 'tcg/tcg.c',
807))
808specific_ss.add(when: 'CONFIG_TCG_INTERPRETER', if_true: files('disas/tci.c', 'tcg/tci.c'))
809
ab318051 810subdir('backends')
c574e161 811subdir('disas')
55166230 812subdir('migration')
ff219dca 813subdir('monitor')
cdaf0722 814subdir('net')
17ef2af6 815subdir('replay')
582ea95f 816subdir('hw')
1a82878a 817subdir('accel')
f556b4a1 818subdir('plugins')
b309c321 819subdir('bsd-user')
3a30446a
MAL
820subdir('linux-user')
821
b309c321
MAL
822bsd_user_ss.add(files('gdbstub.c'))
823specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)
824
3a30446a
MAL
825linux_user_ss.add(files('gdbstub.c', 'thunk.c'))
826specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss)
5d3ea0e1 827
a2ce7dbd
PB
828# needed for fuzzing binaries
829subdir('tests/qtest/libqos')
64ed6f92 830subdir('tests/qtest/fuzz')
a2ce7dbd 831
3154fee4
MAL
832block_mods = []
833softmmu_mods = []
834foreach d, list : modules
835 foreach m, module_ss : list
836 if enable_modules and targetos != 'windows'
837 module_ss = module_ss.apply(config_host, strict: false)
838 sl = static_library(d + '-' + m, [genh, module_ss.sources()],
839 dependencies: [modulecommon, module_ss.dependencies()], pic: true)
840 if d == 'block'
841 block_mods += sl
842 else
843 softmmu_mods += sl
844 endif
845 else
846 if d == 'block'
847 block_ss.add_all(module_ss)
848 else
849 softmmu_ss.add_all(module_ss)
850 endif
851 endif
852 endforeach
853endforeach
854
855nm = find_program('nm')
856undefsym = find_program('scripts/undefsym.sh')
857block_syms = custom_target('block.syms', output: 'block.syms',
858 input: [libqemuutil, block_mods],
859 capture: true,
860 command: [undefsym, nm, '@INPUT@'])
861qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
862 input: [libqemuutil, softmmu_mods],
863 capture: true,
864 command: [undefsym, nm, '@INPUT@'])
865
5e5733e5
MAL
866block_ss = block_ss.apply(config_host, strict: false)
867libblock = static_library('block', block_ss.sources() + genh,
868 dependencies: block_ss.dependencies(),
869 link_depends: block_syms,
870 name_suffix: 'fa',
871 build_by_default: false)
872
873block = declare_dependency(link_whole: [libblock],
b7c70bf2
MAL
874 link_args: '@block.syms',
875 dependencies: [crypto, io])
5e5733e5 876
ff219dca
PB
877qmp_ss = qmp_ss.apply(config_host, strict: false)
878libqmp = static_library('qmp', qmp_ss.sources() + genh,
879 dependencies: qmp_ss.dependencies(),
880 name_suffix: 'fa',
881 build_by_default: false)
882
883qmp = declare_dependency(link_whole: [libqmp])
884
3154fee4
MAL
885foreach m : block_mods + softmmu_mods
886 shared_module(m.name(),
887 name_prefix: '',
888 link_whole: m,
889 install: true,
890 install_dir: config_host['qemu_moddir'])
891endforeach
892
64ed6f92
PB
893softmmu_ss.add(authz, block, chardev, crypto, io, qmp)
894common_ss.add(qom, qemuutil)
895
896common_ss.add_all(when: 'CONFIG_SOFTMMU', if_true: [softmmu_ss])
2becc36a
PB
897common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
898
899common_all = common_ss.apply(config_all, strict: false)
900common_all = static_library('common',
901 build_by_default: false,
902 sources: common_all.sources() + genh,
903 dependencies: common_all.dependencies(),
904 name_suffix: 'fa')
905
c9322ab5
MAL
906feature_to_c = find_program('scripts/feature_to_c.sh')
907
64ed6f92 908emulators = []
2becc36a
PB
909foreach target : target_dirs
910 config_target = config_target_mak[target]
911 target_name = config_target['TARGET_NAME']
912 arch = config_target['TARGET_BASE_ARCH']
859aef02 913 arch_srcs = [config_target_h[target]]
64ed6f92
PB
914 arch_deps = []
915 c_args = ['-DNEED_CPU_H',
916 '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
917 '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
918 link_args = []
2becc36a 919
859aef02 920 config_target += config_host
2becc36a
PB
921 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
922 if targetos == 'linux'
923 target_inc += include_directories('linux-headers', is_system: true)
924 endif
925 if target.endswith('-softmmu')
926 qemu_target_name = 'qemu-system-' + target_name
927 target_type='system'
abff1abf
PB
928 t = target_softmmu_arch[arch].apply(config_target, strict: false)
929 arch_srcs += t.sources()
64ed6f92 930 arch_deps += t.dependencies()
abff1abf 931
2c44220d
MAL
932 hw_dir = target_name == 'sparc64' ? 'sparc64' : arch
933 hw = hw_arch[hw_dir].apply(config_target, strict: false)
934 arch_srcs += hw.sources()
64ed6f92 935 arch_deps += hw.dependencies()
2c44220d 936
2becc36a 937 arch_srcs += config_devices_h[target]
64ed6f92 938 link_args += ['@block.syms', '@qemu.syms']
2becc36a 939 else
3a30446a 940 abi = config_target['TARGET_ABI_DIR']
2becc36a
PB
941 target_type='user'
942 qemu_target_name = 'qemu-' + target_name
943 if 'CONFIG_LINUX_USER' in config_target
944 base_dir = 'linux-user'
945 target_inc += include_directories('linux-user/host/' / config_host['ARCH'])
946 else
947 base_dir = 'bsd-user'
948 endif
949 target_inc += include_directories(
950 base_dir,
3a30446a 951 base_dir / abi,
2becc36a 952 )
3a30446a
MAL
953 if 'CONFIG_LINUX_USER' in config_target
954 dir = base_dir / abi
955 arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c')
956 if config_target.has_key('TARGET_SYSTBL_ABI')
957 arch_srcs += \
958 syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'],
959 extra_args : config_target['TARGET_SYSTBL_ABI'])
960 endif
961 endif
2becc36a
PB
962 endif
963
c9322ab5
MAL
964 if 'TARGET_XML_FILES' in config_target
965 gdbstub_xml = custom_target(target + '-gdbstub-xml.c',
966 output: target + '-gdbstub-xml.c',
967 input: files(config_target['TARGET_XML_FILES'].split()),
968 command: [feature_to_c, '@INPUT@'],
969 capture: true)
970 arch_srcs += gdbstub_xml
971 endif
972
abff1abf
PB
973 t = target_arch[arch].apply(config_target, strict: false)
974 arch_srcs += t.sources()
64ed6f92 975 arch_deps += t.dependencies()
abff1abf 976
2becc36a
PB
977 target_common = common_ss.apply(config_target, strict: false)
978 objects = common_all.extract_objects(target_common.sources())
64ed6f92 979 deps = target_common.dependencies()
2becc36a 980
2becc36a
PB
981 target_specific = specific_ss.apply(config_target, strict: false)
982 arch_srcs += target_specific.sources()
64ed6f92 983 arch_deps += target_specific.dependencies()
2becc36a 984
64ed6f92 985 lib = static_library('qemu-' + target,
859aef02 986 sources: arch_srcs + genh,
b7612f45 987 dependencies: arch_deps,
2becc36a
PB
988 objects: objects,
989 include_directories: target_inc,
64ed6f92
PB
990 c_args: c_args,
991 build_by_default: false,
2becc36a 992 name_suffix: 'fa')
64ed6f92
PB
993
994 if target.endswith('-softmmu')
995 execs = [{
996 'name': 'qemu-system-' + target_name,
997 'gui': false,
998 'sources': files('softmmu/main.c'),
999 'dependencies': []
1000 }]
35be72ba 1001 if targetos == 'windows' and (sdl.found() or gtk.found())
64ed6f92
PB
1002 execs += [{
1003 'name': 'qemu-system-' + target_name + 'w',
1004 'gui': true,
1005 'sources': files('softmmu/main.c'),
1006 'dependencies': []
1007 }]
1008 endif
1009 if config_host.has_key('CONFIG_FUZZ')
1010 specific_fuzz = specific_fuzz_ss.apply(config_target, strict: false)
1011 execs += [{
1012 'name': 'qemu-fuzz-' + target_name,
1013 'gui': false,
1014 'sources': specific_fuzz.sources(),
1015 'dependencies': specific_fuzz.dependencies(),
1016 'link_depends': [files('tests/qtest/fuzz/fork_fuzz.ld')],
1017 }]
1018 endif
1019 else
1020 execs = [{
1021 'name': 'qemu-' + target_name,
1022 'gui': false,
1023 'sources': [],
1024 'dependencies': []
1025 }]
1026 endif
1027 foreach exe: execs
1028 emulators += executable(exe['name'], exe['sources'],
1029 install: true,
1030 c_args: c_args,
1031 dependencies: arch_deps + deps + exe['dependencies'],
1032 objects: lib.extract_all_objects(recursive: true),
1033 link_language: link_language,
1034 link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
1035 link_args: link_args,
1036 gui_app: exe['gui'])
10e1d263
MAL
1037
1038 if 'CONFIG_TRACE_SYSTEMTAP' in config_host
1039 foreach stp: [
bd5f973a
SH
1040 {'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / exe['name'], 'install': false},
1041 {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / get_option('bindir') / exe['name'], 'install': true},
10e1d263
MAL
1042 {'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 'install': true},
1043 {'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true},
1044 ]
bd5f973a 1045 custom_target(exe['name'] + stp['ext'],
10e1d263 1046 input: trace_events_all,
bd5f973a 1047 output: exe['name'] + stp['ext'],
10e1d263
MAL
1048 capture: true,
1049 install: stp['install'],
1050 install_dir: config_host['qemu_datadir'] / '../systemtap/tapset',
1051 command: [
1052 tracetool, '--group=all', '--format=' + stp['fmt'],
1053 '--binary=' + stp['bin'],
1054 '--target-name=' + target_name,
1055 '--target-type=' + target_type,
1056 '--probe-prefix=qemu.' + target_type + '.' + target_name,
1057 '@INPUT@',
1058 ])
1059 endforeach
1060 endif
64ed6f92 1061 endforeach
2becc36a
PB
1062endforeach
1063
931049b4 1064# Other build targets
897b5afa 1065
f556b4a1
PB
1066if 'CONFIG_PLUGIN' in config_host
1067 install_headers('include/qemu/qemu-plugin.h')
1068endif
1069
f15bff25
PB
1070if 'CONFIG_GUEST_AGENT' in config_host
1071 subdir('qga')
1072endif
1073
9755c94a
LV
1074# Don't build qemu-keymap if xkbcommon is not explicitly enabled
1075# when we don't build tools or system
1076if get_option('xkbcommon').auto() and not have_system and not have_tools
1077 xkbcommon = not_found
1078endif
4113f4cf 1079if xkbcommon.found()
28742467
MAL
1080 # used for the update-keymaps target, so include rules even if !have_tools
1081 qemu_keymap = executable('qemu-keymap', files('qemu-keymap.c', 'ui/input-keymap.c') + genh,
1082 dependencies: [qemuutil, xkbcommon], install: have_tools)
1083endif
1084
8855e8f0 1085qemu_block_tools = []
931049b4 1086if have_tools
b7c70bf2
MAL
1087 qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
1088 dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
1089 qemu_io = executable('qemu-io', files('qemu-io.c'),
1090 dependencies: [block, qemuutil], install: true)
8855e8f0 1091 qemu_block_tools += [qemu_img, qemu_io]
5f7e966b 1092 if targetos != 'windows'
b7c70bf2
MAL
1093 qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
1094 dependencies: [block, qemuutil], install: true)
d3ca592b 1095 qemu_block_tools += [qemu_nbd]
b7c70bf2
MAL
1096 endif
1097
7c58bb76 1098 subdir('storage-daemon')
a9c9727c 1099 subdir('contrib/rdmacm-mux')
1d7bb6ab 1100 subdir('contrib/elf2dmp')
a9c9727c 1101
157e7b13
MAL
1102 executable('qemu-edid', files('qemu-edid.c', 'hw/display/edid-generate.c'),
1103 dependencies: qemuutil,
1104 install: true)
1105
931049b4
PB
1106 if 'CONFIG_VHOST_USER' in config_host
1107 subdir('contrib/libvhost-user')
2d7ac0af 1108 subdir('contrib/vhost-user-blk')
b7612f45 1109 subdir('contrib/vhost-user-gpu')
32fcc624 1110 subdir('contrib/vhost-user-input')
99650b62 1111 subdir('contrib/vhost-user-scsi')
931049b4 1112 endif
8f51e01c
MAL
1113
1114 if targetos == 'linux'
1115 executable('qemu-bridge-helper', files('qemu-bridge-helper.c'),
1116 dependencies: [qemuutil, libcap_ng],
1117 install: true,
1118 install_dir: get_option('libexecdir'))
897b5afa
MAL
1119
1120 executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'),
1121 dependencies: [authz, crypto, io, qom, qemuutil,
1122 libcap_ng, libudev, libmpathpersist],
1123 install: true)
8f51e01c
MAL
1124 endif
1125
5ee24e78
MAL
1126 if 'CONFIG_IVSHMEM' in config_host
1127 subdir('contrib/ivshmem-client')
1128 subdir('contrib/ivshmem-server')
1129 endif
931049b4
PB
1130endif
1131
3f99cf57 1132subdir('tools')
bdcbea7a 1133subdir('pc-bios')
ce1c1e7a 1134subdir('tests')
f8aa24ea 1135subdir('docs')
e8f3bd71
MAL
1136if 'CONFIG_GTK' in config_host
1137 subdir('po')
1138endif
3f99cf57 1139
acfdaac5
PB
1140if build_docs
1141 makeinfo = find_program('makeinfo', required: build_docs)
1142
1143 docs_inc = [
1144 '-I', meson.current_source_dir(),
1145 '-I', meson.current_build_dir() / 'docs',
1146 '-I', '@OUTDIR@',
1147 ]
1148
1149 version_texi = configure_file(output: 'version.texi',
1150 input: 'version.texi.in',
1151 configuration: {'VERSION': meson.project_version(),
1152 'qemu_confdir': config_host['qemu_confdir']})
1153
1154 texi = {
1155 'qemu-qmp-ref': ['docs/interop/qemu-qmp-ref.texi', qapi_doc_texi, version_texi],
1156 }
1157 if 'CONFIG_GUEST_AGENT' in config_host
1158 texi += {'qemu-ga-ref': ['docs/interop/qemu-ga-ref.texi', qga_qapi_doc_texi, version_texi]}
1159 endif
1160
1161 if makeinfo.found()
1162 cmd = [
1163 'env', 'LC_ALL=C', makeinfo, '--no-split', '--number-sections', docs_inc,
1164 '@INPUT0@', '-o', '@OUTPUT@',
1165 ]
1166 foreach ext, args: {
1167 'info': [],
1168 'html': ['--no-headers', '--html'],
1169 'txt': ['--no-headers', '--plaintext'],
1170 }
1171 t = []
1172 foreach doc, input: texi
1173 output = doc + '.' + ext
1174 t += custom_target(output,
1175 input: input,
1176 output: output,
1177 install: true,
1178 install_dir: config_host['qemu_docdir'] / 'interop',
1179 command: cmd + args)
1180 endforeach
1181 alias_target(ext, t)
1182 endforeach
1183 endif
1184
1185 texi2pdf = find_program('texi2pdf', required: false)
1186
1187 if texi2pdf.found()
1188 pdfs = []
1189 foreach doc, input: texi
1190 output = doc + '.pdf'
1191 pdfs += custom_target(output,
1192 input: input,
1193 output: output,
1194 command: [texi2pdf, '-q', docs_inc, '@INPUT0@', '-o', '@OUTPUT@'],
1195 build_by_default: false)
1196 endforeach
1197 alias_target('pdf', pdfs)
1198 endif
1199
1200 texi2pod = find_program('scripts/texi2pod.pl')
1201 pod2man = find_program('pod2man', required: build_docs)
1202
1203 if pod2man.found()
1204 foreach doc, input: texi
1205 man = doc + '.7'
1206 pod = custom_target(man + '.pod',
1207 input: input,
1208 output: man + '.pod',
1209 command: [texi2pod,
1210 '-DVERSION="' + meson.project_version() + '"',
1211 '-DCONFDIR="' + config_host['qemu_confdir'] + '"',
1212 '@INPUT0@', '@OUTPUT@'])
1213 man = custom_target(man,
1214 input: pod,
1215 output: man,
1216 capture: true,
1217 install: true,
1218 install_dir: config_host['mandir'] / 'man7',
1219 command: [pod2man, '--utf8', '--section=7', '--center=" "',
1220 '--release=" "', '@INPUT@'])
1221 endforeach
1222 endif
1223endif
1224
f9332757
PB
1225summary_info = {}
1226summary_info += {'Install prefix': config_host['prefix']}
1227summary_info += {'BIOS directory': config_host['qemu_datadir']}
1228summary_info += {'firmware path': config_host['qemu_firmwarepath']}
1229summary_info += {'binary directory': config_host['bindir']}
1230summary_info += {'library directory': config_host['libdir']}
1231summary_info += {'module directory': config_host['qemu_moddir']}
1232summary_info += {'libexec directory': config_host['libexecdir']}
1233summary_info += {'include directory': config_host['includedir']}
1234summary_info += {'config directory': config_host['sysconfdir']}
1235if targetos != 'windows'
1236 summary_info += {'local state directory': config_host['qemu_localstatedir']}
1237 summary_info += {'Manual directory': config_host['mandir']}
1238else
1239 summary_info += {'local state directory': 'queried at runtime'}
1240endif
1241summary_info += {'Build directory': meson.current_build_dir()}
1242summary_info += {'Source path': meson.current_source_dir()}
1243summary_info += {'GIT binary': config_host['GIT']}
1244summary_info += {'GIT submodules': config_host['GIT_SUBMODULES']}
1245summary_info += {'C compiler': meson.get_compiler('c').cmd_array()[0]}
1246summary_info += {'Host C compiler': meson.get_compiler('c', native: true).cmd_array()[0]}
1247if link_language == 'cpp'
1248 summary_info += {'C++ compiler': meson.get_compiler('cpp').cmd_array()[0]}
1249else
1250 summary_info += {'C++ compiler': false}
1251endif
1252if targetos == 'darwin'
1253 summary_info += {'Objective-C compiler': meson.get_compiler('objc').cmd_array()[0]}
1254endif
1255summary_info += {'ARFLAGS': config_host['ARFLAGS']}
1256summary_info += {'CFLAGS': config_host['CFLAGS']}
1257summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']}
1258summary_info += {'QEMU_LDFLAGS': config_host['QEMU_LDFLAGS']}
1259summary_info += {'make': config_host['MAKE']}
1260summary_info += {'install': config_host['INSTALL']}
1261summary_info += {'python': '@0@ (version: @1@)'.format(python.full_path(), python.language_version())}
1262summary_info += {'sphinx-build': config_host['SPHINX_BUILD']}
1263summary_info += {'genisoimage': config_host['GENISOIMAGE']}
1264# TODO: add back version
1265summary_info += {'slirp support': config_host.has_key('CONFIG_SLIRP')}
1266if config_host.has_key('CONFIG_SLIRP')
1267 summary_info += {'smbd': config_host['CONFIG_SMBD_COMMAND']}
1268endif
1269summary_info += {'module support': config_host.has_key('CONFIG_MODULES')}
1270if config_host.has_key('CONFIG_MODULES')
1271 summary_info += {'alternative module path': config_host.has_key('CONFIG_MODULE_UPGRADES')}
1272endif
1273summary_info += {'host CPU': cpu}
1274summary_info += {'host endianness': build_machine.endian()}
1275summary_info += {'target list': config_host['TARGET_DIRS']}
1276summary_info += {'gprof enabled': config_host.has_key('CONFIG_GPROF')}
1277summary_info += {'sparse enabled': meson.get_compiler('c').cmd_array().contains('cgcc')}
1278summary_info += {'strip binaries': get_option('strip')}
1279summary_info += {'profiler': config_host.has_key('CONFIG_PROFILER')}
1280summary_info += {'static build': config_host.has_key('CONFIG_TOOLS')}
1281if targetos == 'darwin'
1282 summary_info += {'Cocoa support': config_host.has_key('CONFIG_COCOA')}
1283endif
1284# TODO: add back version
35be72ba
PB
1285summary_info += {'SDL support': sdl.found()}
1286summary_info += {'SDL image support': sdl_image.found()}
f9332757
PB
1287# TODO: add back version
1288summary_info += {'GTK support': config_host.has_key('CONFIG_GTK')}
1289summary_info += {'GTK GL support': config_host.has_key('CONFIG_GTK_GL')}
b7612f45 1290summary_info += {'pixman': pixman.found()}
f9332757
PB
1291# TODO: add back version
1292summary_info += {'VTE support': config_host.has_key('CONFIG_VTE')}
1293summary_info += {'TLS priority': config_host['CONFIG_TLS_PRIORITY']}
1294summary_info += {'GNUTLS support': config_host.has_key('CONFIG_GNUTLS')}
1295# TODO: add back version
1296summary_info += {'libgcrypt': config_host.has_key('CONFIG_GCRYPT')}
1297if config_host.has_key('CONFIG_GCRYPT')
1298 summary_info += {' hmac': config_host.has_key('CONFIG_GCRYPT_HMAC')}
1299 summary_info += {' XTS': not config_host.has_key('CONFIG_QEMU_PRIVATE_XTS')}
1300endif
1301# TODO: add back version
1302summary_info += {'nettle': config_host.has_key('CONFIG_NETTLE')}
1303if config_host.has_key('CONFIG_NETTLE')
1304 summary_info += {' XTS': not config_host.has_key('CONFIG_QEMU_PRIVATE_XTS')}
1305endif
1306summary_info += {'libtasn1': config_host.has_key('CONFIG_TASN1')}
1307summary_info += {'PAM': config_host.has_key('CONFIG_AUTH_PAM')}
1308summary_info += {'iconv support': config_host.has_key('CONFIG_ICONV')}
1309summary_info += {'curses support': config_host.has_key('CONFIG_CURSES')}
1310# TODO: add back version
1311summary_info += {'virgl support': config_host.has_key('CONFIG_VIRGL')}
1312summary_info += {'curl support': config_host.has_key('CONFIG_CURL')}
1313summary_info += {'mingw32 support': targetos == 'windows'}
1314summary_info += {'Audio drivers': config_host['CONFIG_AUDIO_DRIVERS']}
1315summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
1316summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']}
1317summary_info += {'VirtFS support': config_host.has_key('CONFIG_VIRTFS')}
1318summary_info += {'Multipath support': config_host.has_key('CONFIG_MPATH')}
a0b93237
PB
1319summary_info += {'VNC support': vnc.found()}
1320if vnc.found()
1321 summary_info += {'VNC SASL support': sasl.found()}
1322 summary_info += {'VNC JPEG support': jpeg.found()}
1323 summary_info += {'VNC PNG support': png.found()}
f9332757
PB
1324endif
1325summary_info += {'xen support': config_host.has_key('CONFIG_XEN_BACKEND')}
1326if config_host.has_key('CONFIG_XEN_BACKEND')
1327 summary_info += {'xen ctrl version': config_host['CONFIG_XEN_CTRL_INTERFACE_VERSION']}
1328endif
1329summary_info += {'brlapi support': config_host.has_key('CONFIG_BRLAPI')}
1330summary_info += {'Documentation': config_host.has_key('BUILD_DOCS')}
1331summary_info += {'PIE': get_option('b_pie')}
1332summary_info += {'vde support': config_host.has_key('CONFIG_VDE')}
1333summary_info += {'netmap support': config_host.has_key('CONFIG_NETMAP')}
1334summary_info += {'Linux AIO support': config_host.has_key('CONFIG_LINUX_AIO')}
1335summary_info += {'Linux io_uring support': config_host.has_key('CONFIG_LINUX_IO_URING')}
1336summary_info += {'ATTR/XATTR support': config_host.has_key('CONFIG_ATTR')}
1337summary_info += {'Install blobs': config_host.has_key('INSTALL_BLOBS')}
1338# TODO: add back KVM/HAX/HVF/WHPX/TCG
1339#summary_info += {'KVM support': have_kvm'}
1340#summary_info += {'HAX support': have_hax'}
1341#summary_info += {'HVF support': have_hvf'}
1342#summary_info += {'WHPX support': have_whpx'}
1343#summary_info += {'TCG support': have_tcg'}
1344#if get_option('tcg')
1345# summary_info += {'TCG debug enabled': config_host.has_key('CONFIG_DEBUG_TCG')}
1346# summary_info += {'TCG interpreter': config_host.has_key('CONFIG_TCG_INTERPRETER')}
1347#endif
1348summary_info += {'malloc trim support': config_host.has_key('CONFIG_MALLOC_TRIM')}
1349summary_info += {'RDMA support': config_host.has_key('CONFIG_RDMA')}
1350summary_info += {'PVRDMA support': config_host.has_key('CONFIG_PVRDMA')}
1351summary_info += {'fdt support': config_host.has_key('CONFIG_FDT')}
1352summary_info += {'membarrier': config_host.has_key('CONFIG_MEMBARRIER')}
1353summary_info += {'preadv support': config_host.has_key('CONFIG_PREADV')}
1354summary_info += {'fdatasync': config_host.has_key('CONFIG_FDATASYNC')}
1355summary_info += {'madvise': config_host.has_key('CONFIG_MADVISE')}
1356summary_info += {'posix_madvise': config_host.has_key('CONFIG_POSIX_MADVISE')}
1357summary_info += {'posix_memalign': config_host.has_key('CONFIG_POSIX_MEMALIGN')}
1358summary_info += {'libcap-ng support': config_host.has_key('CONFIG_LIBCAP_NG')}
1359summary_info += {'vhost-net support': config_host.has_key('CONFIG_VHOST_NET')}
1360summary_info += {'vhost-crypto support': config_host.has_key('CONFIG_VHOST_CRYPTO')}
1361summary_info += {'vhost-scsi support': config_host.has_key('CONFIG_VHOST_SCSI')}
1362summary_info += {'vhost-vsock support': config_host.has_key('CONFIG_VHOST_VSOCK')}
1363summary_info += {'vhost-user support': config_host.has_key('CONFIG_VHOST_KERNEL')}
1364summary_info += {'vhost-user-fs support': config_host.has_key('CONFIG_VHOST_USER_FS')}
1365summary_info += {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST_VDPA')}
1366summary_info += {'Trace backends': config_host['TRACE_BACKENDS']}
1367if config_host['TRACE_BACKENDS'].split().contains('simple')
1368 summary_info += {'Trace output file': config_host['CONFIG_TRACE_FILE'] + '-<pid>'}
1369endif
1370# TODO: add back protocol and server version
1371summary_info += {'spice support': config_host.has_key('CONFIG_SPICE')}
1372summary_info += {'rbd support': config_host.has_key('CONFIG_RBD')}
1373summary_info += {'xfsctl support': config_host.has_key('CONFIG_XFS')}
1374summary_info += {'smartcard support': config_host.has_key('CONFIG_SMARTCARD')}
1375summary_info += {'libusb': config_host.has_key('CONFIG_USB_LIBUSB')}
1376summary_info += {'usb net redir': config_host.has_key('CONFIG_USB_REDIR')}
1377summary_info += {'OpenGL support': config_host.has_key('CONFIG_OPENGL')}
1378summary_info += {'OpenGL dmabufs': config_host.has_key('CONFIG_OPENGL_DMABUF')}
1379summary_info += {'libiscsi support': config_host.has_key('CONFIG_LIBISCSI')}
1380summary_info += {'libnfs support': config_host.has_key('CONFIG_LIBNFS')}
1381summary_info += {'build guest agent': config_host.has_key('CONFIG_GUEST_AGENT')}
1382if targetos == 'windows'
1383 if 'WIN_SDK' in config_host
1384 summary_info += {'Windows SDK': config_host['WIN_SDK']}
1385 endif
1386 summary_info += {'QGA VSS support': config_host.has_key('CONFIG_QGA_VSS')}
1387 summary_info += {'QGA w32 disk info': config_host.has_key('CONFIG_QGA_NTDDSCSI')}
1388 summary_info += {'QGA MSI support': config_host.has_key('CONFIG_QGA_MSI_ENABLED')}
1389endif
1390summary_info += {'seccomp support': config_host.has_key('CONFIG_SECCOMP')}
1391summary_info += {'coroutine backend': config_host['CONFIG_COROUTINE_BACKEND']}
1392summary_info += {'coroutine pool': config_host['CONFIG_COROUTINE_POOL'] == '1'}
1393summary_info += {'debug stack usage': config_host.has_key('CONFIG_DEBUG_STACK_USAGE')}
1394summary_info += {'mutex debugging': config_host.has_key('CONFIG_DEBUG_MUTEX')}
1395summary_info += {'crypto afalg': config_host.has_key('CONFIG_AF_ALG')}
1396summary_info += {'GlusterFS support': config_host.has_key('CONFIG_GLUSTERFS')}
bf0e56a3 1397summary_info += {'gcov': get_option('b_coverage')}
f9332757
PB
1398summary_info += {'TPM support': config_host.has_key('CONFIG_TPM')}
1399summary_info += {'libssh support': config_host.has_key('CONFIG_LIBSSH')}
1400summary_info += {'QOM debugging': config_host.has_key('CONFIG_QOM_CAST_DEBUG')}
1401summary_info += {'Live block migration': config_host.has_key('CONFIG_LIVE_BLOCK_MIGRATION')}
1402summary_info += {'lzo support': config_host.has_key('CONFIG_LZO')}
1403summary_info += {'snappy support': config_host.has_key('CONFIG_SNAPPY')}
1404summary_info += {'bzip2 support': config_host.has_key('CONFIG_BZIP2')}
1405summary_info += {'lzfse support': config_host.has_key('CONFIG_LZFSE')}
1406summary_info += {'zstd support': config_host.has_key('CONFIG_ZSTD')}
1407summary_info += {'NUMA host support': config_host.has_key('CONFIG_NUMA')}
1408summary_info += {'libxml2': config_host.has_key('CONFIG_LIBXML2')}
1409summary_info += {'tcmalloc support': config_host.has_key('CONFIG_TCMALLOC')}
1410summary_info += {'jemalloc support': config_host.has_key('CONFIG_JEMALLOC')}
1411summary_info += {'avx2 optimization': config_host.has_key('CONFIG_AVX2_OPT')}
1412summary_info += {'avx512f optimization': config_host.has_key('CONFIG_AVX512F_OPT')}
1413summary_info += {'replication support': config_host.has_key('CONFIG_REPLICATION')}
1414summary_info += {'bochs support': config_host.has_key('CONFIG_BOCHS')}
1415summary_info += {'cloop support': config_host.has_key('CONFIG_CLOOP')}
1416summary_info += {'dmg support': config_host.has_key('CONFIG_DMG')}
1417summary_info += {'qcow v1 support': config_host.has_key('CONFIG_QCOW1')}
1418summary_info += {'vdi support': config_host.has_key('CONFIG_VDI')}
1419summary_info += {'vvfat support': config_host.has_key('CONFIG_VVFAT')}
1420summary_info += {'qed support': config_host.has_key('CONFIG_QED')}
1421summary_info += {'parallels support': config_host.has_key('CONFIG_PARALLELS')}
1422summary_info += {'sheepdog support': config_host.has_key('CONFIG_SHEEPDOG')}
1423summary_info += {'capstone': config_host.has_key('CONFIG_CAPSTONE')}
1424summary_info += {'libpmem support': config_host.has_key('CONFIG_LIBPMEM')}
1425summary_info += {'libdaxctl support': config_host.has_key('CONFIG_LIBDAXCTL')}
1426summary_info += {'libudev': config_host.has_key('CONFIG_LIBUDEV')}
1427summary_info += {'default devices': config_host['CONFIG_MINIKCONF_MODE'] == '--defconfig'}
1428summary_info += {'plugin support': config_host.has_key('CONFIG_PLUGIN')}
1429summary_info += {'fuzzing support': config_host.has_key('CONFIG_FUZZ')}
1430if config_host.has_key('HAVE_GDB_BIN')
1431 summary_info += {'gdb': config_host['HAVE_GDB_BIN']}
1432endif
1433summary_info += {'thread sanitizer': config_host.has_key('CONFIG_TSAN')}
1434summary_info += {'rng-none': config_host.has_key('CONFIG_RNG_NONE')}
1435summary_info += {'Linux keyring': config_host.has_key('CONFIG_SECRET_KEYRING')}
1436summary(summary_info, bool_yn: true)
1437
1438if not supported_cpus.contains(cpu)
1439 message()
1440 warning('SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!')
1441 message()
1442 message('CPU host architecture ' + cpu + ' support is not currently maintained.')
1443 message('The QEMU project intends to remove support for this host CPU in')
1444 message('a future release if nobody volunteers to maintain it and to')
1445 message('provide a build host for our continuous integration setup.')
1446 message('configure has succeeded and you can continue to build, but')
1447 message('if you care about QEMU on this platform you should contact')
1448 message('us upstream at qemu-devel@nongnu.org.')
1449endif
1450
1451if not supported_oses.contains(targetos)
1452 message()
1453 warning('WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!')
1454 message()
1455 message('Host OS ' + targetos + 'support is not currently maintained.')
1456 message('The QEMU project intends to remove support for this host OS in')
1457 message('a future release if nobody volunteers to maintain it and to')
1458 message('provide a build host for our continuous integration setup.')
1459 message('configure has succeeded and you can continue to build, but')
1460 message('if you care about QEMU on this platform you should contact')
1461 message('us upstream at qemu-devel@nongnu.org.')
1462endif