build: check for udev and kmod using pkg-config
authorThierry Reding <treding@nvidia.com>
Tue, 7 Mar 2017 13:40:40 +0000 (14:40 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Wed, 8 Mar 2017 13:43:52 +0000 (14:43 +0100)
commitfc757abab9a3ec3e91bd6428ce79e9bd187e8d1a
tree504811f4fa4d62f86ff3a077bb949f657061199b
parentfb96e4f07e61a155213f6ff19633e71c9763bc17
build: check for udev and kmod using pkg-config

Using AC_CHECK_LIB is dangerous because it modifies the global LIBS
variable that will be passed to each linker invocation. If care is not
taken, each binary will end up depending on libraries listed in this
variable.

A typical way to avoid this is to save and restore the LIBS variable
before and after the AC_CHECK_LIB function, respectively. That's quite
tedious, though, and often a better solution is to detect the presence
as well as compile and linker flags with pkg-config. This can be done
using the PKG_CHECK_MODULES autoconf macro.

Both udev and kmod ship pkg-config files, so use PKG_CHECK_MODULES for
them.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
configure.ac
tests/unit/Makefile.am