override.m4 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. dnl Fix Autoconf bugs by overriding broken internal Autoconf
  2. dnl macros with backports of fixes from newer releases.
  3. dnl
  4. dnl The override bits of this file should be a no-op for the newest
  5. dnl Autoconf version, which means they can be removed once the complete
  6. dnl tree has moved to a new enough Autoconf version.
  7. dnl
  8. dnl The _GCC_AUTOCONF_VERSION_TEST ensures that exactly the desired
  9. dnl Autoconf version is used. It should be kept for consistency.
  10. dnl Use ifdef/ifelse over m4_ifdef/m4_ifelse to be clean for 2.13.
  11. ifdef([m4_PACKAGE_VERSION], [
  12. dnl Provide m4_copy_force and m4_rename_force for old Autoconf versions.
  13. m4_ifndef([m4_copy_force],
  14. [m4_define([m4_copy_force],
  15. [m4_ifdef([$2], [m4_undefine([$2])])m4_copy($@)])])
  16. m4_ifndef([m4_rename_force],
  17. [m4_define([m4_rename_force],
  18. [m4_ifdef([$2], [m4_undefine([$2])])m4_rename($@)])])
  19. dnl AC_DEFUN a commonly used macro so this file is picked up.
  20. m4_copy([AC_PREREQ], [_AC_PREREQ])
  21. AC_DEFUN([AC_PREREQ], [frob])
  22. m4_copy_force([_AC_PREREQ], [AC_PREREQ])
  23. dnl Ensure exactly this Autoconf version is used
  24. m4_ifndef([_GCC_AUTOCONF_VERSION],
  25. [m4_define([_GCC_AUTOCONF_VERSION], [2.64])])
  26. dnl Test for the exact version when AC_INIT is expanded.
  27. dnl This allows to update the tree in steps (for testing)
  28. dnl by putting
  29. dnl m4_define([_GCC_AUTOCONF_VERSION], [X.Y])
  30. dnl in configure.ac before AC_INIT,
  31. dnl without rewriting this file.
  32. dnl Or for updating the whole tree at once with the definition above.
  33. AC_DEFUN([_GCC_AUTOCONF_VERSION_CHECK],
  34. [m4_if(m4_defn([_GCC_AUTOCONF_VERSION]),
  35. m4_defn([m4_PACKAGE_VERSION]), [],
  36. [m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])])
  37. ])
  38. m4_define([AC_INIT], m4_defn([AC_INIT])[
  39. _GCC_AUTOCONF_VERSION_CHECK
  40. ])
  41. dnl Ensure we do not use a buggy M4.
  42. m4_if(m4_index([..wi.d.], [.d.]), [-1],
  43. [m4_fatal(m4_do([m4 with buggy strstr detected. Please install
  44. GNU M4 1.4.16 or newer and set the M4 environment variable]))])
  45. dnl Fix 2.64 cross compile detection for AVR and RTEMS
  46. dnl by not trying to compile fopen.
  47. m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.64],
  48. [m4_foreach([_GCC_LANG], [C, C++, Fortran, Fortran 77],
  49. [m4_define([_AC_LANG_IO_PROGRAM(]_GCC_LANG[)], m4_defn([AC_LANG_PROGRAM(]_GCC_LANG[)]))])])
  50. m4_version_prereq([2.66],, [
  51. dnl We need AC_CHECK_DECL which works for overloaded C++ functions.
  52. # _AC_CHECK_DECL_BODY
  53. # -------------------
  54. # Shell function body for AC_CHECK_DECL.
  55. m4_define([_AC_CHECK_DECL_BODY],
  56. [ AS_LINENO_PUSH([$[]1])
  57. [as_decl_name=`echo $][2|sed 's/ *(.*//'`]
  58. [as_decl_use=`echo $][2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`]
  59. AC_CACHE_CHECK([whether $as_decl_name is declared], [$[]3],
  60. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]4],
  61. [@%:@ifndef $[]as_decl_name
  62. @%:@ifdef __cplusplus
  63. (void) $[]as_decl_use;
  64. @%:@else
  65. (void) $[]as_decl_name;
  66. @%:@endif
  67. @%:@endif
  68. ])],
  69. [AS_VAR_SET([$[]3], [yes])],
  70. [AS_VAR_SET([$[]3], [no])])])
  71. AS_LINENO_POP
  72. ])# _AC_CHECK_DECL_BODY
  73. # _AC_CHECK_DECLS(SYMBOL, ACTION-IF_FOUND, ACTION-IF-NOT-FOUND,
  74. # INCLUDES)
  75. # -------------------------------------------------------------
  76. # Helper to AC_CHECK_DECLS, which generates the check for a single
  77. # SYMBOL with INCLUDES, performs the AC_DEFINE, then expands
  78. # ACTION-IF-FOUND or ACTION-IF-NOT-FOUND.
  79. m4_define([_AC_CHECK_DECLS],
  80. [AC_CHECK_DECL([$1], [ac_have_decl=1], [ac_have_decl=0], [$4])]dnl
  81. [AC_DEFINE_UNQUOTED(AS_TR_CPP(m4_bpatsubst(HAVE_DECL_[$1],[ *(.*])),
  82. [$ac_have_decl],
  83. [Define to 1 if you have the declaration of `$1',
  84. and to 0 if you don't.])]dnl
  85. [m4_ifvaln([$2$3], [AS_IF([test $ac_have_decl = 1], [$2], [$3])])])
  86. ])
  87. ])