Enables output in the JUnit XML format.

Adds basic support for optionally outputting in the XML format
commonly used by JUnit compatible tools.

This format is supported by default by many tools, including
the Jenkins build system. It also is more detailed and
captures more information than the more simplistic TAP
format.

Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
diff --git a/configure.ac b/configure.ac
index 404418e..d24fb0b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -426,6 +426,30 @@
 fi
 AM_CONDITIONAL(ENABLE_DBUS, test "x$enable_dbus" = "xyes")
 
+# Note that other features might want libxml2, or this feature might use
+# alternative xml libraries at some point. Therefore the feature and
+# pre-requisite concepts are split.
+AC_ARG_ENABLE(junit_xml,
+	      AS_HELP_STRING([--disable-junit-xml],
+			     [do not build with JUnit XML output]),,
+	      enable_junit_xml=auto)
+if test "x$enable_junit_xml" != "xno"; then
+	PKG_CHECK_MODULES(LIBXML2,
+			  [libxml-2.0 >= 2.6],
+			  have_libxml2=yes,
+			  have_libxml2=no)
+	if test "x$have_libxml2" = "xno" -a "x$enable_junit_xml" = "xyes"; then
+		AC_MSG_ERROR([JUnit XML support explicitly requested, but libxml2 couldn't be found])
+	fi
+	if test "x$have_libxml2" = "xyes"; then
+		enable_junit_xml=yes
+		AC_DEFINE(ENABLE_JUNIT_XML, [1], [Build Weston with JUnit output support])
+	else
+		enable_junit_xml=no
+	fi
+fi
+AM_CONDITIONAL(ENABLE_JUNIT_XML, test "x$enable_junit_xml" = "xyes")
+
 # ivi-shell support
 AC_ARG_ENABLE(ivi-shell,
               AS_HELP_STRING([--disable-ivi-shell],
@@ -537,6 +561,7 @@
 	FBDEV Compositor		${enable_fbdev_compositor}
 	RDP Compositor			${enable_rdp_compositor}
 	Screen Sharing			${enable_screen_sharing}
+	JUnit XML output		${enable_junit_xml}
 
 	Raspberry Pi BCM headers	${have_bcm_host}