]> git.ipfire.org Git - thirdparty/gcc.git/blame - config/override.m4
re PR target/78478 (Compile Error for i386-rtems)
[thirdparty/gcc.git] / config / override.m4
CommitLineData
0c179631
PB
1dnl Fix Autoconf bugs by overriding broken internal Autoconf
2dnl macros with backports of fixes from newer releases.
9ebed606 3dnl
18c04407
RW
4dnl The override bits of this file should be a no-op for the newest
5dnl Autoconf version, which means they can be removed once the complete
6dnl tree has moved to a new enough Autoconf version.
7dnl
8dnl The _GCC_AUTOCONF_VERSION_TEST ensures that exactly the desired
9dnl Autoconf version is used. It should be kept for consistency.
9ebed606 10
0c179631
PB
11dnl Use ifdef/ifelse over m4_ifdef/m4_ifelse to be clean for 2.13.
12ifdef([m4_PACKAGE_VERSION], [
13
1b3b24c2
RW
14dnl Provide m4_copy_force and m4_rename_force for old Autoconf versions.
15
16m4_ifndef([m4_copy_force],
17[m4_define([m4_copy_force],
18[m4_ifdef([$2], [m4_undefine([$2])])m4_copy($@)])])
19
20m4_ifndef([m4_rename_force],
21[m4_define([m4_rename_force],
22[m4_ifdef([$2], [m4_undefine([$2])])m4_rename($@)])])
23
0c179631 24dnl AC_DEFUN a commonly used macro so this file is picked up.
deb984e6
PB
25m4_copy([AC_PREREQ], [_AC_PREREQ])
26AC_DEFUN([AC_PREREQ], [frob])
1b3b24c2 27m4_copy_force([_AC_PREREQ], [AC_PREREQ])
9ebed606 28
18c04407
RW
29
30dnl Ensure exactly this Autoconf version is used
31m4_ifndef([_GCC_AUTOCONF_VERSION],
5213506e 32 [m4_define([_GCC_AUTOCONF_VERSION], [2.64])])
18c04407
RW
33
34dnl Test for the exact version when AC_INIT is expanded.
35dnl This allows to update the tree in steps (for testing)
36dnl by putting
37dnl m4_define([_GCC_AUTOCONF_VERSION], [X.Y])
38dnl in configure.ac before AC_INIT,
39dnl without rewriting this file.
40dnl Or for updating the whole tree at once with the definition above.
41AC_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])
46m4_define([AC_INIT], m4_defn([AC_INIT])[
47_GCC_AUTOCONF_VERSION_CHECK
48])
49
0115d4a3 50
9d77a2c4
RW
51dnl Ensure we do not use a buggy M4.
52m4_if(m4_index([..wi.d.], [.d.]), [-1],
53 [m4_fatal(m4_do([m4 with buggy strstr detected. Please install
54GNU M4 1.4.16 or newer and set the M4 environment variable]))])
55
56
0115d4a3
RW
57dnl Fix 2.64 cross compile detection for AVR and RTEMS
58dnl by not trying to compile fopen.
59m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.64],
60 [m4_foreach([_GCC_LANG], [C, C++, Fortran, Fortran 77],
61 [m4_define([_AC_LANG_IO_PROGRAM(]_GCC_LANG[)], m4_defn([AC_LANG_PROGRAM(]_GCC_LANG[)]))])])
62
765a0305
JR
63m4_version_prereq([2.66],, [
64dnl We need AC_CHECK_DECL which works for overloaded C++ functions.
65
66# _AC_CHECK_DECL_BODY
67# -------------------
68# Shell function body for AC_CHECK_DECL.
69m4_define([_AC_CHECK_DECL_BODY],
70[ AS_LINENO_PUSH([$[]1])
71 [as_decl_name=`echo $][2|sed 's/ *(.*//'`]
72 [as_decl_use=`echo $][2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`]
73 AC_CACHE_CHECK([whether $as_decl_name is declared], [$[]3],
74 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]4],
75[@%:@ifndef $[]as_decl_name
76@%:@ifdef __cplusplus
77 (void) $[]as_decl_use;
78@%:@else
79 (void) $[]as_decl_name;
80@%:@endif
81@%:@endif
82])],
83 [AS_VAR_SET([$[]3], [yes])],
84 [AS_VAR_SET([$[]3], [no])])])
85 AS_LINENO_POP
86])# _AC_CHECK_DECL_BODY
87
88# _AC_CHECK_DECLS(SYMBOL, ACTION-IF_FOUND, ACTION-IF-NOT-FOUND,
89# INCLUDES)
90# -------------------------------------------------------------
91# Helper to AC_CHECK_DECLS, which generates the check for a single
92# SYMBOL with INCLUDES, performs the AC_DEFINE, then expands
93# ACTION-IF-FOUND or ACTION-IF-NOT-FOUND.
94m4_define([_AC_CHECK_DECLS],
95[AC_CHECK_DECL([$1], [ac_have_decl=1], [ac_have_decl=0], [$4])]dnl
96[AC_DEFINE_UNQUOTED(AS_TR_CPP(m4_bpatsubst(HAVE_DECL_[$1],[ *(.*])),
97 [$ac_have_decl],
98 [Define to 1 if you have the declaration of `$1',
99 and to 0 if you don't.])]dnl
100[m4_ifvaln([$2$3], [AS_IF([test $ac_have_decl = 1], [$2], [$3])])])
101
102])
0c179631 103
18697a1d
AM
104dnl If flex/lex are not found, the top level configure sets LEX to
105dnl "/path_to/missing flex". When AC_PROG_LEX tries to find the flex
106dnl output file, it calls $LEX to do so, but the current lightweight
107dnl "missing" won't create a file. This results in an error.
108dnl Avoid calling the bulk of AC_PROG_LEX when $LEX is "missing".
109AC_DEFUN_ONCE([AC_PROG_LEX],
110[AC_CHECK_PROGS(LEX, flex lex, :)
111case "$LEX" in
112 :|*"missing "*) ;;
113 *) _AC_PROG_LEX_YYTEXT_DECL ;;
114esac])
115
0c179631 116])