tools/configure: Introduce deps on json-c lib for libxl

To replace yajl.

Introduce XEN_JSON_LIBS variable, to be able to remove "-lyajl" later.

As a first step, the variable will have both or only -lyajl. Then
commit "configure: Use json-c by default, fallback to yajl" will make
a change to only have one or the other once the code is ready to build
with only json-c.

Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
This commit is contained in:
Anthony PERARD authored and Andrew Cooper committed 2025-10-06 12:28:43 +01:00
1 parent fd67ca4e58
commit bb3da1c885
6 files changed
+117 -6

No files matched your search

+1
View File
@@ -65,6 +65,7 @@ EXTFS_LIBS := @EXTFS_LIBS@
CURSES_LIBS := @CURSES_LIBS@
TINFO_LIBS := @TINFO_LIBS@
ARGP_LDFLAGS := @argp_ldflags@
XEN_JSON_LIBS := @YAJL_LIBS@ @libjsonc_LIBS@
FILE_OFFSET_BITS := @FILE_OFFSET_BITS@
+3
View File
@@ -27,6 +27,9 @@
/* Define to 1 if you have the `fdt' library (-lfdt). */
#undef HAVE_LIBFDT
/* Use library json-c */
#undef HAVE_LIBJSONC
/* Define to 1 if you have the `lzma' library (-llzma). */
#undef HAVE_LIBLZMA
+105 -2
View File
@@ -660,6 +660,9 @@ libnl
LIBNL3_LIBS
LIBNL3_CFLAGS
argp_ldflags
YAJL_LIBS
libjsonc_LIBS
libjsonc_CFLAGS
PTHREAD_LIBS
PTHREAD_LDFLAGS
PTHREAD_CFLAGS
@@ -882,6 +885,8 @@ pixman_CFLAGS
pixman_LIBS
libzstd_CFLAGS
libzstd_LIBS
libjsonc_CFLAGS
libjsonc_LIBS
LIBNL3_CFLAGS
LIBNL3_LIBS
SYSTEMD_SLEEP_DIR'
@@ -1633,6 +1638,10 @@ Some influential environment variables:
C compiler flags for libzstd, overriding pkg-config
libzstd_LIBS
linker flags for libzstd, overriding pkg-config
libjsonc_CFLAGS
C compiler flags for libjsonc, overriding pkg-config
libjsonc_LIBS
linker flags for libjsonc, overriding pkg-config
LIBNL3_CFLAGS
C compiler flags for LIBNL3, overriding pkg-config
LIBNL3_LIBS linker flags for LIBNL3, overriding pkg-config
@@ -9624,6 +9633,99 @@ printf "%s\n" "$ax_cv_pthread_flags" >&6; }
pkg_failed=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libjsonc" >&5
printf %s "checking for libjsonc... " >&6; }
if test -n "$libjsonc_CFLAGS"; then
pkg_cv_libjsonc_CFLAGS="$libjsonc_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"json-c\""; } >&5
($PKG_CONFIG --exists --print-errors "json-c") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_libjsonc_CFLAGS=`$PKG_CONFIG --cflags "json-c" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test -n "$libjsonc_LIBS"; then
pkg_cv_libjsonc_LIBS="$libjsonc_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"json-c\""; } >&5
($PKG_CONFIG --exists --print-errors "json-c") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_libjsonc_LIBS=`$PKG_CONFIG --libs "json-c" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test $pkg_failed = yes; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
libjsonc_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "json-c" 2>&1`
else
libjsonc_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "json-c" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$libjsonc_PKG_ERRORS" >&5
as_fn_error $? "Package requirements (json-c) were not met:
$libjsonc_PKG_ERRORS
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables libjsonc_CFLAGS
and libjsonc_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details." "$LINENO" 5
elif test $pkg_failed = untried; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
Alternatively, you may set the environment variables libjsonc_CFLAGS
and libjsonc_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
To get pkg-config, see <http://pkg-config.freedesktop.org/>.
See \`config.log' for more details" "$LINENO" 5; }
else
libjsonc_CFLAGS=$pkg_cv_libjsonc_CFLAGS
libjsonc_LIBS=$pkg_cv_libjsonc_LIBS
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
printf "%s\n" "#define HAVE_LIBJSONC 1" >>confdefs.h
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for yajl_alloc in -lyajl" >&5
printf %s "checking for yajl_alloc in -lyajl... " >&6; }
if test ${ac_cv_lib_yajl_yajl_alloc+y}
@@ -9661,9 +9763,10 @@ fi
printf "%s\n" "$ac_cv_lib_yajl_yajl_alloc" >&6; }
if test "x$ac_cv_lib_yajl_yajl_alloc" = xyes
then :
printf "%s\n" "#define HAVE_LIBYAJL 1" >>confdefs.h
YAJL_LIBS=-lyajl
LIBS="-lyajl $LIBS"
printf "%s\n" "#define HAVE_LIBYAJL 1" >>confdefs.h
else $as_nop
as_fn_error $? "Could not find yajl" "$LINENO" 5
+5 -1
View File
@@ -424,7 +424,11 @@ AC_SUBST([ZLIB_CFLAGS])
AC_SUBST([ZLIB_LIBS])
AX_CHECK_EXTFS
AX_CHECK_PTHREAD
AC_CHECK_LIB([yajl], [yajl_alloc], [],
PKG_CHECK_MODULES([libjsonc], [json-c],
[AC_DEFINE([HAVE_LIBJSONC], [1], [Use library json-c])])
AC_CHECK_LIB([yajl], [yajl_alloc],
[AC_SUBST([YAJL_LIBS],[-lyajl])
AC_DEFINE([HAVE_LIBYAJL],[1],[Define to 1 if you have the `yajl' library (-lyajl).])],
[AC_MSG_ERROR([Could not find yajl])])
AC_CHECK_LIB([z], [deflateCopy], [], [AC_MSG_ERROR([Could not find zlib])])
AC_CHECK_HEADER([argp.h], [
+2 -2
View File
@@ -166,7 +166,7 @@ LDLIBS-$(CONFIG_Linux) += -luuid
LDLIBS-$(CONFIG_Linux) += -lrt
LDLIBS-$(CONFIG_ARM) += -lfdt
LDLIBS-y += $(PTHREAD_LIBS)
LDLIBS-y += -lyajl
LDLIBS-y += $(XEN_JSON_LIBS)
LDLIBS += $(LDLIBS-y)
$(OBJS-y) $(PIC_OBJS) $(LIBXL_TEST_OBJS): CFLAGS += $(CFLAGS_LIBXL) -include $(XEN_ROOT)/tools/config.h
@@ -246,7 +246,7 @@ libxenlight_test.so: $(PIC_OBJS) $(LIBXL_TEST_OBJS)
$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS) $(APPEND_LDFLAGS)
test_%: test_%.o test_common.o libxenlight_test.so
$(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenlight)) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) -lyajl $(APPEND_LDFLAGS)
$(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenlight)) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) $(XEN_JSON_LIBS) $(APPEND_LDFLAGS)
libxl-save-helper: $(SAVE_HELPER_OBJS) libxenlight.so
$(CC) $(LDFLAGS) -o $@ $(SAVE_HELPER_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS)
+1 -1
View File
@@ -33,7 +33,7 @@ $(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs i
all: xl
xl: $(XL_OBJS)
$(CC) $(LDFLAGS) -o $@ $(XL_OBJS) $(LDLIBS_libxenutil) $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) -lyajl $(APPEND_LDFLAGS)
$(CC) $(LDFLAGS) -o $@ $(XL_OBJS) $(LDLIBS_libxenutil) $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(XEN_JSON_LIBS) $(APPEND_LDFLAGS)
.PHONY: install
install: all
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.