xref: /qemu/plugins/meson.build (revision ec6f3fc3)
1plugin_ldflags = []
2# Modules need more symbols than just those in plugins/qemu-plugins.symbols
3if not enable_modules
4  if targetos == 'darwin'
5    configure_file(
6      input: files('qemu-plugins.symbols'),
7      output: 'qemu-plugins-ld64.symbols',
8      capture: true,
9      command: ['sed', '-ne', 's/^[[:space:]]*\\(qemu_.*\\);/_\\1/p', '@INPUT@'])
10    plugin_ldflags = ['-Wl,-exported_symbols_list,plugins/qemu-plugins-ld64.symbols']
11  else
12    plugin_ldflags = ['-Xlinker', '--dynamic-list=' + (meson.project_source_root() / 'plugins/qemu-plugins.symbols')]
13  endif
14endif
15
16if get_option('plugins')
17  if targetos == 'windows'
18    dlltool = find_program('dlltool', required: true)
19
20    # Generate a .lib file for plugins to link against.
21    # First, create a .def file listing all the symbols a plugin should expect to have
22    # available in qemu
23    win32_plugin_def = configure_file(
24      input: files('qemu-plugins.symbols'),
25      output: 'qemu_plugin_api.def',
26      capture: true,
27      command: ['sed', '-e', '0,/^/s//EXPORTS/; s/[{};]//g', '@INPUT@'])
28    # then use dlltool to assemble a delaylib.
29    win32_qemu_plugin_api_lib = configure_file(
30      input: win32_plugin_def,
31      output: 'qemu_plugin_api.lib',
32      command: [dlltool, '--input-def', '@INPUT@',
33                '--output-delaylib', '@OUTPUT@', '--dllname', 'qemu.exe']
34    )
35  endif
36  specific_ss.add(files(
37    'loader.c',
38    'core.c',
39    'api.c',
40  ), declare_dependency(link_args: plugin_ldflags))
41endif
42