configure: Run sparse automatically if C=1 specified on "make" command.
authorBen Pfaff <blp@nicira.com>
Fri, 6 May 2011 20:00:49 +0000 (13:00 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 16 May 2011 20:45:53 +0000 (13:45 -0700)
The C=1 convention matches the kernel's convention, so running "make C=1"
will now get sparse results for both userspace and kernel compiles.

acinclude.m4
configure.ac

index 69e61e0e916e2bdad20db4273c7e72a0c3fec88b..3cf793d425b61487e4a4e801c8e5d5b87e995ffb 100644 (file)
@@ -347,3 +347,38 @@ AC_DEFUN([OVS_CHECK_XENSERVER_VERSION],
       AC_MSG_ERROR([This appears to be XenServer $ovs_cv_xsversion, but only XenServer 5.6.100 or later is supported.  (If you are really using a supported version of XenServer, you may override this error message by specifying 'ovs_cv_xsversion=5.6.100' on the "configure" command line.)])
       ;;
   esac])
+
+dnl OVS_MAKE_HAS_IF([if-true], [if-false])
+dnl
+dnl Checks whether make has the GNU make $(if condition,then,else) extension.
+dnl Runs 'if-true' if so, 'if-false' otherwise.
+AC_DEFUN([OVS_MAKE_HAS_IF],
+  [AC_CACHE_CHECK(
+     [whether ${MAKE-make} has GNU make \$(if) extension],
+     [ovs_cv_gnu_make_if],
+     [cat <<'EOF' > conftest.mk
+conftest.out:
+       echo $(if x,y,z) > conftest.out
+.PHONY: all
+EOF
+      rm -f conftest.out
+      AS_ECHO(["$as_me:$LINENO: invoking ${MAKE-make} -f conftest.mk all:"]) >&AS_MESSAGE_LOG_FD 2>&1
+      ${MAKE-make} -f conftest.mk conftest.out >&AS_MESSAGE_LOG_FD 2>&1
+      AS_ECHO(["$as_me:$LINENO: conftest.out contains:"]) >&AS_MESSAGE_LOG_FD 2>&1
+      cat conftest.out >&AS_MESSAGE_LOG_FD 2>&1
+      result=`cat conftest.out`
+      rm -f conftest.mk conftest.out
+      if test "X$result" = "Xy"; then
+        ovs_cv_gnu_make_if=yes
+      else
+        ovs_cv_gnu_make_if=no
+      fi])
+   AS_IF([test $ovs_cv_gnu_make_if = yes], [$1], [$2])])
+
+dnl OVS_ENABLE_SPARSE
+AC_DEFUN([OVS_ENABLE_SPARSE],
+  [OVS_MAKE_HAS_IF(
+     [AC_CONFIG_COMMANDS_PRE(
+        [: ${SPARSE=sparse}
+         AC_SUBST([SPARSE])
+         CC='$(if $(C),REAL_CC="'"$CC"'" CHECK="$(SPARSE) -I $(top_srcdir)/include/sparse" cgcc,'"$CC"')'])])])
index fe91242f5ced3c71c1c5ce8961e630e16ee6fc53..dde42e0c2b2276e4664e4cdcd86dbe91bea38a91 100644 (file)
@@ -86,6 +86,7 @@ OVS_ENABLE_OPTION([-Wno-override-init])
 OVS_CONDITIONAL_CC_OPTION([-Wno-unused], [HAVE_WNO_UNUSED])
 OVS_CONDITIONAL_CC_OPTION([-Wno-unused-parameter], [HAVE_WNO_UNUSED_PARAMETER])
 OVS_ENABLE_WERROR
+OVS_ENABLE_SPARSE
 
 AC_ARG_VAR(KARCH, [Kernel Architecture String])
 AC_SUBST(KARCH)