From: Alex Deiter Date: Thu, 30 Jun 2022 12:46:13 +0000 (+0000) Subject: EX-5477 build: link libjson-c directly to liblustreapi X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=f9255da4c2ef13b9ff15a486833af819e43248d1;p=fs%2Flustre-release.git EX-5477 build: link libjson-c directly to liblustreapi To avoid adding a liblustreapi linker dependency to libjson-c, which makes it harder to build applications using this library, link libjson-c directly to liblustreapi fir the few functions that it needs. - added configure check for yaml - added configure check for json - added json library to the Lustre liblustreapi - replaced hardcoded -lyaml with variable - replaced hardcoded -ljson-c with variable - removed redundant json-c links Test-Parameters: trivial Fixes: fbfd2d075534 ("EX-5176 pcc: use JSON string for trusted.pin xattr") Change-Id: I57b8abb5170b3e3a4d18782c5611929c7c2b7072 Signed-off-by: Alex Deiter Reviewed-on: https://review.whamcloud.com/47844 Reviewed-by: Jian Yu Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Andreas Dilger --- diff --git a/config/lustre-build.m4 b/config/lustre-build.m4 index 7f157e5..d46a6a3 100644 --- a/config/lustre-build.m4 +++ b/config/lustre-build.m4 @@ -128,6 +128,50 @@ AS_IF([test "x$with_libmount" = xyes], [ ]) # LB_LIBMOUNT # +# LB_LIBYAML +# +# Check whether build with libyaml for libnetconfig +# +AC_DEFUN([LB_LIBYAML], [ +AC_CHECK_HEADER([yaml.h], [ + AC_CHECK_LIB([yaml], [yaml_parser_parse], [ + LDLIBYAML="-lyaml" + AC_SUBST(LDLIBYAML) + with_libyaml="yes" + ],[with_libyaml="no"]) +], [with_libyaml="no"]) +AC_MSG_CHECKING([whether to build with libyaml]) +AS_IF([test "x$with_libyaml" = xyes], [ + AC_MSG_RESULT([yes]) +], [ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([libyaml development package is required]) +]) +]) # LB_LIBYAML + +# +# LB_LIBJSON +# +# Check whether build with libjson-c for liblustreapi +# +AC_DEFUN([LB_LIBJSON], [ +AC_CHECK_HEADER([json-c/json.h], [ + AC_CHECK_LIB([json-c], [json_object_get], [ + LDLIBJSON="-ljson-c" + AC_SUBST(LDLIBJSON) + with_libjson="yes" + ],[with_libjson="no"]) +], [with_libjson="no"]) +AC_MSG_CHECKING([whether to build with libjson-c]) +AS_IF([test "x$with_libjson" = xyes], [ + AC_MSG_RESULT([yes]) +], [ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([json-c development package is required]) +]) +]) # LB_LIBJSON + +# # LB_PATH_PUMOUNT # AC_DEFUN([LB_PATH_PUMOUNT], [ @@ -714,6 +758,8 @@ LIBCFS_CONFIG_CDEBUG LC_QUOTA LB_LIBMOUNT +LB_LIBYAML +LB_LIBJSON LB_PATH_SNMP LB_PATH_LUSTREIOKIT LB_PATH_PUMOUNT diff --git a/lnet/utils/lnetconfig/Makefile.am b/lnet/utils/lnetconfig/Makefile.am index 642ef2f..18b5f59 100644 --- a/lnet/utils/lnetconfig/Makefile.am +++ b/lnet/utils/lnetconfig/Makefile.am @@ -32,8 +32,8 @@ liblnetconfig_la_SOURCES = liblnetconfig.c liblnetconfig.h \ liblnetconfig_lnd.c liblnd.h cyaml.c cyaml.h liblnetconfig_la_CPPFLAGS = -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 \ -DLUSTRE_UTILS=1 -fPIC -liblnetconfig_la_LDFLAGS = -L$(top_builddir)/libcfs/libcfs -lyaml -lm \ - $(LIBREADLINE) -version-info 4:0:0 +liblnetconfig_la_LDFLAGS = -L$(top_builddir)/libcfs/libcfs -lm \ + $(LDLIBYAML) $(LIBREADLINE) -version-info 4:0:0 liblnetconfig_la_LIBADD = $(top_builddir)/libcfs/libcfs/libcfs.la EXTRA_DIST = diff --git a/lustre/tests/Makefile.am b/lustre/tests/Makefile.am index 48d4d5c..85c3192 100644 --- a/lustre/tests/Makefile.am +++ b/lustre/tests/Makefile.am @@ -102,7 +102,7 @@ nobase_test_SCRIPTS = $(nobase_noinst_SCRIPTS) test_DATA = $(noinst_DATA) nobase_test_DATA = $(nobase_noinst_DATA) -LIBLUSTREAPI = $(top_builddir)/lustre/utils/liblustreapi.la -ljson-c +LIBLUSTREAPI = $(top_builddir)/lustre/utils/liblustreapi.la badarea_io_CFLAGS=-Wno-stringop-overflow mmap_sanity_LDADD = $(LIBLUSTREAPI) $(PTHREAD_LIBS) diff --git a/lustre/tests/mpi/Makefile.am b/lustre/tests/mpi/Makefile.am index 5e28eb7..7cc95af 100644 --- a/lustre/tests/mpi/Makefile.am +++ b/lustre/tests/mpi/Makefile.am @@ -26,7 +26,7 @@ parallel_grouplock_SOURCES=parallel_grouplock.c lp_utils.c lp_utils.h rr_alloc_SOURCES=rr_alloc.c cascading_rw_SOURCES=cascading_rw.c lp_utils.c lp_utils.h -cascading_rw_LDADD=$(top_builddir)/lustre/utils/liblustreapi.la -ljson-c +cascading_rw_LDADD=$(top_builddir)/lustre/utils/liblustreapi.la mdsrate_SOURCES=mdsrate.c -mdsrate_LDADD=$(top_builddir)/lustre/utils/liblustreapi.la -ljson-c +mdsrate_LDADD=$(top_builddir)/lustre/utils/liblustreapi.la diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index bcde5a5..4201ca5 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -24237,7 +24237,7 @@ test_400a() { # LU-1606, was conf-sanity test_74 fi for prog in $LUSTRE_TESTS_API_DIR/*.c; do - $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi -ljson-c || + $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi || error "client api broken" done rm -f $out diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am index 9f378e9..abb3f3f 100644 --- a/lustre/utils/Makefile.am +++ b/lustre/utils/Makefile.am @@ -54,7 +54,7 @@ endif endif endif # UTILS -LIBLUSTREAPI = liblustreapi.la -ljson-c +LIBLUSTREAPI = liblustreapi.la lib_LIBRARIES = noinst_LIBRARIES = if LDISKFS_ENABLED @@ -69,7 +69,7 @@ lctl_SOURCES = portals.c debug.c obd.c lustre_cfg.c lctl.c obdctl.h if SERVER lctl_SOURCES += lustre_lfsck.c lsnapshot.c endif -lctl_LDADD := $(LIBLUSTREAPI) $(PTHREAD_LIBS) -lyaml +lctl_LDADD := $(LIBLUSTREAPI) $(PTHREAD_LIBS) $(LDLIBYAML) lctl_DEPENDENCIES := liblustreapi.la lfs_SOURCES = lfs.c lfs_project.c lfs_project.h @@ -109,7 +109,7 @@ liblustreapi_la_SOURCES = liblustreapi.c liblustreapi_hsm.c \ liblustreapi_heat.c liblustreapi_pcc.c \ liblustreapi_lseek.c libhsm_scanner.h \ libhsm_scanner.c -liblustreapi_la_LDFLAGS = $(LIBREADLINE) -version-info 1:0:0 \ +liblustreapi_la_LDFLAGS = $(LIBREADLINE) $(LDLIBJSON) -version-info 1:0:0 \ -Wl,--version-script=liblustreapi.map liblustreapi_la_LIBADD = $(top_builddir)/libcfs/libcfs/libcfs.la liblustreapi_la_LIBADD += $(top_builddir)/lnet/utils/lnetconfig/liblnetconfig.la diff --git a/lustre/utils/gss/Makefile.am b/lustre/utils/gss/Makefile.am index b9675df..cba6c4a 100644 --- a/lustre/utils/gss/Makefile.am +++ b/lustre/utils/gss/Makefile.am @@ -5,7 +5,7 @@ AM_CFLAGS := -fPIC \ -D_GNU_SOURCE sbin_PROGRAMS = l_idmap -LIBLUSTREAPI = $(top_builddir)/lustre/utils/liblustreapi.la -ljson-c +LIBLUSTREAPI = $(top_builddir)/lustre/utils/liblustreapi.la if GSS_KEYRING sbin_PROGRAMS += lsvcgssd lgss_keyring