Using the PKG_CHECK_MODULES macro, configure scripts created by Autoconf can automatically extract pkg-config data. For example, adding this line to your configure.ac file:
PKG_CHECK_MODULES([DEPS], [glib-2.0 >= 2.24.1])
will produce the configure script result to verify that the installed version of glib-2.0 is greater than or equal to version 2.24.1, and also add the output pkg-config --cflags glib-2.0 and pkg-config --libs glib-2.0 to the variables DEPS_CFLAGS and pkg-config --libs glib-2.0 respectively. Then you use the variables $(DEPS_CFLAGS) and $(DEPS_LIBS) in the primary elements _CFLAGS and _LDADD :
bin_PROGRAMS = hello hello_CFLAGS = $(DEPS_CFLAGS) hello_SOURCES = hello.c hello_LDADD = $(DEPS_LIBS)
Daniel Trebbien
source share