Allow static building with meson
Added "static-build" option in the meson_options.txt. Setting it to "true" allows static building. Signed-off-by: Tero Tervala <tero.tervala@unikie.com> Message-Id: <20220629163557.932298-1-tero.tervala@unikie.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
fd9b8c96c7
commit
7ad60734b1
4 changed files with 28 additions and 5 deletions
|
@ -31,9 +31,15 @@ libfdt_a = static_library(
|
||||||
|
|
||||||
libfdt_inc = include_directories('.')
|
libfdt_inc = include_directories('.')
|
||||||
|
|
||||||
|
if static_build
|
||||||
|
link_with = libfdt_a
|
||||||
|
else
|
||||||
|
link_with = libfdt
|
||||||
|
endif
|
||||||
|
|
||||||
libfdt_dep = declare_dependency(
|
libfdt_dep = declare_dependency(
|
||||||
include_directories: libfdt_inc,
|
include_directories: libfdt_inc,
|
||||||
link_with: libfdt,
|
link_with: link_with,
|
||||||
)
|
)
|
||||||
|
|
||||||
install_headers(
|
install_headers(
|
||||||
|
|
14
meson.build
14
meson.build
|
@ -31,8 +31,16 @@ add_project_arguments(
|
||||||
language: 'c'
|
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'
|
yamltree = 'yamltree.c'
|
||||||
yaml = dependency('yaml-0.1', required: get_option('yaml'))
|
yaml = dependency('yaml-0.1', required: get_option('yaml'), static: static_build)
|
||||||
if not yaml.found()
|
if not yaml.found()
|
||||||
add_project_arguments('-DNO_YAML', language: 'c')
|
add_project_arguments('-DNO_YAML', language: 'c')
|
||||||
yamltree = []
|
yamltree = []
|
||||||
|
@ -85,6 +93,7 @@ if get_option('tools')
|
||||||
],
|
],
|
||||||
dependencies: util_dep,
|
dependencies: util_dep,
|
||||||
install: true,
|
install: true,
|
||||||
|
link_args: extra_link_args,
|
||||||
)
|
)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -105,10 +114,11 @@ if get_option('tools')
|
||||||
],
|
],
|
||||||
dependencies: [util_dep, yaml],
|
dependencies: [util_dep, yaml],
|
||||||
install: true,
|
install: true,
|
||||||
|
link_args: extra_link_args,
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach e: ['fdtdump', 'fdtget', 'fdtput', 'fdtoverlay']
|
foreach e: ['fdtdump', 'fdtget', 'fdtput', 'fdtoverlay']
|
||||||
executable(e, files(e + '.c'), dependencies: util_dep, install: true)
|
executable(e, files(e + '.c'), dependencies: util_dep, install: true, link_args: extra_link_args)
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
install_data(
|
install_data(
|
||||||
|
|
|
@ -8,3 +8,5 @@ option('valgrind', type: 'feature', value: 'auto',
|
||||||
description: 'Valgrind support')
|
description: 'Valgrind support')
|
||||||
option('python', type: 'feature', value: 'auto',
|
option('python', type: 'feature', value: 'auto',
|
||||||
description: 'Build pylibfdt Python library')
|
description: 'Build pylibfdt Python library')
|
||||||
|
option('static-build', type: 'boolean', value: false,
|
||||||
|
description: 'Build static binaries')
|
||||||
|
|
|
@ -96,15 +96,20 @@ tests += [
|
||||||
]
|
]
|
||||||
|
|
||||||
dl = cc.find_library('dl', required: false)
|
dl = cc.find_library('dl', required: false)
|
||||||
if dl.found()
|
if dl.found() and not static_build
|
||||||
tests += [
|
tests += [
|
||||||
'asm_tree_dump',
|
'asm_tree_dump',
|
||||||
'value-labels',
|
'value-labels',
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
test_deps = [testutil_dep, util_dep, libfdt_dep]
|
||||||
|
if not static_build
|
||||||
|
test_deps += [dl]
|
||||||
|
endif
|
||||||
|
|
||||||
foreach t: tests
|
foreach t: tests
|
||||||
executable(t, files(t + '.c'), dependencies: [testutil_dep, util_dep, libfdt_dep, dl])
|
executable(t, files(t + '.c'), dependencies: test_deps, link_args: extra_link_args)
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
run_tests = find_program('run_tests.sh')
|
run_tests = find_program('run_tests.sh')
|
||||||
|
|
Loading…
Reference in a new issue