• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1project('dtc', 'c',
2  version: '1.6.0',
3  license: ['GPL2+', 'BSD-2'],
4  default_options: 'werror=true',
5)
6
7cc = meson.get_compiler('c')
8
9add_project_arguments(
10  cc.get_supported_arguments([
11    '-Wpointer-arith',
12    '-Wcast-qual',
13    '-Wnested-externs',
14    '-Wstrict-prototypes',
15    '-Wmissing-prototypes',
16    '-Wredundant-decls',
17    '-Wshadow'
18  ]),
19  language: 'c'
20)
21
22if host_machine.system() == 'windows'
23  add_project_arguments(
24    '-D__USE_MINGW_ANSI_STDIO=1',
25    language: 'c'
26  )
27endif
28
29add_project_arguments(
30  '-DFDT_ASSUME_MASK=' + get_option('assume-mask').to_string(),
31  language: 'c'
32)
33
34yamltree = 'yamltree.c'
35yaml = dependency('yaml-0.1', required: get_option('yaml'))
36if not yaml.found()
37  add_project_arguments('-DNO_YAML', language: 'c')
38  yamltree = []
39endif
40
41valgrind = dependency('valgrind', required: get_option('valgrind'))
42if not valgrind.found()
43  add_project_arguments('-DNO_VALGRIND', language: 'c')
44endif
45
46py = import('python')
47py = py.find_installation(required: get_option('python'))
48swig = find_program('swig', required: get_option('python'))
49
50version_gen_h = vcs_tag(
51  input: 'version_gen.h.in',
52  output: 'version_gen.h',
53)
54
55subdir('libfdt')
56
57if get_option('tools')
58  flex = find_program('flex', required: true)
59  bison = find_program('bison', required: true)
60
61  util_dep = declare_dependency(
62    sources: ['util.c', version_gen_h],
63    include_directories: '.',
64    dependencies: libfdt_dep
65  )
66
67  lgen = generator(
68    flex,
69    output: '@PLAINNAME@.lex.c',
70    arguments: ['-o', '@OUTPUT@', '@INPUT@'],
71  )
72
73  pgen = generator(
74    bison,
75    output: ['@BASENAME@.tab.c', '@BASENAME@.tab.h'],
76    arguments: ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'],
77  )
78
79  if cc.check_header('fnmatch.h')
80    executable(
81      'convert-dtsv0',
82      [
83        lgen.process('convert-dtsv0-lexer.l'),
84        'srcpos.c',
85      ],
86      dependencies: util_dep,
87      install: true,
88    )
89  endif
90
91  executable(
92    'dtc',
93    [
94      lgen.process('dtc-lexer.l'),
95      pgen.process('dtc-parser.y'),
96      'checks.c',
97      'data.c',
98      'dtc.c',
99      'flattree.c',
100      'fstree.c',
101      'livetree.c',
102      'srcpos.c',
103      'treesource.c',
104      yamltree,
105    ],
106    dependencies: [util_dep, yaml],
107    install: true,
108  )
109
110  foreach e: ['fdtdump', 'fdtget', 'fdtput', 'fdtoverlay']
111    executable(e, files(e + '.c'), dependencies: util_dep, install: true)
112  endforeach
113
114  install_data(
115    'dtdiff',
116    install_dir: get_option('prefix') / get_option('bindir'),
117    install_mode: 'rwxr-xr-x',
118  )
119endif
120
121if not meson.is_cross_build()
122  if py.found() and swig.found()
123    subdir('pylibfdt')
124  endif
125
126  if get_option('tools')
127    subdir('tests')
128  endif
129endif
130