Skip to content

Commit 39da84f

Browse files
committed
meson: Add build-lsfd option and make rt dependency optional
A dependency on the rt library is unnecessarily required when checking for the clock_gettime and timer_create functions. This causes the build to fail if the rt library is not found. This should not fail the build as rt is only required for the checks. Additionally, the lsfd executable and some tests require rt. There is currently no option to toggle building lsfd. This PR makes it possible to build without the rt library. Function checks no longer require rt for the build. The function checks for the rt library only run when rt is available. This PR adds an option to allow building without lsfd. This makes it possible to build without the executable that requires rt. To not require rt for the test, a additional check has been added. The effected tests won't be built unless rt has been found. Signed-off-by: Jordan Williams <jordan@jwillikers.com> (cherry picked from commit 06b2705)
1 parent 5de7172 commit 39da84f

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

meson.build

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -732,19 +732,25 @@ endif
732732
realtime_libs = []
733733
have = cc.has_function('clock_gettime')
734734
if not have
735-
realtime_libs += cc.find_library('rt', required : true)
736-
have = cc.has_function('clock_gettime',
737-
dependencies : realtime_libs)
735+
lib_rt = cc.find_library('rt', required : false)
736+
if lib_rt.found()
737+
realtime_libs += lib_rt
738+
have = cc.has_function('clock_gettime',
739+
dependencies : realtime_libs)
740+
endif
738741
endif
739742
conf.set('HAVE_CLOCK_GETTIME', have ? 1 : false)
740743

741744
thread_libs = dependency('threads')
742745

743746
have = cc.has_function('timer_create')
744747
if not have
745-
realtime_libs = [cc.find_library('rt', required : true)]
746-
have = cc.has_function('timer_create',
747-
dependencies : realtime_libs)
748+
lib_rt = cc.find_library('rt', required : false)
749+
if lib_rt.found()
750+
realtime_libs = [lib_rt]
751+
have = cc.has_function('timer_create',
752+
dependencies : realtime_libs)
753+
endif
748754
if not have
749755
realtime_libs += thread_libs
750756
have = cc.has_function('timer_create',
@@ -2705,19 +2711,26 @@ if not is_disabler(exe)
27052711
bashcompletions += ['lsblk']
27062712
endif
27072713

2708-
mq_libs = []
2709-
mq_libs += cc.find_library('rt', required : true)
2714+
errnos_h = custom_target('errnos.h',
2715+
input : 'tools/all_errnos',
2716+
output : 'errnos.h',
2717+
command : ['tools/all_errnos', cc.cmd_array(), get_option('c_args')],
2718+
)
2719+
2720+
lib_rt = cc.find_library('rt', required : get_option('build-lsfd'))
27102721

2722+
opt = not get_option('build-lsfd').disabled()
27112723
exe = executable(
27122724
'lsfd',
27132725
lsfd_sources,
27142726
include_directories : includes,
27152727
link_with : [lib_common,
27162728
lib_smartcols],
2717-
dependencies : mq_libs,
2729+
dependencies : [lib_rt],
27182730
install_dir : usrbin_exec_dir,
2719-
install : true)
2720-
if not is_disabler(exe)
2731+
install : opt,
2732+
build_by_default : opt)
2733+
if opt and not is_disabler(exe)
27212734
exes += exe
27222735
manadocs += ['misc-utils/lsfd.1.adoc']
27232736
endif
@@ -3493,14 +3506,14 @@ exe = executable(
34933506
build_by_default: program_tests)
34943507
exes += exe
34953508

3496-
if LINUX
3509+
if LINUX and lib_rt.found()
34973510
exe = executable(
34983511
'test_mkfds',
34993512
'tests/helpers/test_mkfds.c',
35003513
'tests/helpers/test_mkfds.h',
35013514
'tests/helpers/test_mkfds_ppoll.c',
35023515
include_directories : includes,
3503-
dependencies : mq_libs,
3516+
dependencies : [lib_rt],
35043517
build_by_default: program_tests)
35053518
exes += exe
35063519
endif

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ option('build-cal', type : 'feature',
101101
description : 'build cal')
102102
option('build-logger', type : 'feature',
103103
description : 'build logger')
104+
option('build-lsfd', type : 'feature',
105+
description : 'build lsfd')
104106
option('build-switch_root', type : 'feature',
105107
description : 'switch_root')
106108
option('build-pivot_root', type : 'feature',

0 commit comments

Comments
 (0)