aboutsummaryrefslogtreecommitdiffstats
path: root/meson.build
blob: 086a9f2737b9b8d444ac9d4a9f920bfe9dc2c634 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
project('drm_info', 'c',
  version: '2.1.0',
  license: 'MIT',
  meson_version: '>=0.49.0',
  default_options: [
    'c_std=c11',
    'warning_level=2',
  ],
)

add_project_arguments('-D_POSIX_C_SOURCE=200809L', language: 'c')

jsonc = dependency('json-c', version: '>=0.13', fallback: ['json-c', 'json_c'])
libpci = dependency('libpci', required: get_option('libpci'))
libdrm = dependency('libdrm',
  fallback: ['libdrm', 'ext_libdrm'],
  default_options: [
    'libkms=false',
    'intel=false',
    'radeon=false',
    'amdgpu=false',
    'nouveau=false',
    'vmwgfx=false',
    'omap=false',
    'exynos=false',
    'freedreno=false',
    'tegra=false',
    'vc4=false',
    'etnaviv=false',
    'cairo-tests=false',
    'man-pages=false',
    'valgrind=false',
  ],
)

inc = []
# libdrm pretty consistently pulls in the linux userspace API headers.
# We want a new libdrm to get all of the #defines in those headers, but
# we don't actually need to link against a new version of libdrm itself.
#
# We need to make sure we don't use any new libdrm functions, but those
# are added very infrequently, so this is unlikely to be an issue.
if libdrm.version().version_compare('<2.4.99')
  if libdrm.type_name() == 'internal'
    error('libdrm subproject out of date. Run `meson subprojects update`.')
  endif

  msg = [
    'System libdrm version does not have latest Linux DRM headers.',
    'Attempting to use headers from meson subproject if present.',
    'If this fails, update your system libdrm or run `meson subprojects download`.',
  ]
  foreach s : msg
    warning(s)
  endforeach

  fourcc_h = files('subprojects/libdrm/include/drm/drm_fourcc.h')
  inc += include_directories('subprojects/libdrm/include/drm')
  libdrm = libdrm.partial_dependency(link_args: true)
elif libdrm.type_name() == 'internal'
  fourcc_h = files('subprojects/libdrm/include/drm/drm_fourcc.h')
else
  fourcc_h = files(libdrm.get_pkgconfig_variable('includedir') / 'libdrm/drm_fourcc.h')
endif

if libpci.found()
  add_project_arguments('-DHAVE_LIBPCI', language: 'c')
endif

python3 = import('python').find_installation()

tables_c = custom_target('tables_c',
  output : 'tables.c',
  command : [python3, files('fourcc.py'), fourcc_h, '@OUTPUT@'])

executable('drm_info',
  [files('main.c', 'json.c', 'pretty.c'), tables_c],
  include_directories: inc,
  dependencies: [libdrm, libpci, jsonc],
  install: true,
)