1project('drm_info', 'c',
2  version: '2.3.0',
3  license: 'MIT',
4  meson_version: '>=0.49.0',
5  default_options: [
6    'c_std=c11',
7    'warning_level=2',
8  ],
9)
10
11cc = meson.get_compiler('c')
12
13add_project_arguments('-D_POSIX_C_SOURCE=200809L', language: 'c')
14
15jsonc = dependency('json-c', version: '>=0.13', fallback: ['json-c', 'json_c'])
16libpci = dependency('libpci', required: get_option('libpci'))
17libdrm = dependency('libdrm',
18  fallback: ['libdrm', 'ext_libdrm'],
19  default_options: [
20    'libkms=false',
21    'intel=false',
22    'radeon=false',
23    'amdgpu=false',
24    'nouveau=false',
25    'vmwgfx=false',
26    'omap=false',
27    'exynos=false',
28    'freedreno=false',
29    'tegra=false',
30    'vc4=false',
31    'etnaviv=false',
32    'cairo-tests=false',
33    'man-pages=false',
34    'valgrind=false',
35  ],
36)
37
38inc = []
39# libdrm pretty consistently pulls in the linux userspace API headers.
40# We want a new libdrm to get all of the #defines in those headers, but
41# we don't actually need to link against a new version of libdrm itself.
42#
43# We need to make sure we don't use any new libdrm functions, but those
44# are added very infrequently, so this is unlikely to be an issue.
45if libdrm.version().version_compare('<2.4.104')
46  if libdrm.type_name() == 'internal'
47    error('libdrm subproject out of date. Run `meson subprojects update`.')
48  endif
49
50  msg = [
51    'System libdrm version does not have latest Linux DRM headers.',
52    'Attempting to use headers from meson subproject if present.',
53    'If this fails, update your system libdrm or run `meson subprojects download`.',
54  ]
55  foreach s : msg
56    warning(s)
57  endforeach
58
59  fourcc_h = files('subprojects/libdrm/include/drm/drm_fourcc.h')
60  inc += include_directories('subprojects/libdrm/include/drm')
61  libdrm = libdrm.partial_dependency(link_args: true)
62elif libdrm.type_name() == 'internal'
63  fourcc_h = files('subprojects/libdrm/include/drm/drm_fourcc.h')
64else
65  fourcc_h = files(libdrm.get_pkgconfig_variable('includedir') / 'libdrm/drm_fourcc.h')
66endif
67
68if libpci.found()
69  add_project_arguments('-DHAVE_LIBPCI', language: 'c')
70endif
71
72if libdrm.type_name() == 'internal' or cc.has_function('drmModeGetFB2', dependencies: [libdrm])
73  add_project_arguments('-DHAVE_GETFB2', language: 'c')
74endif
75
76python3 = import('python').find_installation()
77
78tables_c = custom_target('tables_c',
79  output : 'tables.c',
80  command : [python3, files('fourcc.py'), fourcc_h, '@OUTPUT@'])
81
82executable('drm_info',
83  [files('main.c', 'modifiers.c', 'json.c', 'pretty.c'), tables_c],
84  include_directories: inc,
85  dependencies: [libdrm, libpci, jsonc],
86  install: true,
87)
88