浏览代码

gcc: Detect a few header files to support Debian's layout.

* m4/gcc.m4 (STARPU_GCC_PLUGIN_SUPPORT): Check for c-* headers.

* gcc-plugin/src/starpu-gcc-config.h.in (HAVE_C_FAMILY_C_COMMON_H,
  HAVE_C_COMMON_H, HAVE_C_FAMILY_C_PRAGMA_H, HAVE_C_PRAGMA_H): New
  macro templates.

* gcc-plugin/src/starpu.c: Adjust accordingly.

* gcc-plugin/src/c-expr.y: Likewise.
Ludovic Courtès 14 年之前
父节点
当前提交
8fb9866642
共有 4 个文件被更改,包括 38 次插入4 次删除
  1. 12 2
      gcc-plugin/src/c-expr.y
  2. 6 0
      gcc-plugin/src/starpu-gcc-config.h.in
  3. 13 2
      gcc-plugin/src/starpu.c
  4. 7 0
      m4/gcc.m4

+ 12 - 2
gcc-plugin/src/c-expr.y

@@ -28,10 +28,20 @@
   #include <gcc-plugin.h>
   #include <plugin.h>
   #include <tree.h>
-  #include <c-family/c-common.h>
-  #include <c-family/c-pragma.h>
   #include <cpplib.h>
 
+  #ifdef HAVE_C_FAMILY_C_COMMON_H
+  # include <c-family/c-common.h>
+  #elif HAVE_C_COMMON_H
+  # include <c-common.h>
+  #endif
+
+  #ifdef HAVE_C_FAMILY_C_PRAGMA_H
+  # include <c-family/c-pragma.h>
+  #elif HAVE_C_PRAGMA_H
+  # include <c-pragma.h>
+  #endif
+
   #if !HAVE_DECL_BUILD_ARRAY_REF
   /* This declaration is missing in GCC 4.6.1.  */
   extern tree build_array_ref (location_t loc, tree array, tree index);

+ 6 - 0
gcc-plugin/src/starpu-gcc-config.h.in

@@ -23,3 +23,9 @@
 #undef HAVE_DECL_BUILD_CALL_EXPR_LOC_VEC
 
 #undef HAVE_DECL_BUILD_ARRAY_REF
+
+#undef HAVE_C_FAMILY_C_COMMON_H
+#undef HAVE_C_COMMON_H
+
+#undef HAVE_C_FAMILY_C_PRAGMA_H
+#undef HAVE_C_PRAGMA_H

+ 13 - 2
gcc-plugin/src/starpu.c

@@ -30,8 +30,19 @@ int plugin_is_GPL_compatible;
 #include <cpplib.h>
 #include <tree.h>
 #include <tree-iterator.h>
-#include <c-family/c-common.h>
-#include <c-family/c-pragma.h>
+
+#ifdef HAVE_C_FAMILY_C_COMMON_H
+# include <c-family/c-common.h>
+#elif HAVE_C_COMMON_H
+# include <c-common.h>
+#endif
+
+#ifdef HAVE_C_FAMILY_C_PRAGMA_H
+# include <c-family/c-pragma.h>
+#elif HAVE_C_PRAGMA_H
+# include <c-pragma.h>
+#endif
+
 #include <tm.h>
 #include <gimple.h>
 #include <tree-pass.h>

+ 7 - 0
m4/gcc.m4

@@ -51,11 +51,18 @@ AC_DEFUN([STARPU_GCC_PLUGIN_SUPPORT], [
     dnl Reason:
     dnl   build_call_expr_loc_array -- not in GCC 4.5.x; appears in 4.6
     dnl   build_call_expr_loc_vec   -- likewise
+    dnl   build_array_ref           -- present but undeclared in 4.6.1
     _STARPU_WITH_GCC_PLUGIN_API([
       AC_CHECK_DECLS([build_call_expr_loc_array, build_call_expr_loc_vec,
                       build_array_ref],
         [], [], [#include <gcc-plugin.h>
 	         #include <tree.h>])
+
+      dnl Work around header naming issues introduced upstream and in Debian
+      dnl (see <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=631082>).
+      AC_CHECK_HEADERS([c-common.h c-pragma.h c-family/c-common.h c-family/c-pragma.h],
+        [], [], [#include <gcc-plugin.h>
+	         #include <tree.h>])
     ])
   fi