Skip to content

meson: Add build-lsfd option and make rt dependency optional #2941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -729,22 +729,27 @@ if not cc.has_function('socket')
endif
endif

lib_rt = cc.find_library('rt', required : false)
realtime_libs = []
have = cc.has_function('clock_gettime')
if not have
realtime_libs += cc.find_library('rt', required : true)
have = cc.has_function('clock_gettime',
dependencies : realtime_libs)
if lib_rt.found()
realtime_libs += lib_rt
have = cc.has_function('clock_gettime',
dependencies : realtime_libs)
endif
endif
conf.set('HAVE_CLOCK_GETTIME', have ? 1 : false)

thread_libs = dependency('threads')

have = cc.has_function('timer_create')
if not have
realtime_libs = [cc.find_library('rt', required : true)]
have = cc.has_function('timer_create',
dependencies : realtime_libs)
if lib_rt.found()
realtime_libs = [lib_rt]
have = cc.has_function('timer_create',
dependencies : realtime_libs)
endif
if not have
realtime_libs += thread_libs
have = cc.has_function('timer_create',
Expand Down Expand Up @@ -2708,16 +2713,18 @@ endif
mq_libs = []
mq_libs += cc.find_library('rt', required : true)

opt = not get_option('build-lsfd').require(lib_rt.found()).disabled()
exe = executable(
'lsfd',
lsfd_sources,
include_directories : includes,
link_with : [lib_common,
lib_smartcols],
dependencies : mq_libs,
dependencies : [lib_rt],
install_dir : usrbin_exec_dir,
install : true)
if not is_disabler(exe)
install : opt,
build_by_default : opt)
if opt and not is_disabler(exe)
exes += exe
manadocs += ['misc-utils/lsfd.1.adoc']
endif
Expand Down Expand Up @@ -3493,14 +3500,14 @@ exe = executable(
build_by_default: program_tests)
exes += exe

if LINUX
if LINUX and lib_rt.found()
exe = executable(
'test_mkfds',
'tests/helpers/test_mkfds.c',
'tests/helpers/test_mkfds.h',
'tests/helpers/test_mkfds_ppoll.c',
include_directories : includes,
dependencies : mq_libs,
dependencies : [lib_rt],
build_by_default: program_tests)
exes += exe
endif
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ option('build-cal', type : 'feature',
description : 'build cal')
option('build-logger', type : 'feature',
description : 'build logger')
option('build-lsfd', type : 'feature',
description : 'build lsfd')
option('build-switch_root', type : 'feature',
description : 'switch_root')
option('build-pivot_root', type : 'feature',
Expand Down