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

@ -26,7 +26,7 @@ else
endif
link_args += version_script
libfdt = both_libraries(
libfdt = library(
'fdt', sources,
version: meson.project_version(),
link_args: link_args,
@ -34,17 +34,11 @@ libfdt = both_libraries(
install: true,
)
if static_build
link_with = libfdt.get_static_lib()
else
link_with = libfdt.get_shared_lib()
endif
libfdt_inc = include_directories('.')
libfdt_dep = declare_dependency(
include_directories: libfdt_inc,
link_with: link_with,
link_with: libfdt,
)
install_headers(