sim: add support for build-time ar & ranlib
[deliverable/binutils-gdb.git] / sim / m4 / sim_ac_toolchain.m4
CommitLineData
c2783492
MF
1dnl Copyright (C) 1997-2021 Free Software Foundation, Inc.
2dnl
3dnl This program is free software; you can redistribute it and/or modify
4dnl it under the terms of the GNU General Public License as published by
5dnl the Free Software Foundation; either version 3 of the License, or
6dnl (at your option) any later version.
7dnl
8dnl This program is distributed in the hope that it will be useful,
9dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11dnl GNU General Public License for more details.
12dnl
13dnl You should have received a copy of the GNU General Public License
14dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
15dnl
16dnl Setup the toolchain variables.
17AC_DEFUN([SIM_AC_TOOLCHAIN],
18[dnl
19AC_CANONICAL_SYSTEM
20AC_USE_SYSTEM_EXTENSIONS
21AC_REQUIRE([AC_PROG_CC])
22AC_REQUIRE([AC_PROG_CPP])
23AC_C_BIGENDIAN
24AC_ARG_PROGRAM
25AC_PROG_INSTALL
26
27dnl Setup toolchain settings for build-time tools..
28if test "x$cross_compiling" = "xno"; then
aa0fca16 29 : "${AR_FOR_BUILD:=\$(AR)}"
c2783492 30 : "${CC_FOR_BUILD:=\$(CC)}"
aa0fca16 31 : "${RANLIB_FOR_BUILD:=\$(RANLIB)}"
c2783492
MF
32 : "${CFLAGS_FOR_BUILD:=\$(CFLAGS)}"
33 : "${LDFLAGS_FOR_BUILD:=\$(LDFLAGS)}"
34else
aa0fca16 35 : "${AR_FOR_BUILD:=ar}"
c2783492 36 : "${CC_FOR_BUILD:=gcc}"
aa0fca16 37 : "${RANLIB_FOR_BUILD:=ranlib}"
c2783492
MF
38 : "${CFLAGS_FOR_BUILD:=-g -O}"
39 : "${LDLFAGS_FOR_BUILD:=}"
40fi
aa0fca16 41AC_SUBST(AR_FOR_BUILD)
c2783492 42AC_SUBST(CC_FOR_BUILD)
aa0fca16 43AC_SUBST(RANLIB_FOR_BUILD)
c2783492
MF
44AC_SUBST(CFLAGS_FOR_BUILD)
45AC_SUBST(LDFLAGS_FOR_BUILD)
46
47AC_SUBST(CFLAGS)
48AC_CHECK_TOOL(AR, ar)
49AC_PROG_RANLIB
50
51# Require C11 or newer. Autoconf-2.70 provides ac_cv_prog_cc_c11 when using
52# AC_PROG_CC, but we're still using Autoconf-2.69, and the newest it understands
53# is C99. So handle it ourselves.
54m4_version_prereq([2.70], [AC_MSG_ERROR([clean this up!])], [:])
55C_DIALECT=
56AC_MSG_CHECKING([whether C11 is supported by default])
57AC_COMPILE_IFELSE([AC_LANG_SOURCE([
58#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
59# error "C11 support not found"
60#endif
61])], [AC_MSG_RESULT([yes])], [
62 AC_MSG_RESULT([no])
63 AC_MSG_CHECKING([for -std=c11 support])
64 ac_save_CC="$CC"
65 CC="$CC -std=c11"
66 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
67#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
68# error "C11 support not found"
69#endif
70])], [
71 AC_MSG_RESULT([yes])
72 CC="$ac_save_CC"
73 C_DIALECT="-std=c11"
74], [AC_MSG_ERROR([C11 is required])])])
75AC_SUBST(C_DIALECT)
76])
This page took 0.040359 seconds and 4 git commands to generate.