我做了類似的事情: 的configure.ac:
AC_DEFUN([CHECK_MYSQL_LIB],
[
AC_CHECK_PROGS(
MYSQL_CONFIG,
mysql_config
)
#In case it fails to find pthread then exit configure
if test "x${MYSQL_CONFIG}" != xmysql_config; then
echo "------------------------------------------"
echo " The mysql library and header file is "
echo " required to build this project. Stopping "
echo " Check 'config.log' for more information. "
echo "------------------------------------------"
(exit 1); exit 1;
else
MYSQL_CONFIG_CFLAGS=`$MYSQL_CONFIG --cflags`
MYSQL_CONFIG_CPPFLAGS=`$MYSQL_CONFIG --include`
MYSQL_CONFIG_LIBS=`$MYSQL_CONFIG --libs`
AC_SUBST([MYSQL_CONFIG_CFLAGS])
AC_SUBST([MYSQL_CONFIG_CPPFLAGS])
AC_SUBST([MYSQL_CONFIG_LIBS])
fi
])
而在Makefile.am:
db_CPPFLAGS=$(MYSQL_CONFIG_CPPFLAGS)
db_LDFLAGS=$(MYSQL_CONFIG_LIBS)
注意,最好在LDFLAGS,而不是添加LDADD。