gcc.m4 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. dnl -*- Autoconf -*-
  2. dnl
  3. dnl Copyright (C) 2011, 2012 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. # ICC 12.1.0 and Clang 3.1 (among others) support `--version',
  29. # define `__GNUC__', and provide a `-print-file-name=plugin'
  30. # that returns GCC's valid header directory. This makes them
  31. # hardly distinguishable from GCC. Actually, ICC 12.1.0 is able
  32. # to compile our plug-in, so we can let it through...
  33. _STARPU_WITH_GCC_PLUGIN_API([
  34. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gcc-plugin.h>
  35. #include <tree.h>
  36. #include <gimple.h>
  37. tree fndecl; gimple call;]],
  38. [[/* Clang 3.1 doesn't support nested functions, so try to
  39. discriminate it this way. */
  40. tree foo (void)
  41. {
  42. return lookup_name (get_identifier ("puts"));
  43. }
  44. fndecl = foo ();
  45. call = gimple_build_call (fndecl, 0);]])],
  46. [ac_cv_have_gcc_plugins="yes"],
  47. [ac_cv_have_gcc_plugins="no"])
  48. ])
  49. else
  50. ac_cv_have_gcc_plugins="no"
  51. fi
  52. ])
  53. if test "x$ac_cv_have_gcc_plugins" = "xyes"; then
  54. dnl Check for specific features.
  55. dnl
  56. dnl Reason:
  57. dnl build_call_expr_loc_array -- not in GCC 4.5.x; appears in 4.6
  58. dnl build_call_expr_loc_vec -- likewise
  59. dnl build_array_ref -- present but undeclared in 4.6.1
  60. dnl build_zero_cst -- not in GCC 4.5.x; appears in 4.6
  61. _STARPU_WITH_GCC_PLUGIN_API([
  62. AC_CHECK_DECLS([build_call_expr_loc_array, build_call_expr_loc_vec,
  63. build_array_ref, build_zero_cst],
  64. [], [], [#include <gcc-plugin.h>
  65. #include <tree.h>])
  66. dnl Work around header naming issues introduced upstream and in Debian
  67. dnl (see <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=631082>).
  68. AC_CHECK_HEADERS([c-common.h c-pragma.h c-family/c-common.h c-family/c-pragma.h],
  69. [], [], [#include <gcc-plugin.h>
  70. #include <tree.h>])
  71. AC_DEFINE_UNQUOTED([STARPU_INCLUDE_DIR],
  72. ["`eval "echo $includedir"`/starpu/$STARPU_EFFECTIVE_VERSION"],
  73. [Define to the directory where StarPU's headers are installed.])
  74. ])
  75. fi
  76. AC_SUBST([GCC_PLUGIN_INCLUDE_DIR])
  77. ])
  78. dnl Substitute `STARPU_GCC_VERSION_MAJOR' and `STARPU_GCC_VERSION_MINOR'.
  79. AC_DEFUN([STARPU_GCC_VERSION], [
  80. AC_COMPUTE_INT([STARPU_GCC_VERSION_MAJOR], [__GNUC__])
  81. AC_COMPUTE_INT([STARPU_GCC_VERSION_MINOR], [__GNUC_MINOR__])
  82. AC_SUBST([STARPU_GCC_VERSION_MAJOR])
  83. AC_SUBST([STARPU_GCC_VERSION_MINOR])
  84. ])