mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 08:17:40 -04:00
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:
parent
1ccd232709
commit
dd1b3e532d
4 changed files with 9 additions and 29 deletions
|
@ -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(
|
||||
|
|
16
meson.build
16
meson.build
|
@ -1,7 +1,7 @@
|
|||
project('dtc', 'c',
|
||||
version: files('VERSION.txt'),
|
||||
license: ['GPL2+', 'BSD-2'],
|
||||
default_options: 'werror=true',
|
||||
default_options: ['werror=true', 'default_library=both'],
|
||||
meson_version: '>=0.57.0'
|
||||
)
|
||||
|
||||
|
@ -27,16 +27,8 @@ add_project_arguments(
|
|||
language: 'c'
|
||||
)
|
||||
|
||||
if get_option('static-build')
|
||||
static_build = true
|
||||
extra_link_args = ['-static']
|
||||
else
|
||||
static_build = false
|
||||
extra_link_args = []
|
||||
endif
|
||||
|
||||
yamltree = 'yamltree.c'
|
||||
yaml = dependency('yaml-0.1', version: '>=0.2.3', required: get_option('yaml'), static: static_build)
|
||||
yaml = dependency('yaml-0.1', version: '>=0.2.3', required: get_option('yaml'))
|
||||
if not yaml.found()
|
||||
add_project_arguments('-DNO_YAML', language: 'c')
|
||||
yamltree = []
|
||||
|
@ -92,7 +84,6 @@ if get_option('tools')
|
|||
],
|
||||
dependencies: util_dep,
|
||||
install: true,
|
||||
link_args: extra_link_args,
|
||||
)
|
||||
endif
|
||||
|
||||
|
@ -113,11 +104,10 @@ if get_option('tools')
|
|||
],
|
||||
dependencies: [util_dep, yaml],
|
||||
install: true,
|
||||
link_args: extra_link_args,
|
||||
)
|
||||
|
||||
foreach e: ['fdtdump', 'fdtget', 'fdtput', 'fdtoverlay']
|
||||
dtc_tools += executable(e, files(e + '.c'), dependencies: util_dep, install: true, link_args: extra_link_args)
|
||||
dtc_tools += executable(e, files(e + '.c'), dependencies: util_dep, install: true)
|
||||
endforeach
|
||||
|
||||
install_data(
|
||||
|
|
|
@ -8,7 +8,5 @@ option('valgrind', type: 'feature', value: 'auto',
|
|||
description: 'Valgrind support')
|
||||
option('python', type: 'feature', value: 'auto',
|
||||
description: 'Build pylibfdt Python library')
|
||||
option('static-build', type: 'boolean', value: false,
|
||||
description: 'Build static binaries')
|
||||
option('tests', type: 'boolean', value: true,
|
||||
description: 'Build tests')
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue