Make tests optional at configure time
authorDavid King <david.king@canonical.com>
Tue, 30 Oct 2012 09:24:27 +0000 (09:24 +0000)
committerDavid King <david.king@canonical.com>
Tue, 30 Oct 2012 09:28:39 +0000 (09:28 +0000)
http://code.google.com/p/accounts-sso/issues/detail?id=124

Makefile.am
configure.ac

index 86b3a55..5740d45 100644 (file)
@@ -2,12 +2,16 @@ ACLOCAL_AMFLAGS = -I m4
 DISTCHECK_CONFIGURE_FLAGS = \
        --enable-gtk-doc \
        --enable-introspection=yes
-SUBDIRS = libsignon-glib docs tests
+SUBDIRS = libsignon-glib docs
 
 if ENABLE_PYTHON
 SUBDIRS += pygobject
 endif
 
+if ENABLE_TESTS
+SUBDIRS += tests
+endif
+
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_in_files = libsignon-glib.pc.in
 pkgconfig_DATA = $(pkgconfig_in_files:.pc.in=.pc)
index af5e663..d09661e 100644 (file)
@@ -33,7 +33,25 @@ PKG_CHECK_MODULES(
 AC_SUBST(DEPS_CFLAGS)
 AC_SUBST(DEPS_LIBS)
 
-PKG_CHECK_MODULES([CHECK], [check >= 0.9.4])
+# Build tests.
+
+CHECK_REQUIRED="check >= 0.9.4"
+
+AC_ARG_ENABLE([tests],
+  [AS_HELP_STRING([--disable-tests], [build with testing support disabled])])
+
+AS_IF([test "x$enable_tests" != "xno"],
+  [PKG_CHECK_EXISTS([$CHECK_REQUIRED], [have_check=yes], [have_check=no])],
+  [have_check=no])
+
+AS_IF([test "x$have_check" = "xyes"],
+  [PKG_CHECK_MODULES([CHECK], [$CHECK_REQUIRED])
+   AC_SUBST([CHECK_CFLAGS])
+   AC_SUBST([CHECK_LIBS])],
+  [AS_IF([test "x$enable_tests" = "xyes"],
+    [AC_MSG_ERROR([tests enabled but required dependencies were not found])])])
+
+AM_CONDITIONAL([ENABLE_TESTS], [test "x$have_check" = "xyes"])
 
 GTK_DOC_CHECK([1.14], [--flavour no-tmpl])