summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac51
-rw-r--r--tests/Makefile.am12
2 files changed, 60 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index c0a68622..b0ef2a37 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,8 +23,7 @@ ac_cv_c_const=yes
ac_cv_c_inline=yes
dnl Checks for libraries.
-AC_CHECK_LIB(ncursesw, initscr, ,
- [AC_MSG_ERROR([Can't find libncursesw -- please install libncursesw5-dev])])
+AC_CHECK_LIB(ncursesw, initscr, , [AC_MSG_ERROR([Can't find libncursesw -- please install libncursesw5-dev])])
AC_CHECK_LIB(apt-pkg, main, , [AC_MSG_ERROR([Can't find the APT libraries -- please install libapt-pkg-dev])])
AC_MSG_CHECKING([whether apt includes the automatic dependency removal patch (required)])
@@ -482,6 +481,54 @@ AC_SUBST(BOOST_UNIT_TEST_LIBS)
##### End Boost.Test check #####
+##### Check for Google Mock #####
+
+dnl Google Mock's developers do not support prebuilt libraries (e.g.,
+dnl they pay no attention to ABI compatibility) and as a result have
+dnl asked Debian not to ship prebuilt libraries. So, if we are
+dnl running on a system where gmock isn't available in $LIBDIR, we
+dnl guess that maybe there's source available that we can compile
+dnl during our own build process.
+
+AC_MSG_CHECKING([how to link gmock])
+
+BUILD_LOCAL_GMOCK=0
+
+OLD_LIBS="$LIBS"
+LIBS="$LIBS -lgmock"
+
+AC_LINK_IFELSE([AC_LANG_SOURCE([
+#include <gmock/gmock.h>
+
+int main(int argc, char **argv)
+{
+ return 0;
+}])],
+ [AC_MSG_RESULT([gmock is in in library path])]
+ ,
+ dnl Ok, check whether we can link it if we include the gmock
+ dnl source code. Note that it will require both pthreads and
+ dnl gtest; no way around that.
+ [LIBS="$OLD_LIBS -lpthread -lgtest"
+ OLD_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS -I/usr/src/gmock"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([
+#include <src/gmock-all.cc>
+
+int main(int argc, char **argv)
+{
+ return 0;
+}])],
+ [AC_MSG_RESULT([source is in /usr/src/gmock])
+ BUILD_LOCAL_GMOCK=1],
+ [AC_MSG_ERROR([Can't figure out where Google Mock lives; either install the google-mock package or place the library in the link path])])
+ CPPFLAGS="$OLD_CPPFLAGS"
+ LIBS="$OLD_LIBS"])
+
+AM_CONDITIONAL([BUILD_LOCAL_GMOCK], [test x$BUILD_LOCAL_GMOCK = x1])
+
+##### End Google Mock check #####
+
PKG_CHECK_MODULES(SQLITE3, sqlite3)
HAVE_GTK=1
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5234d437..2ec9ec02 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,7 +2,6 @@ MAINTAINERCLEANFILES = Makefile.in
INCLUDES = -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/src -I$(srcdir)
BOOST_TEST_LDFLAGS = @BOOST_UNIT_TEST_LIBS@
-GMOCK_LDFLAGS = -lgmock -lgtest
AM_CPPFLAGS = -DBOOST_TEST_DYN_LINK -DSRCDIR=\"$(srcdir)\"
LDADD = $(top_builddir)/src/loggers.o \
$(top_builddir)/src/generic/apt/matching/libgeneric-matching.a \
@@ -33,6 +32,17 @@ interactive_set_test_SOURCES = interactive_set_test.cc
test_choice.o test_choice_set.o test_resolver.o: $(top_srcdir)/src/generic/problemresolver/*.h
test_promotion_set.o test_resolver_costs.o test_resolver_hints.o: $(top_srcdir)/src/generic/problemresolver/*.h
+# Build a local copy of gmock if necessary.
+if BUILD_LOCAL_GMOCK
+noinst_LIBRARIES = libgmock.a
+
+GMOCK_LDFLAGS = $(srcdir)/libgmock.a -lgtest
+libgmock_a_SOURCES = /usr/src/gmock/src/gmock-all.cc
+libgmock_a_CPPFLAGS = -I/usr/src/gmock
+else
+GMOCK_LDFLAGS = -lgmock -lgtest
+endif
+
# Note: test_apt_universe is not built by default because it takes way
# too long. Of course, ideally this would be done in a less ad-hoc
# way...