OSDN Git Service

2010-06-10 Paolo Bonzini <bonzini@gnu.org>
[pf3gnuchains/gcc-fork.git] / config / override.m4
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
11 dnl Use ifdef/ifelse over m4_ifdef/m4_ifelse to be clean for 2.13.
12 ifdef([m4_PACKAGE_VERSION], [
13
14 dnl Provide m4_copy_force and m4_rename_force for old Autoconf versions.
15
16 m4_ifndef([m4_copy_force],
17 [m4_define([m4_copy_force],
18 [m4_ifdef([$2], [m4_undefine([$2])])m4_copy($@)])])
19
20 m4_ifndef([m4_rename_force],
21 [m4_define([m4_rename_force],
22 [m4_ifdef([$2], [m4_undefine([$2])])m4_rename($@)])])
23
24 dnl AC_DEFUN a commonly used macro so this file is picked up.
25 m4_copy([AC_PREREQ], [_AC_PREREQ])
26 AC_DEFUN([AC_PREREQ], [frob])
27 m4_copy_force([_AC_PREREQ], [AC_PREREQ])
28
29
30 dnl Ensure exactly this Autoconf version is used
31 m4_ifndef([_GCC_AUTOCONF_VERSION],
32   [m4_define([_GCC_AUTOCONF_VERSION], [2.64])])
33
34 dnl Test for the exact version when AC_INIT is expanded.
35 dnl This allows to update the tree in steps (for testing)
36 dnl by putting
37 dnl   m4_define([_GCC_AUTOCONF_VERSION], [X.Y])
38 dnl in configure.ac before AC_INIT,
39 dnl without rewriting this file.
40 dnl Or for updating the whole tree at once with the definition above.
41 AC_DEFUN([_GCC_AUTOCONF_VERSION_CHECK],
42 [m4_if(m4_defn([_GCC_AUTOCONF_VERSION]),
43   m4_defn([m4_PACKAGE_VERSION]), [],
44   [m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])])
45 ])
46 m4_define([AC_INIT], m4_defn([AC_INIT])[
47 _GCC_AUTOCONF_VERSION_CHECK
48 ])
49
50
51 dnl Fix 2.64 cross compile detection for AVR and RTEMS
52 dnl by not trying to compile fopen.
53 m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.64],
54   [m4_foreach([_GCC_LANG], [C, C++, Fortran, Fortran 77],
55      [m4_define([_AC_LANG_IO_PROGRAM(]_GCC_LANG[)], m4_defn([AC_LANG_PROGRAM(]_GCC_LANG[)]))])])
56
57 m4_version_prereq([2.66],, [
58 dnl We need AC_CHECK_DECL which works for overloaded C++ functions.
59
60 # _AC_CHECK_DECL_BODY
61 # -------------------
62 # Shell function body for AC_CHECK_DECL.
63 m4_define([_AC_CHECK_DECL_BODY],
64 [  AS_LINENO_PUSH([$[]1])
65   [as_decl_name=`echo $][2|sed 's/ *(.*//'`]
66   [as_decl_use=`echo $][2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`]
67   AC_CACHE_CHECK([whether $as_decl_name is declared], [$[]3],
68   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]4],
69 [@%:@ifndef $[]as_decl_name
70 @%:@ifdef __cplusplus
71   (void) $[]as_decl_use;
72 @%:@else
73   (void) $[]as_decl_name;
74 @%:@endif
75 @%:@endif
76 ])],
77                    [AS_VAR_SET([$[]3], [yes])],
78                    [AS_VAR_SET([$[]3], [no])])])
79   AS_LINENO_POP
80 ])# _AC_CHECK_DECL_BODY
81
82 # _AC_CHECK_DECLS(SYMBOL, ACTION-IF_FOUND, ACTION-IF-NOT-FOUND,
83 #                 INCLUDES)
84 # -------------------------------------------------------------
85 # Helper to AC_CHECK_DECLS, which generates the check for a single
86 # SYMBOL with INCLUDES, performs the AC_DEFINE, then expands
87 # ACTION-IF-FOUND or ACTION-IF-NOT-FOUND.
88 m4_define([_AC_CHECK_DECLS],
89 [AC_CHECK_DECL([$1], [ac_have_decl=1], [ac_have_decl=0], [$4])]dnl
90 [AC_DEFINE_UNQUOTED(AS_TR_CPP(m4_bpatsubst(HAVE_DECL_[$1],[ *(.*])),
91   [$ac_have_decl],
92   [Define to 1 if you have the declaration of `$1',
93    and to 0 if you don't.])]dnl
94 [m4_ifvaln([$2$3], [AS_IF([test $ac_have_decl = 1], [$2], [$3])])])
95
96 ])
97
98 ])