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 <brandon.maier@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Brandon Maier 2025-03-06 20:30:47 -06:00 committed by David Gibson
parent 1ccd232709
commit dd1b3e532d
4 changed files with 9 additions and 29 deletions

View file

@ -98,22 +98,20 @@ tests += [
'truncated_string',
]
test_deps = [testutil_dep, util_dep, libfdt_dep]
dl = cc.find_library('dl', required: false)
if dl.found() and not static_build
if dl.found()
tests += [
'asm_tree_dump',
'value-labels',
]
endif
test_deps = [testutil_dep, util_dep, libfdt_dep]
if not static_build
test_deps += [dl]
endif
tests_exe = []
foreach t: tests
tests_exe += executable(t, files(t + '.c'), dependencies: test_deps, link_args: extra_link_args, build_by_default: false)
tests_exe += executable(t, files(t + '.c'), dependencies: test_deps, build_by_default: false)
endforeach
run_tests = find_program('run_tests.sh')