Skip to content

Commit 06b2705

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>
1 parent 3f4857f commit 06b2705

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

meson.build

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

740743
thread_libs = dependency('threads')
741744

742745
have = cc.has_function('timer_create')
743746
if not have
744-
realtime_libs = [cc.find_library('rt', required : true)]
745-
have = cc.has_function('timer_create',
746-
dependencies : realtime_libs)
747+
lib_rt = cc.find_library('rt', required : false)
748+
if lib_rt.found()
749+
realtime_libs = [lib_rt]
750+
have = cc.has_function('timer_create',
751+
dependencies : realtime_libs)
752+
endif
747753
if not have
748754
realtime_libs += thread_libs
749755
have = cc.has_function('timer_create',
@@ -2711,19 +2717,20 @@ errnos_h = custom_target('errnos.h',
27112717
command : ['tools/all_errnos', cc.cmd_array(), get_option('c_args')],
27122718
)
27132719

2714-
mq_libs = []
2715-
mq_libs += cc.find_library('rt', required : true)
2720+
lib_rt = cc.find_library('rt', required : get_option('build-lsfd'))
27162721

2722+
opt = not get_option('build-lsfd').disabled()
27172723
exe = executable(
27182724
'lsfd',
27192725
lsfd_sources, errnos_h,
27202726
include_directories : includes,
27212727
link_with : [lib_common,
27222728
lib_smartcols],
2723-
dependencies : mq_libs,
2729+
dependencies : [lib_rt],
27242730
install_dir : usrbin_exec_dir,
2725-
install : true)
2726-
if not is_disabler(exe)
2731+
install : opt,
2732+
build_by_default : opt)
2733+
if opt and not is_disabler(exe)
27272734
exes += exe
27282735
manadocs += ['misc-utils/lsfd.1.adoc']
27292736
endif
@@ -3499,14 +3506,14 @@ exe = executable(
34993506
build_by_default: program_tests)
35003507
exes += exe
35013508

3502-
if LINUX
3509+
if LINUX and lib_rt.found()
35033510
exe = executable(
35043511
'test_mkfds',
35053512
'tests/helpers/test_mkfds.c',
35063513
'tests/helpers/test_mkfds.h',
35073514
'tests/helpers/test_mkfds_ppoll.c',
35083515
include_directories : includes,
3509-
dependencies : mq_libs,
3516+
dependencies : [lib_rt],
35103517
build_by_default: program_tests)
35113518
exes += exe
35123519
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)