sparse: Support recent distributions
authorAndy Zhou <azhou@nicira.com>
Fri, 5 Apr 2013 23:56:52 +0000 (16:56 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 18 Apr 2013 17:08:03 +0000 (10:08 -0700)
sparse support seems to be broken on some recent Linux distributions.
For example, ubuntu 12.04 with Linux 3.5 kernel, and Debian latest test
distribution, running Linux 3.2 kernel.

On both systems that sparse was broken, It was not able find the header files
in the  default system include directories.  GCC finds them by default.

This patch adds the required GCC default search path when running sparse.

Tested on:

Ubuntu 12.04 - w/ linux 3.5 kernel
Debian-6 March test distribution - w/ linux 3.2 kernel

Signed-off-by: Andy Zhou <azhou@nicira.com>
[blp@nicira.com also tested on Debian squeeze and wheezy (testing)]
Signed-off-by: Ben Pfaff <blp@nicira.com>
acinclude.m4

index 19a47dd..911a23d 100644 (file)
@@ -478,13 +478,23 @@ AC_DEFUN([OVS_CHECK_SPARSE_TARGET],
    AC_SUBST([SPARSEFLAGS])
    AC_SUBST([CGCCFLAGS])])
 
+dnl OVS_SPARSE_EXTRA_INCLUDES
+dnl
+dnl The cgcc script from "sparse" does not search gcc's default
+dnl search path. Get the default search path from GCC and pass
+dnl them to sparse.
+AC_DEFUN([OVS_SPARSE_EXTRA_INCLUDES],
+    AC_SUBST([SPARSE_EXTRA_INCLUDES],
+           [`$CC -v -E - </dev/null 2>&1 >/dev/null | sed -n -e '/^#include.*search.*starts.*here:/,/^End.*of.*search.*list\./s/^ \(.*\)/-I \1/p' |grep -v /usr/lib | grep -x -v '\-I /usr/include' | tr \\\n ' ' `] ))
+
 dnl OVS_ENABLE_SPARSE
 AC_DEFUN([OVS_ENABLE_SPARSE],
   [AC_REQUIRE([OVS_CHECK_SPARSE_TARGET])
    AC_REQUIRE([OVS_CHECK_MAKE_IF])
+   AC_REQUIRE([OVS_SPARSE_EXTRA_INCLUDES])
    : ${SPARSE=sparse}
    AC_SUBST([SPARSE])
    AC_CONFIG_COMMANDS_PRE(
      [if test $ovs_cv_gnu_make_if = yes; then
-        CC='$(if $(C),REAL_CC="'"$CC"'" CHECK="$(SPARSE) -I $(top_srcdir)/include/sparse $(SPARSEFLAGS)" cgcc $(CGCCFLAGS),'"$CC"')'
+        CC='$(if $(C),REAL_CC="'"$CC"'" CHECK="$(SPARSE) -I $(top_srcdir)/include/sparse $(SPARSEFLAGS) $(SPARSE_EXTRA_INCLUDES) " cgcc $(CGCCFLAGS),'"$CC"')'
       fi])])