Skip to content

Commit dd1b3e5

Browse files
blmaierdgibson
authored andcommitted
meson: support building libfdt without static library
Some packaging systems like NixOS don't support compiling static libraries. However libfdt's meson.build uses `both_library()` which forces the build to always compile shared and static libraries. Removing `both_library()` will make packaging easier. libfdt uses `both_libraries()` to support the 'static-build' option. But we do not need the 'static-build' option as Meson can natively build static using > meson setup builddir/ -Dc_link_args='-static' --prefer-static --default-library=static So drop 'static-build' and then replace `both_libraries()` with `library()`. Signed-off-by: Brandon Maier <[email protected]> Signed-off-by: David Gibson <[email protected]>
1 parent 1ccd232 commit dd1b3e5

File tree

4 files changed

+9
-29
lines changed

4 files changed

+9
-29
lines changed

libfdt/meson.build

+2-8
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,19 @@ else
2626
endif
2727

2828
link_args += version_script
29-
libfdt = both_libraries(
29+
libfdt = library(
3030
'fdt', sources,
3131
version: meson.project_version(),
3232
link_args: link_args,
3333
link_depends: 'version.lds',
3434
install: true,
3535
)
3636

37-
if static_build
38-
link_with = libfdt.get_static_lib()
39-
else
40-
link_with = libfdt.get_shared_lib()
41-
endif
42-
4337
libfdt_inc = include_directories('.')
4438

4539
libfdt_dep = declare_dependency(
4640
include_directories: libfdt_inc,
47-
link_with: link_with,
41+
link_with: libfdt,
4842
)
4943

5044
install_headers(

meson.build

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project('dtc', 'c',
22
version: files('VERSION.txt'),
33
license: ['GPL2+', 'BSD-2'],
4-
default_options: 'werror=true',
4+
default_options: ['werror=true', 'default_library=both'],
55
meson_version: '>=0.57.0'
66
)
77

@@ -27,16 +27,8 @@ add_project_arguments(
2727
language: 'c'
2828
)
2929

30-
if get_option('static-build')
31-
static_build = true
32-
extra_link_args = ['-static']
33-
else
34-
static_build = false
35-
extra_link_args = []
36-
endif
37-
3830
yamltree = 'yamltree.c'
39-
yaml = dependency('yaml-0.1', version: '>=0.2.3', required: get_option('yaml'), static: static_build)
31+
yaml = dependency('yaml-0.1', version: '>=0.2.3', required: get_option('yaml'))
4032
if not yaml.found()
4133
add_project_arguments('-DNO_YAML', language: 'c')
4234
yamltree = []
@@ -92,7 +84,6 @@ if get_option('tools')
9284
],
9385
dependencies: util_dep,
9486
install: true,
95-
link_args: extra_link_args,
9687
)
9788
endif
9889

@@ -113,11 +104,10 @@ if get_option('tools')
113104
],
114105
dependencies: [util_dep, yaml],
115106
install: true,
116-
link_args: extra_link_args,
117107
)
118108

119109
foreach e: ['fdtdump', 'fdtget', 'fdtput', 'fdtoverlay']
120-
dtc_tools += executable(e, files(e + '.c'), dependencies: util_dep, install: true, link_args: extra_link_args)
110+
dtc_tools += executable(e, files(e + '.c'), dependencies: util_dep, install: true)
121111
endforeach
122112

123113
install_data(

meson_options.txt

-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,5 @@ option('valgrind', type: 'feature', value: 'auto',
88
description: 'Valgrind support')
99
option('python', type: 'feature', value: 'auto',
1010
description: 'Build pylibfdt Python library')
11-
option('static-build', type: 'boolean', value: false,
12-
description: 'Build static binaries')
1311
option('tests', type: 'boolean', value: true,
1412
description: 'Build tests')

tests/meson.build

+4-6
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,20 @@ tests += [
9898
'truncated_string',
9999
]
100100

101+
test_deps = [testutil_dep, util_dep, libfdt_dep]
102+
101103
dl = cc.find_library('dl', required: false)
102-
if dl.found() and not static_build
104+
if dl.found()
103105
tests += [
104106
'asm_tree_dump',
105107
'value-labels',
106108
]
107-
endif
108-
109-
test_deps = [testutil_dep, util_dep, libfdt_dep]
110-
if not static_build
111109
test_deps += [dl]
112110
endif
113111

114112
tests_exe = []
115113
foreach t: tests
116-
tests_exe += executable(t, files(t + '.c'), dependencies: test_deps, link_args: extra_link_args, build_by_default: false)
114+
tests_exe += executable(t, files(t + '.c'), dependencies: test_deps, build_by_default: false)
117115
endforeach
118116

119117
run_tests = find_program('run_tests.sh')

0 commit comments

Comments
 (0)