By using the PKG_CHECK_MODULES
macro, Autoconf-generated configure
scripts can retrieve pkg-config data automatically. As an example, adding this line to your configure.ac
file:
PKG_CHECK_MODULES([DEPS], [glib-2.0 >= 2.24.1])
will cause the resulting configure
script to ensure that the installed version of glib-2.0 is greater than or equal to version 2.24.1 as well as append to variables DEPS_CFLAGS
and DEPS_LIBS
the output of pkg-config --cflags glib-2.0
and pkg-config --libs glib-2.0
, respectively. You then use the $(DEPS_CFLAGS)
and $(DEPS_LIBS)
variables in the _CFLAGS
and _LIBS
primaries:
bin_PROGRAMS = hello
hello_CFLAGS = $(DEPS_CFLAGS)
hello_SOURCES = hello.c
hello_LIBS = $(DEPS_LIBS)