Skip to content

Commit 82884ee

Browse files
djbwstellarhopper
authored andcommitted
cxl/monitor: Make libtracefs dependency optional
Build a stub version of 'cxl monitor' that reports that the facility was statically disabled at configure / build time. Provide the meson configuration line to correct the build. This is in response to the fact that some distros fail to ship libtracefs-devel even though they ship libtracefs (looking at you CentOS Stream 8). Signed-off-by: Dan Williams <[email protected]> Link: https://lore.kernel.org/r/167718414197.16926.10394415062829848410.stgit@dwillia2-xfh.jf.intel.com Reviewed-by: Dave Jiang <[email protected]> Reviewed-by: Ira Weiny <[email protected]> Signed-off-by: Vishal Verma <[email protected]>
1 parent cb4c8f9 commit 82884ee

File tree

6 files changed

+44
-17
lines changed

6 files changed

+44
-17
lines changed

config.h.meson

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
/* ndctl test support */
2020
#mesondefine ENABLE_TEST
2121

22+
/* cxl monitor support */
23+
#mesondefine ENABLE_LIBTRACEFS
24+
2225
/* Define to 1 if big-endian-arch */
2326
#mesondefine HAVE_BIG_ENDIAN
2427

cxl/builtin.h

+9
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,14 @@ int cmd_create_region(int argc, const char **argv, struct cxl_ctx *ctx);
2222
int cmd_enable_region(int argc, const char **argv, struct cxl_ctx *ctx);
2323
int cmd_disable_region(int argc, const char **argv, struct cxl_ctx *ctx);
2424
int cmd_destroy_region(int argc, const char **argv, struct cxl_ctx *ctx);
25+
#ifdef ENABLE_LIBTRACEFS
2526
int cmd_monitor(int argc, const char **argv, struct cxl_ctx *ctx);
27+
#else
28+
static inline int cmd_monitor(int argc, const char **argv, struct cxl_ctx *ctx)
29+
{
30+
fprintf(stderr,
31+
"cxl monitor: unavailable, rebuild with '-Dlibtracefs=enabled'\n");
32+
return EXIT_FAILURE;
33+
}
34+
#endif
2635
#endif /* _CXL_BUILTIN_H_ */

cxl/meson.build

+21-12
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,36 @@ cxl_src = [
77
'memdev.c',
88
'json.c',
99
'filter.c',
10-
'event_trace.c',
11-
'monitor.c',
1210
]
1311

1412
if get_option('systemd').enabled()
1513
install_data('cxl-monitor.service', install_dir : systemdunitdir)
1614
endif
1715

16+
deps = [
17+
cxl_dep,
18+
util_dep,
19+
uuid,
20+
kmod,
21+
json,
22+
versiondep,
23+
]
24+
25+
if get_option('libtracefs').enabled()
26+
cxl_src += [
27+
'event_trace.c',
28+
'monitor.c',
29+
]
30+
deps += [
31+
traceevent,
32+
tracefs,
33+
]
34+
endif
35+
1836
cxl_tool = executable('cxl',
1937
cxl_src,
2038
include_directories : root_inc,
21-
dependencies : [
22-
cxl_dep,
23-
util_dep,
24-
uuid,
25-
kmod,
26-
json,
27-
versiondep,
28-
traceevent,
29-
tracefs,
30-
],
39+
dependencies : deps,
3140
install : true,
3241
install_dir : rootbindir,
3342
)

meson.build

+5-2
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@ kmod = dependency('libkmod')
143143
libudev = dependency('libudev')
144144
uuid = dependency('uuid')
145145
json = dependency('json-c')
146-
traceevent = dependency('libtraceevent')
147-
tracefs = dependency('libtracefs')
146+
if get_option('libtracefs').enabled()
147+
traceevent = dependency('libtraceevent')
148+
tracefs = dependency('libtracefs')
149+
endif
148150

149151
if get_option('docs').enabled()
150152
if get_option('asciidoctor').enabled()
@@ -234,6 +236,7 @@ conf.set('ENABLE_TEST', get_option('test').enabled())
234236
conf.set('ENABLE_DESTRUCTIVE', get_option('destructive').enabled())
235237
conf.set('ENABLE_LOGGING', get_option('logging').enabled())
236238
conf.set('ENABLE_DEBUG', get_option('dbg').enabled())
239+
conf.set('ENABLE_LIBTRACEFS', get_option('libtracefs').enabled())
237240

238241
typeof_code = '''
239242
void func() {

meson_options.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ option('version-tag', type : 'string',
22
description : 'override the git version string')
33
option('docs', type : 'feature', value : 'enabled')
44
option('asciidoctor', type : 'feature', value : 'enabled')
5+
option('libtracefs', type : 'feature', value : 'enabled')
56
option('systemd', type : 'feature', value : 'enabled')
67
option('keyutils', type : 'feature', value : 'enabled',
78
description : 'enable nvdimm device passphrase management')

ndctl.spec.in

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ BuildRequires: autoconf
1313
%if 0%{?rhel} < 9
1414
BuildRequires: asciidoc
1515
%define asciidoctor -Dasciidoctor=disabled
16+
%define libtracefs -Dlibtracefs=disabled
1617
%else
1718
BuildRequires: rubygem-asciidoctor
19+
BuildRequires: libtraceevent-devel
20+
BuildRequires: libtracefs-devel
1821
%define asciidoctor -Dasciidoctor=enabled
22+
%define libtracefs -Dlibtracefs=enabled
1923
%endif
2024
BuildRequires: xmlto
2125
BuildRequires: automake
@@ -31,8 +35,6 @@ BuildRequires: keyutils-libs-devel
3135
BuildRequires: systemd-rpm-macros
3236
BuildRequires: iniparser-devel
3337
BuildRequires: meson
34-
BuildRequires: libtraceevent-devel
35-
BuildRequires: libtracefs-devel
3638

3739
%description
3840
Utility library for managing the "libnvdimm" subsystem. The "libnvdimm"
@@ -124,7 +126,7 @@ libcxl is a library for enumerating and communicating with CXL devices.
124126
%setup -q ndctl-%{version}
125127

126128
%build
127-
%meson %{?asciidoctor} -Dversion-tag=%{version}
129+
%meson %{?asciidoctor} %{?libtracefs} -Dversion-tag=%{version}
128130
%meson_build
129131

130132
%install

0 commit comments

Comments
 (0)