build: look for libqrtr-glib with pkg-config

The WITH_QRTR symbol in config.h will let us know both if libqrtr-glib
is found and if libqmi-glib is compiled with QRTR support (as per the
exposed "qmi_qrtr_supported" variable in pkg-config).
This commit is contained in:
Aleksander Morgado
2021-01-22 14:24:14 +01:00
parent da24b7d450
commit 866c1d4ab6
2 changed files with 42 additions and 0 deletions

View File

@@ -421,6 +421,42 @@ case $with_qmi in
;;
esac
dnl-----------------------------------------------------------------------------
dnl QRTR support (both as libqrtr-glib and libqmi-glib apis)
dnl
LIBQRTR_VERSION=1.0.0
PKG_CHECK_MODULES(QRTR, [qrtr-glib >= $LIBQRTR_VERSION],[have_qrtr=yes],[have_qrtr=no])
qmi_qrtr_supported=$($PKG_CONFIG --variable=qmi_qrtr_supported qmi-glib)
AC_ARG_WITH(qrtr, AS_HELP_STRING([--without-qrtr], [Build without QRTR support]), [], [with_qrtr=auto])
if test "x$with_qrtr" = "xauto"; then
if test "x$qmi_qrtr_supported" = "x1" && test "x$with_qmi" = "xyes" && test "x$have_qrtr" = "xyes"; then
with_qrtr=yes
else
with_qrtr=no
fi
fi
case $with_qrtr in
yes)
if test "x$with_qmi" = "xno"; then
AC_MSG_ERROR([QRTR support requires QMI enabled. Configure using --with-qmi, or otherwise configure using --without-qrtr to disable QRTR support.])
elif test "x$have_qrtr" = "xno"; then
AC_MSG_ERROR([Couldn't find libqrtr-glib >= $LIBQRTR_VERSION. Install it, or otherwise configure using --without-qrtr to disable QRTR support.])
elif test "x$qmi_qrtr_supported" != "x1"; then
AC_MSG_ERROR([Couldn't find QRTR support in libqmi-glib. Install it, or otherwise configure using --without-qrtr to disable QRTR support.])
else
AC_DEFINE(WITH_QRTR, 1, [Define if you want QRTR support])
AC_SUBST(QRTR_CFLAGS)
AC_SUBST(QRTR_LIBS)
fi
;;
*)
with_qrtr=no
;;
esac
AM_CONDITIONAL(WITH_QRTR, test "x$with_qrtr" = "xyes")
dnl-----------------------------------------------------------------------------
dnl Distribution version string
dnl
@@ -592,6 +628,7 @@ echo "
policykit: ${with_polkit}
mbim: ${with_mbim}
qmi: ${with_qmi}
qrtr: ${with_qrtr}
systemd suspend/resume: ${with_systemd_suspend_resume}
systemd journal: ${with_systemd_journal}
at command via dbus: ${with_at_command_via_dbus}

View File

@@ -33,6 +33,11 @@ AM_LDFLAGS = \
$(GUDEV_LIBS) \
$(NULL)
if WITH_QRTR
AM_CFLAGS += $(QRTR_CFLAGS)
AM_LDFLAGS += $(QRTR_LIBS)
endif
if WITH_QMI
AM_CFLAGS += $(QMI_CFLAGS)
AM_LDFLAGS += $(QMI_LIBS)