autoconf: Print GCC include path directly and be more robust using it
authorDan Nicholson <dbn.lists@gmail.com>
Fri, 7 Mar 2008 19:48:09 +0000 (11:48 -0800)
committerDan Nicholson <dbn.lists@gmail.com>
Fri, 7 Mar 2008 19:48:09 +0000 (11:48 -0800)
Rather than constructing the GCC include path from `-print-search-dirs',
we can get the path directly from `-print-file-name=include'. This is
used in the Linux kernel build, for example. If no output is returned
from the command, then we don't append a -I path the the makedepend
options.

configure.ac

index ec1bb8288efc1731f829fc439b28fe57be865de3..ca3f917196986a92c59209caf60da7d443790657 100644 (file)
@@ -30,12 +30,13 @@ AC_PATH_PROG(MAKE, make)
 AC_PATH_PROG(MKDEP, makedepend)
 AC_PATH_PROG(SED, sed)
 
+MKDEP_OPTIONS=-fdepend
 dnl Ask gcc where it's keeping its secret headers
 if test "x$GCC" = xyes; then
-    GCC_PATH=$(gcc -print-search-dirs | sed -ne 's/install: //p')
-    MKDEP_OPTIONS="-fdepend -I${GCC_PATH}include"
-else
-    MKDEP_OPTIONS=-fdepend
+    GCC_INCLUDES=`$CC -print-file-name=include`
+    if test "x$GCC_INCLUDES" != x; then
+        MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
+    fi
 fi
 AC_SUBST(MKDEP_OPTIONS)