aboutsummaryrefslogtreecommitdiff
path: root/libfdt/meson.build
blob: e1bf0833990a960d8fa4f836c5867ea36b88666b (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
version_script = '-Wl,--version-script=@0@'.format(meson.current_source_dir() / 'version.lds')
if not cc.has_link_argument(version_script)
  version_script = []
endif

sources = files(
  'fdt.c',
  'fdt_addresses.c',
  'fdt_check.c',
  'fdt_empty_tree.c',
  'fdt_overlay.c',
  'fdt_ro.c',
  'fdt_rw.c',
  'fdt_strerror.c',
  'fdt_sw.c',
  'fdt_wip.c',
)

link_args = []
if cc.has_link_argument('-Wl,--no-undefined')
    link_args += '-Wl,--no-undefined'
else
    # -undefined error is the equivalent of --no-undefined for the macOS linker,
    # but -undefined would also be understood as a valid argument for GNU ld!
    link_args += cc.get_supported_link_arguments('-Wl,-undefined,error')
endif

link_args += version_script
libfdt = library(
  'fdt', sources,
  version: '1.6.0',
  link_args: link_args,
  link_depends: 'version.lds',
  install: true,
)

libfdt_a = static_library(
  'fdt', sources,
  install: true,
)

libfdt_inc = include_directories('.')

if static_build
  link_with = libfdt_a
else
  link_with = libfdt
endif

libfdt_dep = declare_dependency(
  include_directories: libfdt_inc,
  link_with: link_with,
)

install_headers(
  files(
    'fdt.h',
    'libfdt.h',
    'libfdt_env.h',
  )
)

pkgconfig = import('pkgconfig')

pkgconfig.generate(
  libraries: libfdt,
  version: meson.project_version(),
  filebase: 'libfdt',
  name: 'libfdt',
  description: 'Flat Device Tree manipulation',
)