This is an automated email from Gerrit.

"Marc Schink <[email protected]>" just uploaded a new patch set to Gerrit, which you 
can find at https://review.openocd.org/c/openocd/+/9541

-- gerrit

commit 29cd936ba0c332e7498360406d4ac9e4ba30789f
Author: Marc Schink <[email protected]>
Date:   Thu Jun 9 20:15:05 2022 +0200

    [rfc/wip] Add Meson build system
    
    This introduces an initial Meson-based build setup for OpenOCD as a
    modern replacement for the current Autotools build system.
    
    Compared to the current Autotools-based build system, Meson [1] offers
    a clear, declarative configuration language, faster configure and build
    times, and more straightforward handling of dependencies and optional
    features. It also supports native out-of-tree builds and includes built-in
    integration for coverage and scan-build.
    
    Tested with GCC and Clang on:
    
     - Linux (x86_64, aarch64)
     - FreeBSD (x86_64)
     - Windows 10 (64-bit)
       - MSYS2: native, MINGW64, UCRT64
       - Cygwin
    
    [1] https://mesonbuild.com/
    
    Change-Id: I202bb7bc70cd186f74afcdc9e1891c85fae8e690
    Signed-off-by: Marc Schink <[email protected]>

diff --git a/doc/meson.build b/doc/meson.build
new file mode 100644
index 0000000000..c7d37fc48d
--- /dev/null
+++ b/doc/meson.build
@@ -0,0 +1,85 @@
+makeinfo_prog = find_program(
+  'makeinfo',
+  required: false,
+)
+
+if makeinfo_prog.found()
+  date_prog = find_program('date', required: true)
+  date_cmd = run_command(date_prog, '+%d %B %Y', check: true)
+  current_date = date_cmd.stdout().strip()
+
+  version_texi_conf = configuration_data()
+  version_texi_conf.set('UPDATED', current_date)
+  version_texi_conf.set('VERSION', meson.project_version())
+
+  # Generate version.texi in the same way Autotools does.
+  # Use the '.tmpl' prefix because '*.in' files are ignored by .gitignore.
+  version_texi = configure_file(
+    input: 'version.texi.tmpl',
+    output: 'version.texi',
+    configuration: version_texi_conf
+  )
+
+  manual_info_inc_path = meson.current_build_dir()
+
+  # makeinfo does not handle absolute Windows-style paths correctly, so convert
+  # the path to a POSIX-style path first.
+  if is_mingw
+    manual_info_inc_path = run_command('cygpath', '-u',
+      manual_info_inc_path).stdout().strip()
+  endif
+
+  manual_info = custom_target(
+    'manual-info',
+    input: [
+      'openocd.texi',
+      version_texi,
+    ],
+    output: 'openocd.info',
+    command: [
+      makeinfo_prog,
+      '--no-split',
+      '-P', manual_info_inc_path,
+      '--output=@OUTPUT@',
+      '@INPUT0@',
+    ],
+    install: true,
+    install_dir: get_option('infodir')
+  )
+
+  openocd_pdf = custom_target(
+    'manual-pdf',
+    input: [
+      'openocd.texi',
+      version_texi,
+    ],
+    output: 'openocd.pdf',
+    command: [
+      makeinfo_prog,
+      '--pdf',
+      '-P', meson.current_build_dir(),
+      '-o', '@OUTPUT@',
+      '@INPUT0@',
+    ],
+    install: false
+  )
+else
+  warning('makeinfo not found, Info documentation will not be built')
+endif
+
+doxygen_prog = find_program(
+  'doxygen',
+  required: false,
+)
+
+if doxygen_prog.found()
+  doxygen = custom_target(
+    'doxygen',
+    input: doxyfile,
+    output: 'html',
+    command: [doxygen_prog, '@INPUT@'],
+    install: false
+  )
+endif
+
+install_man('openocd.1')
diff --git a/doc/version.texi.tmpl b/doc/version.texi.tmpl
new file mode 100644
index 0000000000..a630b405de
--- /dev/null
+++ b/doc/version.texi.tmpl
@@ -0,0 +1,2 @@
+@set UPDATED @UPDATED@
+@set VERSION @VERSION@
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000000..6206023649
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,688 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+project('openocd', 'c',
+  meson_version: '>= 0.59.0',
+  version: '0.12.0',
+  license: 'GPL-2.0-or-later',
+  default_options: [
+    'werror=true',
+    'warning_level=2',
+    'c_std=gnu99',
+  ]
+)
+
+prefix = get_option('prefix')
+bin_dir = get_option('bindir')
+
+pkg_data_dir = get_option('datadir') / 'openocd'
+
+cc = meson.get_compiler('c')
+
+# For HAVE_* #defines, we wrap set10() in if-statements so they are only 
defined
+# when the value is true, matching the behavior of the Autotools build system.
+conf_data = configuration_data(
+)
+
+conf_data.set10('USE_GCOV', get_option('b_coverage'))
+
+if get_option('buildtype') == 'release'
+  git_desc_output = ''
+  rel_string = ''
+else
+  git = find_program('git', required: true)
+
+  git_desc_output = run_command(
+    git, '-C', meson.project_source_root(), 'describe',
+    check: true).stdout().strip()
+  rel_string = run_command('guess-rev.sh', check: true).stdout().strip()
+endif
+
+conf_data.set_quoted('VERSION', meson.project_version())
+conf_data.set_quoted('GITVERSION', git_desc_output)
+conf_data.set_quoted('RELSTR', rel_string)
+
+conf_data.set_quoted('BINDIR', prefix / bin_dir)
+conf_data.set_quoted('PKGDATADIR', prefix / pkg_data_dir)
+
+# Use GNU C library extensions (e.g., strndup).
+# This also ensures that the 'environ' variable is declared in unistd.h, see
+# environ(7) man page for details.
+conf_data.set10('_GNU_SOURCE', true)
+
+# Header and function checks
+
+check_functions = [
+  'realpath',
+  'usleep',
+  'gettimeofday',
+  'strnlen',
+  'strndup',
+  'mallinfo',
+  'mallinfo2',
+]
+
+foreach func: check_functions
+  # We need to use <string.h> as prefix because otherwise Meson may detect
+  # strndup() even though not available on MinGW.
+  #
+  # For more details, see:
+  # - 
https://github.com/sailfishos-mirror/cairo/commit/3ee18ffc28be480b1c8bfb072f73a991734b3c25
+  # - https://github.com/mesonbuild/meson/issues/3672
+  if func == 'strndup'
+    func_prefix = '#include <string.h>'
+  else
+    func_prefix = ''
+  endif
+
+  if cc.has_function(func, prefix: func_prefix)
+    conf_data.set10('HAVE_@0@'.format(func.to_upper()), true)
+  endif
+endforeach
+
+check_headers = [
+  'arpa/inet.h',
+  'elf.h',
+  'fcntl.h',
+  'inttypes.h',
+  'linux/pci.h',
+  'linux/spi/spidev.h',
+  'malloc.h',
+  'netdb.h',
+  'netinet/in.h',
+  'netinet/tcp.h',
+  'poll.h',
+  'stdbool.h',
+  'strings.h',
+  'sys/ioctl.h',
+  'sys/mman.h',
+  'sys/param.h',
+  'sys/select.h',
+  'sys/socket.h',
+  'sys/stat.h',
+  'sys/sysctl.h',
+  'sys/time.h',
+  'sys/types.h',
+  'unistd.h',
+]
+
+available_headers = []
+
+foreach header: check_headers
+  if cc.has_header(header)
+    header_def = header.underscorify().to_upper()
+    available_headers += header_def
+    conf_data.set10('HAVE_@0@'.format(header_def), true)
+  endif
+endforeach
+
+cc.has_header_symbol(
+  'unistd.h',
+  'environ',
+  prefix: '''
+    #define _GNU_SOURCE
+    #include <stdlib.h>
+  ''',
+  required: true,
+)
+
+if cc.has_header_symbol('elf.h', 'Elf64_Ehdr')
+  conf_data.set10('HAVE_ELF64', true)
+endif
+
+# External dependencies.
+
+m_dep = cc.find_library('m', required: false)
+
+# First try to detect jimtcl using pkg-config. If that fails, fall back to
+# compiler-based detection.
+jim_dep = dependency('jimtcl',
+  required: false,
+  version: '>= 0.79'
+)
+
+if not jim_dep.found()
+  jim_dep = cc.find_library('jim', required: true)
+endif
+
+libusb_dep = dependency('libusb-1.0',
+  required: false
+)
+have_libusb = libusb_dep.found()
+
+if have_libusb
+  conf_data.set10('HAVE_LIBUSB1', true)
+
+  if libusb_dep.version().version_compare('>= 1.0.16')
+    conf_data.set10('HAVE_LIBUSB_GET_PORT_NUMBERS', true)
+  endif
+endif
+
+libjaylink_dep = dependency('libjaylink',
+  required: false,
+  version: '>= 0.2.0'
+)
+
+libgpiod_dep = dependency('libgpiod',
+  required: false,
+  version: '>=1.0'
+)
+libgpiod_version = libgpiod_dep.version()
+
+if libgpiod_version.version_compare('<2.0')
+  # libgpiod is version v1.x.
+  conf_data.set10('HAVE_LIBGPIOD_V1', true)
+
+  # Check if libgpiod v1.x has line request flags bias feature.
+  if libgpiod_version.version_compare('>=1.5')
+    conf_data.set10('HAVE_LIBGPIOD1_FLAGS_BIAS', true)
+  endif
+endif
+
+hidapi_libusb_dep = dependency('hidapi-libusb',
+  required: false
+)
+
+hidapi_raw_dep = dependency('hidapi-hidraw',
+  required: false
+)
+
+libftdi_dep = dependency('libftdi1',
+  required: false
+)
+
+if libftdi_dep.version().version_compare('>= 1.5')
+  conf_data.set10('HAVE_LIBFTDI_TCIOFLUSH', true)
+endif
+
+capstone_dep = dependency('capstone',
+  required: get_option('capstone')
+)
+have_capstone = capstone_dep.found()
+
+if have_capstone
+  conf_data.set10('HAVE_CAPSTONE', true)
+endif
+
+# Platform checks
+
+host_system = host_machine.system()
+
+# Note that 'cygwin' is also used as a platform identifier for MSYS2.
+# For further details on Meson operating system names, refer to:
+# https://mesonbuild.com/Reference-tables.html#operating-system-names
+is_cygwin = host_system == 'cygwin'
+is_windows = host_system == 'windows'
+
+conf_data.set10('IS_CYGWIN', is_cygwin)
+conf_data.set10('IS_DARWIN', host_system == 'darwin')
+
+if meson.version().version_compare('>= 1.3.0')
+  is_mingw = cc.has_define('__MINGW32__')
+else
+  is_mingw = cc.compiles('const int foobar = __MINGW32__;')
+endif
+
+conf_data.set10('IS_MINGW', is_mingw)
+conf_data.set10('IS_WIN32', is_windows or is_cygwin)
+
+# Debug adapters
+
+hidapi_cdep = {
+  'availability': hidapi_libusb_dep.found() or hidapi_raw_dep.found(),
+  'error_message': 'either @0@ or @1@ is 
required'.format(hidapi_raw_dep.name(),
+    hidapi_libusb_dep.name())
+}
+
+arm_arch_cdep = {
+  'availability': host_machine.cpu_family() == 'arm',
+  'error_message': 'adapter is only available on Arm architecture',
+}
+
+arm_aarch64_arch_cdep = {
+  'availability': host_machine.cpu_family() in ['arm', 'aarch64'],
+  'error_message': 'adapter is only available on Arm or AArch64 architecture',
+}
+
+linux_os_cdep = {
+  'availability': host_system == 'linux',
+  'error_message': 'adapter is only available on Linux',
+}
+
+linux_freebsd_os_cdep = {
+  'availability': host_system in ['linux', 'freebsd'],
+  'error_message': 'adapter is only available on Linux or FreeBSD',
+}
+
+debug_adapters = {
+  'am335xgpio': {
+    'name': 'AM335X GPIO bitbang adapter',
+    'custom_deps': [arm_aarch64_arch_cdep],
+    'bitbang': true,
+  },
+  'angie': {
+    'name': 'NanoXplore ANGIE adapter',
+    'deps': [libusb_dep],
+  },
+  'armjtagew': {
+    'name': 'Olimex ARM-JTAG-EW adapter',
+    'deps': [libusb_dep],
+  },
+  'at91rm9200': {
+    'name': 'AT91RM9200 GPIO bitbang adapter',
+    'custom_deps': [arm_arch_cdep],
+    'bitbang': true,
+  },
+  'bcm2835gpio': {
+    'name': 'BCM2835 GPIO bitbang adapter',
+    'custom_deps': [arm_aarch64_arch_cdep],
+    'bitbang': true,
+  },
+  'bus_pirate': {
+    'name': 'Bus Pirate adapter',
+    'custom_deps': [
+      {
+        'availability': not is_mingw,
+        'error_message': 'Bus Pirate is not available on MinGW',
+      },
+    ],
+  },
+  'cmsis_dap_hid': {
+    'name': 'CMSIS-DAP adapter (USB HID)',
+    'custom_deps': [hidapi_cdep],
+  },
+  'cmsis_dap_usb': {
+    'name': 'CMSIS-DAP v2 adapter (USB bulk)',
+    'deps': [libusb_dep],
+  },
+  'cmsis_dap_tcp': {
+    'name': 'CMSIS-DAP v2 adapter (TCP)',
+  },
+  'dmem': {
+    'name': 'CoreSight direct memory adapter',
+    'custom_deps': [linux_os_cdep],
+  },
+  'dummy': {
+    'name': 'Dummy adapter',
+    'bitbang': true,
+  },
+  'ep93xx': {
+    'name': 'EP93xx GPIO bitbang adapter',
+    'custom_deps': [arm_arch_cdep],
+    'bitbang': true,
+  },
+  'esp_usb_jtag': {
+    'name': 'Espressif JTAG adapter',
+    'deps': [libusb_dep],
+  },
+  'ft232r': {
+    'name': 'FT232R GPIO bitbang adapter',
+    'deps': [libusb_dep],
+  },
+  'ftdi': {
+    'name': 'FTDI adapter (MPSSE mode)',
+    'deps': [libusb_dep],
+  },
+  'ftdi_cjtag': {
+    'name': 'FTDI adapter with cJTAG support',
+    'deps': [libusb_dep],
+  },
+  'imx_gpio': {
+    'name': 'IMX GPIO bitbang adapter',
+    'custom_deps': [arm_aarch64_arch_cdep],
+    'bitbang': true,
+  },
+  'jlink': {
+    'name': 'SEGGER J-Link adapter',
+    'deps': [libjaylink_dep],
+  },
+  'ch347': {
+    'name': 'CH347-based adapter',
+    'deps': [libusb_dep],
+  },
+  'jtag_dpi': {
+    'name': 'JTAG DPI adapter',
+  },
+  'jtag_vpi': {
+    'name': 'JTAG VPI adapter',
+  },
+  'kitprog': {
+    'name': 'Cypress KitProg adapter',
+    'deps': [libusb_dep, hidapi_libusb_dep],
+  },
+  'linuxgpiod': {
+    'name': 'Linux GPIO bitbang adapter (libgpiod)',
+    'deps': [libgpiod_dep],
+    'bitbang': true,
+  },
+  'linuxspidev': {
+    'name': 'Linux SPI-based adapter (spidev)',
+    'custom_deps': [
+      linux_os_cdep,
+      {
+        'availability': available_headers.contains('LINUX_SPI_SPIDEV_H'),
+        'error_message': 'The #include file \"spidev.h\" is missing',
+      },
+    ],
+  },
+  'nulink': {
+    'name': 'Nuvoton Nu-Link adapter',
+    'custom_deps': [hidapi_cdep],
+    'def': 'HLADAPTER_NULINK',
+    'hla': true,
+  },
+  'opendous': {
+    'name': 'OpenDous JTAG adapter',
+    'deps': [libusb_dep],
+  },
+  'openjtag': {
+    'name': 'OpenJTAG adapter',
+    'deps': [libftdi_dep, libusb_dep],
+  },
+  'osbdm': {
+    'name': 'OSBDM adapter',
+    'deps': [libusb_dep],
+  },
+  'presto': {
+    'name': 'ASIX Presto adapter',
+    'deps': [libftdi_dep],
+  },
+  'parport': {
+    'name': 'Parallel port bitbang adapter',
+    'custom_deps': [linux_freebsd_os_cdep],
+    'bitbang': true,
+  },
+  'remote_bitbang': {
+    'name': 'Remote bitbang adapter',
+    'bitbang': true,
+  },
+  'rlink': {
+    'name': 'Raisonance RLink adapter',
+    'deps': [libusb_dep],
+  },
+  'rshim': {
+    'name': 'RShim-based adapter',
+    'custom_deps': [linux_freebsd_os_cdep],
+  },
+  'stlink': {
+    'name': 'ST-Link adapter',
+    'deps': [libusb_dep],
+    'def': 'HLADAPTER_STLINK',
+    'hla': true,
+  },
+  'sysfsgpio': {
+    'name': 'Linux GPIO bitbang adapter (sysfsgpio)',
+    'custom_deps': [linux_os_cdep],
+    'bitbang': true,
+  },
+  'ti_icdi': {
+    'name': 'TI ICDI adapter',
+    'deps': [libusb_dep],
+    'def': 'HLADAPTER_ICDI',
+    'hla': true,
+  },
+  'ulink': {
+    'name': 'Keil ULINK adapter',
+    'deps': [libusb_dep],
+  },
+  'usb_blaster': {
+    'name': 'Altera USB-Blaster adapter',
+    'deps': [libftdi_dep],
+  },
+  'usb_blaster_2': {
+    'name': 'Altera USB-Blaster II adapter',
+    'deps': [libusb_dep],
+  },
+  'usbprog': {
+    'name': 'USBProg adapter',
+    'deps': [libusb_dep],
+  },
+  'vdebug': {
+    'name': 'Cadence virtual debug adapter',
+  },
+  'vsllink': {
+    'name': 'Versaloon-Link JTAG adapter',
+    'deps': [libusb_dep],
+  },
+  'xds110': {
+    'name': 'TI XDS110 adapter',
+    'deps': [libusb_dep],
+  },
+  'xlnx_xvc': {
+    'name': 'Xilinx XVC adapter',
+    'custom_deps': [
+      linux_os_cdep,
+      {
+        'availability': available_headers.contains('LINUX_PCI_H'),
+        'error_message': 'The #include file \"linux/pci.h\" is missing',
+      },
+      {
+        'availability': available_headers.contains('SYS_MMAN_H'),
+        'error_message': 'The #include file \"sys/mman.h\" is missing',
+      },
+    ],
+  },
+}
+
+# Build high-level adapter (HLA) support only if we build certain adapters.
+build_hl_adapter = false
+
+# Build bitbang adapter support.
+build_bitbang_adapter = false
+
+build_adapters = []
+debug_adapters_summary = {
+}
+
+foreach adapter_id, adapter : debug_adapters
+  available = get_option('adapter_@0@'.format(adapter_id))
+
+  # Check whether dependencies are available.
+  foreach dep : adapter.get('deps', [])
+    available = available.require(dep.found(),
+      error_message: '@0@ required but not found'.format(dep.name()))
+  endforeach
+
+  # Check whether custom dependencies are available.
+  foreach custom_dep : adapter.get('custom_deps', [])
+    available = available.require(custom_dep['availability'],
+      error_message: custom_dep['error_message'])
+  endforeach
+
+  adapter_available = available.allowed()
+
+  def = adapter.get('def', adapter_id.underscorify().to_upper())
+  conf_data.set10('BUILD_@0@'.format(def), adapter_available)
+
+  if adapter_available
+    build_adapters += adapter_id
+
+    if adapter.get('hla', false)
+      build_hl_adapter = true
+    endif
+
+    if adapter.get('bitbang', false)
+      build_bitbang_adapter = true
+    endif
+  endif
+
+  debug_adapters_summary += {
+    adapter['name']: available
+  }
+endforeach
+
+conf_data.set10('BUILD_HLADAPTER', build_hl_adapter)
+
+# Compiler flags
+
+config_h = configure_file(
+  output: 'config.h',
+  configuration: conf_data
+)
+
+core_cflags = [
+  '-DHAVE_CONFIG_H',
+]
+
+if is_mingw
+  core_cflags += [
+    '-D__USE_MINGW_ANSI_STDIO',
+    '-DFD_SETSIZE=128',
+  ]
+endif
+
+# Note that -Wall and -Wextra are controlled by Meson's warning_level option,
+# while -Werror is controlled by the werror option.
+
+# Basic warning flags.
+basic_warning_flags = [
+  '-Wstrict-prototypes',
+  '-Wformat-security',
+  '-Wshadow',
+]
+
+core_cflags += cc.get_supported_arguments(basic_warning_flags)
+
+extra_warning_flags = [
+  '-Wno-unused-parameter',
+  '-Wno-gnu-folding-constant',
+  '-Wbad-function-cast',
+  '-Wcast-align',
+  '-Wredundant-decls',
+  '-Wpointer-arith',
+  '-Wundef',
+]
+
+if get_option('extra_warnings')
+  core_cflags += cc.get_supported_arguments(extra_warning_flags)
+endif
+
+# OpenOCD target
+
+core_dep = declare_dependency(
+  include_directories: include_directories('.', 'src'),
+  dependencies: jim_dep,
+  compile_args: core_cflags
+)
+
+startup_tcl_sources = [
+]
+
+subdir('src/rtt')
+subdir('src/jtag')
+subdir('src/target')
+subdir('src/rtos')
+subdir('src/server')
+subdir('src/flash')
+subdir('src/transport')
+subdir('src/helper')
+subdir('src/pld')
+subdir('src/svf')
+subdir('src/xsvf')
+
+openocd_sources = [
+  'src/hello.c',
+  'src/main.c',
+  'src/openocd.c',
+]
+
+startup_tcl_all = custom_target(
+  'startup_tcl',
+  input: startup_tcl_sources,
+  output: 'startup.tcl',
+  command: ['cat', '@INPUT@'],
+  capture: true
+)
+
+startup_tcl_chars = custom_target(
+  'startup_tcl_chars',
+  input: startup_tcl_all,
+  output: 'startup_tcl.inc',
+  command: [
+     meson.project_source_root() / 'src/helper/bin2char.sh',
+  ],
+  feed: true,
+  capture: true,
+)
+
+openocd_sources += [
+  startup_tcl_chars
+]
+
+deps = [
+  core_dep,
+]
+
+if m_dep.found()
+  deps += m_dep
+endif
+
+if is_windows
+  deps += cc.find_library('ws2_32', required: true)
+endif
+
+executable('openocd',
+  openocd_sources,
+  dependencies: deps,
+  link_with: [
+    jtag_lib,
+    svf_lib,
+    xsvf_lib,
+    target_lib,
+    rtos_lib,
+    server_lib,
+    flash_lib,
+    transport_lib,
+    helper_lib,
+    rtt_lib,
+    pld_lib,
+  ],
+  install: true
+)
+
+# Documentation targets
+
+doxyfile_conf = configuration_data()
+doxyfile_conf.set('srcdir', meson.project_source_root())
+doxyfile_conf.set('builddir', meson.project_build_root())
+
+doxyfile = configure_file(
+  input: 'Doxyfile.in',
+  output: 'Doxyfile',
+  configuration: doxyfile_conf
+)
+
+subdir('doc')
+
+# Configuration summary
+
+summary(
+  debug_adapters_summary,
+  section: 'Debug adapters',
+)
+
+features_summary = {
+  'Capstone disassembly framework': capstone_dep
+}
+
+summary(
+  features_summary,
+  section: 'Features'
+)
+
+# Data installation
+
+install_subdir(
+  'tcl',
+  install_dir: pkg_data_dir / 'scripts',
+  strip_directory: true
+)
+
+install_subdir(
+  'contrib/libdcc',
+  install_dir: pkg_data_dir / 'contrib',
+)
+
+install_data(
+  'contrib/60-openocd.rules',
+  install_dir: pkg_data_dir / 'contrib'
+)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000000..fc17f805d8
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,281 @@
+# Project options.
+
+option('extra_warnings',
+  type: 'boolean',
+  value: true,
+  description: 'Use extra compiler warnings'
+)
+
+# Debug adapter options.
+
+option('adapter_am335xgpio',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable AM335X GPIO bitbang adapter'
+)
+
+option('adapter_angie',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable ANGIE adapter'
+)
+
+option('adapter_armjtagew',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Olimex ARM-JTAG-EW adapter'
+)
+
+option('adapter_at91rm9200',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable AT91RM9200 GPIO bitbang adapter'
+)
+
+option('adapter_bcm2835gpio',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable BCM2835 GPIO bitbang adapter'
+)
+
+option('adapter_bus_pirate',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Bus Pirate adapter'
+)
+
+option('adapter_cmsis_dap_hid',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable CMSIS-DAP adapter (USB HID)'
+)
+
+option('adapter_cmsis_dap_usb',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable CMSIS-DAP v2 adapter (USB bulk)'
+)
+
+option('adapter_cmsis_dap_tcp',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable CMSIS-DAP v2 adapter (TCP)'
+)
+
+option('adapter_dmem',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable CoreSight direct memory adapter'
+)
+
+option('adapter_dummy',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable dummy adapter (for testing)'
+)
+
+option('adapter_ep93xx',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable EP93xx GPIO bitbang adapter'
+)
+
+option('adapter_esp_usb_jtag',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Espressif JTAG adapter'
+)
+
+option('adapter_ft232r',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable FT232R GPIO bitbang adapter'
+)
+
+option('adapter_ftdi',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable FTDI adapter (MPSSE mode)'
+)
+
+option('adapter_ftdi_cjtag',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable FTDI adapter with cJTAG support'
+)
+
+option('adapter_imx_gpio',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable IMX GPIO bitbang adapter'
+)
+
+option('adapter_jlink',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable SEGGER J-Link adapter'
+)
+
+option('adapter_ch347',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable CH347-based adapter'
+)
+
+option('adapter_jtag_dpi',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable JTAG DPI adapter'
+)
+
+option('adapter_jtag_vpi',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable JTAG VPI adapter'
+)
+
+option('adapter_kitprog',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Cypress KitProg adapter'
+)
+
+option('adapter_linuxgpiod',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Linux GPIO bitbang adapter (libgpiod)'
+)
+
+option('adapter_linuxspidev',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Linux SPI-based adapter (spidev)'
+)
+
+option('adapter_nulink',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Nuvoton Nu-Link adapter'
+)
+
+option('adapter_opendous',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable OpenDous JTAG adapter'
+)
+
+option('adapter_openjtag',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable OpenJTAG adapter'
+)
+
+option('adapter_osbdm',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable OSBDM adapter'
+)
+
+option('adapter_parport',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable parallel port bitbang adapter'
+)
+
+option('adapter_presto',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable ASIX Presto adapter'
+)
+
+option('adapter_remote_bitbang',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable remote bitbang adapter'
+)
+
+option('adapter_rlink',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Raisonance RLink adapter'
+)
+
+option('adapter_rshim',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable RShim-based adapter'
+)
+
+option('adapter_stlink',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable ST-Link adapter'
+)
+
+option('adapter_sysfsgpio',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable sysfsgpio GPIO bitbang adapter'
+)
+
+option('adapter_ti_icdi',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable TI ICDI adapter'
+)
+
+option('adapter_ulink',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Keil ULINK adapter'
+)
+
+option('adapter_usb_blaster',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Altera USB-Blaster adapter'
+)
+
+option('adapter_usb_blaster_2',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Altera USB-Blaster II adapter'
+)
+
+option('adapter_usbprog',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable USBProg adapter'
+)
+
+option('adapter_vdebug',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Cadence virtual adapter'
+)
+
+option('adapter_vsllink',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Versaloon-Link adapter'
+)
+
+option('adapter_xds110',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable TI XDS110 adapter'
+)
+
+option('adapter_xlnx_xvc',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Xilinx XVC adapter'
+)
+
+# Feature options.
+
+option('capstone',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable Capstone disassembly framework'
+)
diff --git a/src/flash/meson.build b/src/flash/meson.build
new file mode 100644
index 0000000000..9655f11e09
--- /dev/null
+++ b/src/flash/meson.build
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+subdir('nor')
+subdir('nand')
+
+flash_sources = [
+  'common.c',
+]
+
+startup_tcl_sources += files('startup.tcl')
+
+flash_lib = static_library(
+  'flash',
+  sources: flash_sources,
+  link_with: [
+    flash_nor_lib,
+    flash_nand_lib,
+  ],
+  dependencies: core_dep,
+  install: false
+)
diff --git a/src/flash/nand/meson.build b/src/flash/nand/meson.build
new file mode 100644
index 0000000000..d7ad5db22d
--- /dev/null
+++ b/src/flash/nand/meson.build
@@ -0,0 +1,37 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+flash_nand_driver_sources = [
+  'at91sam9.c',
+  'davinci.c',
+  'lpc3180.c',
+  'lpc32xx.c',
+  'mx3.c',
+  'mxc.c',
+  'nonce.c',
+  'nuc910.c',
+  'orion.c',
+  's3c2410.c',
+  's3c2412.c',
+  's3c2440.c',
+  's3c2443.c',
+  's3c24xx.c',
+  's3c6400.c',
+]
+
+flash_nand_sources = [
+  'arm_io.c',
+  'core.c',
+  'driver.c',
+  'ecc.c',
+  'ecc_kw.c',
+  'fileio.c',
+  'tcl.c',
+  flash_nand_driver_sources,
+]
+
+flash_nand_lib = static_library(
+  'flash_nand',
+  sources: flash_nand_sources,
+  dependencies: core_dep,
+  install: false
+)
diff --git a/src/flash/nor/meson.build b/src/flash/nor/meson.build
new file mode 100644
index 0000000000..eeef56aa68
--- /dev/null
+++ b/src/flash/nor/meson.build
@@ -0,0 +1,96 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+flash_nor_driver_sources = [
+  'aduc702x.c',
+  'aducm360.c',
+  'ambiqmicro.c',
+  'artery.c',
+  'at91sam3.c',
+  'at91sam4.c',
+  'at91sam4l.c',
+  'at91sam7.c',
+  'at91samd.c',
+  'ath79.c',
+  'atsame5.c',
+  'atsamv.c',
+  'avrf.c',
+  'bl602.c',
+  'bluenrg-x.c',
+  'cc26xx.c',
+  'cc3220sf.c',
+  'cfi.c',
+  'dsp5680xx_flash.c',
+  'dw-spi.c',
+  'efm32.c',
+  'em357.c',
+  'eneispif.c',
+  'esirisc_flash.c',
+  'faux.c',
+  'fespi.c',
+  'fm3.c',
+  'fm4.c',
+  'hpm_xpi.c',
+  'jtagspi.c',
+  'kinetis.c',
+  'kinetis_ke.c',
+  'lpc2000.c',
+  'lpc288x.c',
+  'lpc2900.c',
+  'lpcspifi.c',
+  'max32xxx.c',
+  'mdr.c',
+  'mrvlqspi.c',
+  'msp432.c',
+  'mspm0.c',
+  'niietcm4.c',
+  'non_cfi.c',
+  'npcx.c',
+  'nrf5.c',
+  'numicro.c',
+  'ocl.c',
+  'pic32mx.c',
+  'psoc4.c',
+  'psoc5lp.c',
+  'psoc6.c',
+  'qn908x.c',
+  'read_only.c',
+  'renesas_rpchf.c',
+  'rp2xxx.c',
+  'rsl10.c',
+  'sfdp.c',
+  'sh_qspi.c',
+  'sim3x.c',
+  'spi.c',
+  'stellaris.c',
+  'stm32f1x.c',
+  'stm32f2x.c',
+  'stm32h7x.c',
+  'stm32l4x.c',
+  'stm32lx.c',
+  'stmqspi.c',
+  'stmsmi.c',
+  'str7x.c',
+  'str9x.c',
+  'str9xpec.c',
+  'swm050.c',
+  'tms470.c',
+  'virtual.c',
+  'w600.c',
+  'xcf.c',
+  'xmc1xxx.c',
+  'xmc4xxx.c',
+]
+
+flash_nor_sources = [
+  'core.c',
+  'drivers.c',
+  'tcl.c',
+  flash_nor_driver_sources,
+]
+
+flash_nor_lib = static_library(
+  'flash_nor',
+  sources: flash_nor_sources,
+  dependencies: core_dep,
+  install: false
+)
diff --git a/src/helper/meson.build b/src/helper/meson.build
new file mode 100644
index 0000000000..1182626bd0
--- /dev/null
+++ b/src/helper/meson.build
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+helper_sources = [
+  'base64.c',
+  'binarybuffer.c',
+  'command.c',
+  'configuration.c',
+  'crc32.c',
+  'fileio.c',
+  'jep106.c',
+  'jim-nvp.c',
+  'log.c',
+  'nvp.c',
+  'options.c',
+  'replacements.c',
+  'time_support.c',
+  'time_support_common.c',
+  'util.c',
+]
+
+startup_tcl_sources += files('startup.tcl')
+
+helper_lib = static_library(
+  'helper',
+  sources: helper_sources,
+  dependencies: core_dep,
+  install: false
+)
diff --git a/src/jtag/drivers/meson.build b/src/jtag/drivers/meson.build
new file mode 100644
index 0000000000..9101b72578
--- /dev/null
+++ b/src/jtag/drivers/meson.build
@@ -0,0 +1,245 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+jtag_drivers_dep = declare_dependency(
+  include_directories: include_directories('.'),
+  dependencies: core_dep
+)
+
+jtag_drivers_libs = [
+]
+
+jtag_drivers_sources = [
+  'driver.c',
+]
+
+if build_bitbang_adapter
+  jtag_drivers_sources += 'bitbang.c'
+endif
+
+if 'presto' in build_adapters or 'esp_usb_jtag' in build_adapters
+  jtag_drivers_sources += 'bitq.c'
+endif
+
+if have_libusb
+  jtag_drivers_sources += 'libusb_helper.c'
+endif
+
+if 'am335xgpio' in build_adapters
+  jtag_drivers_sources += 'am335xgpio.c'
+endif
+
+if 'at91rm9200' in build_adapters
+  jtag_drivers_sources += 'at91rm9200.c'
+endif
+
+if 'bcm2835gpio' in build_adapters
+  jtag_drivers_sources += 'bcm2835gpio.c'
+endif
+
+if 'angie' in build_adapters
+  jtag_drivers_sources += 'angie.c'
+
+  install_data([
+    'angie/angie_bitstream.bit',
+    'angie/angie_firmware.bin',
+    ],
+    install_dir: pkg_data_dir / 'angie',
+  )
+endif
+
+if 'ch347' in build_adapters
+  jtag_drivers_sources += 'ch347.c'
+endif
+
+if 'armjtagew' in build_adapters
+  jtag_drivers_sources += 'arm-jtag-ew.c'
+endif
+
+if 'bus_pirate' in build_adapters
+  jtag_drivers_sources += 'buspirate.c'
+endif
+
+cmsis_dap_sources = []
+
+if 'cmsis_dap_hid' in build_adapters
+  cmsis_dap_sources += 'cmsis_dap_usb_hid.c'
+endif
+
+if 'cmsis_dap_usb' in build_adapters
+  cmsis_dap_sources += 'cmsis_dap_usb_bulk.c'
+endif
+
+if 'cmsis_dap_tcp' in build_adapters
+  cmsis_dap_sources += 'cmsis_dap_tcp.c'
+endif
+
+if cmsis_dap_sources.length() > 0
+  cmsis_dap_sources += 'cmsis_dap.c'
+endif
+
+jtag_drivers_sources += cmsis_dap_sources
+
+if 'dmem' in build_adapters
+  jtag_drivers_sources += 'dmem.c'
+endif
+
+if 'dummy' in build_adapters
+  jtag_drivers_sources += 'dummy.c'
+endif
+
+if 'ep93xx' in build_adapters
+  jtag_drivers_sources += 'ep93xx.c'
+endif
+
+if 'esp_usb_jtag' in build_adapters
+  jtag_drivers_sources += 'esp_usb_jtag.c'
+endif
+
+if 'ft232r' in build_adapters
+  jtag_drivers_sources += 'ft232r.c'
+endif
+
+if 'ftdi' in build_adapters or 'ftdi_cjtag' in build_adapters
+  jtag_drivers_sources += [
+    'mpsse.c',
+    'ftdi.c',
+  ]
+endif
+
+if 'imx_gpio' in build_adapters
+  jtag_drivers_sources += 'imx_gpio.c'
+endif
+
+if 'jlink' in build_adapters
+  jtag_drivers_sources += 'jlink.c'
+endif
+
+if 'jtag_dpi' in build_adapters
+  jtag_drivers_sources += 'jtag_dpi.c'
+endif
+
+if 'jtag_vpi' in build_adapters
+  jtag_drivers_sources += 'jtag_vpi.c'
+endif
+
+if 'kitprog' in build_adapters
+  jtag_drivers_sources += 'kitprog.c'
+endif
+
+if 'linuxgpiod' in build_adapters
+  jtag_drivers_sources += 'linuxgpiod.c'
+endif
+
+if 'linuxspidev' in build_adapters
+  jtag_drivers_sources += 'linuxspidev.c'
+endif
+
+if 'nulink' in build_adapters
+  jtag_drivers_sources += 'nulink_usb.c'
+endif
+
+if 'opendous' in build_adapters
+  jtag_drivers_sources += 'opendous.c'
+endif
+
+if 'openjtag' in build_adapters
+  jtag_drivers_sources += 'openjtag.c'
+endif
+
+if 'osbdm' in build_adapters
+  jtag_drivers_sources += 'osbdm.c'
+endif
+
+if 'parport' in build_adapters
+  jtag_drivers_sources += 'parport.c'
+endif
+
+if 'presto' in build_adapters
+  jtag_drivers_sources += 'presto.c'
+endif
+
+if 'remote_bitbang' in build_adapters
+  jtag_drivers_sources += 'remote_bitbang.c'
+endif
+
+if 'rlink' in build_adapters
+  jtag_drivers_sources += [
+    'rlink.c',
+    'rlink_speed_table.c',
+  ]
+endif
+
+if 'rshim' in build_adapters
+  jtag_drivers_sources += 'rshim.c'
+endif
+
+if 'stlink' in build_adapters
+  jtag_drivers_sources += 'stlink_usb.c'
+endif
+
+if 'sysfsgpio' in build_adapters
+  jtag_drivers_sources += 'sysfsgpio.c'
+endif
+
+if 'ti_icdi' in build_adapters
+  jtag_drivers_sources += 'ti_icdi_usb.c'
+endif
+
+if 'ulink' in build_adapters
+  jtag_drivers_sources += 'ulink.c'
+
+  install_data([
+      'OpenULINK/ulink_firmware.hex',
+    ],
+    install_dir: pkg_data_dir / 'OpenULINK',
+  )
+endif
+
+if 'usb_blaster' in build_adapters or 'usb_blaster_2' in build_adapters
+  subdir('usb_blaster')
+  jtag_drivers_libs += jtag_drivers_usb_blaster_lib
+endif
+
+if 'usbprog' in build_adapters
+  jtag_drivers_sources += 'usbprog.c'
+endif
+
+if 'vsllink' in build_adapters
+  jtag_drivers_sources += [
+    'versaloon/usbtoxxx/usbtogpio.c',
+    'versaloon/usbtoxxx/usbtojtagraw.c',
+    'versaloon/usbtoxxx/usbtopwr.c',
+    'versaloon/usbtoxxx/usbtoswd.c',
+    'versaloon/usbtoxxx/usbtoxxx.c',
+    'versaloon/versaloon.c',
+    'vsllink.c',
+  ]
+endif
+
+if 'vdebug' in build_adapters
+  jtag_drivers_sources += 'vdebug.c'
+endif
+
+if 'xds110' in build_adapters
+  jtag_drivers_sources += 'xds110.c'
+endif
+
+if 'xlnx_xvc' in build_adapters
+  jtag_drivers_sources += 'xlnx-xvc.c'
+endif
+
+jtag_drivers_lib = static_library(
+  'jtag_drivers',
+  sources: jtag_drivers_sources,
+  link_with: jtag_drivers_libs,
+  dependencies: [
+    jtag_drivers_dep,
+    hidapi_libusb_dep,
+    hidapi_raw_dep,
+    libftdi_dep,
+    libgpiod_dep,
+    libjaylink_dep,
+    libusb_dep,
+  ],
+  install: false
+)
diff --git a/src/jtag/drivers/usb_blaster/meson.build 
b/src/jtag/drivers/usb_blaster/meson.build
new file mode 100644
index 0000000000..6766027ddc
--- /dev/null
+++ b/src/jtag/drivers/usb_blaster/meson.build
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+usb_blaster_sources = [
+  'usb_blaster.c'
+]
+
+if 'usb_blaster' in build_adapters
+  usb_blaster_sources += 'ublast_access_ftdi.c'
+endif
+
+if 'usb_blaster_2' in build_adapters
+  usb_blaster_sources += 'ublast2_access_libusb.c'
+endif
+
+jtag_drivers_usb_blaster_lib = static_library(
+  'jtag_drivers_usb_blaster',
+  sources: usb_blaster_sources,
+  dependencies: [
+    jtag_drivers_dep,
+    libftdi_dep,
+    libusb_dep,
+  ],
+  install: false
+)
diff --git a/src/jtag/hla/meson.build b/src/jtag/hla/meson.build
new file mode 100644
index 0000000000..dcb1cd69cc
--- /dev/null
+++ b/src/jtag/hla/meson.build
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+jtag_hla_sources = [
+  'hla_interface.c',
+  'hla_layout.c',
+  'hla_transport.c',
+]
+
+jtag_hla_lib = static_library(
+  'jtag_hla',
+  sources: jtag_hla_sources,
+  dependencies: [
+    core_dep,
+  ],
+  install: false
+)
diff --git a/src/jtag/meson.build b/src/jtag/meson.build
new file mode 100644
index 0000000000..8a8f91f9f9
--- /dev/null
+++ b/src/jtag/meson.build
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+subdir('drivers')
+
+jtag_sources = [
+  'core.c',
+  'tcl.c',
+  'interfaces.c',
+  'commands.c',
+  'interface.c',
+  'adapter.c',
+  'swim.c',
+]
+
+link_with = [
+  jtag_drivers_lib,
+]
+
+if build_hl_adapter
+  subdir('hla')
+  link_with += jtag_hla_lib
+endif
+
+startup_tcl_sources += files('startup.tcl')
+
+jtag_lib = static_library(
+  'jtag',
+  sources: jtag_sources,
+  dependencies: core_dep,
+  link_with: link_with,
+  install: false
+)
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/src/pld/meson.build b/src/pld/meson.build
new file mode 100644
index 0000000000..9933e22780
--- /dev/null
+++ b/src/pld/meson.build
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+pld_sources = [
+  'certus.c',
+  'ecp2_3.c',
+  'ecp5.c',
+  'efinix.c',
+  'gatemate.c',
+  'gowin.c',
+  'intel.c',
+  'lattice.c',
+  'lattice_bit.c',
+  'pld.c',
+  'raw_bit.c',
+  'virtex2.c',
+  'xilinx_bit.c',
+]
+
+pld_lib = static_library(
+  'pld',
+  sources: pld_sources,
+  dependencies: core_dep,
+  install: false
+)
diff --git a/src/rtos/meson.build b/src/rtos/meson.build
new file mode 100644
index 0000000000..5809ff4174
--- /dev/null
+++ b/src/rtos/meson.build
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+rtos_sources = [
+  'chibios.c',
+  'chromium-ec.c',
+  'ecos.c',
+  'embkernel.c',
+  'freertos.c',
+  'hwthread.c',
+  'linux.c',
+  'mqx.c',
+  'nuttx.c',
+  'riot.c',
+  'rtkernel.c',
+  'rtos.c',
+  'rtos_chibios_stackings.c',
+  'rtos_ecos_stackings.c',
+  'rtos_embkernel_stackings.c',
+  'rtos_mqx_stackings.c',
+  'rtos_nuttx_stackings.c',
+  'rtos_riot_stackings.c',
+  'rtos_standard_stackings.c',
+  'rtos_ucos_iii_stackings.c',
+  'threadx.c',
+  'ucos_iii.c',
+  'zephyr.c',
+]
+
+rtos_lib = static_library(
+  'rtos',
+  sources: rtos_sources,
+  dependencies: core_dep,
+  install: false
+)
diff --git a/src/rtt/meson.build b/src/rtt/meson.build
new file mode 100644
index 0000000000..72796a6272
--- /dev/null
+++ b/src/rtt/meson.build
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+rtt_sources = [
+  'rtt.c',
+  'tcl.c',
+]
+
+rtt_lib = static_library(
+  'rtt',
+  sources: rtt_sources,
+  dependencies: core_dep,
+  install: false
+)
diff --git a/src/server/meson.build b/src/server/meson.build
new file mode 100644
index 0000000000..da3cdb59a8
--- /dev/null
+++ b/src/server/meson.build
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+server_sources = [
+  'gdb_server.c',
+  'ipdbg.c',
+  'rtt_server.c',
+  'server.c',
+  'tcl_server.c',
+  'telnet_server.c',
+]
+
+startup_tcl_sources += files('startup.tcl')
+
+server_lib = static_library(
+  'server',
+  sources: server_sources,
+  dependencies: core_dep,
+  install: false
+)
diff --git a/src/svf/meson.build b/src/svf/meson.build
new file mode 100644
index 0000000000..8e1e03e158
--- /dev/null
+++ b/src/svf/meson.build
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+svf_sources = [
+  'svf.c',
+]
+
+svf_lib = static_library(
+  'svf',
+  sources: svf_sources,
+  dependencies: core_dep,
+  install: false,
+)
diff --git a/src/target/espressif/meson.build b/src/target/espressif/meson.build
new file mode 100644
index 0000000000..ee2b459702
--- /dev/null
+++ b/src/target/espressif/meson.build
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+target_espressif_sources = [
+  'esp.c',
+  'esp32.c',
+  'esp32_apptrace.c',
+  'esp32_sysview.c',
+  'esp32s2.c',
+  'esp32s3.c',
+  'esp_algorithm.c',
+  'esp_semihosting.c',
+  'esp_xtensa.c',
+  'esp_xtensa_algorithm.c',
+  'esp_xtensa_apptrace.c',
+  'esp_xtensa_semihosting.c',
+  'esp_xtensa_smp.c',
+]
+
+target_espressif_lib = static_library(
+  'target_espressif',
+  sources: target_espressif_sources,
+  dependencies: core_dep,
+  install: false
+)
diff --git a/src/target/meson.build b/src/target/meson.build
new file mode 100644
index 0000000000..e28dc16698
--- /dev/null
+++ b/src/target/meson.build
@@ -0,0 +1,177 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+subdir('espressif')
+subdir('xtensa')
+subdir('openrisc')
+subdir('riscv')
+
+target_core_sources = [
+  'algorithm.c',
+  'breakpoints.c',
+  'image.c',
+  'register.c',
+  'rtt.c',
+  'semihosting_common.c',
+  'smp.c',
+  'target.c',
+  'target_request.c',
+  'testee.c',
+]
+
+target_arm7_9_sources = [
+  'arm720t.c',
+  'arm7_9_common.c',
+  'arm7tdmi.c',
+  'arm920t.c',
+  'arm926ejs.c',
+  'arm946e.c',
+  'arm966e.c',
+  'arm9tdmi.c',
+  'feroceon.c',
+]
+
+target_armv4_5_sources = [
+  'armv4_5.c',
+  'armv4_5_cache.c',
+  'armv4_5_mmu.c',
+  target_arm7_9_sources,
+]
+
+target_armv6_sources = [
+  'arm11.c',
+  'arm11_dbgtap.c',
+]
+
+target_armv7_sources = [
+  'armv7m.c',
+  'armv7m_cache.c',
+  'armv7m_trace.c',
+  'cortex_m.c',
+  'armv7a.c',
+  'armv7a_mmu.c',
+  'cortex_a.c',
+  'ls1_sap.c',
+  'mem_ap.c',
+]
+
+target_armv8_sources = [
+  'a64_disassembler.c',
+  'aarch64.c',
+  'armv8.c',
+  'armv8_cache.c',
+  'armv8_dpm.c',
+  'armv8_opcodes.c',
+]
+
+target_arm_debug_sources = [
+  'adi_v5_dapdirect.c',
+  'adi_v5_jtag.c',
+  'adi_v5_swd.c',
+  'arm_adi_v5.c',
+  'arm_cti.c',
+  'arm_dap.c',
+  'arm_disassembler.c',
+  'arm_dpm.c',
+  'arm_jtag.c',
+  'arm_semihosting.c',
+  'arm_simulator.c',
+  'arm_tpiu_swo.c',
+  'armv7a_cache.c',
+  'armv7a_cache_l2x.c',
+  'embeddedice.c',
+  'etb.c',
+  'etm.c',
+  'etm_dummy.c',
+]
+
+target_arm_misc_sources = [
+  'fa526.c',
+  'xscale.c',
+]
+
+target_avr32_sources = [
+  'avr32_ap7k.c',
+  'avr32_jtag.c',
+  'avr32_mem.c',
+  'avr32_regs.c',
+]
+
+target_mips32_sources = [
+  'mips32.c',
+  'mips32_dmaacc.c',
+  'mips32_pracc.c',
+  'mips_ejtag.c',
+  'mips_m4k.c',
+]
+
+target_mips64_sources = [
+  'mips64.c',
+  'mips64_pracc.c',
+  'mips_ejtag.c',
+  'mips_mips64.c',
+]
+
+target_stm8_sources = [
+  'stm8.c',
+]
+
+target_intel_ia32_sources = [
+  'lakemont.c',
+  'quark_d20xx.c',
+  'quark_x10xx.c',
+  'x86_32_common.c',
+]
+
+target_esirisc_sources = [
+  'esirisc.c',
+  'esirisc_jtag.c',
+  'esirisc_trace.c',
+]
+
+target_arc_sources = [
+  'arc.c',
+  'arc_cmd.c',
+  'arc_jtag.c',
+  'arc_mem.c',
+]
+
+target_sources = [
+  target_arc_sources,
+  target_esirisc_sources,
+  target_stm8_sources,
+  target_intel_ia32_sources,
+  target_mips32_sources,
+  target_mips64_sources,
+  target_avr32_sources,
+  target_core_sources,
+  target_armv4_5_sources,
+  target_armv6_sources,
+  target_armv7_sources,
+  target_armv8_sources,
+  target_arm_debug_sources,
+  target_arm_misc_sources,
+  'avrt.c',
+  'trace.c',
+  'dsp5680xx.c',
+  'dsp563xx.c',
+  'dsp563xx_once.c',
+  'hla_target.c',
+]
+
+startup_tcl_sources += files('startup.tcl')
+
+target_lib = static_library(
+  'target',
+  sources: target_sources,
+  install: false,
+  dependencies: [
+    core_dep,
+    capstone_dep,
+  ],
+  link_with: [
+    target_espressif_lib,
+    target_openrisc_lib,
+    target_riscv_lib,
+    target_xtensa_lib,
+  ],
+)
diff --git a/src/target/openrisc/meson.build b/src/target/openrisc/meson.build
new file mode 100644
index 0000000000..629b07b91e
--- /dev/null
+++ b/src/target/openrisc/meson.build
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+target_openrisc_sources = [
+  'jsp_server.c',
+  'or1k.c',
+  'or1k_du_adv.c',
+  'or1k_tap_mohor.c',
+  'or1k_tap_vjtag.c',
+  'or1k_tap_xilinx_bscan.c',
+]
+
+target_openrisc_lib = static_library(
+  'target_openrisc',
+  sources: target_openrisc_sources,
+  dependencies: core_dep,
+  install: false
+)
diff --git a/src/target/riscv/meson.build b/src/target/riscv/meson.build
new file mode 100644
index 0000000000..7aa078bff9
--- /dev/null
+++ b/src/target/riscv/meson.build
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+target_riscv_sources = [
+  'batch.c',
+  'debug_defines.c',
+  'debug_reg_printer.c',
+  'program.c',
+  'riscv-011.c',
+  'riscv-011_reg.c',
+  'riscv-013.c',
+  'riscv-013_reg.c',
+  'riscv.c',
+  'riscv_reg.c',
+  'riscv_semihosting.c',
+]
+
+startup_tcl_sources += files('startup.tcl')
+
+target_riscv_lib = static_library(
+  'target_riscv',
+  sources: target_riscv_sources,
+  dependencies: core_dep,
+  install: false
+)
diff --git a/src/target/xtensa/meson.build b/src/target/xtensa/meson.build
new file mode 100644
index 0000000000..95352587a8
--- /dev/null
+++ b/src/target/xtensa/meson.build
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+target_xtensa_sources = [
+  'xtensa.c',
+  'xtensa_chip.c',
+  'xtensa_debug_module.c',
+  'xtensa_fileio.c',
+]
+
+target_xtensa_lib = static_library(
+  'target_xtensa',
+  sources: target_xtensa_sources,
+  dependencies: core_dep,
+  install: false
+)
diff --git a/src/transport/meson.build b/src/transport/meson.build
new file mode 100644
index 0000000000..9a08435546
--- /dev/null
+++ b/src/transport/meson.build
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+transport_sources = [
+  'transport.c',
+]
+
+transport_lib = static_library(
+  'transport',
+  sources: transport_sources,
+  dependencies: core_dep,
+  install: false
+)
diff --git a/src/xsvf/meson.build b/src/xsvf/meson.build
new file mode 100644
index 0000000000..9ff53cab75
--- /dev/null
+++ b/src/xsvf/meson.build
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+xsvf_sources = [
+  'xsvf.c',
+]
+
+xsvf_lib = static_library(
+  'xsvf',
+  sources: xsvf_sources,
+  dependencies: core_dep,
+  install: false
+)

-- 

Reply via email to