]> Git Repo - qemu.git/blame - meson.build
seccomp: convert to meson
[qemu.git] / meson.build
CommitLineData
a5665051 1project('qemu', ['c'], meson_version: '>=0.55.0',
a5cb7c5a
PB
2 default_options: ['warning_level=1', 'c_std=gnu99', 'cpp_std=gnu++11', 'b_colorout=auto'] +
3 (meson.version().version_compare('>=0.56.0') ? [ 'b_staticpic=false' ] : []),
a5665051
PB
4 version: run_command('head', meson.source_root() / 'VERSION').stdout().strip())
5
6not_found = dependency('', required: false)
b29b40f4
PB
7if meson.version().version_compare('>=0.56.0')
8 keyval = import('keyval')
9else
10 keyval = import('unstable-keyval')
11endif
a81df1b6 12ss = import('sourceset')
8b18cdbf 13fs = import('fs')
a81df1b6 14
ce1c1e7a 15sh = find_program('sh')
a81df1b6 16cc = meson.get_compiler('c')
a5665051 17config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
3154fee4 18enable_modules = 'CONFIG_MODULES' in config_host
35be72ba 19enable_static = 'CONFIG_STATIC' in config_host
e3667660
YL
20
21# Temporary directory used for files created while
22# configure runs. Since it is in the build directory
23# we can safely blow away any previous version of it
24# (and we need not jump through hoops to try to delete
25# it when configure exits.)
26tmpdir = meson.current_build_dir() / 'meson-private/temp'
8fe11232
MAL
27
28if get_option('qemu_suffix').startswith('/')
29 error('qemu_suffix cannot start with a /')
30endif
31
16bf7a33 32qemu_confdir = get_option('sysconfdir') / get_option('qemu_suffix')
ab4c0996 33qemu_datadir = get_option('datadir') / get_option('qemu_suffix')
491e74c1 34qemu_docdir = get_option('docdir') / get_option('qemu_suffix')
16bf7a33
PB
35qemu_moddir = get_option('libdir') / get_option('qemu_suffix')
36
37qemu_desktopdir = get_option('datadir') / 'applications'
38qemu_icondir = get_option('datadir') / 'icons'
39
859aef02
PB
40config_host_data = configuration_data()
41genh = []
a5665051 42
760e4327
PB
43target_dirs = config_host['TARGET_DIRS'].split()
44have_user = false
45have_system = false
46foreach target : target_dirs
47 have_user = have_user or target.endswith('-user')
48 have_system = have_system or target.endswith('-softmmu')
49endforeach
50have_tools = 'CONFIG_TOOLS' in config_host
51have_block = have_system or have_tools
52
201e8ed7
PB
53python = import('python').find_installation()
54
55supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
6125673e 56supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64',
201e8ed7
PB
57 'arm', 'aarch64', 'mips', 'mips64', 'sparc', 'sparc64']
58
59cpu = host_machine.cpu_family()
60targetos = host_machine.system()
61
8a19980e
PB
62if cpu in ['x86', 'x86_64']
63 kvm_targets = ['i386-softmmu', 'x86_64-softmmu']
64elif cpu == 'aarch64'
65 kvm_targets = ['aarch64-softmmu']
66elif cpu == 's390x'
67 kvm_targets = ['s390x-softmmu']
68elif cpu in ['ppc', 'ppc64']
69 kvm_targets = ['ppc-softmmu', 'ppc64-softmmu']
fbc5884c
HC
70elif cpu in ['mips', 'mips64']
71 kvm_targets = ['mips-softmmu', 'mipsel-softmmu', 'mips64-softmmu', 'mips64el-softmmu']
8a19980e
PB
72else
73 kvm_targets = []
74endif
75
76accelerator_targets = { 'CONFIG_KVM': kvm_targets }
0c3e41d4
AB
77if cpu in ['x86', 'x86_64', 'arm', 'aarch64']
78 # i368 emulator provides xenpv machine type for multiple architectures
79 accelerator_targets += {
80 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'],
81 }
82endif
8a19980e
PB
83if cpu in ['x86', 'x86_64']
84 accelerator_targets += {
85 'CONFIG_HAX': ['i386-softmmu', 'x86_64-softmmu'],
8a19980e
PB
86 'CONFIG_HVF': ['x86_64-softmmu'],
87 'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
88 }
89endif
90
201e8ed7
PB
91##################
92# Compiler flags #
93##################
94
ff9ed62b
AB
95# Specify linker-script with add_project_link_arguments so that it is not placed
96# within a linker --start-group/--end-group pair
97if 'CONFIG_FUZZ' in config_host
98 add_project_link_arguments(['-Wl,-T,',
99 (meson.current_source_dir() / 'tests/qtest/fuzz/fork_fuzz.ld')],
100 native: false, language: ['c', 'cpp', 'objc'])
101endif
102
a5665051
PB
103add_project_arguments(config_host['QEMU_CFLAGS'].split(),
104 native: false, language: ['c', 'objc'])
105add_project_arguments(config_host['QEMU_CXXFLAGS'].split(),
106 native: false, language: 'cpp')
107add_project_link_arguments(config_host['QEMU_LDFLAGS'].split(),
108 native: false, language: ['c', 'cpp', 'objc'])
a5665051 109
1e6e616d
PB
110if targetos == 'linux'
111 add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',
112 '-isystem', 'linux-headers',
113 language: ['c', 'cpp'])
114endif
115
116if 'CONFIG_TCG_INTERPRETER' in config_host
117 tcg_arch = 'tci'
118elif config_host['ARCH'] == 'sparc64'
119 tcg_arch = 'sparc'
120elif config_host['ARCH'] == 's390x'
121 tcg_arch = 's390'
122elif config_host['ARCH'] in ['x86_64', 'x32']
123 tcg_arch = 'i386'
124elif config_host['ARCH'] == 'ppc64'
125 tcg_arch = 'ppc'
126elif config_host['ARCH'] in ['riscv32', 'riscv64']
127 tcg_arch = 'riscv'
128else
129 tcg_arch = config_host['ARCH']
130endif
131add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch,
132 '-iquote', '.',
133 '-iquote', meson.current_source_dir(),
134 '-iquote', meson.current_source_dir() / 'accel/tcg',
135 '-iquote', meson.current_source_dir() / 'include',
136 '-iquote', meson.current_source_dir() / 'disas/libvixl',
137 language: ['c', 'cpp', 'objc'])
c46f76d1 138
fc929892
MAL
139link_language = meson.get_external_property('link_language', 'cpp')
140if link_language == 'cpp'
141 add_languages('cpp', required: true, native: false)
142endif
a5665051
PB
143if host_machine.system() == 'darwin'
144 add_languages('objc', required: false, native: false)
145endif
146
deb62371
PB
147sparse = find_program('cgcc', required: get_option('sparse'))
148if sparse.found()
968b4db3
PB
149 run_target('sparse',
150 command: [find_program('scripts/check_sparse.py'),
deb62371
PB
151 'compile_commands.json', sparse.full_path(), '-Wbitwise',
152 '-Wno-transparent-union', '-Wno-old-initializer',
153 '-Wno-non-pointer-null'])
968b4db3
PB
154endif
155
6ec0e15d
PB
156###########################################
157# Target-specific checks and dependencies #
158###########################################
159
160if targetos != 'linux' and get_option('mpath').enabled()
161 error('Multipath is supported only on Linux')
162endif
163
a81df1b6
PB
164m = cc.find_library('m', required: false)
165util = cc.find_library('util', required: false)
4a96337d 166winmm = []
a81df1b6 167socket = []
04c6f1e7 168version_res = []
d92989aa
MAL
169coref = []
170iokit = []
b6c7cfd4 171emulator_link_args = []
b4e312e9 172cocoa = not_found
8a19980e 173hvf = not_found
a81df1b6
PB
174if targetos == 'windows'
175 socket = cc.find_library('ws2_32')
4a96337d 176 winmm = cc.find_library('winmm')
04c6f1e7
MAL
177
178 win = import('windows')
179 version_res = win.compile_resources('version.rc',
180 depend_files: files('pc-bios/qemu-nsis.ico'),
181 include_directories: include_directories('.'))
d92989aa
MAL
182elif targetos == 'darwin'
183 coref = dependency('appleframeworks', modules: 'CoreFoundation')
184 iokit = dependency('appleframeworks', modules: 'IOKit')
b4e312e9 185 cocoa = dependency('appleframeworks', modules: 'Cocoa', required: get_option('cocoa'))
cfad62f1
PB
186elif targetos == 'sunos'
187 socket = [cc.find_library('socket'),
188 cc.find_library('nsl'),
189 cc.find_library('resolv')]
190elif targetos == 'haiku'
191 socket = [cc.find_library('posix_error_mapper'),
192 cc.find_library('network'),
193 cc.find_library('bsd')]
b6c7cfd4
PB
194elif targetos == 'openbsd'
195 if not get_option('tcg').disabled() and target_dirs.length() > 0
196 # Disable OpenBSD W^X if available
197 emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
198 endif
a81df1b6 199endif
6ec0e15d 200
8a19980e
PB
201accelerators = []
202if not get_option('kvm').disabled() and targetos == 'linux'
203 accelerators += 'CONFIG_KVM'
204endif
205if not get_option('xen').disabled() and 'CONFIG_XEN_BACKEND' in config_host
206 accelerators += 'CONFIG_XEN'
207 have_xen_pci_passthrough = not get_option('xen_pci_passthrough').disabled() and targetos == 'linux'
208else
209 have_xen_pci_passthrough = false
210endif
211if not get_option('whpx').disabled() and targetos == 'windows'
57e2a1f8 212 if get_option('whpx').enabled() and host_machine.cpu() != 'x86_64'
8a19980e
PB
213 error('WHPX requires 64-bit host')
214 elif cc.has_header('WinHvPlatform.h', required: get_option('whpx')) and \
215 cc.has_header('WinHvEmulation.h', required: get_option('whpx'))
216 accelerators += 'CONFIG_WHPX'
217 endif
218endif
219if not get_option('hvf').disabled()
220 hvf = dependency('appleframeworks', modules: 'Hypervisor',
221 required: get_option('hvf'))
222 if hvf.found()
223 accelerators += 'CONFIG_HVF'
224 endif
225endif
226if not get_option('hax').disabled()
227 if get_option('hax').enabled() or targetos in ['windows', 'darwin', 'netbsd']
228 accelerators += 'CONFIG_HAX'
229 endif
230endif
231if not get_option('tcg').disabled()
232 if cpu not in supported_cpus
233 if 'CONFIG_TCG_INTERPRETER' in config_host
234 warning('Unsupported CPU @0@, will use TCG with TCI (experimental)'.format(cpu))
235 else
236 error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
237 endif
238 endif
239 accelerators += 'CONFIG_TCG'
240 config_host += { 'CONFIG_TCG': 'y' }
241endif
242
243if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled()
244 error('KVM not available on this platform')
245endif
246if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled()
247 error('HVF not available on this platform')
248endif
249if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
250 error('WHPX not available on this platform')
251endif
252if not have_xen_pci_passthrough and get_option('xen_pci_passthrough').enabled()
253 if 'CONFIG_XEN' in accelerators
254 error('Xen PCI passthrough not available on this platform')
255 else
256 error('Xen PCI passthrough requested but Xen not enabled')
257 endif
258endif
b4e312e9
PB
259if not cocoa.found() and get_option('cocoa').enabled()
260 error('Cocoa not available on this platform')
261endif
262
6ec0e15d
PB
263################
264# Dependencies #
265################
266
215b0c2f
PB
267# The path to glib.h is added to all compilation commands. This was
268# grandfathered in from the QEMU Makefiles.
269add_project_arguments(config_host['GLIB_CFLAGS'].split(),
270 native: false, language: ['c', 'cpp', 'objc'])
953d5a9e
MAL
271glib = declare_dependency(compile_args: config_host['GLIB_CFLAGS'].split(),
272 link_args: config_host['GLIB_LIBS'].split())
273# override glib dep with the configure results (for subprojects)
274meson.override_dependency('glib-2.0', glib)
275
a81df1b6
PB
276gio = not_found
277if 'CONFIG_GIO' in config_host
278 gio = declare_dependency(compile_args: config_host['GIO_CFLAGS'].split(),
279 link_args: config_host['GIO_LIBS'].split())
280endif
281lttng = not_found
282if 'CONFIG_TRACE_UST' in config_host
283 lttng = declare_dependency(link_args: config_host['LTTNG_UST_LIBS'].split())
284endif
285urcubp = not_found
286if 'CONFIG_TRACE_UST' in config_host
287 urcubp = declare_dependency(link_args: config_host['URCU_BP_LIBS'].split())
288endif
46859d93
DB
289gcrypt = not_found
290if 'CONFIG_GCRYPT' in config_host
291 gcrypt = declare_dependency(compile_args: config_host['GCRYPT_CFLAGS'].split(),
292 link_args: config_host['GCRYPT_LIBS'].split())
293endif
a81df1b6
PB
294nettle = not_found
295if 'CONFIG_NETTLE' in config_host
296 nettle = declare_dependency(compile_args: config_host['NETTLE_CFLAGS'].split(),
297 link_args: config_host['NETTLE_LIBS'].split())
298endif
299gnutls = not_found
300if 'CONFIG_GNUTLS' in config_host
301 gnutls = declare_dependency(compile_args: config_host['GNUTLS_CFLAGS'].split(),
302 link_args: config_host['GNUTLS_LIBS'].split())
303endif
b7612f45
PB
304pixman = not_found
305if have_system or have_tools
306 pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8',
1a94933f 307 method: 'pkg-config', static: enable_static)
b7612f45 308endif
5e7fbd25
MAL
309pam = not_found
310if 'CONFIG_AUTH_PAM' in config_host
311 pam = cc.find_library('pam')
312endif
5e5733e5 313libaio = cc.find_library('aio', required: false)
1ffb3bbb 314zlib = dependency('zlib', required: true, static: enable_static)
5e5733e5
MAL
315linux_io_uring = not_found
316if 'CONFIG_LINUX_IO_URING' in config_host
317 linux_io_uring = declare_dependency(compile_args: config_host['LINUX_IO_URING_CFLAGS'].split(),
318 link_args: config_host['LINUX_IO_URING_LIBS'].split())
319endif
320libxml2 = not_found
321if 'CONFIG_LIBXML2' in config_host
322 libxml2 = declare_dependency(compile_args: config_host['LIBXML2_CFLAGS'].split(),
323 link_args: config_host['LIBXML2_LIBS'].split())
324endif
325libnfs = not_found
30045c05
PB
326if not get_option('libnfs').auto() or have_block
327 libnfs = dependency('libnfs', version: '>=1.9.3',
328 required: get_option('libnfs'),
329 method: 'pkg-config', static: enable_static)
5e5733e5 330endif
ec0d5893
MAL
331libattr = not_found
332if 'CONFIG_ATTR' in config_host
333 libattr = declare_dependency(link_args: config_host['LIBATTR_LIBS'].split())
334endif
3f99cf57 335seccomp = not_found
90835c2b
PB
336if not get_option('seccomp').auto() or have_system or have_tools
337 seccomp = dependency('libseccomp', version: '>=2.3.0',
338 required: get_option('seccomp'),
339 method: 'pkg-config', static: enable_static)
3f99cf57
PB
340endif
341libcap_ng = not_found
342if 'CONFIG_LIBCAP_NG' in config_host
343 libcap_ng = declare_dependency(link_args: config_host['LIBCAP_NG_LIBS'].split())
344endif
1917ec6d
PB
345if get_option('xkbcommon').auto() and not have_system and not have_tools
346 xkbcommon = not_found
347else
348 xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
1a94933f 349 method: 'pkg-config', static: enable_static)
ade60d4f 350endif
cdaf0722
MAL
351vde = not_found
352if config_host.has_key('CONFIG_VDE')
353 vde = declare_dependency(link_args: config_host['VDE_LIBS'].split())
354endif
478e943f
PB
355pulse = not_found
356if 'CONFIG_LIBPULSE' in config_host
357 pulse = declare_dependency(compile_args: config_host['PULSE_CFLAGS'].split(),
358 link_args: config_host['PULSE_LIBS'].split())
359endif
360alsa = not_found
361if 'CONFIG_ALSA' in config_host
362 alsa = declare_dependency(compile_args: config_host['ALSA_CFLAGS'].split(),
363 link_args: config_host['ALSA_LIBS'].split())
364endif
365jack = not_found
366if 'CONFIG_LIBJACK' in config_host
367 jack = declare_dependency(link_args: config_host['JACK_LIBS'].split())
368endif
2634733c 369spice = not_found
d72c34cc 370spice_headers = not_found
2634733c
PB
371if 'CONFIG_SPICE' in config_host
372 spice = declare_dependency(compile_args: config_host['SPICE_CFLAGS'].split(),
373 link_args: config_host['SPICE_LIBS'].split())
d72c34cc 374 spice_headers = declare_dependency(compile_args: config_host['SPICE_CFLAGS'].split())
2634733c 375endif
5ee24e78 376rt = cc.find_library('rt', required: false)
ccf7afa5
PB
377libdl = not_found
378if 'CONFIG_PLUGIN' in config_host
379 libdl = cc.find_library('dl', required: true)
380endif
99650b62 381libiscsi = not_found
9db405a3
PB
382if not get_option('libiscsi').auto() or have_block
383 libiscsi = dependency('libiscsi', version: '>=1.9.0',
384 required: get_option('libiscsi'),
385 method: 'pkg-config', static: enable_static)
99650b62 386endif
5e5733e5 387zstd = not_found
b1def33d
PB
388if not get_option('zstd').auto() or have_block
389 zstd = dependency('libzstd', version: '>=1.4.0',
390 required: get_option('zstd'),
391 method: 'pkg-config', static: enable_static)
5e5733e5 392endif
ea458960
MAL
393gbm = not_found
394if 'CONFIG_GBM' in config_host
395 gbm = declare_dependency(compile_args: config_host['GBM_CFLAGS'].split(),
396 link_args: config_host['GBM_LIBS'].split())
397endif
398virgl = not_found
399if 'CONFIG_VIRGL' in config_host
400 virgl = declare_dependency(compile_args: config_host['VIRGL_CFLAGS'].split(),
401 link_args: config_host['VIRGL_LIBS'].split())
402endif
1d7bb6ab 403curl = not_found
f9cd86fe
PB
404if not get_option('curl').auto() or have_block
405 curl = dependency('libcurl', version: '>=7.29.0',
406 method: 'pkg-config',
407 required: get_option('curl'),
408 static: enable_static)
1d7bb6ab 409endif
f15bff25 410libudev = not_found
f01496a3 411if targetos == 'linux' and (have_system or have_tools)
6ec0e15d 412 libudev = dependency('libudev',
a0fbbb6e 413 method: 'pkg-config',
5c53015a 414 required: get_option('libudev'),
6ec0e15d
PB
415 static: enable_static)
416endif
417
5c53015a 418mpathlibs = [libudev]
6ec0e15d
PB
419mpathpersist = not_found
420mpathpersist_new_api = false
421if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
422 mpath_test_source_new = '''
423 #include <libudev.h>
424 #include <mpath_persist.h>
425 unsigned mpath_mx_alloc_len = 1024;
426 int logsink;
427 static struct config *multipath_conf;
428 extern struct udev *udev;
429 extern struct config *get_multipath_config(void);
430 extern void put_multipath_config(struct config *conf);
431 struct udev *udev;
432 struct config *get_multipath_config(void) { return multipath_conf; }
433 void put_multipath_config(struct config *conf) { }
434 int main(void) {
435 udev = udev_new();
436 multipath_conf = mpath_lib_init();
437 return 0;
438 }'''
439 mpath_test_source_old = '''
440 #include <libudev.h>
441 #include <mpath_persist.h>
442 unsigned mpath_mx_alloc_len = 1024;
443 int logsink;
444 int main(void) {
445 struct udev *udev = udev_new();
446 mpath_lib_init(udev);
447 return 0;
448 }'''
5c53015a
PB
449 libmpathpersist = cc.find_library('mpathpersist',
450 required: get_option('mpath'),
451 static: enable_static)
452 if libmpathpersist.found()
453 mpathlibs += libmpathpersist
454 if enable_static
455 mpathlibs += cc.find_library('devmapper',
456 required: get_option('mpath'),
457 static: enable_static)
43b43a40 458 endif
5c53015a
PB
459 mpathlibs += cc.find_library('multipath',
460 required: get_option('mpath'),
461 static: enable_static)
462 foreach lib: mpathlibs
463 if not lib.found()
464 mpathlibs = []
465 break
466 endif
467 endforeach
468 if mpathlibs.length() == 0
469 msg = 'Dependencies missing for libmpathpersist'
470 elif cc.links(mpath_test_source_new, dependencies: mpathlibs)
6ec0e15d
PB
471 mpathpersist = declare_dependency(dependencies: mpathlibs)
472 mpathpersist_new_api = true
473 elif cc.links(mpath_test_source_old, dependencies: mpathlibs)
474 mpathpersist = declare_dependency(dependencies: mpathlibs)
475 else
5c53015a
PB
476 msg = 'Cannot detect libmpathpersist API'
477 endif
478 if not mpathpersist.found()
6ec0e15d 479 if get_option('mpath').enabled()
5c53015a 480 error(msg)
6ec0e15d 481 else
5c53015a 482 warning(msg + ', disabling')
6ec0e15d
PB
483 endif
484 endif
485 endif
f15bff25 486endif
6ec0e15d 487
5285e593 488iconv = not_found
5285e593 489curses = not_found
30fe76b1 490if have_system and not get_option('curses').disabled()
925a40df
PB
491 curses_test = '''
492 #include <locale.h>
493 #include <curses.h>
494 #include <wchar.h>
495 int main(void) {
496 wchar_t wch = L'w';
497 setlocale(LC_ALL, "");
498 resize_term(0, 0);
499 addwstr(L"wide chars\n");
500 addnwstr(&wch, 1);
501 add_wch(WACS_DEGREE);
502 return 0;
503 }'''
504
ca31e307
YL
505 curses_dep_list = targetos == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw']
506 foreach curses_dep : curses_dep_list
507 if not curses.found()
508 curses = dependency(curses_dep,
509 required: false,
510 method: 'pkg-config',
511 static: enable_static)
512 endif
513 endforeach
925a40df 514 msg = get_option('curses').enabled() ? 'curses library not found' : ''
0dbce6ef 515 curses_compile_args = ['-DNCURSES_WIDECHAR']
925a40df 516 if curses.found()
0dbce6ef
PB
517 if cc.links(curses_test, args: curses_compile_args, dependencies: [curses])
518 curses = declare_dependency(compile_args: curses_compile_args, dependencies: [curses])
925a40df
PB
519 else
520 msg = 'curses package not usable'
521 curses = not_found
5285e593
YL
522 endif
523 endif
925a40df 524 if not curses.found()
925a40df
PB
525 has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
526 if targetos != 'windows' and not has_curses_h
527 message('Trying with /usr/include/ncursesw')
528 curses_compile_args += ['-I/usr/include/ncursesw']
529 has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
530 endif
531 if has_curses_h
532 curses_libname_list = (targetos == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
533 foreach curses_libname : curses_libname_list
5285e593
YL
534 libcurses = cc.find_library(curses_libname,
535 required: false,
5285e593 536 static: enable_static)
925a40df
PB
537 if libcurses.found()
538 if cc.links(curses_test, args: curses_compile_args, dependencies: libcurses)
539 curses = declare_dependency(compile_args: curses_compile_args,
540 dependencies: [libcurses])
541 break
542 else
543 msg = 'curses library not usable'
544 endif
5285e593 545 endif
925a40df
PB
546 endforeach
547 endif
548 endif
549 if not get_option('iconv').disabled()
550 foreach link_args : [ ['-liconv'], [] ]
551 # Programs will be linked with glib and this will bring in libiconv on FreeBSD.
552 # We need to use libiconv if available because mixing libiconv's headers with
553 # the system libc does not work.
554 # However, without adding glib to the dependencies -L/usr/local/lib will not be
555 # included in the command line and libiconv will not be found.
556 if cc.links('''
557 #include <iconv.h>
558 int main(void) {
559 iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
560 return conv != (iconv_t) -1;
561 }''', args: config_host['GLIB_CFLAGS'].split() + config_host['GLIB_LIBS'].split() + link_args)
562 iconv = declare_dependency(link_args: link_args, dependencies: glib)
563 break
5285e593 564 endif
30fe76b1
PB
565 endforeach
566 endif
925a40df
PB
567 if curses.found() and not iconv.found()
568 if get_option('iconv').enabled()
569 error('iconv not available')
570 endif
571 msg = 'iconv required for curses UI but not available'
572 curses = not_found
573 endif
574 if not curses.found() and msg != ''
575 if get_option('curses').enabled()
576 error(msg)
30fe76b1 577 else
925a40df 578 warning(msg + ', disabling')
30fe76b1 579 endif
5285e593
YL
580 endif
581endif
582
2634733c 583brlapi = not_found
8c6d4ff4
PB
584if not get_option('brlapi').auto() or have_system
585 brlapi = cc.find_library('brlapi', has_headers: ['brlapi.h'],
586 required: get_option('brlapi'),
587 static: enable_static)
588 if brlapi.found() and not cc.links('''
589 #include <brlapi.h>
590 #include <stddef.h>
591 int main(void) { return brlapi__openConnection (NULL, NULL, NULL); }''', dependencies: brlapi)
592 brlapi = not_found
593 if get_option('brlapi').enabled()
594 error('could not link brlapi')
595 else
596 warning('could not link brlapi, disabling')
597 endif
598 endif
2634733c 599endif
35be72ba 600
760e4327
PB
601sdl = not_found
602if have_system
363743da 603 sdl = dependency('sdl2', required: get_option('sdl'), static: enable_static)
760e4327
PB
604 sdl_image = not_found
605endif
35be72ba
PB
606if sdl.found()
607 # work around 2.0.8 bug
608 sdl = declare_dependency(compile_args: '-Wno-undef',
609 dependencies: sdl)
7161a433 610 sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
1a94933f 611 method: 'pkg-config', static: enable_static)
35be72ba
PB
612else
613 if get_option('sdl_image').enabled()
a8dc2ace
ST
614 error('sdl-image required, but SDL was @0@'.format(
615 get_option('sdl').disabled() ? 'disabled' : 'not found'))
35be72ba
PB
616 endif
617 sdl_image = not_found
2634733c 618endif
35be72ba 619
5e5733e5 620rbd = not_found
fabd1e93
PB
621if not get_option('rbd').auto() or have_block
622 librados = cc.find_library('rados', required: get_option('rbd'),
623 static: enable_static)
624 librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'],
625 required: get_option('rbd'),
626 static: enable_static)
627 if librados.found() and librbd.found() and cc.links('''
628 #include <stdio.h>
629 #include <rbd/librbd.h>
630 int main(void) {
631 rados_t cluster;
632 rados_create(&cluster, NULL);
633 return 0;
634 }''', dependencies: [librbd, librados])
635 rbd = declare_dependency(dependencies: [librbd, librados])
636 endif
5e5733e5 637endif
fabd1e93 638
5e5733e5 639glusterfs = not_found
08821ca2
PB
640glusterfs_ftruncate_has_stat = false
641glusterfs_iocb_has_stat = false
642if not get_option('glusterfs').auto() or have_block
643 glusterfs = dependency('glusterfs-api', version: '>=3',
644 required: get_option('glusterfs'),
645 method: 'pkg-config', static: enable_static)
646 if glusterfs.found()
647 glusterfs_ftruncate_has_stat = cc.links('''
648 #include <glusterfs/api/glfs.h>
649
650 int
651 main(void)
652 {
653 /* new glfs_ftruncate() passes two additional args */
654 return glfs_ftruncate(NULL, 0, NULL, NULL);
655 }
656 ''', dependencies: glusterfs)
657 glusterfs_iocb_has_stat = cc.links('''
658 #include <glusterfs/api/glfs.h>
659
660 /* new glfs_io_cbk() passes two additional glfs_stat structs */
661 static void
662 glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
663 {}
664
665 int
666 main(void)
667 {
668 glfs_io_cbk iocb = &glusterfs_iocb;
669 iocb(NULL, 0 , NULL, NULL, NULL);
670 return 0;
671 }
672 ''', dependencies: glusterfs)
673 endif
5e5733e5
MAL
674endif
675libssh = not_found
676if 'CONFIG_LIBSSH' in config_host
677 libssh = declare_dependency(compile_args: config_host['LIBSSH_CFLAGS'].split(),
678 link_args: config_host['LIBSSH_LIBS'].split())
679endif
680libbzip2 = not_found
29ba6116
PB
681if not get_option('bzip2').auto() or have_block
682 libbzip2 = cc.find_library('bz2', has_headers: ['bzlib.h'],
683 required: get_option('bzip2'),
684 static: enable_static)
685 if libbzip2.found() and not cc.links('''
686 #include <bzlib.h>
687 int main(void) { BZ2_bzlibVersion(); return 0; }''', dependencies: libbzip2)
688 libbzip2 = not_found
689 if get_option('bzip2').enabled()
690 error('could not link libbzip2')
691 else
692 warning('could not link libbzip2, disabling')
693 endif
694 endif
5e5733e5 695endif
ecea3696 696
5e5733e5 697liblzfse = not_found
ecea3696
PB
698if not get_option('lzfse').auto() or have_block
699 liblzfse = cc.find_library('lzfse', has_headers: ['lzfse.h'],
700 required: get_option('lzfse'),
701 static: enable_static)
702endif
703if liblzfse.found() and not cc.links('''
704 #include <lzfse.h>
705 int main(void) { lzfse_decode_scratch_size(); return 0; }''', dependencies: liblzfse)
706 liblzfse = not_found
707 if get_option('lzfse').enabled()
708 error('could not link liblzfse')
709 else
710 warning('could not link liblzfse, disabling')
711 endif
5e5733e5 712endif
ecea3696 713
478e943f
PB
714oss = not_found
715if 'CONFIG_AUDIO_OSS' in config_host
716 oss = declare_dependency(link_args: config_host['OSS_LIBS'].split())
717endif
718dsound = not_found
719if 'CONFIG_AUDIO_DSOUND' in config_host
720 dsound = declare_dependency(link_args: config_host['DSOUND_LIBS'].split())
721endif
722coreaudio = not_found
723if 'CONFIG_AUDIO_COREAUDIO' in config_host
724 coreaudio = declare_dependency(link_args: config_host['COREAUDIO_LIBS'].split())
2b1ccdf4
MAL
725endif
726opengl = not_found
727if 'CONFIG_OPENGL' in config_host
de2d3005
PB
728 opengl = declare_dependency(compile_args: config_host['OPENGL_CFLAGS'].split(),
729 link_args: config_host['OPENGL_LIBS'].split())
2b1ccdf4
MAL
730endif
731gtk = not_found
732if 'CONFIG_GTK' in config_host
733 gtk = declare_dependency(compile_args: config_host['GTK_CFLAGS'].split(),
734 link_args: config_host['GTK_LIBS'].split())
735endif
736vte = not_found
737if 'CONFIG_VTE' in config_host
738 vte = declare_dependency(compile_args: config_host['VTE_CFLAGS'].split(),
739 link_args: config_host['VTE_LIBS'].split())
740endif
741x11 = not_found
742if 'CONFIG_X11' in config_host
743 x11 = declare_dependency(compile_args: config_host['X11_CFLAGS'].split(),
744 link_args: config_host['X11_LIBS'].split())
745endif
a0b93237 746vnc = not_found
2b1ccdf4 747png = not_found
2b1ccdf4 748jpeg = not_found
2b1ccdf4 749sasl = not_found
a0b93237
PB
750if get_option('vnc').enabled()
751 vnc = declare_dependency() # dummy dependency
752 png = dependency('libpng', required: get_option('vnc_png'),
1a94933f 753 method: 'pkg-config', static: enable_static)
8e242b3c
PB
754 jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'),
755 method: 'pkg-config', static: enable_static)
a0b93237
PB
756 sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'],
757 required: get_option('vnc_sasl'),
758 static: enable_static)
759 if sasl.found()
760 sasl = declare_dependency(dependencies: sasl,
761 compile_args: '-DSTRUCT_IOVEC_DEFINED')
762 endif
478e943f 763endif
241611ea 764
708eab42 765snappy = not_found
241611ea
PB
766if not get_option('snappy').auto() or have_system
767 snappy = cc.find_library('snappy', has_headers: ['snappy-c.h'],
768 required: get_option('snappy'),
769 static: enable_static)
770endif
771if snappy.found() and not cc.links('''
772 #include <snappy-c.h>
773 int main(void) { snappy_max_compressed_length(4096); return 0; }''', dependencies: snappy)
774 snappy = not_found
775 if get_option('snappy').enabled()
776 error('could not link libsnappy')
777 else
778 warning('could not link libsnappy, disabling')
779 endif
708eab42 780endif
0c32a0ae 781
708eab42 782lzo = not_found
0c32a0ae
PB
783if not get_option('lzo').auto() or have_system
784 lzo = cc.find_library('lzo2', has_headers: ['lzo/lzo1x.h'],
785 required: get_option('lzo'),
786 static: enable_static)
787endif
788if lzo.found() and not cc.links('''
789 #include <lzo/lzo1x.h>
790 int main(void) { lzo_version(); return 0; }''', dependencies: lzo)
791 lzo = not_found
792 if get_option('lzo').enabled()
793 error('could not link liblzo2')
794 else
795 warning('could not link liblzo2, disabling')
796 endif
708eab42 797endif
0c32a0ae 798
55166230
MAL
799rdma = not_found
800if 'CONFIG_RDMA' in config_host
801 rdma = declare_dependency(link_args: config_host['RDMA_LIBS'].split())
802endif
ab318051
MAL
803numa = not_found
804if 'CONFIG_NUMA' in config_host
805 numa = declare_dependency(link_args: config_host['NUMA_LIBS'].split())
806endif
582ea95f
MAL
807xen = not_found
808if 'CONFIG_XEN_BACKEND' in config_host
809 xen = declare_dependency(compile_args: config_host['XEN_CFLAGS'].split(),
810 link_args: config_host['XEN_LIBS'].split())
811endif
06677ce1
PB
812cacard = not_found
813if 'CONFIG_SMARTCARD' in config_host
814 cacard = declare_dependency(compile_args: config_host['SMARTCARD_CFLAGS'].split(),
815 link_args: config_host['SMARTCARD_LIBS'].split())
816endif
0a40bcb7
CB
817u2f = not_found
818if have_system
819 u2f = dependency('u2f-emu', required: get_option('u2f'),
820 method: 'pkg-config',
821 static: enable_static)
822endif
06677ce1
PB
823usbredir = not_found
824if 'CONFIG_USB_REDIR' in config_host
825 usbredir = declare_dependency(compile_args: config_host['USB_REDIR_CFLAGS'].split(),
826 link_args: config_host['USB_REDIR_LIBS'].split())
827endif
828libusb = not_found
829if 'CONFIG_USB_LIBUSB' in config_host
830 libusb = declare_dependency(compile_args: config_host['LIBUSB_CFLAGS'].split(),
831 link_args: config_host['LIBUSB_LIBS'].split())
832endif
c9322ab5
MAL
833libpmem = not_found
834if 'CONFIG_LIBPMEM' in config_host
835 libpmem = declare_dependency(compile_args: config_host['LIBPMEM_CFLAGS'].split(),
836 link_args: config_host['LIBPMEM_LIBS'].split())
837endif
c7c91a74
BR
838libdaxctl = not_found
839if 'CONFIG_LIBDAXCTL' in config_host
840 libdaxctl = declare_dependency(link_args: config_host['LIBDAXCTL_LIBS'].split())
841endif
8ce0a45f
MAL
842tasn1 = not_found
843if 'CONFIG_TASN1' in config_host
844 tasn1 = declare_dependency(compile_args: config_host['TASN1_CFLAGS'].split(),
845 link_args: config_host['TASN1_LIBS'].split())
846endif
af04e89d
MAL
847keyutils = dependency('libkeyutils', required: false,
848 method: 'pkg-config', static: enable_static)
a81df1b6 849
3909def8
MAL
850has_gettid = cc.has_function('gettid')
851
aa087962
PB
852# Malloc tests
853
854malloc = []
855if get_option('malloc') == 'system'
856 has_malloc_trim = \
857 not get_option('malloc_trim').disabled() and \
858 cc.links('''#include <malloc.h>
859 int main(void) { malloc_trim(0); return 0; }''')
860else
861 has_malloc_trim = false
862 malloc = cc.find_library(get_option('malloc'), required: true)
863endif
864if not has_malloc_trim and get_option('malloc_trim').enabled()
865 if get_option('malloc') == 'system'
866 error('malloc_trim not available on this platform.')
867 else
868 error('malloc_trim not available with non-libc memory allocator')
869 endif
870endif
871
84e319a5
HR
872# Check whether the glibc provides statx()
873
874statx_test = '''
875 #ifndef _GNU_SOURCE
876 #define _GNU_SOURCE
877 #endif
878 #include <sys/stat.h>
879 int main(void) {
880 struct statx statxbuf;
881 statx(0, "", 0, STATX_BASIC_STATS, &statxbuf);
882 return 0;
883 }'''
884
885has_statx = cc.links(statx_test)
886
eb6a3886
SH
887have_vhost_user_blk_server = (targetos == 'linux' and
888 'CONFIG_VHOST_USER' in config_host)
e5e856c1
SH
889
890if get_option('vhost_user_blk_server').enabled()
891 if targetos != 'linux'
892 error('vhost_user_blk_server requires linux')
eb6a3886
SH
893 elif 'CONFIG_VHOST_USER' not in config_host
894 error('vhost_user_blk_server requires vhost-user support')
e5e856c1
SH
895 endif
896elif get_option('vhost_user_blk_server').disabled() or not have_system
897 have_vhost_user_blk_server = false
898endif
899
9e62ba48 900
df4ea709
HR
901if get_option('fuse').disabled() and get_option('fuse_lseek').enabled()
902 error('Cannot enable fuse-lseek while fuse is disabled')
903endif
904
a484a719
HR
905fuse = dependency('fuse3', required: get_option('fuse'),
906 version: '>=3.1', method: 'pkg-config',
907 static: enable_static)
908
df4ea709
HR
909fuse_lseek = not_found
910if not get_option('fuse_lseek').disabled()
911 if fuse.version().version_compare('>=3.8')
912 # Dummy dependency
913 fuse_lseek = declare_dependency()
914 elif get_option('fuse_lseek').enabled()
915 if fuse.found()
916 error('fuse-lseek requires libfuse >=3.8, found ' + fuse.version())
917 else
918 error('fuse-lseek requires libfuse, which was not found')
919 endif
920 endif
921endif
922
9e62ba48
DB
923if get_option('cfi')
924 cfi_flags=[]
925 # Check for dependency on LTO
926 if not get_option('b_lto')
927 error('Selected Control-Flow Integrity but LTO is disabled')
928 endif
929 if config_host.has_key('CONFIG_MODULES')
930 error('Selected Control-Flow Integrity is not compatible with modules')
931 endif
932 # Check for cfi flags. CFI requires LTO so we can't use
933 # get_supported_arguments, but need a more complex "compiles" which allows
934 # custom arguments
935 if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall',
936 args: ['-flto', '-fsanitize=cfi-icall'] )
937 cfi_flags += '-fsanitize=cfi-icall'
938 else
939 error('-fsanitize=cfi-icall is not supported by the compiler')
940 endif
941 if cc.compiles('int main () { return 0; }',
942 name: '-fsanitize-cfi-icall-generalize-pointers',
943 args: ['-flto', '-fsanitize=cfi-icall',
944 '-fsanitize-cfi-icall-generalize-pointers'] )
945 cfi_flags += '-fsanitize-cfi-icall-generalize-pointers'
946 else
947 error('-fsanitize-cfi-icall-generalize-pointers is not supported by the compiler')
948 endif
949 if get_option('cfi_debug')
950 if cc.compiles('int main () { return 0; }',
951 name: '-fno-sanitize-trap=cfi-icall',
952 args: ['-flto', '-fsanitize=cfi-icall',
953 '-fno-sanitize-trap=cfi-icall'] )
954 cfi_flags += '-fno-sanitize-trap=cfi-icall'
955 else
956 error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
957 endif
958 endif
959 add_project_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
960 add_project_link_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
961endif
962
a0c9162c
PB
963#################
964# config-host.h #
965#################
859aef02 966
16bf7a33
PB
967config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir'))
968config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix'))
969config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir)
970config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir)
971config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir)
972config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('qemu_firmwarepath'))
973config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir'))
974config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir)
975config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
976config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
977config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
978config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
979
8c6d4ff4 980config_host_data.set('CONFIG_BRLAPI', brlapi.found())
b4e312e9 981config_host_data.set('CONFIG_COCOA', cocoa.found())
f01496a3 982config_host_data.set('CONFIG_LIBUDEV', libudev.found())
0c32a0ae 983config_host_data.set('CONFIG_LZO', lzo.found())
6ec0e15d
PB
984config_host_data.set('CONFIG_MPATH', mpathpersist.found())
985config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
f9cd86fe 986config_host_data.set('CONFIG_CURL', curl.found())
5285e593 987config_host_data.set('CONFIG_CURSES', curses.found())
08821ca2
PB
988config_host_data.set('CONFIG_GLUSTERFS', glusterfs.found())
989if glusterfs.found()
990 config_host_data.set('CONFIG_GLUSTERFS_XLATOR_OPT', glusterfs.version().version_compare('>=4'))
991 config_host_data.set('CONFIG_GLUSTERFS_DISCARD', glusterfs.version().version_compare('>=5'))
992 config_host_data.set('CONFIG_GLUSTERFS_FALLOCATE', glusterfs.version().version_compare('>=6'))
993 config_host_data.set('CONFIG_GLUSTERFS_ZEROFILL', glusterfs.version().version_compare('>=6'))
994 config_host_data.set('CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT', glusterfs_ftruncate_has_stat)
995 config_host_data.set('CONFIG_GLUSTERFS_IOCB_HAS_STAT', glusterfs_iocb_has_stat)
996endif
9db405a3 997config_host_data.set('CONFIG_LIBISCSI', libiscsi.found())
30045c05 998config_host_data.set('CONFIG_LIBNFS', libnfs.found())
fabd1e93 999config_host_data.set('CONFIG_RBD', rbd.found())
35be72ba
PB
1000config_host_data.set('CONFIG_SDL', sdl.found())
1001config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
90835c2b 1002config_host_data.set('CONFIG_SECCOMP', seccomp.found())
241611ea 1003config_host_data.set('CONFIG_SNAPPY', snappy.found())
e5e856c1 1004config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server)
a0b93237
PB
1005config_host_data.set('CONFIG_VNC', vnc.found())
1006config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
1007config_host_data.set('CONFIG_VNC_PNG', png.found())
1008config_host_data.set('CONFIG_VNC_SASL', sasl.found())
4113f4cf 1009config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
af04e89d 1010config_host_data.set('CONFIG_KEYUTILS', keyutils.found())
3909def8 1011config_host_data.set('CONFIG_GETTID', has_gettid)
aa087962 1012config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim)
84e319a5 1013config_host_data.set('CONFIG_STATX', has_statx)
b1def33d 1014config_host_data.set('CONFIG_ZSTD', zstd.found())
a484a719 1015config_host_data.set('CONFIG_FUSE', fuse.found())
df4ea709 1016config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found())
9e62ba48 1017config_host_data.set('CONFIG_CFI', get_option('cfi'))
859aef02
PB
1018config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
1019config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0])
1020config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1])
1021config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('.')[2])
1022
48f670ec 1023config_host_data.set('HAVE_BTRFS_H', cc.has_header('linux/btrfs.h'))
2964be52 1024config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h'))
2802d91d 1025config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h'))
ded5d78c 1026config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
4a9d5f89 1027config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
88c78f16 1028config_host_data.set('HAVE_SYS_SIGNAL_H', cc.has_header('sys/signal.h'))
ded5d78c 1029
765686d6 1030ignored = ['CONFIG_QEMU_INTERP_PREFIX'] # actually per-target
859aef02 1031arrays = ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
16bf7a33 1032strings = ['HOST_DSOSUF', 'CONFIG_IASL']
859aef02 1033foreach k, v: config_host
765686d6
PB
1034 if ignored.contains(k)
1035 # do nothing
1036 elif arrays.contains(k)
859aef02
PB
1037 if v != ''
1038 v = '"' + '", "'.join(v.split()) + '", '
1039 endif
1040 config_host_data.set(k, v)
1041 elif k == 'ARCH'
1042 config_host_data.set('HOST_' + v.to_upper(), 1)
1043 elif strings.contains(k)
1044 if not k.startswith('CONFIG_')
1045 k = 'CONFIG_' + k.to_upper()
1046 endif
1047 config_host_data.set_quoted(k, v)
1048 elif k.startswith('CONFIG_') or k.startswith('HAVE_') or k.startswith('HOST_')
1049 config_host_data.set(k, v == 'y' ? 1 : v)
1050 endif
1051endforeach
859aef02 1052
a0c9162c
PB
1053########################
1054# Target configuration #
1055########################
1056
2becc36a 1057minikconf = find_program('scripts/minikconf.py')
05512f55 1058config_all = {}
a98006bc 1059config_all_devices = {}
ca0fc784 1060config_all_disas = {}
2becc36a
PB
1061config_devices_mak_list = []
1062config_devices_h = {}
859aef02 1063config_target_h = {}
2becc36a 1064config_target_mak = {}
ca0fc784
PB
1065
1066disassemblers = {
1067 'alpha' : ['CONFIG_ALPHA_DIS'],
1068 'arm' : ['CONFIG_ARM_DIS'],
1069 'avr' : ['CONFIG_AVR_DIS'],
1070 'cris' : ['CONFIG_CRIS_DIS'],
1071 'hppa' : ['CONFIG_HPPA_DIS'],
1072 'i386' : ['CONFIG_I386_DIS'],
1073 'x86_64' : ['CONFIG_I386_DIS'],
1074 'x32' : ['CONFIG_I386_DIS'],
1075 'lm32' : ['CONFIG_LM32_DIS'],
1076 'm68k' : ['CONFIG_M68K_DIS'],
1077 'microblaze' : ['CONFIG_MICROBLAZE_DIS'],
1078 'mips' : ['CONFIG_MIPS_DIS'],
1079 'moxie' : ['CONFIG_MOXIE_DIS'],
1080 'nios2' : ['CONFIG_NIOS2_DIS'],
1081 'or1k' : ['CONFIG_OPENRISC_DIS'],
1082 'ppc' : ['CONFIG_PPC_DIS'],
1083 'riscv' : ['CONFIG_RISCV_DIS'],
1084 'rx' : ['CONFIG_RX_DIS'],
1085 's390' : ['CONFIG_S390_DIS'],
1086 'sh4' : ['CONFIG_SH4_DIS'],
1087 'sparc' : ['CONFIG_SPARC_DIS'],
1088 'xtensa' : ['CONFIG_XTENSA_DIS'],
1089}
1090if link_language == 'cpp'
1091 disassemblers += {
1092 'aarch64' : [ 'CONFIG_ARM_A64_DIS'],
1093 'arm' : [ 'CONFIG_ARM_DIS', 'CONFIG_ARM_A64_DIS'],
1094 'mips' : [ 'CONFIG_MIPS_DIS', 'CONFIG_NANOMIPS_DIS'],
1095 }
1096endif
1097
0a189110
PB
1098host_kconfig = \
1099 ('CONFIG_TPM' in config_host ? ['CONFIG_TPM=y'] : []) + \
1100 ('CONFIG_SPICE' in config_host ? ['CONFIG_SPICE=y'] : []) + \
1101 ('CONFIG_IVSHMEM' in config_host ? ['CONFIG_IVSHMEM=y'] : []) + \
1102 ('CONFIG_OPENGL' in config_host ? ['CONFIG_OPENGL=y'] : []) + \
1103 ('CONFIG_X11' in config_host ? ['CONFIG_X11=y'] : []) + \
1104 ('CONFIG_VHOST_USER' in config_host ? ['CONFIG_VHOST_USER=y'] : []) + \
1105 ('CONFIG_VHOST_VDPA' in config_host ? ['CONFIG_VHOST_VDPA=y'] : []) + \
1106 ('CONFIG_VHOST_KERNEL' in config_host ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
1107 ('CONFIG_VIRTFS' in config_host ? ['CONFIG_VIRTFS=y'] : []) + \
1108 ('CONFIG_LINUX' in config_host ? ['CONFIG_LINUX=y'] : []) + \
1109 ('CONFIG_PVRDMA' in config_host ? ['CONFIG_PVRDMA=y'] : [])
1110
a9a74907 1111ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ]
05512f55 1112
fdb75aef
PB
1113default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host
1114actual_target_dirs = []
fbb4121d 1115fdt_required = []
a81df1b6 1116foreach target : target_dirs
765686d6
PB
1117 config_target = { 'TARGET_NAME': target.split('-')[0] }
1118 if target.endswith('linux-user')
fdb75aef
PB
1119 if targetos != 'linux'
1120 if default_targets
1121 continue
1122 endif
1123 error('Target @0@ is only available on a Linux host'.format(target))
1124 endif
765686d6
PB
1125 config_target += { 'CONFIG_LINUX_USER': 'y' }
1126 elif target.endswith('bsd-user')
fdb75aef
PB
1127 if 'CONFIG_BSD' not in config_host
1128 if default_targets
1129 continue
1130 endif
1131 error('Target @0@ is only available on a BSD host'.format(target))
1132 endif
765686d6
PB
1133 config_target += { 'CONFIG_BSD_USER': 'y' }
1134 elif target.endswith('softmmu')
1135 config_target += { 'CONFIG_SOFTMMU': 'y' }
1136 endif
1137 if target.endswith('-user')
1138 config_target += {
1139 'CONFIG_USER_ONLY': 'y',
1140 'CONFIG_QEMU_INTERP_PREFIX':
1141 config_host['CONFIG_QEMU_INTERP_PREFIX'].format(config_target['TARGET_NAME'])
1142 }
1143 endif
859aef02 1144
0a189110 1145 accel_kconfig = []
8a19980e
PB
1146 foreach sym: accelerators
1147 if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, [])
1148 config_target += { sym: 'y' }
1149 config_all += { sym: 'y' }
1150 if sym == 'CONFIG_XEN' and have_xen_pci_passthrough
1151 config_target += { 'CONFIG_XEN_PCI_PASSTHROUGH': 'y' }
1152 endif
0a189110 1153 accel_kconfig += [ sym + '=y' ]
8a19980e
PB
1154 endif
1155 endforeach
0a189110 1156 if accel_kconfig.length() == 0
fdb75aef
PB
1157 if default_targets
1158 continue
1159 endif
1160 error('No accelerator available for target @0@'.format(target))
1161 endif
8a19980e 1162
fdb75aef 1163 actual_target_dirs += target
765686d6 1164 config_target += keyval.load('default-configs/targets' / target + '.mak')
a9a74907 1165 config_target += { 'TARGET_' + config_target['TARGET_ARCH'].to_upper(): 'y' }
765686d6 1166
fbb4121d
PB
1167 if 'TARGET_NEED_FDT' in config_target
1168 fdt_required += target
1169 endif
1170
fa73168b
PB
1171 # Add default keys
1172 if 'TARGET_BASE_ARCH' not in config_target
1173 config_target += {'TARGET_BASE_ARCH': config_target['TARGET_ARCH']}
1174 endif
1175 if 'TARGET_ABI_DIR' not in config_target
1176 config_target += {'TARGET_ABI_DIR': config_target['TARGET_ARCH']}
1177 endif
859aef02 1178
ca0fc784
PB
1179 foreach k, v: disassemblers
1180 if config_host['ARCH'].startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k)
1181 foreach sym: v
1182 config_target += { sym: 'y' }
1183 config_all_disas += { sym: 'y' }
1184 endforeach
1185 endif
1186 endforeach
1187
859aef02
PB
1188 config_target_data = configuration_data()
1189 foreach k, v: config_target
1190 if not k.startswith('TARGET_') and not k.startswith('CONFIG_')
1191 # do nothing
1192 elif ignored.contains(k)
1193 # do nothing
1194 elif k == 'TARGET_BASE_ARCH'
a9a74907
PB
1195 # Note that TARGET_BASE_ARCH ends up in config-target.h but it is
1196 # not used to select files from sourcesets.
859aef02 1197 config_target_data.set('TARGET_' + v.to_upper(), 1)
765686d6 1198 elif k == 'TARGET_NAME' or k == 'CONFIG_QEMU_INTERP_PREFIX'
859aef02
PB
1199 config_target_data.set_quoted(k, v)
1200 elif v == 'y'
1201 config_target_data.set(k, 1)
1202 else
1203 config_target_data.set(k, v)
1204 endif
1205 endforeach
1206 config_target_h += {target: configure_file(output: target + '-config-target.h',
1207 configuration: config_target_data)}
2becc36a
PB
1208
1209 if target.endswith('-softmmu')
2becc36a
PB
1210 config_devices_mak = target + '-config-devices.mak'
1211 config_devices_mak = configure_file(
1bb4cb1c 1212 input: ['default-configs/devices' / target + '.mak', 'Kconfig'],
2becc36a
PB
1213 output: config_devices_mak,
1214 depfile: config_devices_mak + '.d',
1215 capture: true,
1216 command: [minikconf, config_host['CONFIG_MINIKCONF_MODE'],
1217 config_devices_mak, '@DEPFILE@', '@INPUT@',
0a189110 1218 host_kconfig, accel_kconfig])
859aef02
PB
1219
1220 config_devices_data = configuration_data()
1221 config_devices = keyval.load(config_devices_mak)
1222 foreach k, v: config_devices
1223 config_devices_data.set(k, 1)
1224 endforeach
2becc36a 1225 config_devices_mak_list += config_devices_mak
859aef02
PB
1226 config_devices_h += {target: configure_file(output: target + '-config-devices.h',
1227 configuration: config_devices_data)}
1228 config_target += config_devices
a98006bc 1229 config_all_devices += config_devices
2becc36a
PB
1230 endif
1231 config_target_mak += {target: config_target}
a81df1b6 1232endforeach
fdb75aef 1233target_dirs = actual_target_dirs
a81df1b6 1234
2becc36a
PB
1235# This configuration is used to build files that are shared by
1236# multiple binaries, and then extracted out of the "common"
1237# static_library target.
1238#
1239# We do not use all_sources()/all_dependencies(), because it would
1240# build literally all source files, including devices only used by
1241# targets that are not built for this compilation. The CONFIG_ALL
1242# pseudo symbol replaces it.
1243
05512f55 1244config_all += config_all_devices
2becc36a
PB
1245config_all += config_host
1246config_all += config_all_disas
1247config_all += {
1248 'CONFIG_XEN': config_host.has_key('CONFIG_XEN_BACKEND'),
1249 'CONFIG_SOFTMMU': have_system,
1250 'CONFIG_USER_ONLY': have_user,
1251 'CONFIG_ALL': true,
1252}
1253
a0c9162c
PB
1254##############
1255# Submodules #
1256##############
8b18cdbf
RH
1257
1258capstone = not_found
1259capstone_opt = get_option('capstone')
1260if capstone_opt in ['enabled', 'auto', 'system']
1261 have_internal = fs.exists(meson.current_source_dir() / 'capstone/Makefile')
bcf36862
RH
1262 capstone = dependency('capstone', version: '>=4.0',
1263 static: enable_static, method: 'pkg-config',
8b18cdbf
RH
1264 required: capstone_opt == 'system' or
1265 capstone_opt == 'enabled' and not have_internal)
1266 if capstone.found()
1267 capstone_opt = 'system'
1268 elif have_internal
1269 capstone_opt = 'internal'
1270 else
1271 capstone_opt = 'disabled'
1272 endif
1273endif
1274if capstone_opt == 'internal'
1275 capstone_data = configuration_data()
1276 capstone_data.set('CAPSTONE_USE_SYS_DYN_MEM', '1')
1277
1278 capstone_files = files(
1279 'capstone/cs.c',
1280 'capstone/MCInst.c',
1281 'capstone/MCInstrDesc.c',
1282 'capstone/MCRegisterInfo.c',
1283 'capstone/SStream.c',
1284 'capstone/utils.c'
1285 )
1286
1287 if 'CONFIG_ARM_DIS' in config_all_disas
1288 capstone_data.set('CAPSTONE_HAS_ARM', '1')
1289 capstone_files += files(
1290 'capstone/arch/ARM/ARMDisassembler.c',
1291 'capstone/arch/ARM/ARMInstPrinter.c',
1292 'capstone/arch/ARM/ARMMapping.c',
1293 'capstone/arch/ARM/ARMModule.c'
1294 )
1295 endif
1296
1297 # FIXME: This config entry currently depends on a c++ compiler.
1298 # Which is needed for building libvixl, but not for capstone.
1299 if 'CONFIG_ARM_A64_DIS' in config_all_disas
1300 capstone_data.set('CAPSTONE_HAS_ARM64', '1')
1301 capstone_files += files(
1302 'capstone/arch/AArch64/AArch64BaseInfo.c',
1303 'capstone/arch/AArch64/AArch64Disassembler.c',
1304 'capstone/arch/AArch64/AArch64InstPrinter.c',
1305 'capstone/arch/AArch64/AArch64Mapping.c',
1306 'capstone/arch/AArch64/AArch64Module.c'
1307 )
1308 endif
1309
1310 if 'CONFIG_PPC_DIS' in config_all_disas
1311 capstone_data.set('CAPSTONE_HAS_POWERPC', '1')
1312 capstone_files += files(
1313 'capstone/arch/PowerPC/PPCDisassembler.c',
1314 'capstone/arch/PowerPC/PPCInstPrinter.c',
1315 'capstone/arch/PowerPC/PPCMapping.c',
1316 'capstone/arch/PowerPC/PPCModule.c'
1317 )
1318 endif
1319
3d562845
RH
1320 if 'CONFIG_S390_DIS' in config_all_disas
1321 capstone_data.set('CAPSTONE_HAS_SYSZ', '1')
1322 capstone_files += files(
1323 'capstone/arch/SystemZ/SystemZDisassembler.c',
1324 'capstone/arch/SystemZ/SystemZInstPrinter.c',
1325 'capstone/arch/SystemZ/SystemZMapping.c',
1326 'capstone/arch/SystemZ/SystemZModule.c',
1327 'capstone/arch/SystemZ/SystemZMCTargetDesc.c'
1328 )
1329 endif
1330
8b18cdbf
RH
1331 if 'CONFIG_I386_DIS' in config_all_disas
1332 capstone_data.set('CAPSTONE_HAS_X86', 1)
1333 capstone_files += files(
1334 'capstone/arch/X86/X86Disassembler.c',
1335 'capstone/arch/X86/X86DisassemblerDecoder.c',
1336 'capstone/arch/X86/X86ATTInstPrinter.c',
1337 'capstone/arch/X86/X86IntelInstPrinter.c',
eef20e40 1338 'capstone/arch/X86/X86InstPrinterCommon.c',
8b18cdbf
RH
1339 'capstone/arch/X86/X86Mapping.c',
1340 'capstone/arch/X86/X86Module.c'
1341 )
1342 endif
1343
1344 configure_file(output: 'capstone-defs.h', configuration: capstone_data)
1345
1346 capstone_cargs = [
1347 # FIXME: There does not seem to be a way to completely replace the c_args
1348 # that come from add_project_arguments() -- we can only add to them.
1349 # So: disable all warnings with a big hammer.
1350 '-Wno-error', '-w',
1351
1352 # Include all configuration defines via a header file, which will wind up
1353 # as a dependency on the object file, and thus changes here will result
1354 # in a rebuild.
1355 '-include', 'capstone-defs.h'
1356 ]
1357
1358 libcapstone = static_library('capstone',
1359 sources: capstone_files,
1360 c_args: capstone_cargs,
1361 include_directories: 'capstone/include')
1362 capstone = declare_dependency(link_with: libcapstone,
eef20e40 1363 include_directories: 'capstone/include/capstone')
8b18cdbf 1364endif
4d34a86b
PB
1365
1366slirp = not_found
1367slirp_opt = 'disabled'
1368if have_system
1369 slirp_opt = get_option('slirp')
1370 if slirp_opt in ['enabled', 'auto', 'system']
1371 have_internal = fs.exists(meson.current_source_dir() / 'slirp/meson.build')
1372 slirp = dependency('slirp', static: enable_static,
1373 method: 'pkg-config',
1374 required: slirp_opt == 'system' or
1375 slirp_opt == 'enabled' and not have_internal)
1376 if slirp.found()
1377 slirp_opt = 'system'
1378 elif have_internal
1379 slirp_opt = 'internal'
1380 else
1381 slirp_opt = 'disabled'
1382 endif
1383 endif
1384 if slirp_opt == 'internal'
1385 slirp_deps = []
1386 if targetos == 'windows'
1387 slirp_deps = cc.find_library('iphlpapi')
1388 endif
1389 slirp_conf = configuration_data()
1390 slirp_conf.set('SLIRP_MAJOR_VERSION', meson.project_version().split('.')[0])
1391 slirp_conf.set('SLIRP_MINOR_VERSION', meson.project_version().split('.')[1])
1392 slirp_conf.set('SLIRP_MICRO_VERSION', meson.project_version().split('.')[2])
1393 slirp_conf.set_quoted('SLIRP_VERSION_STRING', meson.project_version())
1394 slirp_cargs = ['-DG_LOG_DOMAIN="Slirp"']
1395 slirp_files = [
1396 'slirp/src/arp_table.c',
1397 'slirp/src/bootp.c',
1398 'slirp/src/cksum.c',
1399 'slirp/src/dhcpv6.c',
1400 'slirp/src/dnssearch.c',
1401 'slirp/src/if.c',
1402 'slirp/src/ip6_icmp.c',
1403 'slirp/src/ip6_input.c',
1404 'slirp/src/ip6_output.c',
1405 'slirp/src/ip_icmp.c',
1406 'slirp/src/ip_input.c',
1407 'slirp/src/ip_output.c',
1408 'slirp/src/mbuf.c',
1409 'slirp/src/misc.c',
1410 'slirp/src/ncsi.c',
1411 'slirp/src/ndp_table.c',
1412 'slirp/src/sbuf.c',
1413 'slirp/src/slirp.c',
1414 'slirp/src/socket.c',
1415 'slirp/src/state.c',
1416 'slirp/src/stream.c',
1417 'slirp/src/tcp_input.c',
1418 'slirp/src/tcp_output.c',
1419 'slirp/src/tcp_subr.c',
1420 'slirp/src/tcp_timer.c',
1421 'slirp/src/tftp.c',
1422 'slirp/src/udp.c',
1423 'slirp/src/udp6.c',
1424 'slirp/src/util.c',
1425 'slirp/src/version.c',
1426 'slirp/src/vmstate.c',
1427 ]
1428
1429 configure_file(
1430 input : 'slirp/src/libslirp-version.h.in',
1431 output : 'libslirp-version.h',
1432 configuration: slirp_conf)
1433
1434 slirp_inc = include_directories('slirp', 'slirp/src')
1435 libslirp = static_library('slirp',
1436 sources: slirp_files,
1437 c_args: slirp_cargs,
1438 include_directories: slirp_inc)
1439 slirp = declare_dependency(link_with: libslirp,
1440 dependencies: slirp_deps,
1441 include_directories: slirp_inc)
1442 endif
1443endif
1444
fbb4121d
PB
1445fdt = not_found
1446fdt_opt = get_option('fdt')
1447if have_system
1448 if fdt_opt in ['enabled', 'auto', 'system']
1449 have_internal = fs.exists(meson.current_source_dir() / 'dtc/libfdt/Makefile.libfdt')
1450 fdt = cc.find_library('fdt', static: enable_static,
1451 required: fdt_opt == 'system' or
1452 fdt_opt == 'enabled' and not have_internal)
1453 if fdt.found() and cc.links('''
1454 #include <libfdt.h>
1455 #include <libfdt_env.h>
1456 int main(void) { fdt_check_full(NULL, 0); return 0; }''',
1457 dependencies: fdt)
1458 fdt_opt = 'system'
1459 elif have_internal
1460 fdt_opt = 'internal'
1461 else
1462 fdt_opt = 'disabled'
1463 endif
1464 endif
1465 if fdt_opt == 'internal'
1466 fdt_files = files(
1467 'dtc/libfdt/fdt.c',
1468 'dtc/libfdt/fdt_ro.c',
1469 'dtc/libfdt/fdt_wip.c',
1470 'dtc/libfdt/fdt_sw.c',
1471 'dtc/libfdt/fdt_rw.c',
1472 'dtc/libfdt/fdt_strerror.c',
1473 'dtc/libfdt/fdt_empty_tree.c',
1474 'dtc/libfdt/fdt_addresses.c',
1475 'dtc/libfdt/fdt_overlay.c',
1476 'dtc/libfdt/fdt_check.c',
1477 )
1478
1479 fdt_inc = include_directories('dtc/libfdt')
1480 libfdt = static_library('fdt',
1481 sources: fdt_files,
1482 include_directories: fdt_inc)
1483 fdt = declare_dependency(link_with: libfdt,
1484 include_directories: fdt_inc)
1485 endif
1486endif
1487if not fdt.found() and fdt_required.length() > 0
1488 error('fdt not available but required by targets ' + ', '.join(fdt_required))
1489endif
1490
8b18cdbf 1491config_host_data.set('CONFIG_CAPSTONE', capstone.found())
fbb4121d 1492config_host_data.set('CONFIG_FDT', fdt.found())
4d34a86b 1493config_host_data.set('CONFIG_SLIRP', slirp.found())
8b18cdbf 1494
a0c9162c
PB
1495#####################
1496# Generated sources #
1497#####################
8b18cdbf 1498
a0c9162c 1499genh += configure_file(output: 'config-host.h', configuration: config_host_data)
a81df1b6 1500
3f885659 1501hxtool = find_program('scripts/hxtool')
650b5d54 1502shaderinclude = find_program('scripts/shaderinclude.pl')
a81df1b6
PB
1503qapi_gen = find_program('scripts/qapi-gen.py')
1504qapi_gen_depends = [ meson.source_root() / 'scripts/qapi/__init__.py',
1505 meson.source_root() / 'scripts/qapi/commands.py',
1506 meson.source_root() / 'scripts/qapi/common.py',
a81df1b6
PB
1507 meson.source_root() / 'scripts/qapi/error.py',
1508 meson.source_root() / 'scripts/qapi/events.py',
1509 meson.source_root() / 'scripts/qapi/expr.py',
1510 meson.source_root() / 'scripts/qapi/gen.py',
1511 meson.source_root() / 'scripts/qapi/introspect.py',
1512 meson.source_root() / 'scripts/qapi/parser.py',
1513 meson.source_root() / 'scripts/qapi/schema.py',
1514 meson.source_root() / 'scripts/qapi/source.py',
1515 meson.source_root() / 'scripts/qapi/types.py',
1516 meson.source_root() / 'scripts/qapi/visit.py',
1517 meson.source_root() / 'scripts/qapi/common.py',
a81df1b6
PB
1518 meson.source_root() / 'scripts/qapi-gen.py'
1519]
1520
1521tracetool = [
1522 python, files('scripts/tracetool.py'),
1523 '--backend=' + config_host['TRACE_BACKENDS']
1524]
1525
2c273f32
MAL
1526qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
1527 meson.current_source_dir(),
859aef02 1528 config_host['PKGVERSION'], meson.project_version()]
2c273f32
MAL
1529qemu_version = custom_target('qemu-version.h',
1530 output: 'qemu-version.h',
1531 command: qemu_version_cmd,
1532 capture: true,
1533 build_by_default: true,
1534 build_always_stale: true)
1535genh += qemu_version
1536
3f885659
MAL
1537hxdep = []
1538hx_headers = [
1539 ['qemu-options.hx', 'qemu-options.def'],
1540 ['qemu-img-cmds.hx', 'qemu-img-cmds.h'],
1541]
1542if have_system
1543 hx_headers += [
1544 ['hmp-commands.hx', 'hmp-commands.h'],
1545 ['hmp-commands-info.hx', 'hmp-commands-info.h'],
1546 ]
1547endif
1548foreach d : hx_headers
b7c70bf2 1549 hxdep += custom_target(d[1],
3f885659
MAL
1550 input: files(d[0]),
1551 output: d[1],
1552 capture: true,
1553 build_by_default: true, # to be removed when added to a target
1554 command: [hxtool, '-h', '@INPUT0@'])
1555endforeach
1556genh += hxdep
1557
a0c9162c
PB
1558###################
1559# Collect sources #
1560###################
a81df1b6 1561
55567891 1562authz_ss = ss.source_set()
4a96337d 1563blockdev_ss = ss.source_set()
7e2b888f 1564block_ss = ss.source_set()
2becc36a 1565bsd_user_ss = ss.source_set()
c2306d71 1566chardev_ss = ss.source_set()
7e2b888f 1567common_ss = ss.source_set()
2389304a 1568crypto_ss = ss.source_set()
f78536b1 1569io_ss = ss.source_set()
2becc36a 1570linux_user_ss = ss.source_set()
7e2b888f 1571qmp_ss = ss.source_set()
da33fc09 1572qom_ss = ss.source_set()
7e2b888f 1573softmmu_ss = ss.source_set()
64ed6f92 1574specific_fuzz_ss = ss.source_set()
7e2b888f
PMD
1575specific_ss = ss.source_set()
1576stub_ss = ss.source_set()
1577trace_ss = ss.source_set()
1578user_ss = ss.source_set()
1579util_ss = ss.source_set()
2becc36a 1580
3154fee4 1581modules = {}
2becc36a
PB
1582hw_arch = {}
1583target_arch = {}
1584target_softmmu_arch = {}
a81df1b6
PB
1585
1586###############
1587# Trace files #
1588###############
1589
c9322ab5
MAL
1590# TODO: add each directory to the subdirs from its own meson.build, once
1591# we have those
a81df1b6
PB
1592trace_events_subdirs = [
1593 'accel/kvm',
1594 'accel/tcg',
1595 'crypto',
1596 'monitor',
1597]
1598if have_user
1599 trace_events_subdirs += [ 'linux-user' ]
1600endif
1601if have_block
1602 trace_events_subdirs += [
1603 'authz',
1604 'block',
1605 'io',
1606 'nbd',
1607 'scsi',
1608 ]
1609endif
1610if have_system
1611 trace_events_subdirs += [
1612 'audio',
1613 'backends',
1614 'backends/tpm',
1615 'chardev',
1616 'hw/9pfs',
1617 'hw/acpi',
1618 'hw/alpha',
1619 'hw/arm',
1620 'hw/audio',
1621 'hw/block',
1622 'hw/block/dataplane',
1623 'hw/char',
1624 'hw/display',
1625 'hw/dma',
1626 'hw/hppa',
1627 'hw/hyperv',
1628 'hw/i2c',
1629 'hw/i386',
1630 'hw/i386/xen',
1631 'hw/ide',
1632 'hw/input',
1633 'hw/intc',
1634 'hw/isa',
1635 'hw/mem',
1636 'hw/mips',
1637 'hw/misc',
1638 'hw/misc/macio',
1639 'hw/net',
98e5d7a2 1640 'hw/net/can',
a81df1b6
PB
1641 'hw/nvram',
1642 'hw/pci',
1643 'hw/pci-host',
1644 'hw/ppc',
1645 'hw/rdma',
1646 'hw/rdma/vmw',
1647 'hw/rtc',
1648 'hw/s390x',
1649 'hw/scsi',
1650 'hw/sd',
1651 'hw/sparc',
1652 'hw/sparc64',
1653 'hw/ssi',
1654 'hw/timer',
1655 'hw/tpm',
1656 'hw/usb',
1657 'hw/vfio',
1658 'hw/virtio',
1659 'hw/watchdog',
1660 'hw/xen',
1661 'hw/gpio',
a81df1b6
PB
1662 'migration',
1663 'net',
8b7a5507 1664 'softmmu',
a81df1b6
PB
1665 'ui',
1666 ]
1667endif
1668trace_events_subdirs += [
1669 'hw/core',
1670 'qapi',
1671 'qom',
1672 'target/arm',
1673 'target/hppa',
1674 'target/i386',
a9dc68d9 1675 'target/i386/kvm',
a81df1b6
PB
1676 'target/mips',
1677 'target/ppc',
1678 'target/riscv',
1679 'target/s390x',
1680 'target/sparc',
1681 'util',
1682]
1683
0df750e9
MAL
1684vhost_user = not_found
1685if 'CONFIG_VHOST_USER' in config_host
1686 libvhost_user = subproject('libvhost-user')
1687 vhost_user = libvhost_user.get_variable('vhost_user_dep')
1688endif
1689
a81df1b6
PB
1690subdir('qapi')
1691subdir('qobject')
1692subdir('stubs')
1693subdir('trace')
1694subdir('util')
5582c58f
MAL
1695subdir('qom')
1696subdir('authz')
a81df1b6 1697subdir('crypto')
2d78b56e 1698subdir('ui')
a81df1b6 1699
3154fee4
MAL
1700
1701if enable_modules
1702 libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO')
1703 modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
1704endif
1705
2becc36a 1706stub_ss = stub_ss.apply(config_all, strict: false)
a81df1b6
PB
1707
1708util_ss.add_all(trace_ss)
2becc36a 1709util_ss = util_ss.apply(config_all, strict: false)
a81df1b6
PB
1710libqemuutil = static_library('qemuutil',
1711 sources: util_ss.sources() + stub_ss.sources() + genh,
aa087962 1712 dependencies: [util_ss.dependencies(), m, glib, socket, malloc])
a81df1b6 1713qemuutil = declare_dependency(link_with: libqemuutil,
04c6f1e7 1714 sources: genh + version_res)
a81df1b6 1715
abff1abf
PB
1716decodetree = generator(find_program('scripts/decodetree.py'),
1717 output: 'decode-@[email protected]',
1718 arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@'])
1719
478e943f 1720subdir('audio')
7fcfd456 1721subdir('io')
848e8ff6 1722subdir('chardev')
ec0d5893 1723subdir('fsdev')
abff1abf 1724subdir('libdecnumber')
d3b18480 1725subdir('target')
708eab42 1726subdir('dump')
ec0d5893 1727
5e5733e5
MAL
1728block_ss.add(files(
1729 'block.c',
1730 'blockjob.c',
1731 'job.c',
1732 'qemu-io-cmds.c',
1733))
1734block_ss.add(when: 'CONFIG_REPLICATION', if_true: files('replication.c'))
1735
1736subdir('nbd')
1737subdir('scsi')
1738subdir('block')
1739
4a96337d
PB
1740blockdev_ss.add(files(
1741 'blockdev.c',
cbc20bfb 1742 'blockdev-nbd.c',
4a96337d
PB
1743 'iothread.c',
1744 'job-qmp.c',
1745))
1746
1747# os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
1748# os-win32.c does not
1749blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
1750softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
4a96337d
PB
1751
1752common_ss.add(files('cpus-common.c'))
1753
5d3ea0e1 1754subdir('softmmu')
c9322ab5 1755
f343346b 1756common_ss.add(capstone)
d9f24bf5 1757specific_ss.add(files('cpu.c', 'disas.c', 'gdbstub.c'), capstone)
c9322ab5
MAL
1758specific_ss.add(files('exec-vary.c'))
1759specific_ss.add(when: 'CONFIG_TCG', if_true: files(
1760 'fpu/softfloat.c',
1761 'tcg/optimize.c',
1762 'tcg/tcg-common.c',
1763 'tcg/tcg-op-gvec.c',
1764 'tcg/tcg-op-vec.c',
1765 'tcg/tcg-op.c',
1766 'tcg/tcg.c',
1767))
1768specific_ss.add(when: 'CONFIG_TCG_INTERPRETER', if_true: files('disas/tci.c', 'tcg/tci.c'))
1769
ab318051 1770subdir('backends')
c574e161 1771subdir('disas')
55166230 1772subdir('migration')
ff219dca 1773subdir('monitor')
cdaf0722 1774subdir('net')
17ef2af6 1775subdir('replay')
582ea95f 1776subdir('hw')
1a82878a 1777subdir('accel')
f556b4a1 1778subdir('plugins')
b309c321 1779subdir('bsd-user')
3a30446a
MAL
1780subdir('linux-user')
1781
b309c321
MAL
1782bsd_user_ss.add(files('gdbstub.c'))
1783specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)
1784
3a30446a
MAL
1785linux_user_ss.add(files('gdbstub.c', 'thunk.c'))
1786specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss)
5d3ea0e1 1787
a2ce7dbd
PB
1788# needed for fuzzing binaries
1789subdir('tests/qtest/libqos')
64ed6f92 1790subdir('tests/qtest/fuzz')
a2ce7dbd 1791
a0c9162c
PB
1792########################
1793# Library dependencies #
1794########################
1795
3154fee4
MAL
1796block_mods = []
1797softmmu_mods = []
1798foreach d, list : modules
1799 foreach m, module_ss : list
1800 if enable_modules and targetos != 'windows'
3e292c51 1801 module_ss = module_ss.apply(config_all, strict: false)
3154fee4
MAL
1802 sl = static_library(d + '-' + m, [genh, module_ss.sources()],
1803 dependencies: [modulecommon, module_ss.dependencies()], pic: true)
1804 if d == 'block'
1805 block_mods += sl
1806 else
1807 softmmu_mods += sl
1808 endif
1809 else
1810 if d == 'block'
1811 block_ss.add_all(module_ss)
1812 else
1813 softmmu_ss.add_all(module_ss)
1814 endif
1815 endif
1816 endforeach
1817endforeach
1818
1819nm = find_program('nm')
604f3e4e 1820undefsym = find_program('scripts/undefsym.py')
3154fee4
MAL
1821block_syms = custom_target('block.syms', output: 'block.syms',
1822 input: [libqemuutil, block_mods],
1823 capture: true,
1824 command: [undefsym, nm, '@INPUT@'])
1825qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
1826 input: [libqemuutil, softmmu_mods],
1827 capture: true,
1828 command: [undefsym, nm, '@INPUT@'])
1829
da33fc09
PMD
1830qom_ss = qom_ss.apply(config_host, strict: false)
1831libqom = static_library('qom', qom_ss.sources() + genh,
1832 dependencies: [qom_ss.dependencies()],
1833 name_suffix: 'fa')
1834
1835qom = declare_dependency(link_whole: libqom)
1836
55567891
PMD
1837authz_ss = authz_ss.apply(config_host, strict: false)
1838libauthz = static_library('authz', authz_ss.sources() + genh,
1839 dependencies: [authz_ss.dependencies()],
1840 name_suffix: 'fa',
1841 build_by_default: false)
1842
1843authz = declare_dependency(link_whole: libauthz,
1844 dependencies: qom)
1845
2389304a
PMD
1846crypto_ss = crypto_ss.apply(config_host, strict: false)
1847libcrypto = static_library('crypto', crypto_ss.sources() + genh,
1848 dependencies: [crypto_ss.dependencies()],
1849 name_suffix: 'fa',
1850 build_by_default: false)
1851
1852crypto = declare_dependency(link_whole: libcrypto,
1853 dependencies: [authz, qom])
1854
f78536b1
PMD
1855io_ss = io_ss.apply(config_host, strict: false)
1856libio = static_library('io', io_ss.sources() + genh,
1857 dependencies: [io_ss.dependencies()],
1858 link_with: libqemuutil,
1859 name_suffix: 'fa',
1860 build_by_default: false)
1861
1862io = declare_dependency(link_whole: libio, dependencies: [crypto, qom])
1863
7e6edef3
PMD
1864libmigration = static_library('migration', sources: migration_files + genh,
1865 name_suffix: 'fa',
1866 build_by_default: false)
1867migration = declare_dependency(link_with: libmigration,
1868 dependencies: [zlib, qom, io])
1869softmmu_ss.add(migration)
1870
5e5733e5
MAL
1871block_ss = block_ss.apply(config_host, strict: false)
1872libblock = static_library('block', block_ss.sources() + genh,
1873 dependencies: block_ss.dependencies(),
1874 link_depends: block_syms,
1875 name_suffix: 'fa',
1876 build_by_default: false)
1877
1878block = declare_dependency(link_whole: [libblock],
b7c70bf2
MAL
1879 link_args: '@block.syms',
1880 dependencies: [crypto, io])
5e5733e5 1881
4fb9071f
SH
1882blockdev_ss = blockdev_ss.apply(config_host, strict: false)
1883libblockdev = static_library('blockdev', blockdev_ss.sources() + genh,
1884 dependencies: blockdev_ss.dependencies(),
1885 name_suffix: 'fa',
1886 build_by_default: false)
1887
1888blockdev = declare_dependency(link_whole: [libblockdev],
1889 dependencies: [block])
1890
ff219dca
PB
1891qmp_ss = qmp_ss.apply(config_host, strict: false)
1892libqmp = static_library('qmp', qmp_ss.sources() + genh,
1893 dependencies: qmp_ss.dependencies(),
1894 name_suffix: 'fa',
1895 build_by_default: false)
1896
1897qmp = declare_dependency(link_whole: [libqmp])
1898
c2306d71
PMD
1899libchardev = static_library('chardev', chardev_ss.sources() + genh,
1900 name_suffix: 'fa',
1901 build_by_default: false)
1902
1903chardev = declare_dependency(link_whole: libchardev)
1904
e28ab096
PMD
1905libhwcore = static_library('hwcore', sources: hwcore_files + genh,
1906 name_suffix: 'fa',
1907 build_by_default: false)
1908hwcore = declare_dependency(link_whole: libhwcore)
1909common_ss.add(hwcore)
1910
064f8ee7
PMD
1911###########
1912# Targets #
1913###########
1914
3154fee4
MAL
1915foreach m : block_mods + softmmu_mods
1916 shared_module(m.name(),
1917 name_prefix: '',
1918 link_whole: m,
1919 install: true,
16bf7a33 1920 install_dir: qemu_moddir)
3154fee4
MAL
1921endforeach
1922
4fb9071f 1923softmmu_ss.add(authz, blockdev, chardev, crypto, io, qmp)
64ed6f92
PB
1924common_ss.add(qom, qemuutil)
1925
1926common_ss.add_all(when: 'CONFIG_SOFTMMU', if_true: [softmmu_ss])
2becc36a
PB
1927common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
1928
1929common_all = common_ss.apply(config_all, strict: false)
1930common_all = static_library('common',
1931 build_by_default: false,
1932 sources: common_all.sources() + genh,
1933 dependencies: common_all.dependencies(),
1934 name_suffix: 'fa')
1935
c9322ab5
MAL
1936feature_to_c = find_program('scripts/feature_to_c.sh')
1937
fd5eef85 1938emulators = {}
2becc36a
PB
1939foreach target : target_dirs
1940 config_target = config_target_mak[target]
1941 target_name = config_target['TARGET_NAME']
1942 arch = config_target['TARGET_BASE_ARCH']
859aef02 1943 arch_srcs = [config_target_h[target]]
64ed6f92
PB
1944 arch_deps = []
1945 c_args = ['-DNEED_CPU_H',
1946 '-DCONFIG_TARGET="@[email protected]"'.format(target),
1947 '-DCONFIG_DEVICES="@[email protected]"'.format(target)]
b6c7cfd4 1948 link_args = emulator_link_args
2becc36a 1949
859aef02 1950 config_target += config_host
2becc36a
PB
1951 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
1952 if targetos == 'linux'
1953 target_inc += include_directories('linux-headers', is_system: true)
1954 endif
1955 if target.endswith('-softmmu')
1956 qemu_target_name = 'qemu-system-' + target_name
1957 target_type='system'
abff1abf
PB
1958 t = target_softmmu_arch[arch].apply(config_target, strict: false)
1959 arch_srcs += t.sources()
64ed6f92 1960 arch_deps += t.dependencies()
abff1abf 1961
2c44220d
MAL
1962 hw_dir = target_name == 'sparc64' ? 'sparc64' : arch
1963 hw = hw_arch[hw_dir].apply(config_target, strict: false)
1964 arch_srcs += hw.sources()
64ed6f92 1965 arch_deps += hw.dependencies()
2c44220d 1966
2becc36a 1967 arch_srcs += config_devices_h[target]
64ed6f92 1968 link_args += ['@block.syms', '@qemu.syms']
2becc36a 1969 else
3a30446a 1970 abi = config_target['TARGET_ABI_DIR']
2becc36a
PB
1971 target_type='user'
1972 qemu_target_name = 'qemu-' + target_name
1973 if 'CONFIG_LINUX_USER' in config_target
1974 base_dir = 'linux-user'
1975 target_inc += include_directories('linux-user/host/' / config_host['ARCH'])
1976 else
1977 base_dir = 'bsd-user'
1978 endif
1979 target_inc += include_directories(
1980 base_dir,
3a30446a 1981 base_dir / abi,
2becc36a 1982 )
3a30446a
MAL
1983 if 'CONFIG_LINUX_USER' in config_target
1984 dir = base_dir / abi
1985 arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c')
1986 if config_target.has_key('TARGET_SYSTBL_ABI')
1987 arch_srcs += \
1988 syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'],
1989 extra_args : config_target['TARGET_SYSTBL_ABI'])
1990 endif
1991 endif
2becc36a
PB
1992 endif
1993
c9322ab5
MAL
1994 if 'TARGET_XML_FILES' in config_target
1995 gdbstub_xml = custom_target(target + '-gdbstub-xml.c',
1996 output: target + '-gdbstub-xml.c',
1997 input: files(config_target['TARGET_XML_FILES'].split()),
1998 command: [feature_to_c, '@INPUT@'],
1999 capture: true)
2000 arch_srcs += gdbstub_xml
2001 endif
2002
abff1abf
PB
2003 t = target_arch[arch].apply(config_target, strict: false)
2004 arch_srcs += t.sources()
64ed6f92 2005 arch_deps += t.dependencies()
abff1abf 2006
2becc36a
PB
2007 target_common = common_ss.apply(config_target, strict: false)
2008 objects = common_all.extract_objects(target_common.sources())
64ed6f92 2009 deps = target_common.dependencies()
2becc36a 2010
2becc36a
PB
2011 target_specific = specific_ss.apply(config_target, strict: false)
2012 arch_srcs += target_specific.sources()
64ed6f92 2013 arch_deps += target_specific.dependencies()
2becc36a 2014
64ed6f92 2015 lib = static_library('qemu-' + target,
859aef02 2016 sources: arch_srcs + genh,
b7612f45 2017 dependencies: arch_deps,
2becc36a
PB
2018 objects: objects,
2019 include_directories: target_inc,
64ed6f92
PB
2020 c_args: c_args,
2021 build_by_default: false,
2becc36a 2022 name_suffix: 'fa')
64ed6f92
PB
2023
2024 if target.endswith('-softmmu')
2025 execs = [{
2026 'name': 'qemu-system-' + target_name,
2027 'gui': false,
2028 'sources': files('softmmu/main.c'),
2029 'dependencies': []
2030 }]
35be72ba 2031 if targetos == 'windows' and (sdl.found() or gtk.found())
64ed6f92
PB
2032 execs += [{
2033 'name': 'qemu-system-' + target_name + 'w',
2034 'gui': true,
2035 'sources': files('softmmu/main.c'),
2036 'dependencies': []
2037 }]
2038 endif
2039 if config_host.has_key('CONFIG_FUZZ')
2040 specific_fuzz = specific_fuzz_ss.apply(config_target, strict: false)
2041 execs += [{
2042 'name': 'qemu-fuzz-' + target_name,
2043 'gui': false,
2044 'sources': specific_fuzz.sources(),
2045 'dependencies': specific_fuzz.dependencies(),
64ed6f92
PB
2046 }]
2047 endif
2048 else
2049 execs = [{
2050 'name': 'qemu-' + target_name,
2051 'gui': false,
2052 'sources': [],
2053 'dependencies': []
2054 }]
2055 endif
2056 foreach exe: execs
fd5eef85
PB
2057 emulators += {exe['name']:
2058 executable(exe['name'], exe['sources'],
64ed6f92
PB
2059 install: true,
2060 c_args: c_args,
2061 dependencies: arch_deps + deps + exe['dependencies'],
2062 objects: lib.extract_all_objects(recursive: true),
2063 link_language: link_language,
2064 link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
2065 link_args: link_args,
2066 gui_app: exe['gui'])
fd5eef85 2067 }
10e1d263
MAL
2068
2069 if 'CONFIG_TRACE_SYSTEMTAP' in config_host
2070 foreach stp: [
bd5f973a
SH
2071 {'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / exe['name'], 'install': false},
2072 {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / get_option('bindir') / exe['name'], 'install': true},
10e1d263
MAL
2073 {'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 'install': true},
2074 {'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true},
2075 ]
bd5f973a 2076 custom_target(exe['name'] + stp['ext'],
10e1d263 2077 input: trace_events_all,
bd5f973a 2078 output: exe['name'] + stp['ext'],
10e1d263
MAL
2079 capture: true,
2080 install: stp['install'],
16bf7a33 2081 install_dir: get_option('datadir') / 'systemtap/tapset',
10e1d263
MAL
2082 command: [
2083 tracetool, '--group=all', '--format=' + stp['fmt'],
2084 '--binary=' + stp['bin'],
2085 '--target-name=' + target_name,
2086 '--target-type=' + target_type,
2087 '--probe-prefix=qemu.' + target_type + '.' + target_name,
2088 '@INPUT@',
2089 ])
2090 endforeach
2091 endif
64ed6f92 2092 endforeach
2becc36a
PB
2093endforeach
2094
931049b4 2095# Other build targets
897b5afa 2096
f556b4a1
PB
2097if 'CONFIG_PLUGIN' in config_host
2098 install_headers('include/qemu/qemu-plugin.h')
2099endif
2100
f15bff25
PB
2101if 'CONFIG_GUEST_AGENT' in config_host
2102 subdir('qga')
2103endif
2104
9755c94a
LV
2105# Don't build qemu-keymap if xkbcommon is not explicitly enabled
2106# when we don't build tools or system
4113f4cf 2107if xkbcommon.found()
28742467
MAL
2108 # used for the update-keymaps target, so include rules even if !have_tools
2109 qemu_keymap = executable('qemu-keymap', files('qemu-keymap.c', 'ui/input-keymap.c') + genh,
2110 dependencies: [qemuutil, xkbcommon], install: have_tools)
2111endif
2112
931049b4 2113if have_tools
b7c70bf2
MAL
2114 qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
2115 dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
2116 qemu_io = executable('qemu-io', files('qemu-io.c'),
2117 dependencies: [block, qemuutil], install: true)
eb705985 2118 qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
cbc20bfb 2119 dependencies: [blockdev, qemuutil], install: true)
b7c70bf2 2120
7c58bb76 2121 subdir('storage-daemon')
a9c9727c 2122 subdir('contrib/rdmacm-mux')
1d7bb6ab 2123 subdir('contrib/elf2dmp')
a9c9727c 2124
157e7b13
MAL
2125 executable('qemu-edid', files('qemu-edid.c', 'hw/display/edid-generate.c'),
2126 dependencies: qemuutil,
2127 install: true)
2128
931049b4 2129 if 'CONFIG_VHOST_USER' in config_host
2d7ac0af 2130 subdir('contrib/vhost-user-blk')
b7612f45 2131 subdir('contrib/vhost-user-gpu')
32fcc624 2132 subdir('contrib/vhost-user-input')
99650b62 2133 subdir('contrib/vhost-user-scsi')
931049b4 2134 endif
8f51e01c
MAL
2135
2136 if targetos == 'linux'
2137 executable('qemu-bridge-helper', files('qemu-bridge-helper.c'),
2138 dependencies: [qemuutil, libcap_ng],
2139 install: true,
2140 install_dir: get_option('libexecdir'))
897b5afa
MAL
2141
2142 executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'),
2143 dependencies: [authz, crypto, io, qom, qemuutil,
6ec0e15d 2144 libcap_ng, mpathpersist],
897b5afa 2145 install: true)
8f51e01c
MAL
2146 endif
2147
5ee24e78
MAL
2148 if 'CONFIG_IVSHMEM' in config_host
2149 subdir('contrib/ivshmem-client')
2150 subdir('contrib/ivshmem-server')
2151 endif
931049b4
PB
2152endif
2153
f5aa6320 2154subdir('scripts')
3f99cf57 2155subdir('tools')
bdcbea7a 2156subdir('pc-bios')
f8aa24ea 2157subdir('docs')
e3667660 2158subdir('tests')
e8f3bd71
MAL
2159if 'CONFIG_GTK' in config_host
2160 subdir('po')
2161endif
3f99cf57 2162
8adfeba9
MAL
2163if host_machine.system() == 'windows'
2164 nsis_cmd = [
2165 find_program('scripts/nsis.py'),
2166 '@OUTPUT@',
2167 get_option('prefix'),
2168 meson.current_source_dir(),
24bdcc96 2169 host_machine.cpu(),
8adfeba9
MAL
2170 '--',
2171 '-DDISPLAYVERSION=' + meson.project_version(),
2172 ]
2173 if build_docs
2174 nsis_cmd += '-DCONFIG_DOCUMENTATION=y'
2175 endif
2176 if 'CONFIG_GTK' in config_host
2177 nsis_cmd += '-DCONFIG_GTK=y'
2178 endif
2179
2180 nsis = custom_target('nsis',
2181 output: 'qemu-setup-' + meson.project_version() + '.exe',
2182 input: files('qemu.nsi'),
2183 build_always_stale: true,
2184 command: nsis_cmd + ['@INPUT@'])
2185 alias_target('installer', nsis)
2186endif
2187
a0c9162c
PB
2188#########################
2189# Configuration summary #
2190#########################
2191
f9332757 2192summary_info = {}
16bf7a33
PB
2193summary_info += {'Install prefix': get_option('prefix')}
2194summary_info += {'BIOS directory': qemu_datadir}
2195summary_info += {'firmware path': get_option('qemu_firmwarepath')}
2196summary_info += {'binary directory': get_option('bindir')}
2197summary_info += {'library directory': get_option('libdir')}
2198summary_info += {'module directory': qemu_moddir}
2199summary_info += {'libexec directory': get_option('libexecdir')}
2200summary_info += {'include directory': get_option('includedir')}
2201summary_info += {'config directory': get_option('sysconfdir')}
f9332757 2202if targetos != 'windows'
16bf7a33 2203 summary_info += {'local state directory': get_option('localstatedir')}
b81efab7 2204 summary_info += {'Manual directory': get_option('mandir')}
f9332757
PB
2205else
2206 summary_info += {'local state directory': 'queried at runtime'}
2207endif
491e74c1 2208summary_info += {'Doc directory': get_option('docdir')}
f9332757
PB
2209summary_info += {'Build directory': meson.current_build_dir()}
2210summary_info += {'Source path': meson.current_source_dir()}
2211summary_info += {'GIT binary': config_host['GIT']}
2212summary_info += {'GIT submodules': config_host['GIT_SUBMODULES']}
2213summary_info += {'C compiler': meson.get_compiler('c').cmd_array()[0]}
2214summary_info += {'Host C compiler': meson.get_compiler('c', native: true).cmd_array()[0]}
2215if link_language == 'cpp'
2216 summary_info += {'C++ compiler': meson.get_compiler('cpp').cmd_array()[0]}
2217else
2218 summary_info += {'C++ compiler': false}
2219endif
2220if targetos == 'darwin'
2221 summary_info += {'Objective-C compiler': meson.get_compiler('objc').cmd_array()[0]}
2222endif
2223summary_info += {'ARFLAGS': config_host['ARFLAGS']}
47b30835
PB
2224summary_info += {'CFLAGS': ' '.join(get_option('c_args')
2225 + ['-O' + get_option('optimization')]
2226 + (get_option('debug') ? ['-g'] : []))}
2227if link_language == 'cpp'
2228 summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args')
2229 + ['-O' + get_option('optimization')]
2230 + (get_option('debug') ? ['-g'] : []))}
2231endif
2232link_args = get_option(link_language + '_link_args')
2233if link_args.length() > 0
2234 summary_info += {'LDFLAGS': ' '.join(link_args)}
2235endif
f9332757
PB
2236summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']}
2237summary_info += {'QEMU_LDFLAGS': config_host['QEMU_LDFLAGS']}
2238summary_info += {'make': config_host['MAKE']}
f9332757 2239summary_info += {'python': '@0@ (version: @1@)'.format(python.full_path(), python.language_version())}
e3667660 2240summary_info += {'sphinx-build': sphinx_build.found()}
f9332757
PB
2241summary_info += {'genisoimage': config_host['GENISOIMAGE']}
2242# TODO: add back version
4d34a86b
PB
2243summary_info += {'slirp support': slirp_opt == 'disabled' ? false : slirp_opt}
2244if slirp_opt != 'disabled'
f9332757
PB
2245 summary_info += {'smbd': config_host['CONFIG_SMBD_COMMAND']}
2246endif
2247summary_info += {'module support': config_host.has_key('CONFIG_MODULES')}
2248if config_host.has_key('CONFIG_MODULES')
2249 summary_info += {'alternative module path': config_host.has_key('CONFIG_MODULE_UPGRADES')}
2250endif
2251summary_info += {'host CPU': cpu}
2252summary_info += {'host endianness': build_machine.endian()}
fdb75aef 2253summary_info += {'target list': ' '.join(target_dirs)}
f9332757 2254summary_info += {'gprof enabled': config_host.has_key('CONFIG_GPROF')}
deb62371 2255summary_info += {'sparse enabled': sparse.found()}
f9332757
PB
2256summary_info += {'strip binaries': get_option('strip')}
2257summary_info += {'profiler': config_host.has_key('CONFIG_PROFILER')}
cdad781d 2258summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
3e8529dd 2259summary_info += {'static build': config_host.has_key('CONFIG_STATIC')}
f9332757
PB
2260if targetos == 'darwin'
2261 summary_info += {'Cocoa support': config_host.has_key('CONFIG_COCOA')}
2262endif
2263# TODO: add back version
35be72ba
PB
2264summary_info += {'SDL support': sdl.found()}
2265summary_info += {'SDL image support': sdl_image.found()}
f9332757
PB
2266# TODO: add back version
2267summary_info += {'GTK support': config_host.has_key('CONFIG_GTK')}
2268summary_info += {'GTK GL support': config_host.has_key('CONFIG_GTK_GL')}
b7612f45 2269summary_info += {'pixman': pixman.found()}
f9332757
PB
2270# TODO: add back version
2271summary_info += {'VTE support': config_host.has_key('CONFIG_VTE')}
2272summary_info += {'TLS priority': config_host['CONFIG_TLS_PRIORITY']}
2273summary_info += {'GNUTLS support': config_host.has_key('CONFIG_GNUTLS')}
2274# TODO: add back version
2275summary_info += {'libgcrypt': config_host.has_key('CONFIG_GCRYPT')}
2276if config_host.has_key('CONFIG_GCRYPT')
2277 summary_info += {' hmac': config_host.has_key('CONFIG_GCRYPT_HMAC')}
2278 summary_info += {' XTS': not config_host.has_key('CONFIG_QEMU_PRIVATE_XTS')}
2279endif
2280# TODO: add back version
2281summary_info += {'nettle': config_host.has_key('CONFIG_NETTLE')}
2282if config_host.has_key('CONFIG_NETTLE')
2283 summary_info += {' XTS': not config_host.has_key('CONFIG_QEMU_PRIVATE_XTS')}
2284endif
2285summary_info += {'libtasn1': config_host.has_key('CONFIG_TASN1')}
2286summary_info += {'PAM': config_host.has_key('CONFIG_AUTH_PAM')}
5285e593
YL
2287summary_info += {'iconv support': iconv.found()}
2288summary_info += {'curses support': curses.found()}
f9332757
PB
2289# TODO: add back version
2290summary_info += {'virgl support': config_host.has_key('CONFIG_VIRGL')}
f9cd86fe 2291summary_info += {'curl support': curl.found()}
f9332757
PB
2292summary_info += {'mingw32 support': targetos == 'windows'}
2293summary_info += {'Audio drivers': config_host['CONFIG_AUDIO_DRIVERS']}
2294summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
2295summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']}
2296summary_info += {'VirtFS support': config_host.has_key('CONFIG_VIRTFS')}
cece116c 2297summary_info += {'build virtiofs daemon': have_virtiofsd}
6ec0e15d 2298summary_info += {'Multipath support': mpathpersist.found()}
a0b93237
PB
2299summary_info += {'VNC support': vnc.found()}
2300if vnc.found()
2301 summary_info += {'VNC SASL support': sasl.found()}
2302 summary_info += {'VNC JPEG support': jpeg.found()}
2303 summary_info += {'VNC PNG support': png.found()}
f9332757
PB
2304endif
2305summary_info += {'xen support': config_host.has_key('CONFIG_XEN_BACKEND')}
2306if config_host.has_key('CONFIG_XEN_BACKEND')
2307 summary_info += {'xen ctrl version': config_host['CONFIG_XEN_CTRL_INTERFACE_VERSION']}
2308endif
8c6d4ff4 2309summary_info += {'brlapi support': brlapi.found()}
e3667660 2310summary_info += {'Documentation': build_docs}
f9332757
PB
2311summary_info += {'PIE': get_option('b_pie')}
2312summary_info += {'vde support': config_host.has_key('CONFIG_VDE')}
2313summary_info += {'netmap support': config_host.has_key('CONFIG_NETMAP')}
2314summary_info += {'Linux AIO support': config_host.has_key('CONFIG_LINUX_AIO')}
2315summary_info += {'Linux io_uring support': config_host.has_key('CONFIG_LINUX_IO_URING')}
2316summary_info += {'ATTR/XATTR support': config_host.has_key('CONFIG_ATTR')}
c8d5450b 2317summary_info += {'Install blobs': get_option('install_blobs')}
05512f55
PB
2318summary_info += {'KVM support': config_all.has_key('CONFIG_KVM')}
2319summary_info += {'HAX support': config_all.has_key('CONFIG_HAX')}
2320summary_info += {'HVF support': config_all.has_key('CONFIG_HVF')}
2321summary_info += {'WHPX support': config_all.has_key('CONFIG_WHPX')}
2322summary_info += {'TCG support': config_all.has_key('CONFIG_TCG')}
2323if config_all.has_key('CONFIG_TCG')
2324 summary_info += {'TCG debug enabled': config_host.has_key('CONFIG_DEBUG_TCG')}
2325 summary_info += {'TCG interpreter': config_host.has_key('CONFIG_TCG_INTERPRETER')}
2326endif
aa087962 2327summary_info += {'malloc trim support': has_malloc_trim}
f9332757
PB
2328summary_info += {'RDMA support': config_host.has_key('CONFIG_RDMA')}
2329summary_info += {'PVRDMA support': config_host.has_key('CONFIG_PVRDMA')}
fbb4121d 2330summary_info += {'fdt support': fdt_opt == 'disabled' ? false : fdt_opt}
f9332757
PB
2331summary_info += {'membarrier': config_host.has_key('CONFIG_MEMBARRIER')}
2332summary_info += {'preadv support': config_host.has_key('CONFIG_PREADV')}
2333summary_info += {'fdatasync': config_host.has_key('CONFIG_FDATASYNC')}
2334summary_info += {'madvise': config_host.has_key('CONFIG_MADVISE')}
2335summary_info += {'posix_madvise': config_host.has_key('CONFIG_POSIX_MADVISE')}
2336summary_info += {'posix_memalign': config_host.has_key('CONFIG_POSIX_MEMALIGN')}
2337summary_info += {'libcap-ng support': config_host.has_key('CONFIG_LIBCAP_NG')}
b54b82df 2338summary_info += {'vhost-kernel support': config_host.has_key('CONFIG_VHOST_KERNEL')}
f9332757
PB
2339summary_info += {'vhost-net support': config_host.has_key('CONFIG_VHOST_NET')}
2340summary_info += {'vhost-crypto support': config_host.has_key('CONFIG_VHOST_CRYPTO')}
2341summary_info += {'vhost-scsi support': config_host.has_key('CONFIG_VHOST_SCSI')}
2342summary_info += {'vhost-vsock support': config_host.has_key('CONFIG_VHOST_VSOCK')}
b54b82df 2343summary_info += {'vhost-user support': config_host.has_key('CONFIG_VHOST_USER')}
e5e856c1 2344summary_info += {'vhost-user-blk server support': have_vhost_user_blk_server}
f9332757
PB
2345summary_info += {'vhost-user-fs support': config_host.has_key('CONFIG_VHOST_USER_FS')}
2346summary_info += {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST_VDPA')}
2347summary_info += {'Trace backends': config_host['TRACE_BACKENDS']}
2348if config_host['TRACE_BACKENDS'].split().contains('simple')
2349 summary_info += {'Trace output file': config_host['CONFIG_TRACE_FILE'] + '-<pid>'}
2350endif
2351# TODO: add back protocol and server version
2352summary_info += {'spice support': config_host.has_key('CONFIG_SPICE')}
fabd1e93 2353summary_info += {'rbd support': rbd.found()}
f9332757
PB
2354summary_info += {'xfsctl support': config_host.has_key('CONFIG_XFS')}
2355summary_info += {'smartcard support': config_host.has_key('CONFIG_SMARTCARD')}
0a40bcb7 2356summary_info += {'U2F support': u2f.found()}
f9332757
PB
2357summary_info += {'libusb': config_host.has_key('CONFIG_USB_LIBUSB')}
2358summary_info += {'usb net redir': config_host.has_key('CONFIG_USB_REDIR')}
2359summary_info += {'OpenGL support': config_host.has_key('CONFIG_OPENGL')}
2360summary_info += {'OpenGL dmabufs': config_host.has_key('CONFIG_OPENGL_DMABUF')}
9db405a3 2361summary_info += {'libiscsi support': libiscsi.found()}
30045c05 2362summary_info += {'libnfs support': libnfs.found()}
f9332757
PB
2363summary_info += {'build guest agent': config_host.has_key('CONFIG_GUEST_AGENT')}
2364if targetos == 'windows'
2365 if 'WIN_SDK' in config_host
2366 summary_info += {'Windows SDK': config_host['WIN_SDK']}
2367 endif
2368 summary_info += {'QGA VSS support': config_host.has_key('CONFIG_QGA_VSS')}
2369 summary_info += {'QGA w32 disk info': config_host.has_key('CONFIG_QGA_NTDDSCSI')}
4bad7c3b 2370 summary_info += {'QGA MSI support': config_host.has_key('CONFIG_QGA_MSI')}
f9332757 2371endif
90835c2b 2372summary_info += {'seccomp support': seccomp.found()}
9e62ba48
DB
2373summary_info += {'CFI support': get_option('cfi')}
2374summary_info += {'CFI debug support': get_option('cfi_debug')}
f9332757
PB
2375summary_info += {'coroutine backend': config_host['CONFIG_COROUTINE_BACKEND']}
2376summary_info += {'coroutine pool': config_host['CONFIG_COROUTINE_POOL'] == '1'}
2377summary_info += {'debug stack usage': config_host.has_key('CONFIG_DEBUG_STACK_USAGE')}
2378summary_info += {'mutex debugging': config_host.has_key('CONFIG_DEBUG_MUTEX')}
2379summary_info += {'crypto afalg': config_host.has_key('CONFIG_AF_ALG')}
08821ca2 2380summary_info += {'GlusterFS support': glusterfs.found()}
bf0e56a3 2381summary_info += {'gcov': get_option('b_coverage')}
f9332757
PB
2382summary_info += {'TPM support': config_host.has_key('CONFIG_TPM')}
2383summary_info += {'libssh support': config_host.has_key('CONFIG_LIBSSH')}
2384summary_info += {'QOM debugging': config_host.has_key('CONFIG_QOM_CAST_DEBUG')}
2385summary_info += {'Live block migration': config_host.has_key('CONFIG_LIVE_BLOCK_MIGRATION')}
0c32a0ae 2386summary_info += {'lzo support': lzo.found()}
241611ea 2387summary_info += {'snappy support': snappy.found()}
29ba6116 2388summary_info += {'bzip2 support': libbzip2.found()}
ecea3696 2389summary_info += {'lzfse support': liblzfse.found()}
b1def33d 2390summary_info += {'zstd support': zstd.found()}
f9332757
PB
2391summary_info += {'NUMA host support': config_host.has_key('CONFIG_NUMA')}
2392summary_info += {'libxml2': config_host.has_key('CONFIG_LIBXML2')}
aa087962 2393summary_info += {'memory allocator': get_option('malloc')}
f9332757
PB
2394summary_info += {'avx2 optimization': config_host.has_key('CONFIG_AVX2_OPT')}
2395summary_info += {'avx512f optimization': config_host.has_key('CONFIG_AVX512F_OPT')}
2396summary_info += {'replication support': config_host.has_key('CONFIG_REPLICATION')}
2397summary_info += {'bochs support': config_host.has_key('CONFIG_BOCHS')}
2398summary_info += {'cloop support': config_host.has_key('CONFIG_CLOOP')}
2399summary_info += {'dmg support': config_host.has_key('CONFIG_DMG')}
2400summary_info += {'qcow v1 support': config_host.has_key('CONFIG_QCOW1')}
2401summary_info += {'vdi support': config_host.has_key('CONFIG_VDI')}
2402summary_info += {'vvfat support': config_host.has_key('CONFIG_VVFAT')}
2403summary_info += {'qed support': config_host.has_key('CONFIG_QED')}
2404summary_info += {'parallels support': config_host.has_key('CONFIG_PARALLELS')}
2405summary_info += {'sheepdog support': config_host.has_key('CONFIG_SHEEPDOG')}
8b18cdbf 2406summary_info += {'capstone': capstone_opt == 'disabled' ? false : capstone_opt}
f9332757
PB
2407summary_info += {'libpmem support': config_host.has_key('CONFIG_LIBPMEM')}
2408summary_info += {'libdaxctl support': config_host.has_key('CONFIG_LIBDAXCTL')}
f01496a3 2409summary_info += {'libudev': libudev.found()}
f9332757
PB
2410summary_info += {'default devices': config_host['CONFIG_MINIKCONF_MODE'] == '--defconfig'}
2411summary_info += {'plugin support': config_host.has_key('CONFIG_PLUGIN')}
2412summary_info += {'fuzzing support': config_host.has_key('CONFIG_FUZZ')}
2413if config_host.has_key('HAVE_GDB_BIN')
2414 summary_info += {'gdb': config_host['HAVE_GDB_BIN']}
2415endif
2416summary_info += {'thread sanitizer': config_host.has_key('CONFIG_TSAN')}
2417summary_info += {'rng-none': config_host.has_key('CONFIG_RNG_NONE')}
2418summary_info += {'Linux keyring': config_host.has_key('CONFIG_SECRET_KEYRING')}
a484a719 2419summary_info += {'FUSE exports': fuse.found()}
df4ea709 2420summary_info += {'FUSE lseek': fuse_lseek.found()}
f9332757
PB
2421summary(summary_info, bool_yn: true)
2422
2423if not supported_cpus.contains(cpu)
2424 message()
2425 warning('SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!')
2426 message()
2427 message('CPU host architecture ' + cpu + ' support is not currently maintained.')
2428 message('The QEMU project intends to remove support for this host CPU in')
2429 message('a future release if nobody volunteers to maintain it and to')
2430 message('provide a build host for our continuous integration setup.')
2431 message('configure has succeeded and you can continue to build, but')
2432 message('if you care about QEMU on this platform you should contact')
2433 message('us upstream at [email protected].')
2434endif
2435
2436if not supported_oses.contains(targetos)
2437 message()
2438 warning('WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!')
2439 message()
2440 message('Host OS ' + targetos + 'support is not currently maintained.')
2441 message('The QEMU project intends to remove support for this host OS in')
2442 message('a future release if nobody volunteers to maintain it and to')
2443 message('provide a build host for our continuous integration setup.')
2444 message('configure has succeeded and you can continue to build, but')
2445 message('if you care about QEMU on this platform you should contact')
2446 message('us upstream at [email protected].')
2447endif
This page took 0.471377 seconds and 4 git commands to generate.