blob: afe53d8f0c9aa3ba369261191a809712d2690156 [file] [log] [blame]
Paolo Bonzinia5665052019-06-10 12:05:14 +02001project('qemu', ['c'], meson_version: '>=0.55.0',
Gerd Hoffmann90756b22020-08-25 08:43:42 +02002 default_options: ['warning_level=1', 'c_std=gnu99', 'cpp_std=gnu++11',
Paolo Bonzini3e0e5192020-09-01 12:48:00 -04003 'b_colorout=auto'],
Paolo Bonzinia5665052019-06-10 12:05:14 +02004 version: run_command('head', meson.source_root() / 'VERSION').stdout().strip())
5
6not_found = dependency('', required: false)
Paolo Bonzinib29b40f2020-08-10 18:04:43 +02007if meson.version().version_compare('>=0.56.0')
8 keyval = import('keyval')
9else
10 keyval = import('unstable-keyval')
11endif
Paolo Bonzinia81df1b2020-08-19 08:44:56 -040012ss = import('sourceset')
13
Paolo Bonzinice1c1e72020-01-28 16:41:44 +010014sh = find_program('sh')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -040015cc = meson.get_compiler('c')
Paolo Bonzinia5665052019-06-10 12:05:14 +020016config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
Marc-André Lureau3154fee2019-08-29 22:07:01 +040017enable_modules = 'CONFIG_MODULES' in config_host
Paolo Bonzini35be72b2020-02-06 14:17:15 +010018enable_static = 'CONFIG_STATIC' in config_host
Paolo Bonzinif8aa24e2020-08-05 15:49:10 +020019build_docs = 'BUILD_DOCS' in config_host
Marc-André Lureau8fe11232020-09-11 14:42:48 +020020
21if get_option('qemu_suffix').startswith('/')
22 error('qemu_suffix cannot start with a /')
23endif
24
Marc-André Lureauab4c0992020-08-26 15:04:16 +040025qemu_datadir = get_option('datadir') / get_option('qemu_suffix')
Marc-André Lureau491e74c2020-08-26 15:04:17 +040026qemu_docdir = get_option('docdir') / get_option('qemu_suffix')
Paolo Bonzini859aef02020-08-04 18:14:26 +020027config_host_data = configuration_data()
28genh = []
Paolo Bonzinia5665052019-06-10 12:05:14 +020029
Paolo Bonzini760e4322020-08-26 08:09:48 +020030target_dirs = config_host['TARGET_DIRS'].split()
31have_user = false
32have_system = false
33foreach target : target_dirs
34 have_user = have_user or target.endswith('-user')
35 have_system = have_system or target.endswith('-softmmu')
36endforeach
37have_tools = 'CONFIG_TOOLS' in config_host
38have_block = have_system or have_tools
39
Paolo Bonzini201e8ed2020-09-01 07:45:54 -040040python = import('python').find_installation()
41
42supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
43supported_cpus = ['ppc', 'ppc64', 's390x', 'sparc64', 'riscv32', 'riscv64', 'x86', 'x86_64',
44 'arm', 'aarch64', 'mips', 'mips64', 'sparc', 'sparc64']
45
46cpu = host_machine.cpu_family()
47targetos = host_machine.system()
48
49configure_file(input: files('scripts/ninjatool.py'),
50 output: 'ninjatool',
51 configuration: config_host)
52
53##################
54# Compiler flags #
55##################
56
Paolo Bonzinia5665052019-06-10 12:05:14 +020057add_project_arguments(config_host['QEMU_CFLAGS'].split(),
58 native: false, language: ['c', 'objc'])
59add_project_arguments(config_host['QEMU_CXXFLAGS'].split(),
60 native: false, language: 'cpp')
61add_project_link_arguments(config_host['QEMU_LDFLAGS'].split(),
62 native: false, language: ['c', 'cpp', 'objc'])
63add_project_arguments(config_host['QEMU_INCLUDES'].split(),
64 language: ['c', 'cpp', 'objc'])
65
Alexander Bulekovc46f76d2020-09-02 13:36:50 -040066# Specify linker-script with add_project_link_arguments so that it is not placed
67# within a linker --start-group/--end-group pair
68if 'CONFIG_FUZZ' in config_host
69 add_project_link_arguments(['-Wl,-T,',
70 (meson.current_source_dir() / 'tests/qtest/fuzz/fork_fuzz.ld')],
71 native: false, language: ['c', 'cpp', 'objc'])
72endif
73
Marc-André Lureaufc929892019-07-13 01:47:54 +040074link_language = meson.get_external_property('link_language', 'cpp')
75if link_language == 'cpp'
76 add_languages('cpp', required: true, native: false)
77endif
Paolo Bonzinia5665052019-06-10 12:05:14 +020078if host_machine.system() == 'darwin'
79 add_languages('objc', required: false, native: false)
80endif
81
Paolo Bonzini968b4db2020-02-03 14:45:33 +010082if 'SPARSE_CFLAGS' in config_host
83 run_target('sparse',
84 command: [find_program('scripts/check_sparse.py'),
85 config_host['SPARSE_CFLAGS'].split(),
86 'compile_commands.json'])
87endif
88
Paolo Bonzini6ec0e152020-09-16 18:07:29 +020089###########################################
90# Target-specific checks and dependencies #
91###########################################
92
93if targetos != 'linux' and get_option('mpath').enabled()
94 error('Multipath is supported only on Linux')
95endif
96
Paolo Bonzinia81df1b2020-08-19 08:44:56 -040097m = cc.find_library('m', required: false)
98util = cc.find_library('util', required: false)
Paolo Bonzini4a963372020-08-03 16:22:28 +020099winmm = []
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400100socket = []
Marc-André Lureau04c6f1e2019-07-18 00:31:05 +0400101version_res = []
Marc-André Lureaud92989a2019-08-20 19:48:59 +0400102coref = []
103iokit = []
104cocoa = []
105hvf = []
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400106if targetos == 'windows'
107 socket = cc.find_library('ws2_32')
Paolo Bonzini4a963372020-08-03 16:22:28 +0200108 winmm = cc.find_library('winmm')
Marc-André Lureau04c6f1e2019-07-18 00:31:05 +0400109
110 win = import('windows')
111 version_res = win.compile_resources('version.rc',
112 depend_files: files('pc-bios/qemu-nsis.ico'),
113 include_directories: include_directories('.'))
Marc-André Lureaud92989a2019-08-20 19:48:59 +0400114elif targetos == 'darwin'
115 coref = dependency('appleframeworks', modules: 'CoreFoundation')
116 iokit = dependency('appleframeworks', modules: 'IOKit')
117 cocoa = dependency('appleframeworks', modules: 'Cocoa')
118 hvf = dependency('appleframeworks', modules: 'Hypervisor')
Paolo Bonzinicfad62f2020-08-09 23:47:45 +0200119elif targetos == 'sunos'
120 socket = [cc.find_library('socket'),
121 cc.find_library('nsl'),
122 cc.find_library('resolv')]
123elif targetos == 'haiku'
124 socket = [cc.find_library('posix_error_mapper'),
125 cc.find_library('network'),
126 cc.find_library('bsd')]
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400127endif
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200128
129################
130# Dependencies #
131################
132
Paolo Bonzini215b0c22020-09-01 08:41:17 -0400133# The path to glib.h is added to all compilation commands. This was
134# grandfathered in from the QEMU Makefiles.
135add_project_arguments(config_host['GLIB_CFLAGS'].split(),
136 native: false, language: ['c', 'cpp', 'objc'])
137glib = declare_dependency(link_args: config_host['GLIB_LIBS'].split())
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400138gio = not_found
139if 'CONFIG_GIO' in config_host
140 gio = declare_dependency(compile_args: config_host['GIO_CFLAGS'].split(),
141 link_args: config_host['GIO_LIBS'].split())
142endif
143lttng = not_found
144if 'CONFIG_TRACE_UST' in config_host
145 lttng = declare_dependency(link_args: config_host['LTTNG_UST_LIBS'].split())
146endif
147urcubp = not_found
148if 'CONFIG_TRACE_UST' in config_host
149 urcubp = declare_dependency(link_args: config_host['URCU_BP_LIBS'].split())
150endif
Daniel P. Berrangé46859d92020-09-01 14:30:49 +0100151gcrypt = not_found
152if 'CONFIG_GCRYPT' in config_host
153 gcrypt = declare_dependency(compile_args: config_host['GCRYPT_CFLAGS'].split(),
154 link_args: config_host['GCRYPT_LIBS'].split())
155endif
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400156nettle = not_found
157if 'CONFIG_NETTLE' in config_host
158 nettle = declare_dependency(compile_args: config_host['NETTLE_CFLAGS'].split(),
159 link_args: config_host['NETTLE_LIBS'].split())
160endif
161gnutls = not_found
162if 'CONFIG_GNUTLS' in config_host
163 gnutls = declare_dependency(compile_args: config_host['GNUTLS_CFLAGS'].split(),
164 link_args: config_host['GNUTLS_LIBS'].split())
165endif
Paolo Bonzinib7612f42020-08-26 08:22:58 +0200166pixman = not_found
167if have_system or have_tools
168 pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8',
Paolo Bonzini1a949332020-08-31 06:27:00 -0400169 method: 'pkg-config', static: enable_static)
Paolo Bonzinib7612f42020-08-26 08:22:58 +0200170endif
Marc-André Lureau5e7fbd22019-07-15 22:54:34 +0400171pam = not_found
172if 'CONFIG_AUTH_PAM' in config_host
173 pam = cc.find_library('pam')
174endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400175libaio = cc.find_library('aio', required: false)
Paolo Bonzini1ffb3bb2020-08-28 19:33:54 +0200176zlib = dependency('zlib', required: true, static: enable_static)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400177linux_io_uring = not_found
178if 'CONFIG_LINUX_IO_URING' in config_host
179 linux_io_uring = declare_dependency(compile_args: config_host['LINUX_IO_URING_CFLAGS'].split(),
180 link_args: config_host['LINUX_IO_URING_LIBS'].split())
181endif
182libxml2 = not_found
183if 'CONFIG_LIBXML2' in config_host
184 libxml2 = declare_dependency(compile_args: config_host['LIBXML2_CFLAGS'].split(),
185 link_args: config_host['LIBXML2_LIBS'].split())
186endif
187libnfs = not_found
188if 'CONFIG_LIBNFS' in config_host
189 libnfs = declare_dependency(link_args: config_host['LIBNFS_LIBS'].split())
190endif
Marc-André Lureauec0d5892019-07-15 15:04:49 +0400191libattr = not_found
192if 'CONFIG_ATTR' in config_host
193 libattr = declare_dependency(link_args: config_host['LIBATTR_LIBS'].split())
194endif
Paolo Bonzini3f99cf52020-02-05 09:45:39 +0100195seccomp = not_found
196if 'CONFIG_SECCOMP' in config_host
197 seccomp = declare_dependency(compile_args: config_host['SECCOMP_CFLAGS'].split(),
198 link_args: config_host['SECCOMP_LIBS'].split())
199endif
200libcap_ng = not_found
201if 'CONFIG_LIBCAP_NG' in config_host
202 libcap_ng = declare_dependency(link_args: config_host['LIBCAP_NG_LIBS'].split())
203endif
Paolo Bonzini1917ec62020-08-26 03:24:11 -0400204if get_option('xkbcommon').auto() and not have_system and not have_tools
205 xkbcommon = not_found
206else
207 xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
Paolo Bonzini1a949332020-08-31 06:27:00 -0400208 method: 'pkg-config', static: enable_static)
Marc-André Lureauade60d42019-07-15 14:48:31 +0400209endif
Marc-André Lureaucdaf0722019-07-22 23:47:50 +0400210slirp = not_found
211if config_host.has_key('CONFIG_SLIRP')
212 slirp = declare_dependency(compile_args: config_host['SLIRP_CFLAGS'].split(),
213 link_args: config_host['SLIRP_LIBS'].split())
214endif
215vde = not_found
216if config_host.has_key('CONFIG_VDE')
217 vde = declare_dependency(link_args: config_host['VDE_LIBS'].split())
218endif
Paolo Bonzini478e9432020-08-17 12:47:55 +0200219pulse = not_found
220if 'CONFIG_LIBPULSE' in config_host
221 pulse = declare_dependency(compile_args: config_host['PULSE_CFLAGS'].split(),
222 link_args: config_host['PULSE_LIBS'].split())
223endif
224alsa = not_found
225if 'CONFIG_ALSA' in config_host
226 alsa = declare_dependency(compile_args: config_host['ALSA_CFLAGS'].split(),
227 link_args: config_host['ALSA_LIBS'].split())
228endif
229jack = not_found
230if 'CONFIG_LIBJACK' in config_host
231 jack = declare_dependency(link_args: config_host['JACK_LIBS'].split())
232endif
Paolo Bonzini26347332019-07-29 15:40:07 +0200233spice = not_found
234if 'CONFIG_SPICE' in config_host
235 spice = declare_dependency(compile_args: config_host['SPICE_CFLAGS'].split(),
236 link_args: config_host['SPICE_LIBS'].split())
237endif
Marc-André Lureau5ee24e72019-07-12 23:16:54 +0400238rt = cc.find_library('rt', required: false)
Paolo Bonziniccf7afa2020-09-01 06:44:23 -0400239libdl = not_found
240if 'CONFIG_PLUGIN' in config_host
241 libdl = cc.find_library('dl', required: true)
242endif
Paolo Bonzini99650b62019-06-10 12:21:14 +0200243libiscsi = not_found
244if 'CONFIG_LIBISCSI' in config_host
245 libiscsi = declare_dependency(compile_args: config_host['LIBISCSI_CFLAGS'].split(),
246 link_args: config_host['LIBISCSI_LIBS'].split())
247endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400248zstd = not_found
249if 'CONFIG_ZSTD' in config_host
250 zstd = declare_dependency(compile_args: config_host['ZSTD_CFLAGS'].split(),
251 link_args: config_host['ZSTD_LIBS'].split())
252endif
Marc-André Lureauea458962019-07-12 22:23:46 +0400253gbm = not_found
254if 'CONFIG_GBM' in config_host
255 gbm = declare_dependency(compile_args: config_host['GBM_CFLAGS'].split(),
256 link_args: config_host['GBM_LIBS'].split())
257endif
258virgl = not_found
259if 'CONFIG_VIRGL' in config_host
260 virgl = declare_dependency(compile_args: config_host['VIRGL_CFLAGS'].split(),
261 link_args: config_host['VIRGL_LIBS'].split())
262endif
Marc-André Lureau1d7bb6a2019-07-12 23:47:06 +0400263curl = not_found
264if 'CONFIG_CURL' in config_host
265 curl = declare_dependency(compile_args: config_host['CURL_CFLAGS'].split(),
266 link_args: config_host['CURL_LIBS'].split())
267endif
Paolo Bonzinif15bff22019-07-18 13:19:02 +0200268libudev = not_found
Paolo Bonzinif01496a2020-09-16 17:54:14 +0200269if targetos == 'linux' and (have_system or have_tools)
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200270 libudev = dependency('libudev',
271 required: get_option('mpath').enabled(),
272 static: enable_static)
Paolo Bonzinif15bff22019-07-18 13:19:02 +0200273endif
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200274
275mpathpersist = not_found
276mpathpersist_new_api = false
277if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
278 mpath_test_source_new = '''
279 #include <libudev.h>
280 #include <mpath_persist.h>
281 unsigned mpath_mx_alloc_len = 1024;
282 int logsink;
283 static struct config *multipath_conf;
284 extern struct udev *udev;
285 extern struct config *get_multipath_config(void);
286 extern void put_multipath_config(struct config *conf);
287 struct udev *udev;
288 struct config *get_multipath_config(void) { return multipath_conf; }
289 void put_multipath_config(struct config *conf) { }
290 int main(void) {
291 udev = udev_new();
292 multipath_conf = mpath_lib_init();
293 return 0;
294 }'''
295 mpath_test_source_old = '''
296 #include <libudev.h>
297 #include <mpath_persist.h>
298 unsigned mpath_mx_alloc_len = 1024;
299 int logsink;
300 int main(void) {
301 struct udev *udev = udev_new();
302 mpath_lib_init(udev);
303 return 0;
304 }'''
Paolo Bonzini43b43a42020-09-17 12:25:09 +0200305 mpathlibs = [libudev]
306 if enable_static
307 mpathlibs += cc.find_library('devmapper',
308 required: get_option('mpath'),
309 static: enable_static)
310 endif
311 mpathlibs += cc.find_library('multipath',
312 required: get_option('mpath'),
313 static: enable_static)
314 mpathlibs += cc.find_library('mpathpersist',
315 required: get_option('mpath'),
316 static: enable_static)
317 foreach lib: mpathlibs
318 if not lib.found()
319 mpathlibs = []
320 break
321 endif
322 endforeach
323 if mpathlibs.length() > 0
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200324 if cc.links(mpath_test_source_new, dependencies: mpathlibs)
325 mpathpersist = declare_dependency(dependencies: mpathlibs)
326 mpathpersist_new_api = true
327 elif cc.links(mpath_test_source_old, dependencies: mpathlibs)
328 mpathpersist = declare_dependency(dependencies: mpathlibs)
329 else
330 if get_option('mpath').enabled()
331 error('Cannot detect libmpathpersist API')
332 else
333 warning('Cannot detect libmpathpersist API, disabling')
334 endif
335 endif
336 endif
337endif
338
Paolo Bonzini26347332019-07-29 15:40:07 +0200339brlapi = not_found
340if 'CONFIG_BRLAPI' in config_host
341 brlapi = declare_dependency(link_args: config_host['BRLAPI_LIBS'].split())
342endif
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100343
Paolo Bonzini760e4322020-08-26 08:09:48 +0200344sdl = not_found
345if have_system
Yonggang Luo363743d2020-08-26 23:10:03 +0800346 sdl = dependency('sdl2', required: get_option('sdl'), static: enable_static)
Paolo Bonzini760e4322020-08-26 08:09:48 +0200347 sdl_image = not_found
348endif
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100349if sdl.found()
350 # work around 2.0.8 bug
351 sdl = declare_dependency(compile_args: '-Wno-undef',
352 dependencies: sdl)
Volker Rümelin7161a432020-08-29 12:41:58 +0200353 sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
Paolo Bonzini1a949332020-08-31 06:27:00 -0400354 method: 'pkg-config', static: enable_static)
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100355else
356 if get_option('sdl_image').enabled()
Sergei Trofimovicha8dc2ac2020-09-08 08:40:16 +0100357 error('sdl-image required, but SDL was @0@'.format(
358 get_option('sdl').disabled() ? 'disabled' : 'not found'))
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100359 endif
360 sdl_image = not_found
Paolo Bonzini26347332019-07-29 15:40:07 +0200361endif
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100362
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400363rbd = not_found
364if 'CONFIG_RBD' in config_host
365 rbd = declare_dependency(link_args: config_host['RBD_LIBS'].split())
366endif
367glusterfs = not_found
368if 'CONFIG_GLUSTERFS' in config_host
369 glusterfs = declare_dependency(compile_args: config_host['GLUSTERFS_CFLAGS'].split(),
370 link_args: config_host['GLUSTERFS_LIBS'].split())
371endif
372libssh = not_found
373if 'CONFIG_LIBSSH' in config_host
374 libssh = declare_dependency(compile_args: config_host['LIBSSH_CFLAGS'].split(),
375 link_args: config_host['LIBSSH_LIBS'].split())
376endif
377libbzip2 = not_found
378if 'CONFIG_BZIP2' in config_host
379 libbzip2 = declare_dependency(link_args: config_host['BZIP2_LIBS'].split())
380endif
381liblzfse = not_found
382if 'CONFIG_LZFSE' in config_host
383 liblzfse = declare_dependency(link_args: config_host['LZFSE_LIBS'].split())
384endif
Paolo Bonzini478e9432020-08-17 12:47:55 +0200385oss = not_found
386if 'CONFIG_AUDIO_OSS' in config_host
387 oss = declare_dependency(link_args: config_host['OSS_LIBS'].split())
388endif
389dsound = not_found
390if 'CONFIG_AUDIO_DSOUND' in config_host
391 dsound = declare_dependency(link_args: config_host['DSOUND_LIBS'].split())
392endif
393coreaudio = not_found
394if 'CONFIG_AUDIO_COREAUDIO' in config_host
395 coreaudio = declare_dependency(link_args: config_host['COREAUDIO_LIBS'].split())
396endif
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +0400397opengl = not_found
398if 'CONFIG_OPENGL' in config_host
Paolo Bonzinide2d3002020-09-01 08:41:17 -0400399 opengl = declare_dependency(compile_args: config_host['OPENGL_CFLAGS'].split(),
400 link_args: config_host['OPENGL_LIBS'].split())
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +0400401endif
402gtk = not_found
403if 'CONFIG_GTK' in config_host
404 gtk = declare_dependency(compile_args: config_host['GTK_CFLAGS'].split(),
405 link_args: config_host['GTK_LIBS'].split())
406endif
407vte = not_found
408if 'CONFIG_VTE' in config_host
409 vte = declare_dependency(compile_args: config_host['VTE_CFLAGS'].split(),
410 link_args: config_host['VTE_LIBS'].split())
411endif
412x11 = not_found
413if 'CONFIG_X11' in config_host
414 x11 = declare_dependency(compile_args: config_host['X11_CFLAGS'].split(),
415 link_args: config_host['X11_LIBS'].split())
416endif
417curses = not_found
418if 'CONFIG_CURSES' in config_host
419 curses = declare_dependency(compile_args: config_host['CURSES_CFLAGS'].split(),
420 link_args: config_host['CURSES_LIBS'].split())
421endif
422iconv = not_found
423if 'CONFIG_ICONV' in config_host
424 iconv = declare_dependency(compile_args: config_host['ICONV_CFLAGS'].split(),
425 link_args: config_host['ICONV_LIBS'].split())
426endif
Paolo Bonzinia0b93232020-02-06 15:48:52 +0100427vnc = not_found
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +0400428png = not_found
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +0400429jpeg = not_found
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +0400430sasl = not_found
Paolo Bonzinia0b93232020-02-06 15:48:52 +0100431if get_option('vnc').enabled()
432 vnc = declare_dependency() # dummy dependency
433 png = dependency('libpng', required: get_option('vnc_png'),
Paolo Bonzini1a949332020-08-31 06:27:00 -0400434 method: 'pkg-config', static: enable_static)
Paolo Bonzinia0b93232020-02-06 15:48:52 +0100435 jpeg = cc.find_library('jpeg', has_headers: ['jpeglib.h'],
436 required: get_option('vnc_jpeg'),
437 static: enable_static)
438 sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'],
439 required: get_option('vnc_sasl'),
440 static: enable_static)
441 if sasl.found()
442 sasl = declare_dependency(dependencies: sasl,
443 compile_args: '-DSTRUCT_IOVEC_DEFINED')
444 endif
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +0400445endif
Paolo Bonzini4a963372020-08-03 16:22:28 +0200446fdt = not_found
447if 'CONFIG_FDT' in config_host
448 fdt = declare_dependency(compile_args: config_host['FDT_CFLAGS'].split(),
449 link_args: config_host['FDT_LIBS'].split())
450endif
Marc-André Lureau708eab42019-09-03 16:59:33 +0400451snappy = not_found
452if 'CONFIG_SNAPPY' in config_host
453 snappy = declare_dependency(link_args: config_host['SNAPPY_LIBS'].split())
454endif
455lzo = not_found
456if 'CONFIG_LZO' in config_host
457 lzo = declare_dependency(link_args: config_host['LZO_LIBS'].split())
458endif
Marc-André Lureau55166232019-07-24 19:16:22 +0400459rdma = not_found
460if 'CONFIG_RDMA' in config_host
461 rdma = declare_dependency(link_args: config_host['RDMA_LIBS'].split())
462endif
Marc-André Lureauab318052019-07-24 19:23:16 +0400463numa = not_found
464if 'CONFIG_NUMA' in config_host
465 numa = declare_dependency(link_args: config_host['NUMA_LIBS'].split())
466endif
Marc-André Lureau582ea952019-08-15 15:15:32 +0400467xen = not_found
468if 'CONFIG_XEN_BACKEND' in config_host
469 xen = declare_dependency(compile_args: config_host['XEN_CFLAGS'].split(),
470 link_args: config_host['XEN_LIBS'].split())
471endif
Paolo Bonzini06677ce2020-08-06 13:07:39 +0200472cacard = not_found
473if 'CONFIG_SMARTCARD' in config_host
474 cacard = declare_dependency(compile_args: config_host['SMARTCARD_CFLAGS'].split(),
475 link_args: config_host['SMARTCARD_LIBS'].split())
476endif
César Belley0a40bcb2020-08-26 13:42:04 +0200477u2f = not_found
478if have_system
479 u2f = dependency('u2f-emu', required: get_option('u2f'),
480 method: 'pkg-config',
481 static: enable_static)
482endif
Paolo Bonzini06677ce2020-08-06 13:07:39 +0200483usbredir = not_found
484if 'CONFIG_USB_REDIR' in config_host
485 usbredir = declare_dependency(compile_args: config_host['USB_REDIR_CFLAGS'].split(),
486 link_args: config_host['USB_REDIR_LIBS'].split())
487endif
488libusb = not_found
489if 'CONFIG_USB_LIBUSB' in config_host
490 libusb = declare_dependency(compile_args: config_host['LIBUSB_CFLAGS'].split(),
491 link_args: config_host['LIBUSB_LIBS'].split())
492endif
Marc-André Lureauc9322ab2019-08-18 19:51:17 +0400493capstone = not_found
494if 'CONFIG_CAPSTONE' in config_host
495 capstone = declare_dependency(compile_args: config_host['CAPSTONE_CFLAGS'].split(),
496 link_args: config_host['CAPSTONE_LIBS'].split())
497endif
498libpmem = not_found
499if 'CONFIG_LIBPMEM' in config_host
500 libpmem = declare_dependency(compile_args: config_host['LIBPMEM_CFLAGS'].split(),
501 link_args: config_host['LIBPMEM_LIBS'].split())
502endif
Bruce Rogersc7c91a72020-08-24 09:52:12 -0600503libdaxctl = not_found
504if 'CONFIG_LIBDAXCTL' in config_host
505 libdaxctl = declare_dependency(link_args: config_host['LIBDAXCTL_LIBS'].split())
506endif
Marc-André Lureau8ce0a452020-08-28 15:07:20 +0400507tasn1 = not_found
508if 'CONFIG_TASN1' in config_host
509 tasn1 = declare_dependency(compile_args: config_host['TASN1_CFLAGS'].split(),
510 link_args: config_host['TASN1_LIBS'].split())
511endif
Marc-André Lureauaf04e892020-08-28 15:07:25 +0400512keyutils = dependency('libkeyutils', required: false,
513 method: 'pkg-config', static: enable_static)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400514
Marc-André Lureau3909def2020-08-28 15:07:33 +0400515has_gettid = cc.has_function('gettid')
516
Paolo Bonziniaa087962020-09-01 11:15:30 -0400517# Malloc tests
518
519malloc = []
520if get_option('malloc') == 'system'
521 has_malloc_trim = \
522 not get_option('malloc_trim').disabled() and \
523 cc.links('''#include <malloc.h>
524 int main(void) { malloc_trim(0); return 0; }''')
525else
526 has_malloc_trim = false
527 malloc = cc.find_library(get_option('malloc'), required: true)
528endif
529if not has_malloc_trim and get_option('malloc_trim').enabled()
530 if get_option('malloc') == 'system'
531 error('malloc_trim not available on this platform.')
532 else
533 error('malloc_trim not available with non-libc memory allocator')
534 endif
535endif
536
Paolo Bonzini859aef02020-08-04 18:14:26 +0200537# Create config-host.h
538
Paolo Bonzinif01496a2020-09-16 17:54:14 +0200539config_host_data.set('CONFIG_LIBUDEV', libudev.found())
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200540config_host_data.set('CONFIG_MPATH', mpathpersist.found())
541config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100542config_host_data.set('CONFIG_SDL', sdl.found())
543config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
Paolo Bonzinia0b93232020-02-06 15:48:52 +0100544config_host_data.set('CONFIG_VNC', vnc.found())
545config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
546config_host_data.set('CONFIG_VNC_PNG', png.found())
547config_host_data.set('CONFIG_VNC_SASL', sasl.found())
Laurent Vivier4113f4c2020-08-24 17:24:29 +0200548config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
Marc-André Lureauaf04e892020-08-28 15:07:25 +0400549config_host_data.set('CONFIG_KEYUTILS', keyutils.found())
Marc-André Lureau3909def2020-08-28 15:07:33 +0400550config_host_data.set('CONFIG_GETTID', has_gettid)
Paolo Bonziniaa087962020-09-01 11:15:30 -0400551config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim)
Paolo Bonzini859aef02020-08-04 18:14:26 +0200552config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
553config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0])
554config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1])
555config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('.')[2])
556
557arrays = ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
558strings = ['HOST_DSOSUF', 'CONFIG_IASL', 'qemu_confdir', 'qemu_datadir',
559 'qemu_moddir', 'qemu_localstatedir', 'qemu_helperdir', 'qemu_localedir',
560 'qemu_icondir', 'qemu_desktopdir', 'qemu_firmwarepath']
561foreach k, v: config_host
562 if arrays.contains(k)
563 if v != ''
564 v = '"' + '", "'.join(v.split()) + '", '
565 endif
566 config_host_data.set(k, v)
567 elif k == 'ARCH'
568 config_host_data.set('HOST_' + v.to_upper(), 1)
569 elif strings.contains(k)
570 if not k.startswith('CONFIG_')
571 k = 'CONFIG_' + k.to_upper()
572 endif
573 config_host_data.set_quoted(k, v)
574 elif k.startswith('CONFIG_') or k.startswith('HAVE_') or k.startswith('HOST_')
575 config_host_data.set(k, v == 'y' ? 1 : v)
576 endif
577endforeach
578genh += configure_file(output: 'config-host.h', configuration: config_host_data)
579
Paolo Bonzini2becc362020-02-03 11:42:03 +0100580minikconf = find_program('scripts/minikconf.py')
Paolo Bonzinia98006b2020-09-01 05:32:23 -0400581config_all_devices = {}
Paolo Bonzinica0fc782020-09-01 06:04:28 -0400582config_all_disas = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +0100583config_devices_mak_list = []
584config_devices_h = {}
Paolo Bonzini859aef02020-08-04 18:14:26 +0200585config_target_h = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +0100586config_target_mak = {}
Paolo Bonzinica0fc782020-09-01 06:04:28 -0400587
588disassemblers = {
589 'alpha' : ['CONFIG_ALPHA_DIS'],
590 'arm' : ['CONFIG_ARM_DIS'],
591 'avr' : ['CONFIG_AVR_DIS'],
592 'cris' : ['CONFIG_CRIS_DIS'],
593 'hppa' : ['CONFIG_HPPA_DIS'],
594 'i386' : ['CONFIG_I386_DIS'],
595 'x86_64' : ['CONFIG_I386_DIS'],
596 'x32' : ['CONFIG_I386_DIS'],
597 'lm32' : ['CONFIG_LM32_DIS'],
598 'm68k' : ['CONFIG_M68K_DIS'],
599 'microblaze' : ['CONFIG_MICROBLAZE_DIS'],
600 'mips' : ['CONFIG_MIPS_DIS'],
601 'moxie' : ['CONFIG_MOXIE_DIS'],
602 'nios2' : ['CONFIG_NIOS2_DIS'],
603 'or1k' : ['CONFIG_OPENRISC_DIS'],
604 'ppc' : ['CONFIG_PPC_DIS'],
605 'riscv' : ['CONFIG_RISCV_DIS'],
606 'rx' : ['CONFIG_RX_DIS'],
607 's390' : ['CONFIG_S390_DIS'],
608 'sh4' : ['CONFIG_SH4_DIS'],
609 'sparc' : ['CONFIG_SPARC_DIS'],
610 'xtensa' : ['CONFIG_XTENSA_DIS'],
611}
612if link_language == 'cpp'
613 disassemblers += {
614 'aarch64' : [ 'CONFIG_ARM_A64_DIS'],
615 'arm' : [ 'CONFIG_ARM_DIS', 'CONFIG_ARM_A64_DIS'],
616 'mips' : [ 'CONFIG_MIPS_DIS', 'CONFIG_NANOMIPS_DIS'],
617 }
618endif
619
Paolo Bonzini2becc362020-02-03 11:42:03 +0100620kconfig_external_symbols = [
621 'CONFIG_KVM',
622 'CONFIG_XEN',
623 'CONFIG_TPM',
624 'CONFIG_SPICE',
625 'CONFIG_IVSHMEM',
626 'CONFIG_OPENGL',
627 'CONFIG_X11',
628 'CONFIG_VHOST_USER',
Laurent Vivier40bc0ca2020-09-24 23:00:23 +0200629 'CONFIG_VHOST_VDPA',
Paolo Bonzini2becc362020-02-03 11:42:03 +0100630 'CONFIG_VHOST_KERNEL',
631 'CONFIG_VIRTFS',
632 'CONFIG_LINUX',
633 'CONFIG_PVRDMA',
634]
Paolo Bonzini859aef02020-08-04 18:14:26 +0200635ignored = ['TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_DIRS']
Paolo Bonzinica0fc782020-09-01 06:04:28 -0400636
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400637foreach target : target_dirs
Paolo Bonzini859aef02020-08-04 18:14:26 +0200638 config_target = keyval.load(meson.current_build_dir() / target / 'config-target.mak')
639
Paolo Bonzinica0fc782020-09-01 06:04:28 -0400640 foreach k, v: disassemblers
641 if config_host['ARCH'].startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k)
642 foreach sym: v
643 config_target += { sym: 'y' }
644 config_all_disas += { sym: 'y' }
645 endforeach
646 endif
647 endforeach
648
Paolo Bonzini859aef02020-08-04 18:14:26 +0200649 config_target_data = configuration_data()
650 foreach k, v: config_target
651 if not k.startswith('TARGET_') and not k.startswith('CONFIG_')
652 # do nothing
653 elif ignored.contains(k)
654 # do nothing
655 elif k == 'TARGET_BASE_ARCH'
656 config_target_data.set('TARGET_' + v.to_upper(), 1)
657 elif k == 'TARGET_NAME'
658 config_target_data.set_quoted(k, v)
659 elif v == 'y'
660 config_target_data.set(k, 1)
661 else
662 config_target_data.set(k, v)
663 endif
664 endforeach
665 config_target_h += {target: configure_file(output: target + '-config-target.h',
666 configuration: config_target_data)}
Paolo Bonzini2becc362020-02-03 11:42:03 +0100667
668 if target.endswith('-softmmu')
Paolo Bonzini2becc362020-02-03 11:42:03 +0100669 base_kconfig = []
670 foreach sym : kconfig_external_symbols
Paolo Bonzini859aef02020-08-04 18:14:26 +0200671 if sym in config_target or sym in config_host
Paolo Bonzini2becc362020-02-03 11:42:03 +0100672 base_kconfig += '@0@=y'.format(sym)
673 endif
674 endforeach
675
676 config_devices_mak = target + '-config-devices.mak'
677 config_devices_mak = configure_file(
678 input: ['default-configs' / target + '.mak', 'Kconfig'],
679 output: config_devices_mak,
680 depfile: config_devices_mak + '.d',
681 capture: true,
682 command: [minikconf, config_host['CONFIG_MINIKCONF_MODE'],
683 config_devices_mak, '@DEPFILE@', '@INPUT@',
684 base_kconfig])
Paolo Bonzini859aef02020-08-04 18:14:26 +0200685
686 config_devices_data = configuration_data()
687 config_devices = keyval.load(config_devices_mak)
688 foreach k, v: config_devices
689 config_devices_data.set(k, 1)
690 endforeach
Paolo Bonzini2becc362020-02-03 11:42:03 +0100691 config_devices_mak_list += config_devices_mak
Paolo Bonzini859aef02020-08-04 18:14:26 +0200692 config_devices_h += {target: configure_file(output: target + '-config-devices.h',
693 configuration: config_devices_data)}
694 config_target += config_devices
Paolo Bonzinia98006b2020-09-01 05:32:23 -0400695 config_all_devices += config_devices
Paolo Bonzini2becc362020-02-03 11:42:03 +0100696 endif
697 config_target_mak += {target: config_target}
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400698endforeach
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400699
Paolo Bonzini2becc362020-02-03 11:42:03 +0100700# This configuration is used to build files that are shared by
701# multiple binaries, and then extracted out of the "common"
702# static_library target.
703#
704# We do not use all_sources()/all_dependencies(), because it would
705# build literally all source files, including devices only used by
706# targets that are not built for this compilation. The CONFIG_ALL
707# pseudo symbol replaces it.
708
Paolo Bonzini2becc362020-02-03 11:42:03 +0100709config_all = config_all_devices
710config_all += config_host
711config_all += config_all_disas
712config_all += {
713 'CONFIG_XEN': config_host.has_key('CONFIG_XEN_BACKEND'),
714 'CONFIG_SOFTMMU': have_system,
715 'CONFIG_USER_ONLY': have_user,
716 'CONFIG_ALL': true,
717}
718
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400719# Generators
720
Marc-André Lureau3f885652019-07-15 18:06:04 +0400721hxtool = find_program('scripts/hxtool')
Marc-André Lureau650b5d52019-07-15 17:36:47 +0400722shaderinclude = find_program('scripts/shaderinclude.pl')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400723qapi_gen = find_program('scripts/qapi-gen.py')
724qapi_gen_depends = [ meson.source_root() / 'scripts/qapi/__init__.py',
725 meson.source_root() / 'scripts/qapi/commands.py',
726 meson.source_root() / 'scripts/qapi/common.py',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400727 meson.source_root() / 'scripts/qapi/error.py',
728 meson.source_root() / 'scripts/qapi/events.py',
729 meson.source_root() / 'scripts/qapi/expr.py',
730 meson.source_root() / 'scripts/qapi/gen.py',
731 meson.source_root() / 'scripts/qapi/introspect.py',
732 meson.source_root() / 'scripts/qapi/parser.py',
733 meson.source_root() / 'scripts/qapi/schema.py',
734 meson.source_root() / 'scripts/qapi/source.py',
735 meson.source_root() / 'scripts/qapi/types.py',
736 meson.source_root() / 'scripts/qapi/visit.py',
737 meson.source_root() / 'scripts/qapi/common.py',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400738 meson.source_root() / 'scripts/qapi-gen.py'
739]
740
741tracetool = [
742 python, files('scripts/tracetool.py'),
743 '--backend=' + config_host['TRACE_BACKENDS']
744]
745
Marc-André Lureau2c273f32019-07-15 17:10:19 +0400746qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
747 meson.current_source_dir(),
Paolo Bonzini859aef02020-08-04 18:14:26 +0200748 config_host['PKGVERSION'], meson.project_version()]
Marc-André Lureau2c273f32019-07-15 17:10:19 +0400749qemu_version = custom_target('qemu-version.h',
750 output: 'qemu-version.h',
751 command: qemu_version_cmd,
752 capture: true,
753 build_by_default: true,
754 build_always_stale: true)
755genh += qemu_version
756
Marc-André Lureau3f885652019-07-15 18:06:04 +0400757hxdep = []
758hx_headers = [
759 ['qemu-options.hx', 'qemu-options.def'],
760 ['qemu-img-cmds.hx', 'qemu-img-cmds.h'],
761]
762if have_system
763 hx_headers += [
764 ['hmp-commands.hx', 'hmp-commands.h'],
765 ['hmp-commands-info.hx', 'hmp-commands-info.h'],
766 ]
767endif
768foreach d : hx_headers
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +0400769 hxdep += custom_target(d[1],
Marc-André Lureau3f885652019-07-15 18:06:04 +0400770 input: files(d[0]),
771 output: d[1],
772 capture: true,
773 build_by_default: true, # to be removed when added to a target
774 command: [hxtool, '-h', '@INPUT0@'])
775endforeach
776genh += hxdep
777
Peter Maydelleb937362020-09-25 17:23:08 +0100778SPHINX_ARGS = [config_host['SPHINX_BUILD'],
779 '-Dversion=' + meson.project_version(),
780 '-Drelease=' + config_host['PKGVERSION']]
781
782if get_option('werror')
783 SPHINX_ARGS += [ '-W' ]
784endif
785
Peter Maydellb3f48302020-09-25 17:23:09 +0100786sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py',
787 meson.source_root() / 'docs/sphinx/hxtool.py',
788 meson.source_root() / 'docs/sphinx/kerneldoc.py',
789 meson.source_root() / 'docs/sphinx/kernellog.py',
790 meson.source_root() / 'docs/sphinx/qapidoc.py',
791 meson.source_root() / 'docs/sphinx/qmp_lexer.py',
792 qapi_gen_depends ]
793
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400794# Collect sourcesets.
795
796util_ss = ss.source_set()
797stub_ss = ss.source_set()
798trace_ss = ss.source_set()
Marc-André Lureau3154fee2019-08-29 22:07:01 +0400799block_ss = ss.source_set()
Paolo Bonzini4a963372020-08-03 16:22:28 +0200800blockdev_ss = ss.source_set()
Paolo Bonziniff219dc2020-08-04 21:14:26 +0200801qmp_ss = ss.source_set()
Paolo Bonzini2becc362020-02-03 11:42:03 +0100802common_ss = ss.source_set()
803softmmu_ss = ss.source_set()
804user_ss = ss.source_set()
805bsd_user_ss = ss.source_set()
806linux_user_ss = ss.source_set()
807specific_ss = ss.source_set()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +0200808specific_fuzz_ss = ss.source_set()
Paolo Bonzini2becc362020-02-03 11:42:03 +0100809
Marc-André Lureau3154fee2019-08-29 22:07:01 +0400810modules = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +0100811hw_arch = {}
812target_arch = {}
813target_softmmu_arch = {}
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400814
815###############
816# Trace files #
817###############
818
Marc-André Lureauc9322ab2019-08-18 19:51:17 +0400819# TODO: add each directory to the subdirs from its own meson.build, once
820# we have those
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400821trace_events_subdirs = [
822 'accel/kvm',
823 'accel/tcg',
824 'crypto',
825 'monitor',
826]
827if have_user
828 trace_events_subdirs += [ 'linux-user' ]
829endif
830if have_block
831 trace_events_subdirs += [
832 'authz',
833 'block',
834 'io',
835 'nbd',
836 'scsi',
837 ]
838endif
839if have_system
840 trace_events_subdirs += [
841 'audio',
842 'backends',
843 'backends/tpm',
844 'chardev',
845 'hw/9pfs',
846 'hw/acpi',
847 'hw/alpha',
848 'hw/arm',
849 'hw/audio',
850 'hw/block',
851 'hw/block/dataplane',
852 'hw/char',
853 'hw/display',
854 'hw/dma',
855 'hw/hppa',
856 'hw/hyperv',
857 'hw/i2c',
858 'hw/i386',
859 'hw/i386/xen',
860 'hw/ide',
861 'hw/input',
862 'hw/intc',
863 'hw/isa',
864 'hw/mem',
865 'hw/mips',
866 'hw/misc',
867 'hw/misc/macio',
868 'hw/net',
869 'hw/nvram',
870 'hw/pci',
871 'hw/pci-host',
872 'hw/ppc',
873 'hw/rdma',
874 'hw/rdma/vmw',
875 'hw/rtc',
876 'hw/s390x',
877 'hw/scsi',
878 'hw/sd',
879 'hw/sparc',
880 'hw/sparc64',
881 'hw/ssi',
882 'hw/timer',
883 'hw/tpm',
884 'hw/usb',
885 'hw/vfio',
886 'hw/virtio',
887 'hw/watchdog',
888 'hw/xen',
889 'hw/gpio',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400890 'migration',
891 'net',
Philippe Mathieu-Daudé8b7a5502020-08-05 15:02:20 +0200892 'softmmu',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400893 'ui',
894 ]
895endif
896trace_events_subdirs += [
897 'hw/core',
898 'qapi',
899 'qom',
900 'target/arm',
901 'target/hppa',
902 'target/i386',
903 'target/mips',
904 'target/ppc',
905 'target/riscv',
906 'target/s390x',
907 'target/sparc',
908 'util',
909]
910
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400911subdir('qapi')
912subdir('qobject')
913subdir('stubs')
914subdir('trace')
915subdir('util')
Marc-André Lureau5582c582019-07-16 19:28:54 +0400916subdir('qom')
917subdir('authz')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400918subdir('crypto')
Marc-André Lureau2d78b562019-07-15 16:00:36 +0400919subdir('ui')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400920
Marc-André Lureau3154fee2019-08-29 22:07:01 +0400921
922if enable_modules
923 libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO')
924 modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
925endif
926
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400927# Build targets from sourcesets
928
Paolo Bonzini2becc362020-02-03 11:42:03 +0100929stub_ss = stub_ss.apply(config_all, strict: false)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400930
931util_ss.add_all(trace_ss)
Paolo Bonzini2becc362020-02-03 11:42:03 +0100932util_ss = util_ss.apply(config_all, strict: false)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400933libqemuutil = static_library('qemuutil',
934 sources: util_ss.sources() + stub_ss.sources() + genh,
Paolo Bonziniaa087962020-09-01 11:15:30 -0400935 dependencies: [util_ss.dependencies(), m, glib, socket, malloc])
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400936qemuutil = declare_dependency(link_with: libqemuutil,
Marc-André Lureau04c6f1e2019-07-18 00:31:05 +0400937 sources: genh + version_res)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400938
Paolo Bonziniabff1ab2020-08-07 12:10:23 +0200939decodetree = generator(find_program('scripts/decodetree.py'),
940 output: 'decode-@BASENAME@.c.inc',
941 arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@'])
942
Paolo Bonzini478e9432020-08-17 12:47:55 +0200943subdir('audio')
Marc-André Lureau7fcfd452019-07-16 19:33:55 +0400944subdir('io')
Marc-André Lureau848e8ff2019-07-15 23:18:07 +0400945subdir('chardev')
Marc-André Lureauec0d5892019-07-15 15:04:49 +0400946subdir('fsdev')
Paolo Bonziniabff1ab2020-08-07 12:10:23 +0200947subdir('libdecnumber')
Marc-André Lureaud3b18482019-08-17 14:55:32 +0400948subdir('target')
Marc-André Lureau708eab42019-09-03 16:59:33 +0400949subdir('dump')
Marc-André Lureauec0d5892019-07-15 15:04:49 +0400950
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400951block_ss.add(files(
952 'block.c',
953 'blockjob.c',
954 'job.c',
955 'qemu-io-cmds.c',
956))
957block_ss.add(when: 'CONFIG_REPLICATION', if_true: files('replication.c'))
958
959subdir('nbd')
960subdir('scsi')
961subdir('block')
962
Paolo Bonzini4a963372020-08-03 16:22:28 +0200963blockdev_ss.add(files(
964 'blockdev.c',
965 'blockdev-nbd.c',
966 'iothread.c',
967 'job-qmp.c',
968))
969
970# os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
971# os-win32.c does not
972blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
973softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
974
975softmmu_ss.add_all(blockdev_ss)
976softmmu_ss.add(files(
977 'bootdevice.c',
978 'dma-helpers.c',
979 'qdev-monitor.c',
980), sdl)
981
982softmmu_ss.add(when: 'CONFIG_TPM', if_true: files('tpm.c'))
983softmmu_ss.add(when: 'CONFIG_SECCOMP', if_true: [files('qemu-seccomp.c'), seccomp])
984softmmu_ss.add(when: ['CONFIG_FDT', fdt], if_true: [files('device_tree.c')])
985
986common_ss.add(files('cpus-common.c'))
987
Paolo Bonzini5d3ea0e2020-08-06 13:40:26 +0200988subdir('softmmu')
Marc-André Lureauc9322ab2019-08-18 19:51:17 +0400989
Bruce Rogersc7c91a72020-08-24 09:52:12 -0600990specific_ss.add(files('disas.c', 'exec.c', 'gdbstub.c'), capstone, libpmem, libdaxctl)
Marc-André Lureauc9322ab2019-08-18 19:51:17 +0400991specific_ss.add(files('exec-vary.c'))
992specific_ss.add(when: 'CONFIG_TCG', if_true: files(
993 'fpu/softfloat.c',
994 'tcg/optimize.c',
995 'tcg/tcg-common.c',
996 'tcg/tcg-op-gvec.c',
997 'tcg/tcg-op-vec.c',
998 'tcg/tcg-op.c',
999 'tcg/tcg.c',
1000))
1001specific_ss.add(when: 'CONFIG_TCG_INTERPRETER', if_true: files('disas/tci.c', 'tcg/tci.c'))
1002
Marc-André Lureauab318052019-07-24 19:23:16 +04001003subdir('backends')
Marc-André Lureauc574e162019-07-26 12:02:31 +04001004subdir('disas')
Marc-André Lureau55166232019-07-24 19:16:22 +04001005subdir('migration')
Paolo Bonziniff219dc2020-08-04 21:14:26 +02001006subdir('monitor')
Marc-André Lureaucdaf0722019-07-22 23:47:50 +04001007subdir('net')
Marc-André Lureau17ef2af2019-07-22 23:40:45 +04001008subdir('replay')
Marc-André Lureau582ea952019-08-15 15:15:32 +04001009subdir('hw')
Marc-André Lureau1a828782019-08-18 16:13:08 +04001010subdir('accel')
Paolo Bonzinif556b4a2020-01-24 13:08:01 +01001011subdir('plugins')
Marc-André Lureaub309c322019-08-18 19:20:37 +04001012subdir('bsd-user')
Marc-André Lureau3a304462019-08-18 16:13:08 +04001013subdir('linux-user')
1014
Marc-André Lureaub309c322019-08-18 19:20:37 +04001015bsd_user_ss.add(files('gdbstub.c'))
1016specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)
1017
Marc-André Lureau3a304462019-08-18 16:13:08 +04001018linux_user_ss.add(files('gdbstub.c', 'thunk.c'))
1019specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss)
Paolo Bonzini5d3ea0e2020-08-06 13:40:26 +02001020
Paolo Bonzinia2ce7db2020-08-04 20:00:40 +02001021# needed for fuzzing binaries
1022subdir('tests/qtest/libqos')
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001023subdir('tests/qtest/fuzz')
Paolo Bonzinia2ce7db2020-08-04 20:00:40 +02001024
Marc-André Lureau3154fee2019-08-29 22:07:01 +04001025block_mods = []
1026softmmu_mods = []
1027foreach d, list : modules
1028 foreach m, module_ss : list
1029 if enable_modules and targetos != 'windows'
Gerd Hoffmann3e292c52020-09-14 15:42:20 +02001030 module_ss = module_ss.apply(config_all, strict: false)
Marc-André Lureau3154fee2019-08-29 22:07:01 +04001031 sl = static_library(d + '-' + m, [genh, module_ss.sources()],
1032 dependencies: [modulecommon, module_ss.dependencies()], pic: true)
1033 if d == 'block'
1034 block_mods += sl
1035 else
1036 softmmu_mods += sl
1037 endif
1038 else
1039 if d == 'block'
1040 block_ss.add_all(module_ss)
1041 else
1042 softmmu_ss.add_all(module_ss)
1043 endif
1044 endif
1045 endforeach
1046endforeach
1047
1048nm = find_program('nm')
Yonggang Luo604f3e42020-09-03 01:00:50 +08001049undefsym = find_program('scripts/undefsym.py')
Marc-André Lureau3154fee2019-08-29 22:07:01 +04001050block_syms = custom_target('block.syms', output: 'block.syms',
1051 input: [libqemuutil, block_mods],
1052 capture: true,
1053 command: [undefsym, nm, '@INPUT@'])
1054qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
1055 input: [libqemuutil, softmmu_mods],
1056 capture: true,
1057 command: [undefsym, nm, '@INPUT@'])
1058
Marc-André Lureau5e5733e2019-08-29 22:34:43 +04001059block_ss = block_ss.apply(config_host, strict: false)
1060libblock = static_library('block', block_ss.sources() + genh,
1061 dependencies: block_ss.dependencies(),
1062 link_depends: block_syms,
1063 name_suffix: 'fa',
1064 build_by_default: false)
1065
1066block = declare_dependency(link_whole: [libblock],
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04001067 link_args: '@block.syms',
1068 dependencies: [crypto, io])
Marc-André Lureau5e5733e2019-08-29 22:34:43 +04001069
Paolo Bonziniff219dc2020-08-04 21:14:26 +02001070qmp_ss = qmp_ss.apply(config_host, strict: false)
1071libqmp = static_library('qmp', qmp_ss.sources() + genh,
1072 dependencies: qmp_ss.dependencies(),
1073 name_suffix: 'fa',
1074 build_by_default: false)
1075
1076qmp = declare_dependency(link_whole: [libqmp])
1077
Marc-André Lureau3154fee2019-08-29 22:07:01 +04001078foreach m : block_mods + softmmu_mods
1079 shared_module(m.name(),
1080 name_prefix: '',
1081 link_whole: m,
1082 install: true,
1083 install_dir: config_host['qemu_moddir'])
1084endforeach
1085
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001086softmmu_ss.add(authz, block, chardev, crypto, io, qmp)
1087common_ss.add(qom, qemuutil)
1088
1089common_ss.add_all(when: 'CONFIG_SOFTMMU', if_true: [softmmu_ss])
Paolo Bonzini2becc362020-02-03 11:42:03 +01001090common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
1091
1092common_all = common_ss.apply(config_all, strict: false)
1093common_all = static_library('common',
1094 build_by_default: false,
1095 sources: common_all.sources() + genh,
1096 dependencies: common_all.dependencies(),
1097 name_suffix: 'fa')
1098
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04001099feature_to_c = find_program('scripts/feature_to_c.sh')
1100
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001101emulators = []
Paolo Bonzini2becc362020-02-03 11:42:03 +01001102foreach target : target_dirs
1103 config_target = config_target_mak[target]
1104 target_name = config_target['TARGET_NAME']
1105 arch = config_target['TARGET_BASE_ARCH']
Paolo Bonzini859aef02020-08-04 18:14:26 +02001106 arch_srcs = [config_target_h[target]]
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001107 arch_deps = []
1108 c_args = ['-DNEED_CPU_H',
1109 '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
1110 '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
1111 link_args = []
Paolo Bonzini2becc362020-02-03 11:42:03 +01001112
Paolo Bonzini859aef02020-08-04 18:14:26 +02001113 config_target += config_host
Paolo Bonzini2becc362020-02-03 11:42:03 +01001114 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
1115 if targetos == 'linux'
1116 target_inc += include_directories('linux-headers', is_system: true)
1117 endif
1118 if target.endswith('-softmmu')
1119 qemu_target_name = 'qemu-system-' + target_name
1120 target_type='system'
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02001121 t = target_softmmu_arch[arch].apply(config_target, strict: false)
1122 arch_srcs += t.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001123 arch_deps += t.dependencies()
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02001124
Marc-André Lureau2c442202019-08-17 13:55:58 +04001125 hw_dir = target_name == 'sparc64' ? 'sparc64' : arch
1126 hw = hw_arch[hw_dir].apply(config_target, strict: false)
1127 arch_srcs += hw.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001128 arch_deps += hw.dependencies()
Marc-André Lureau2c442202019-08-17 13:55:58 +04001129
Paolo Bonzini2becc362020-02-03 11:42:03 +01001130 arch_srcs += config_devices_h[target]
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001131 link_args += ['@block.syms', '@qemu.syms']
Paolo Bonzini2becc362020-02-03 11:42:03 +01001132 else
Marc-André Lureau3a304462019-08-18 16:13:08 +04001133 abi = config_target['TARGET_ABI_DIR']
Paolo Bonzini2becc362020-02-03 11:42:03 +01001134 target_type='user'
1135 qemu_target_name = 'qemu-' + target_name
1136 if 'CONFIG_LINUX_USER' in config_target
1137 base_dir = 'linux-user'
1138 target_inc += include_directories('linux-user/host/' / config_host['ARCH'])
1139 else
1140 base_dir = 'bsd-user'
1141 endif
1142 target_inc += include_directories(
1143 base_dir,
Marc-André Lureau3a304462019-08-18 16:13:08 +04001144 base_dir / abi,
Paolo Bonzini2becc362020-02-03 11:42:03 +01001145 )
Marc-André Lureau3a304462019-08-18 16:13:08 +04001146 if 'CONFIG_LINUX_USER' in config_target
1147 dir = base_dir / abi
1148 arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c')
1149 if config_target.has_key('TARGET_SYSTBL_ABI')
1150 arch_srcs += \
1151 syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'],
1152 extra_args : config_target['TARGET_SYSTBL_ABI'])
1153 endif
1154 endif
Paolo Bonzini2becc362020-02-03 11:42:03 +01001155 endif
1156
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04001157 if 'TARGET_XML_FILES' in config_target
1158 gdbstub_xml = custom_target(target + '-gdbstub-xml.c',
1159 output: target + '-gdbstub-xml.c',
1160 input: files(config_target['TARGET_XML_FILES'].split()),
1161 command: [feature_to_c, '@INPUT@'],
1162 capture: true)
1163 arch_srcs += gdbstub_xml
1164 endif
1165
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02001166 t = target_arch[arch].apply(config_target, strict: false)
1167 arch_srcs += t.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001168 arch_deps += t.dependencies()
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02001169
Paolo Bonzini2becc362020-02-03 11:42:03 +01001170 target_common = common_ss.apply(config_target, strict: false)
1171 objects = common_all.extract_objects(target_common.sources())
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001172 deps = target_common.dependencies()
Paolo Bonzini2becc362020-02-03 11:42:03 +01001173
Paolo Bonzini2becc362020-02-03 11:42:03 +01001174 target_specific = specific_ss.apply(config_target, strict: false)
1175 arch_srcs += target_specific.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001176 arch_deps += target_specific.dependencies()
Paolo Bonzini2becc362020-02-03 11:42:03 +01001177
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001178 lib = static_library('qemu-' + target,
Paolo Bonzini859aef02020-08-04 18:14:26 +02001179 sources: arch_srcs + genh,
Paolo Bonzinib7612f42020-08-26 08:22:58 +02001180 dependencies: arch_deps,
Paolo Bonzini2becc362020-02-03 11:42:03 +01001181 objects: objects,
1182 include_directories: target_inc,
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001183 c_args: c_args,
1184 build_by_default: false,
Paolo Bonzini2becc362020-02-03 11:42:03 +01001185 name_suffix: 'fa')
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001186
1187 if target.endswith('-softmmu')
1188 execs = [{
1189 'name': 'qemu-system-' + target_name,
1190 'gui': false,
1191 'sources': files('softmmu/main.c'),
1192 'dependencies': []
1193 }]
Paolo Bonzini35be72b2020-02-06 14:17:15 +01001194 if targetos == 'windows' and (sdl.found() or gtk.found())
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001195 execs += [{
1196 'name': 'qemu-system-' + target_name + 'w',
1197 'gui': true,
1198 'sources': files('softmmu/main.c'),
1199 'dependencies': []
1200 }]
1201 endif
1202 if config_host.has_key('CONFIG_FUZZ')
1203 specific_fuzz = specific_fuzz_ss.apply(config_target, strict: false)
1204 execs += [{
1205 'name': 'qemu-fuzz-' + target_name,
1206 'gui': false,
1207 'sources': specific_fuzz.sources(),
1208 'dependencies': specific_fuzz.dependencies(),
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001209 }]
1210 endif
1211 else
1212 execs = [{
1213 'name': 'qemu-' + target_name,
1214 'gui': false,
1215 'sources': [],
1216 'dependencies': []
1217 }]
1218 endif
1219 foreach exe: execs
1220 emulators += executable(exe['name'], exe['sources'],
1221 install: true,
1222 c_args: c_args,
1223 dependencies: arch_deps + deps + exe['dependencies'],
1224 objects: lib.extract_all_objects(recursive: true),
1225 link_language: link_language,
1226 link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
1227 link_args: link_args,
1228 gui_app: exe['gui'])
Marc-André Lureau10e1d262019-08-20 12:29:52 +04001229
1230 if 'CONFIG_TRACE_SYSTEMTAP' in config_host
1231 foreach stp: [
Stefan Hajnoczibd5f9732020-08-25 08:49:53 +02001232 {'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / exe['name'], 'install': false},
1233 {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / get_option('bindir') / exe['name'], 'install': true},
Marc-André Lureau10e1d262019-08-20 12:29:52 +04001234 {'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 'install': true},
1235 {'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true},
1236 ]
Stefan Hajnoczibd5f9732020-08-25 08:49:53 +02001237 custom_target(exe['name'] + stp['ext'],
Marc-André Lureau10e1d262019-08-20 12:29:52 +04001238 input: trace_events_all,
Stefan Hajnoczibd5f9732020-08-25 08:49:53 +02001239 output: exe['name'] + stp['ext'],
Marc-André Lureau10e1d262019-08-20 12:29:52 +04001240 capture: true,
1241 install: stp['install'],
Marc-André Lureauab4c0992020-08-26 15:04:16 +04001242 install_dir: qemu_datadir / '../systemtap/tapset',
Marc-André Lureau10e1d262019-08-20 12:29:52 +04001243 command: [
1244 tracetool, '--group=all', '--format=' + stp['fmt'],
1245 '--binary=' + stp['bin'],
1246 '--target-name=' + target_name,
1247 '--target-type=' + target_type,
1248 '--probe-prefix=qemu.' + target_type + '.' + target_name,
1249 '@INPUT@',
1250 ])
1251 endforeach
1252 endif
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02001253 endforeach
Paolo Bonzini2becc362020-02-03 11:42:03 +01001254endforeach
1255
Paolo Bonzini931049b2020-02-05 09:44:24 +01001256# Other build targets
Marc-André Lureau897b5af2019-07-16 21:54:15 +04001257
Paolo Bonzinif556b4a2020-01-24 13:08:01 +01001258if 'CONFIG_PLUGIN' in config_host
1259 install_headers('include/qemu/qemu-plugin.h')
1260endif
1261
Paolo Bonzinif15bff22019-07-18 13:19:02 +02001262if 'CONFIG_GUEST_AGENT' in config_host
1263 subdir('qga')
1264endif
1265
Laurent Vivier9755c942020-08-24 17:24:30 +02001266# Don't build qemu-keymap if xkbcommon is not explicitly enabled
1267# when we don't build tools or system
Laurent Vivier4113f4c2020-08-24 17:24:29 +02001268if xkbcommon.found()
Marc-André Lureau28742462019-09-19 20:24:43 +04001269 # used for the update-keymaps target, so include rules even if !have_tools
1270 qemu_keymap = executable('qemu-keymap', files('qemu-keymap.c', 'ui/input-keymap.c') + genh,
1271 dependencies: [qemuutil, xkbcommon], install: have_tools)
1272endif
1273
Philippe Mathieu-Daudé8855e8f2020-08-21 17:05:56 +02001274qemu_block_tools = []
Paolo Bonzini931049b2020-02-05 09:44:24 +01001275if have_tools
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04001276 qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
1277 dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
1278 qemu_io = executable('qemu-io', files('qemu-io.c'),
1279 dependencies: [block, qemuutil], install: true)
Daniel P. Berrangéeb705982020-08-25 11:38:50 +01001280 qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04001281 dependencies: [block, qemuutil], install: true)
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04001282
Paolo Bonzini7c58bb72020-08-04 20:18:36 +02001283 subdir('storage-daemon')
Paolo Bonzinia9c97272019-06-10 12:27:52 +02001284 subdir('contrib/rdmacm-mux')
Marc-André Lureau1d7bb6a2019-07-12 23:47:06 +04001285 subdir('contrib/elf2dmp')
Paolo Bonzinia9c97272019-06-10 12:27:52 +02001286
Marc-André Lureau157e7b12019-07-15 14:50:58 +04001287 executable('qemu-edid', files('qemu-edid.c', 'hw/display/edid-generate.c'),
1288 dependencies: qemuutil,
1289 install: true)
1290
Paolo Bonzini931049b2020-02-05 09:44:24 +01001291 if 'CONFIG_VHOST_USER' in config_host
1292 subdir('contrib/libvhost-user')
Paolo Bonzini2d7ac0a2019-06-10 12:18:02 +02001293 subdir('contrib/vhost-user-blk')
Paolo Bonzinib7612f42020-08-26 08:22:58 +02001294 subdir('contrib/vhost-user-gpu')
Marc-André Lureau32fcc622019-07-12 22:11:20 +04001295 subdir('contrib/vhost-user-input')
Paolo Bonzini99650b62019-06-10 12:21:14 +02001296 subdir('contrib/vhost-user-scsi')
Paolo Bonzini931049b2020-02-05 09:44:24 +01001297 endif
Marc-André Lureau8f51e012019-07-15 14:39:25 +04001298
1299 if targetos == 'linux'
1300 executable('qemu-bridge-helper', files('qemu-bridge-helper.c'),
1301 dependencies: [qemuutil, libcap_ng],
1302 install: true,
1303 install_dir: get_option('libexecdir'))
Marc-André Lureau897b5af2019-07-16 21:54:15 +04001304
1305 executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'),
1306 dependencies: [authz, crypto, io, qom, qemuutil,
Paolo Bonzini6ec0e152020-09-16 18:07:29 +02001307 libcap_ng, mpathpersist],
Marc-André Lureau897b5af2019-07-16 21:54:15 +04001308 install: true)
Marc-André Lureau8f51e012019-07-15 14:39:25 +04001309 endif
1310
Marc-André Lureau5ee24e72019-07-12 23:16:54 +04001311 if 'CONFIG_IVSHMEM' in config_host
1312 subdir('contrib/ivshmem-client')
1313 subdir('contrib/ivshmem-server')
1314 endif
Paolo Bonzini931049b2020-02-05 09:44:24 +01001315endif
1316
Marc-André Lureauf5aa6322020-08-26 17:06:18 +04001317subdir('scripts')
Paolo Bonzini3f99cf52020-02-05 09:45:39 +01001318subdir('tools')
Marc-André Lureaubdcbea72019-07-15 21:22:31 +04001319subdir('pc-bios')
Paolo Bonzinice1c1e72020-01-28 16:41:44 +01001320subdir('tests')
Paolo Bonzinif8aa24e2020-08-05 15:49:10 +02001321subdir('docs')
Marc-André Lureaue8f3bd72019-09-19 21:02:09 +04001322if 'CONFIG_GTK' in config_host
1323 subdir('po')
1324endif
Paolo Bonzini3f99cf52020-02-05 09:45:39 +01001325
Marc-André Lureau8adfeba2020-08-26 15:04:19 +04001326if host_machine.system() == 'windows'
1327 nsis_cmd = [
1328 find_program('scripts/nsis.py'),
1329 '@OUTPUT@',
1330 get_option('prefix'),
1331 meson.current_source_dir(),
1332 host_machine.cpu_family(),
1333 '--',
1334 '-DDISPLAYVERSION=' + meson.project_version(),
1335 ]
1336 if build_docs
1337 nsis_cmd += '-DCONFIG_DOCUMENTATION=y'
1338 endif
1339 if 'CONFIG_GTK' in config_host
1340 nsis_cmd += '-DCONFIG_GTK=y'
1341 endif
1342
1343 nsis = custom_target('nsis',
1344 output: 'qemu-setup-' + meson.project_version() + '.exe',
1345 input: files('qemu.nsi'),
1346 build_always_stale: true,
1347 command: nsis_cmd + ['@INPUT@'])
1348 alias_target('installer', nsis)
1349endif
1350
Paolo Bonzinif9332752020-02-03 13:28:38 +01001351summary_info = {}
1352summary_info += {'Install prefix': config_host['prefix']}
1353summary_info += {'BIOS directory': config_host['qemu_datadir']}
1354summary_info += {'firmware path': config_host['qemu_firmwarepath']}
1355summary_info += {'binary directory': config_host['bindir']}
1356summary_info += {'library directory': config_host['libdir']}
1357summary_info += {'module directory': config_host['qemu_moddir']}
1358summary_info += {'libexec directory': config_host['libexecdir']}
1359summary_info += {'include directory': config_host['includedir']}
1360summary_info += {'config directory': config_host['sysconfdir']}
1361if targetos != 'windows'
1362 summary_info += {'local state directory': config_host['qemu_localstatedir']}
Marc-André Lureaub81efab2020-08-26 15:04:18 +04001363 summary_info += {'Manual directory': get_option('mandir')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01001364else
1365 summary_info += {'local state directory': 'queried at runtime'}
1366endif
Marc-André Lureau491e74c2020-08-26 15:04:17 +04001367summary_info += {'Doc directory': get_option('docdir')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01001368summary_info += {'Build directory': meson.current_build_dir()}
1369summary_info += {'Source path': meson.current_source_dir()}
1370summary_info += {'GIT binary': config_host['GIT']}
1371summary_info += {'GIT submodules': config_host['GIT_SUBMODULES']}
1372summary_info += {'C compiler': meson.get_compiler('c').cmd_array()[0]}
1373summary_info += {'Host C compiler': meson.get_compiler('c', native: true).cmd_array()[0]}
1374if link_language == 'cpp'
1375 summary_info += {'C++ compiler': meson.get_compiler('cpp').cmd_array()[0]}
1376else
1377 summary_info += {'C++ compiler': false}
1378endif
1379if targetos == 'darwin'
1380 summary_info += {'Objective-C compiler': meson.get_compiler('objc').cmd_array()[0]}
1381endif
1382summary_info += {'ARFLAGS': config_host['ARFLAGS']}
1383summary_info += {'CFLAGS': config_host['CFLAGS']}
1384summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']}
1385summary_info += {'QEMU_LDFLAGS': config_host['QEMU_LDFLAGS']}
1386summary_info += {'make': config_host['MAKE']}
Paolo Bonzinif9332752020-02-03 13:28:38 +01001387summary_info += {'python': '@0@ (version: @1@)'.format(python.full_path(), python.language_version())}
1388summary_info += {'sphinx-build': config_host['SPHINX_BUILD']}
1389summary_info += {'genisoimage': config_host['GENISOIMAGE']}
1390# TODO: add back version
1391summary_info += {'slirp support': config_host.has_key('CONFIG_SLIRP')}
1392if config_host.has_key('CONFIG_SLIRP')
1393 summary_info += {'smbd': config_host['CONFIG_SMBD_COMMAND']}
1394endif
1395summary_info += {'module support': config_host.has_key('CONFIG_MODULES')}
1396if config_host.has_key('CONFIG_MODULES')
1397 summary_info += {'alternative module path': config_host.has_key('CONFIG_MODULE_UPGRADES')}
1398endif
1399summary_info += {'host CPU': cpu}
1400summary_info += {'host endianness': build_machine.endian()}
1401summary_info += {'target list': config_host['TARGET_DIRS']}
1402summary_info += {'gprof enabled': config_host.has_key('CONFIG_GPROF')}
1403summary_info += {'sparse enabled': meson.get_compiler('c').cmd_array().contains('cgcc')}
1404summary_info += {'strip binaries': get_option('strip')}
1405summary_info += {'profiler': config_host.has_key('CONFIG_PROFILER')}
Laurent Vivier3e8529d2020-09-17 16:07:00 +02001406summary_info += {'static build': config_host.has_key('CONFIG_STATIC')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01001407if targetos == 'darwin'
1408 summary_info += {'Cocoa support': config_host.has_key('CONFIG_COCOA')}
1409endif
1410# TODO: add back version
Paolo Bonzini35be72b2020-02-06 14:17:15 +01001411summary_info += {'SDL support': sdl.found()}
1412summary_info += {'SDL image support': sdl_image.found()}
Paolo Bonzinif9332752020-02-03 13:28:38 +01001413# TODO: add back version
1414summary_info += {'GTK support': config_host.has_key('CONFIG_GTK')}
1415summary_info += {'GTK GL support': config_host.has_key('CONFIG_GTK_GL')}
Paolo Bonzinib7612f42020-08-26 08:22:58 +02001416summary_info += {'pixman': pixman.found()}
Paolo Bonzinif9332752020-02-03 13:28:38 +01001417# TODO: add back version
1418summary_info += {'VTE support': config_host.has_key('CONFIG_VTE')}
1419summary_info += {'TLS priority': config_host['CONFIG_TLS_PRIORITY']}
1420summary_info += {'GNUTLS support': config_host.has_key('CONFIG_GNUTLS')}
1421# TODO: add back version
1422summary_info += {'libgcrypt': config_host.has_key('CONFIG_GCRYPT')}
1423if config_host.has_key('CONFIG_GCRYPT')
1424 summary_info += {' hmac': config_host.has_key('CONFIG_GCRYPT_HMAC')}
1425 summary_info += {' XTS': not config_host.has_key('CONFIG_QEMU_PRIVATE_XTS')}
1426endif
1427# TODO: add back version
1428summary_info += {'nettle': config_host.has_key('CONFIG_NETTLE')}
1429if config_host.has_key('CONFIG_NETTLE')
1430 summary_info += {' XTS': not config_host.has_key('CONFIG_QEMU_PRIVATE_XTS')}
1431endif
1432summary_info += {'libtasn1': config_host.has_key('CONFIG_TASN1')}
1433summary_info += {'PAM': config_host.has_key('CONFIG_AUTH_PAM')}
1434summary_info += {'iconv support': config_host.has_key('CONFIG_ICONV')}
1435summary_info += {'curses support': config_host.has_key('CONFIG_CURSES')}
1436# TODO: add back version
1437summary_info += {'virgl support': config_host.has_key('CONFIG_VIRGL')}
1438summary_info += {'curl support': config_host.has_key('CONFIG_CURL')}
1439summary_info += {'mingw32 support': targetos == 'windows'}
1440summary_info += {'Audio drivers': config_host['CONFIG_AUDIO_DRIVERS']}
1441summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
1442summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']}
1443summary_info += {'VirtFS support': config_host.has_key('CONFIG_VIRTFS')}
Paolo Bonzini6ec0e152020-09-16 18:07:29 +02001444summary_info += {'Multipath support': mpathpersist.found()}
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001445summary_info += {'VNC support': vnc.found()}
1446if vnc.found()
1447 summary_info += {'VNC SASL support': sasl.found()}
1448 summary_info += {'VNC JPEG support': jpeg.found()}
1449 summary_info += {'VNC PNG support': png.found()}
Paolo Bonzinif9332752020-02-03 13:28:38 +01001450endif
1451summary_info += {'xen support': config_host.has_key('CONFIG_XEN_BACKEND')}
1452if config_host.has_key('CONFIG_XEN_BACKEND')
1453 summary_info += {'xen ctrl version': config_host['CONFIG_XEN_CTRL_INTERFACE_VERSION']}
1454endif
1455summary_info += {'brlapi support': config_host.has_key('CONFIG_BRLAPI')}
1456summary_info += {'Documentation': config_host.has_key('BUILD_DOCS')}
1457summary_info += {'PIE': get_option('b_pie')}
1458summary_info += {'vde support': config_host.has_key('CONFIG_VDE')}
1459summary_info += {'netmap support': config_host.has_key('CONFIG_NETMAP')}
1460summary_info += {'Linux AIO support': config_host.has_key('CONFIG_LINUX_AIO')}
1461summary_info += {'Linux io_uring support': config_host.has_key('CONFIG_LINUX_IO_URING')}
1462summary_info += {'ATTR/XATTR support': config_host.has_key('CONFIG_ATTR')}
1463summary_info += {'Install blobs': config_host.has_key('INSTALL_BLOBS')}
1464# TODO: add back KVM/HAX/HVF/WHPX/TCG
1465#summary_info += {'KVM support': have_kvm'}
1466#summary_info += {'HAX support': have_hax'}
1467#summary_info += {'HVF support': have_hvf'}
1468#summary_info += {'WHPX support': have_whpx'}
1469#summary_info += {'TCG support': have_tcg'}
1470#if get_option('tcg')
1471# summary_info += {'TCG debug enabled': config_host.has_key('CONFIG_DEBUG_TCG')}
1472# summary_info += {'TCG interpreter': config_host.has_key('CONFIG_TCG_INTERPRETER')}
1473#endif
Paolo Bonziniaa087962020-09-01 11:15:30 -04001474summary_info += {'malloc trim support': has_malloc_trim}
Paolo Bonzinif9332752020-02-03 13:28:38 +01001475summary_info += {'RDMA support': config_host.has_key('CONFIG_RDMA')}
1476summary_info += {'PVRDMA support': config_host.has_key('CONFIG_PVRDMA')}
1477summary_info += {'fdt support': config_host.has_key('CONFIG_FDT')}
1478summary_info += {'membarrier': config_host.has_key('CONFIG_MEMBARRIER')}
1479summary_info += {'preadv support': config_host.has_key('CONFIG_PREADV')}
1480summary_info += {'fdatasync': config_host.has_key('CONFIG_FDATASYNC')}
1481summary_info += {'madvise': config_host.has_key('CONFIG_MADVISE')}
1482summary_info += {'posix_madvise': config_host.has_key('CONFIG_POSIX_MADVISE')}
1483summary_info += {'posix_memalign': config_host.has_key('CONFIG_POSIX_MEMALIGN')}
1484summary_info += {'libcap-ng support': config_host.has_key('CONFIG_LIBCAP_NG')}
1485summary_info += {'vhost-net support': config_host.has_key('CONFIG_VHOST_NET')}
1486summary_info += {'vhost-crypto support': config_host.has_key('CONFIG_VHOST_CRYPTO')}
1487summary_info += {'vhost-scsi support': config_host.has_key('CONFIG_VHOST_SCSI')}
1488summary_info += {'vhost-vsock support': config_host.has_key('CONFIG_VHOST_VSOCK')}
1489summary_info += {'vhost-user support': config_host.has_key('CONFIG_VHOST_KERNEL')}
1490summary_info += {'vhost-user-fs support': config_host.has_key('CONFIG_VHOST_USER_FS')}
1491summary_info += {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST_VDPA')}
1492summary_info += {'Trace backends': config_host['TRACE_BACKENDS']}
1493if config_host['TRACE_BACKENDS'].split().contains('simple')
1494 summary_info += {'Trace output file': config_host['CONFIG_TRACE_FILE'] + '-<pid>'}
1495endif
1496# TODO: add back protocol and server version
1497summary_info += {'spice support': config_host.has_key('CONFIG_SPICE')}
1498summary_info += {'rbd support': config_host.has_key('CONFIG_RBD')}
1499summary_info += {'xfsctl support': config_host.has_key('CONFIG_XFS')}
1500summary_info += {'smartcard support': config_host.has_key('CONFIG_SMARTCARD')}
César Belley0a40bcb2020-08-26 13:42:04 +02001501summary_info += {'U2F support': u2f.found()}
Paolo Bonzinif9332752020-02-03 13:28:38 +01001502summary_info += {'libusb': config_host.has_key('CONFIG_USB_LIBUSB')}
1503summary_info += {'usb net redir': config_host.has_key('CONFIG_USB_REDIR')}
1504summary_info += {'OpenGL support': config_host.has_key('CONFIG_OPENGL')}
1505summary_info += {'OpenGL dmabufs': config_host.has_key('CONFIG_OPENGL_DMABUF')}
1506summary_info += {'libiscsi support': config_host.has_key('CONFIG_LIBISCSI')}
1507summary_info += {'libnfs support': config_host.has_key('CONFIG_LIBNFS')}
1508summary_info += {'build guest agent': config_host.has_key('CONFIG_GUEST_AGENT')}
1509if targetos == 'windows'
1510 if 'WIN_SDK' in config_host
1511 summary_info += {'Windows SDK': config_host['WIN_SDK']}
1512 endif
1513 summary_info += {'QGA VSS support': config_host.has_key('CONFIG_QGA_VSS')}
1514 summary_info += {'QGA w32 disk info': config_host.has_key('CONFIG_QGA_NTDDSCSI')}
Stefan Hajnoczi4bad7c32020-09-14 10:52:31 +01001515 summary_info += {'QGA MSI support': config_host.has_key('CONFIG_QGA_MSI')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01001516endif
1517summary_info += {'seccomp support': config_host.has_key('CONFIG_SECCOMP')}
1518summary_info += {'coroutine backend': config_host['CONFIG_COROUTINE_BACKEND']}
1519summary_info += {'coroutine pool': config_host['CONFIG_COROUTINE_POOL'] == '1'}
1520summary_info += {'debug stack usage': config_host.has_key('CONFIG_DEBUG_STACK_USAGE')}
1521summary_info += {'mutex debugging': config_host.has_key('CONFIG_DEBUG_MUTEX')}
1522summary_info += {'crypto afalg': config_host.has_key('CONFIG_AF_ALG')}
1523summary_info += {'GlusterFS support': config_host.has_key('CONFIG_GLUSTERFS')}
Marc-André Lureaubf0e56a2019-10-04 17:35:16 +04001524summary_info += {'gcov': get_option('b_coverage')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01001525summary_info += {'TPM support': config_host.has_key('CONFIG_TPM')}
1526summary_info += {'libssh support': config_host.has_key('CONFIG_LIBSSH')}
1527summary_info += {'QOM debugging': config_host.has_key('CONFIG_QOM_CAST_DEBUG')}
1528summary_info += {'Live block migration': config_host.has_key('CONFIG_LIVE_BLOCK_MIGRATION')}
1529summary_info += {'lzo support': config_host.has_key('CONFIG_LZO')}
1530summary_info += {'snappy support': config_host.has_key('CONFIG_SNAPPY')}
1531summary_info += {'bzip2 support': config_host.has_key('CONFIG_BZIP2')}
1532summary_info += {'lzfse support': config_host.has_key('CONFIG_LZFSE')}
1533summary_info += {'zstd support': config_host.has_key('CONFIG_ZSTD')}
1534summary_info += {'NUMA host support': config_host.has_key('CONFIG_NUMA')}
1535summary_info += {'libxml2': config_host.has_key('CONFIG_LIBXML2')}
Paolo Bonziniaa087962020-09-01 11:15:30 -04001536summary_info += {'memory allocator': get_option('malloc')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01001537summary_info += {'avx2 optimization': config_host.has_key('CONFIG_AVX2_OPT')}
1538summary_info += {'avx512f optimization': config_host.has_key('CONFIG_AVX512F_OPT')}
1539summary_info += {'replication support': config_host.has_key('CONFIG_REPLICATION')}
1540summary_info += {'bochs support': config_host.has_key('CONFIG_BOCHS')}
1541summary_info += {'cloop support': config_host.has_key('CONFIG_CLOOP')}
1542summary_info += {'dmg support': config_host.has_key('CONFIG_DMG')}
1543summary_info += {'qcow v1 support': config_host.has_key('CONFIG_QCOW1')}
1544summary_info += {'vdi support': config_host.has_key('CONFIG_VDI')}
1545summary_info += {'vvfat support': config_host.has_key('CONFIG_VVFAT')}
1546summary_info += {'qed support': config_host.has_key('CONFIG_QED')}
1547summary_info += {'parallels support': config_host.has_key('CONFIG_PARALLELS')}
1548summary_info += {'sheepdog support': config_host.has_key('CONFIG_SHEEPDOG')}
1549summary_info += {'capstone': config_host.has_key('CONFIG_CAPSTONE')}
1550summary_info += {'libpmem support': config_host.has_key('CONFIG_LIBPMEM')}
1551summary_info += {'libdaxctl support': config_host.has_key('CONFIG_LIBDAXCTL')}
Paolo Bonzinif01496a2020-09-16 17:54:14 +02001552summary_info += {'libudev': libudev.found()}
Paolo Bonzinif9332752020-02-03 13:28:38 +01001553summary_info += {'default devices': config_host['CONFIG_MINIKCONF_MODE'] == '--defconfig'}
1554summary_info += {'plugin support': config_host.has_key('CONFIG_PLUGIN')}
1555summary_info += {'fuzzing support': config_host.has_key('CONFIG_FUZZ')}
1556if config_host.has_key('HAVE_GDB_BIN')
1557 summary_info += {'gdb': config_host['HAVE_GDB_BIN']}
1558endif
1559summary_info += {'thread sanitizer': config_host.has_key('CONFIG_TSAN')}
1560summary_info += {'rng-none': config_host.has_key('CONFIG_RNG_NONE')}
1561summary_info += {'Linux keyring': config_host.has_key('CONFIG_SECRET_KEYRING')}
1562summary(summary_info, bool_yn: true)
1563
1564if not supported_cpus.contains(cpu)
1565 message()
1566 warning('SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!')
1567 message()
1568 message('CPU host architecture ' + cpu + ' support is not currently maintained.')
1569 message('The QEMU project intends to remove support for this host CPU in')
1570 message('a future release if nobody volunteers to maintain it and to')
1571 message('provide a build host for our continuous integration setup.')
1572 message('configure has succeeded and you can continue to build, but')
1573 message('if you care about QEMU on this platform you should contact')
1574 message('us upstream at qemu-devel@nongnu.org.')
1575endif
1576
1577if not supported_oses.contains(targetos)
1578 message()
1579 warning('WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!')
1580 message()
1581 message('Host OS ' + targetos + 'support is not currently maintained.')
1582 message('The QEMU project intends to remove support for this host OS in')
1583 message('a future release if nobody volunteers to maintain it and to')
1584 message('provide a build host for our continuous integration setup.')
1585 message('configure has succeeded and you can continue to build, but')
1586 message('if you care about QEMU on this platform you should contact')
1587 message('us upstream at qemu-devel@nongnu.org.')
1588endif