1 dnl Copyright (C) 1997-2021 Free Software Foundation, Inc.
3 dnl This program is free software; you can redistribute it and/or modify
4 dnl it under the terms of the GNU General Public License as published by
5 dnl the Free Software Foundation; either version 3 of the License, or
6 dnl (at your option) any later version.
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 dnl GNU General Public License for more details.
13 dnl You should have received a copy of the GNU General Public License
14 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
16 dnl Setup the toolchain variables.
17 AC_DEFUN([SIM_AC_TOOLCHAIN],
20 AC_USE_SYSTEM_EXTENSIONS
21 AC_REQUIRE([AC_PROG_CC])
22 AC_REQUIRE([AC_PROG_CPP])
27 dnl Setup toolchain settings for build-time tools..
28 if test "x$cross_compiling" = "xno"; then
29 : "${AR_FOR_BUILD:=\$(AR)}"
30 : "${CC_FOR_BUILD:=\$(CC)}"
31 : "${RANLIB_FOR_BUILD:=\$(RANLIB)}"
32 : "${CFLAGS_FOR_BUILD:=\$(CFLAGS)}"
33 : "${LDFLAGS_FOR_BUILD:=\$(LDFLAGS)}"
35 : "${AR_FOR_BUILD:=ar}"
36 : "${CC_FOR_BUILD:=gcc}"
37 : "${RANLIB_FOR_BUILD:=ranlib}"
38 : "${CFLAGS_FOR_BUILD:=-g -O}"
39 : "${LDLFAGS_FOR_BUILD:=}"
41 AC_SUBST(AR_FOR_BUILD)
42 AC_SUBST(CC_FOR_BUILD)
43 AC_SUBST(RANLIB_FOR_BUILD)
44 AC_SUBST(CFLAGS_FOR_BUILD)
45 AC_SUBST(LDFLAGS_FOR_BUILD)
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.
54 m4_version_prereq([2.70], [AC_MSG_ERROR([clean this up!])], [:])
56 AC_MSG_CHECKING([whether C11 is supported by default])
57 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
58 #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
59 # error "C11 support not found"
61 ])], [AC_MSG_RESULT([yes])], [
63 AC_MSG_CHECKING([for -std=c11 support])
66 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
67 #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
68 # error "C11 support not found"
74 ], [AC_MSG_ERROR([C11 is required])])])