My first autotools project, might be something simple and dumb: it's creating a makefile that can't find glib and other 3rd party libraries. (Running Ubuntu Linux, compiling a C static library if that matters.)
Configure.ac includes these lines:
PKG_CHECK_MODULES([libglib], [glib-2.0 >= 2.28])
PKG_CHECK_MODULES([libobject], [gobject-2.0 >= 2.28])
PKG_CHECK_MODULES([libuuid], [uuid])
Makefile.am is as follows
lib_LIBRARIES=libblah.a
libblah_a_SOURCES=blah.c util.c
libblah_a_CPPFLAGS=$(libglib_CFLAGS) $(libobject_CFLAGS) $(libuuid_CFLAGS)
libblah_a_LIBADD=$(libglib_LIBS) $(libobject_LIBS) $(libuuid_LIBS)
Running autoreconf --install generates Makefile.in with this:
libglib_CFLAGS = @libglib_CFLAGS@
libglib_LIBS = @libglib_LIBS@
libobject_CFLAGS = @libobject_CFLAGS@
libobject_LIBS = @libobject_LIBS@
libuuid_CFLAGS = @libuuid_CFLAGS@
libuuid_LIBS = @libuuid_LIBS@
Looks good! Except then the configure script claims it found these libraries yet spits out a Makefile that converts the above line into this uselessness:
libglib_CFLAGS =
libglib_LIBS =
libobject_CFLAGS =
libobject_LIBS =
libuuid_CFLAGS =
libuuid_LIBS =
Help!
Edit: Here is the full configure.ac file:
AC_INIT([amblah], [1.0], [[email protected]])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
Makefile
libblah/Makefile
tests/Makefile
])
AC_OUTPUT
AC_PROG_RANLIB
PKG_PROG_PKG_CONFIG(0.26)
PKG_CHECK_MODULES([libglib], [glib-2.0 >= 2.28])
PKG_CHECK_MODULES([libobject], [gobject-2.0 >= 2.28])
PKG_CHECK_MODULES([libuuid], [uuid])
pkg-config
directly? – William PursellPKG_CONFIG=true
. (Note that this is somewhat tongue-in-cheek: PKG_CONFIG=true effectively disables PKG_CHECK_MODULES and requires the user to assign LDFLAGS and CPPFLAGS correctly.) – William PursellAC_SUBST(XXX_CFLAGS)
andAC_SUBST(XXX_LIBS)
for those libraries? – Etan Reisnerpkg-config
detects the libraries. I was using it with my handcrafted Makefile before attempting the migration to autotools. Example,pkg-config --libs glib-2.0
gives-lglib-2.0
. As for PKG_CONFIG, I'm not explicitly setting it anywhere. A grep of the files shows this in config.log:PKG_CONFIG='/usr/bin/pkg-config'
. – David M