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 34if get_option('static-build') 35 static_build = true 36 extra_link_args = ['-static'] 37else 38 static_build = false 39 extra_link_args = [] 40endif 41 42yamltree = 'yamltree.c' 43yaml = dependency('yaml-0.1', required: get_option('yaml'), static: static_build) 44if not yaml.found() 45 add_project_arguments('-DNO_YAML', language: 'c') 46 yamltree = [] 47endif 48 49valgrind = dependency('valgrind', required: get_option('valgrind')) 50if not valgrind.found() 51 add_project_arguments('-DNO_VALGRIND', language: 'c') 52endif 53 54py = import('python') 55py = py.find_installation(required: get_option('python')) 56swig = find_program('swig', required: get_option('python')) 57 58version_gen_h = vcs_tag( 59 input: 'version_gen.h.in', 60 output: 'version_gen.h', 61) 62 63subdir('libfdt') 64 65if get_option('tools') 66 flex = find_program('flex', required: true) 67 bison = find_program('bison', required: true) 68 69 util_dep = declare_dependency( 70 sources: ['util.c', version_gen_h], 71 include_directories: '.', 72 dependencies: libfdt_dep 73 ) 74 75 lgen = generator( 76 flex, 77 output: '@[email protected]', 78 arguments: ['-o', '@OUTPUT@', '@INPUT@'], 79 ) 80 81 pgen = generator( 82 bison, 83 output: ['@[email protected]', '@[email protected]'], 84 arguments: ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'], 85 ) 86 87 if cc.check_header('fnmatch.h') 88 executable( 89 'convert-dtsv0', 90 [ 91 lgen.process('convert-dtsv0-lexer.l'), 92 'srcpos.c', 93 ], 94 dependencies: util_dep, 95 install: true, 96 link_args: extra_link_args, 97 ) 98 endif 99 100 executable( 101 'dtc', 102 [ 103 lgen.process('dtc-lexer.l'), 104 pgen.process('dtc-parser.y'), 105 'checks.c', 106 'data.c', 107 'dtc.c', 108 'flattree.c', 109 'fstree.c', 110 'livetree.c', 111 'srcpos.c', 112 'treesource.c', 113 yamltree, 114 ], 115 dependencies: [util_dep, yaml], 116 install: true, 117 link_args: extra_link_args, 118 ) 119 120 foreach e: ['fdtdump', 'fdtget', 'fdtput', 'fdtoverlay'] 121 executable(e, files(e + '.c'), dependencies: util_dep, install: true, link_args: extra_link_args) 122 endforeach 123 124 install_data( 125 'dtdiff', 126 install_dir: get_option('prefix') / get_option('bindir'), 127 install_mode: 'rwxr-xr-x', 128 ) 129endif 130 131if not meson.is_cross_build() 132 if py.found() and swig.found() 133 subdir('pylibfdt') 134 endif 135 136 if get_option('tools') 137 subdir('tests') 138 endif 139endif 140