configure.ac: Improve pkg-config related checks.

Until now, we checked for certain (optional) libraries via pkg-config and
the configure script would abort if any of them was not found, even
though they were optional. It was up to the user to then figure out which
combination of --disable-<drivername> switches were required for his
specific OS (and set of installed libs) to get a working configure run.

Only if the user already specified enough --disable-<drivername>
switches beforehand, so that all drivers which require a missing library
were disabled, would the configure run not check for that specific lib
(and would thus not fail).

With this change, we now always unconditionally check for all libs
(required and optional) via pkg-config. However, whether an (optional) lib
is found or not, configure will not abort. Instead, it'll just disable
all drivers which need a lib that cannot be found.

The user will no longer have to supply --disable-<drivername> parameters
in order to get a working build.
This commit is contained in:
Uwe Hermann 2013-04-08 14:46:13 +02:00
parent 3f98bf7017
commit aba6926245
1 changed files with 48 additions and 50 deletions

View File

@ -281,28 +281,36 @@ fi
# libsigrok.pc file. # libsigrok.pc file.
SR_PKGLIBS="" SR_PKGLIBS=""
# libglib-2.0 is always needed. # libglib-2.0 is always needed. Abort if it's not found.
# Note: glib-2.0 is part of the libsigrok API (hard pkg-config requirement). # Note: glib-2.0 is part of the libsigrok API (hard pkg-config requirement).
AM_PATH_GLIB_2_0([2.28.0], AM_PATH_GLIB_2_0([2.28.0],
[CFLAGS="$CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"]) [CFLAGS="$CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"])
# libusb-1.0 is only needed for some hardware drivers. # libzip is always needed. Abort if it's not found.
if test "x$LA_ASIX_SIGMA" != xno \ PKG_CHECK_MODULES([libzip], [libzip >= 0.8],
-o "x$LA_CHRONOVU_LA8" != xno \ [CFLAGS="$CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS";
-o "x$LA_FX2LAFW" != xno \ SR_PKGLIBS="$SR_PKGLIBS libzip"])
-o "x$HW_HANTEK_DSO" != xno \
-o "x$LA_ZEROPLUS_LOGIC_CUBE" != xno; then # libusb-1.0 is only needed for some hardware drivers. Disable the respective
# drivers if it is not found.
case "$build" in case "$build" in
*freebsd*) *freebsd*)
# FreeBSD comes with an "integrated" libusb-1.0-style USB API. # FreeBSD comes with an "integrated" libusb-1.0-style USB API.
# This means libusb-1.0 is always available, no need to check for it,
# and no need to (potentially) disable any drivers if it's not found.
AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1], AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
[Specifies whether we have a libusb.h header.]) [Specifies whether we have a libusb.h header.])
;; ;;
*) *)
PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.9], PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.9],
[CFLAGS="$CFLAGS $libusb_CFLAGS"; [have_libusb1_0="yes"; CFLAGS="$CFLAGS $libusb_CFLAGS";
LIBS="$LIBS $libusb_LIBS"; LIBS="$LIBS $libusb_LIBS";
SR_PKGLIBS="$SR_PKGLIBS libusb-1.0"]) SR_PKGLIBS="$SR_PKGLIBS libusb-1.0"],
[have_libusb1_0="no"; LA_FX2LAFW="no"; HW_HANTEK_DSO="no";
HW_LASCAR_EL_USB="no"; HW_NEXUS_OSCIPRIME="no";
HW_UNI_T_DMM="no"; HW_VICTOR_DMM="no";
LA_ZEROPLUS_LOGIC_CUBE="no"])
# Define HAVE_LIBUSB_1_0 in config.h if we found libusb-1.0. # Define HAVE_LIBUSB_1_0 in config.h if we found libusb-1.0.
if test "x$libusb_CFLAGS" != "x"; then if test "x$libusb_CFLAGS" != "x"; then
AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1], AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
@ -310,37 +318,27 @@ if test "x$LA_ASIX_SIGMA" != xno \
fi fi
;; ;;
esac esac
fi
# libzip is always needed. # libftdi is only needed for some hardware drivers. Disable them if not found.
PKG_CHECK_MODULES([libzip], [libzip >= 0.8],
[CFLAGS="$CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS";
SR_PKGLIBS="$SR_PKGLIBS libzip"])
# libftdi is only needed for some hardware drivers.
if test "x$LA_ASIX_SIGMA" != xno \
-o "x$LA_CHRONOVU_LA8" != xno; then
PKG_CHECK_MODULES([libftdi], [libftdi >= 0.16], PKG_CHECK_MODULES([libftdi], [libftdi >= 0.16],
[CFLAGS="$CFLAGS $libftdi_CFLAGS"; [CFLAGS="$CFLAGS $libftdi_CFLAGS";
LIBS="$LIBS $libftdi_LIBS"; LIBS="$LIBS $libftdi_LIBS";
SR_PKGLIBS="$SR_PKGLIBS libftdi"]) SR_PKGLIBS="$SR_PKGLIBS libftdi"],
fi [LA_ASIX_SIGMA="no"; LA_CHRONOVU_LA8="no"])
# libudev is only needed for some hardware drivers. # libudev is only needed for some hardware drivers. Disable them if not found.
if test "x$LA_LINK_MSO19" != xno; then
PKG_CHECK_MODULES([libudev], [libudev >= 151], PKG_CHECK_MODULES([libudev], [libudev >= 151],
[CFLAGS="$CFLAGS $libudev_CFLAGS"; LIBS="$LIBS $libudev_LIBS"; [CFLAGS="$CFLAGS $libudev_CFLAGS"; LIBS="$LIBS $libudev_LIBS";
SR_PKGLIBS="$SR_PKGLIBS libudev"]) SR_PKGLIBS="$SR_PKGLIBS libudev"],
fi [LA_LINK_MSO19="no"])
# ALSA is only needed for some hardware drivers. # ALSA is only needed for some hardware drivers. Disable them if not found.
if test "x$HW_ALSA" != xno; then
PKG_CHECK_MODULES([alsa], [alsa >= 1.0], PKG_CHECK_MODULES([alsa], [alsa >= 1.0],
[CFLAGS="$CFLAGS $alsa_CFLAGS"; LIBS="$LIBS $alsa_LIBS"; [CFLAGS="$CFLAGS $alsa_CFLAGS"; LIBS="$LIBS $alsa_LIBS";
SR_PKGLIBS="$SR_PKGLIBS alsa"]) SR_PKGLIBS="$SR_PKGLIBS alsa"],
fi [HW_ALSA="no"])
# The Check unit testing framework is optional. # The Check unit testing framework is optional. Disable if not found.
PKG_CHECK_MODULES([check], [check >= 0.9.4], PKG_CHECK_MODULES([check], [check >= 0.9.4],
[have_check="yes"; CFLAGS="$CFLAGS $check_CFLAGS"; [have_check="yes"; CFLAGS="$CFLAGS $check_CFLAGS";
LIBS="$LIBS $check_LIBS"], [have_check="no"]) LIBS="$LIBS $check_LIBS"], [have_check="no"])
@ -443,7 +441,7 @@ echo "Detected libraries:"
echo echo
# Note: This only works for libs with pkg-config integration. # Note: This only works for libs with pkg-config integration.
for lib in "glib-2.0" "libusb-1.0" "libzip" "libftdi" "libudev" "alsa" "check"; do for lib in "glib-2.0" "libzip" "libusb-1.0" "libftdi" "libudev" "alsa" "check"; do
if `$PKG_CONFIG --exists $lib`; then if `$PKG_CONFIG --exists $lib`; then
ver=`$PKG_CONFIG --modversion $lib` ver=`$PKG_CONFIG --modversion $lib`
answer="yes ($ver)" answer="yes ($ver)"