gcc.m4 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. dnl -*- Autoconf -*-
  2. dnl
  3. dnl Copyright (C) 2011 Institut National de Recherche en Informatique et Automatique
  4. dnl
  5. dnl StarPU is free software; you can redistribute it and/or modify
  6. dnl it under the terms of the GNU Lesser General Public License as published by
  7. dnl the Free Software Foundation; either version 2.1 of the License, or (at
  8. dnl your option) any later version.
  9. dnl
  10. dnl StarPU is distributed in the hope that it will be useful, but
  11. dnl WITHOUT ANY WARRANTY; without even the implied warranty of
  12. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. dnl
  14. dnl See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. dnl Run its argument with CPPFLAGS pointing to GCC's plug-in API.
  16. AC_DEFUN([_STARPU_WITH_GCC_PLUGIN_API], [
  17. GCC_PLUGIN_INCLUDE_DIR="`"$CC" -print-file-name=plugin`/include"
  18. save_CPPFLAGS="$CPPFLAGS"
  19. CPPFLAGS="-I$GCC_PLUGIN_INCLUDE_DIR"
  20. $1
  21. CPPFLAGS="$save_CPPFLAGS"
  22. ])
  23. dnl Check whether GCC plug-in support is available (GCC 4.5+).
  24. AC_DEFUN([STARPU_GCC_PLUGIN_SUPPORT], [
  25. AC_REQUIRE([AC_PROG_CC])
  26. AC_CACHE_CHECK([whether GCC supports plug-ins], [ac_cv_have_gcc_plugins], [
  27. if test "x$GCC" = xyes; then
  28. _STARPU_WITH_GCC_PLUGIN_API([
  29. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gcc-plugin.h>
  30. #include <tree.h>
  31. #include <gimple.h>
  32. tree fndecl; gimple call;]],
  33. [[fndecl = lookup_name (get_identifier ("puts"));
  34. call = gimple_build_call (fndecl, 0);]])],
  35. [ac_cv_have_gcc_plugins="yes"],
  36. [ac_cv_have_gcc_plugins="no"])
  37. ])
  38. else
  39. ac_cv_have_gcc_plugins="no"
  40. fi
  41. ])
  42. if test "x$ac_cv_have_gcc_plugins" = "xyes"; then
  43. dnl Check for specific features.
  44. dnl
  45. dnl Reason:
  46. dnl build_call_expr_loc_array -- not in GCC 4.5.x; appears in 4.6
  47. dnl build_call_expr_loc_vec -- likewise
  48. dnl build_array_ref -- present but undeclared in 4.6.1
  49. _STARPU_WITH_GCC_PLUGIN_API([
  50. AC_CHECK_DECLS([build_call_expr_loc_array, build_call_expr_loc_vec,
  51. build_array_ref],
  52. [], [], [#include <gcc-plugin.h>
  53. #include <tree.h>])
  54. dnl Work around header naming issues introduced upstream and in Debian
  55. dnl (see <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=631082>).
  56. AC_CHECK_HEADERS([c-common.h c-pragma.h c-family/c-common.h c-family/c-pragma.h],
  57. [], [], [#include <gcc-plugin.h>
  58. #include <tree.h>])
  59. ])
  60. fi
  61. AC_SUBST([GCC_PLUGIN_INCLUDE_DIR])
  62. ])