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,66 +281,64 @@ 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 \
-o "x$LA_CHRONOVU_LA8" != xno \
-o "x$LA_FX2LAFW" != xno \
-o "x$HW_HANTEK_DSO" != xno \
-o "x$LA_ZEROPLUS_LOGIC_CUBE" != xno; then
case "$build" in
*freebsd*)
# FreeBSD comes with an "integrated" libusb-1.0-style USB API.
AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
[Specifies whether we have a libusb.h header.])
;;
*)
PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.9],
[CFLAGS="$CFLAGS $libusb_CFLAGS";
LIBS="$LIBS $libusb_LIBS";
SR_PKGLIBS="$SR_PKGLIBS libusb-1.0"])
# Define HAVE_LIBUSB_1_0 in config.h if we found libusb-1.0.
if test "x$libusb_CFLAGS" != "x"; then
AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
[Specifies whether we have a libusb.h header.])
fi
;;
esac
fi
# libzip is always needed.
PKG_CHECK_MODULES([libzip], [libzip >= 0.8], PKG_CHECK_MODULES([libzip], [libzip >= 0.8],
[CFLAGS="$CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS"; [CFLAGS="$CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS";
SR_PKGLIBS="$SR_PKGLIBS libzip"]) SR_PKGLIBS="$SR_PKGLIBS libzip"])
# libftdi is only needed for some hardware drivers. # libusb-1.0 is only needed for some hardware drivers. Disable the respective
if test "x$LA_ASIX_SIGMA" != xno \ # drivers if it is not found.
-o "x$LA_CHRONOVU_LA8" != xno; then case "$build" in
PKG_CHECK_MODULES([libftdi], [libftdi >= 0.16], *freebsd*)
[CFLAGS="$CFLAGS $libftdi_CFLAGS"; # FreeBSD comes with an "integrated" libusb-1.0-style USB API.
LIBS="$LIBS $libftdi_LIBS"; # This means libusb-1.0 is always available, no need to check for it,
SR_PKGLIBS="$SR_PKGLIBS libftdi"]) # and no need to (potentially) disable any drivers if it's not found.
fi AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
[Specifies whether we have a libusb.h header.])
;;
*)
PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.9],
[have_libusb1_0="yes"; CFLAGS="$CFLAGS $libusb_CFLAGS";
LIBS="$LIBS $libusb_LIBS";
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"])
# libudev is only needed for some hardware drivers. # Define HAVE_LIBUSB_1_0 in config.h if we found libusb-1.0.
if test "x$LA_LINK_MSO19" != xno; then if test "x$libusb_CFLAGS" != "x"; then
PKG_CHECK_MODULES([libudev], [libudev >= 151], AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
[CFLAGS="$CFLAGS $libudev_CFLAGS"; LIBS="$LIBS $libudev_LIBS"; [Specifies whether we have a libusb.h header.])
SR_PKGLIBS="$SR_PKGLIBS libudev"]) fi
fi ;;
esac
# ALSA is only needed for some hardware drivers. # libftdi is only needed for some hardware drivers. Disable them if not found.
if test "x$HW_ALSA" != xno; then PKG_CHECK_MODULES([libftdi], [libftdi >= 0.16],
PKG_CHECK_MODULES([alsa], [alsa >= 1.0], [CFLAGS="$CFLAGS $libftdi_CFLAGS";
[CFLAGS="$CFLAGS $alsa_CFLAGS"; LIBS="$LIBS $alsa_LIBS"; LIBS="$LIBS $libftdi_LIBS";
SR_PKGLIBS="$SR_PKGLIBS alsa"]) SR_PKGLIBS="$SR_PKGLIBS libftdi"],
fi [LA_ASIX_SIGMA="no"; LA_CHRONOVU_LA8="no"])
# The Check unit testing framework is optional. # libudev is only needed for some hardware drivers. Disable them if not found.
PKG_CHECK_MODULES([libudev], [libudev >= 151],
[CFLAGS="$CFLAGS $libudev_CFLAGS"; LIBS="$LIBS $libudev_LIBS";
SR_PKGLIBS="$SR_PKGLIBS libudev"],
[LA_LINK_MSO19="no"])
# ALSA is only needed for some hardware drivers. Disable them if not found.
PKG_CHECK_MODULES([alsa], [alsa >= 1.0],
[CFLAGS="$CFLAGS $alsa_CFLAGS"; LIBS="$LIBS $alsa_LIBS";
SR_PKGLIBS="$SR_PKGLIBS alsa"],
[HW_ALSA="no"])
# 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)"