sim: unify toolchain settings
[binutils-gdb.git] / sim / m4 / sim_ac_common.m4
1 dnl Copyright (C) 1997-2021 Free Software Foundation, Inc.
2 dnl
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.
7 dnl
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.
12 dnl
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/>.
15 dnl
16 dnl SIM_AC_COMMON invokes AC macros used by all simulators and by the common
17 dnl directory. It is intended to be invoked before any target specific stuff.
18 dnl SIM_AC_OUTPUT is a cover function to AC_OUTPUT to generate the Makefile.
19 dnl It is intended to be invoked last.
20 dnl
21 dnl See README-HACKING for more details.
22 AC_DEFUN([SIM_AC_COMMON],
23 [dnl
24 SIM_AC_TOOLCHAIN
25 AC_CONFIG_HEADERS([config.h:config.in])
26
27 # Some of the common include files depend on bfd.h, and bfd.h checks
28 # that config.h is included first by testing that the PACKAGE macro
29 # is defined.
30 PACKAGE=sim
31 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package. ])
32 AC_SUBST(PACKAGE)
33
34 # Dependency checking.
35 ZW_CREATE_DEPDIR
36 ZW_PROG_COMPILER_DEPENDENCIES([CC])
37
38 # Check for the 'make' the user wants to use.
39 AC_CHECK_PROGS(MAKE, make)
40 MAKE_IS_GNU=
41 case "`$MAKE --version 2>&1 | sed 1q`" in
42 *GNU*)
43 MAKE_IS_GNU=yes
44 ;;
45 esac
46 AM_CONDITIONAL(GMAKE, test "$MAKE_IS_GNU" = yes)
47
48 dnl We don't use gettext, but bfd does. So we do the appropriate checks
49 dnl to see if there are intl libraries we should link against.
50 ALL_LINGUAS=
51 ZW_GNU_GETTEXT_SISTER_DIR(../../intl)
52
53 # Check for common headers.
54 # NB: You can assume C11 headers exist.
55 AC_CHECK_HEADERS(unistd.h)
56 AC_CHECK_HEADERS(sys/time.h sys/times.h sys/resource.h sys/mman.h)
57 AC_CHECK_HEADERS(fcntl.h fpu_control.h)
58 AC_CHECK_HEADERS(dlfcn.h sys/stat.h)
59 AC_CHECK_FUNCS(getrusage time sigaction __setfpucw)
60 AC_CHECK_FUNCS(mmap munmap lstat truncate ftruncate posix_fallocate)
61 AC_CHECK_MEMBERS([[struct stat.st_dev], [struct stat.st_ino],
62 [struct stat.st_mode], [struct stat.st_nlink], [struct stat.st_uid],
63 [struct stat.st_gid], [struct stat.st_rdev], [struct stat.st_size],
64 [struct stat.st_blksize], [struct stat.st_blocks], [struct stat.st_atime],
65 [struct stat.st_mtime], [struct stat.st_ctime]], [], [],
66 [[#ifdef HAVE_SYS_TYPES_H
67 #include <sys/types.h>
68 #endif
69 #ifdef HAVE_SYS_STAT_H
70 #include <sys/stat.h>
71 #endif]])
72 AC_CHECK_TYPES(socklen_t, [], [],
73 [#include <sys/types.h>
74 #include <sys/socket.h>
75 ])
76
77 # Check for socket libraries
78 AC_CHECK_LIB(socket, bind)
79 AC_CHECK_LIB(nsl, gethostbyname)
80
81 # BFD conditionally uses zlib, so we must link it in if libbfd does, by
82 # using the same condition.
83 AM_ZLIB
84
85 # BFD uses libdl when when plugins enabled.
86 AC_PLUGINS
87 AM_CONDITIONAL(PLUGINS, test "$plugins" = yes)
88 LT_INIT([dlopen])
89 AC_SUBST(lt_cv_dlopen_libs)
90
91 dnl Standard (and optional) simulator options.
92 dnl Eventually all simulators will support these.
93 dnl Do not add any here that cannot be supported by all simulators.
94 dnl Do not add similar but different options to a particular simulator,
95 dnl all shall eventually behave the same way.
96
97
98 dnl We don't use automake, but we still want to support
99 dnl --enable-maintainer-mode.
100 AM_MAINTAINER_MODE
101
102
103 dnl --enable-sim-debug is for developers of the simulator
104 dnl the allowable values are work-in-progress
105 AC_MSG_CHECKING([for sim debug setting])
106 sim_debug="0"
107 AC_ARG_ENABLE(sim-debug,
108 [AS_HELP_STRING([--enable-sim-debug=opts],
109 [Enable debugging flags (for developers of the sim itself)])],
110 [case "${enableval}" in
111 yes) sim_debug="7";;
112 no) sim_debug="0";;
113 *) sim_debug="($enableval)";;
114 esac])dnl
115 if test "$sim_debug" != "0"; then
116 AC_DEFINE_UNQUOTED([DEBUG], [$sim_debug], [Sim debug setting])
117 fi
118 AC_DEFINE_UNQUOTED([WITH_DEBUG], [$sim_debug], [Sim debug setting])
119 AC_MSG_RESULT($sim_debug)
120
121
122 dnl --enable-sim-stdio is for users of the simulator
123 dnl It determines if IO from the program is routed through STDIO (buffered)
124 AC_MSG_CHECKING([for sim stdio debug behavior])
125 sim_stdio="0"
126 AC_ARG_ENABLE(sim-stdio,
127 [AS_HELP_STRING([--enable-sim-stdio],
128 [Specify whether to use stdio for console input/output])],
129 [case "${enableval}" in
130 yes) sim_stdio="DO_USE_STDIO";;
131 no) sim_stdio="DONT_USE_STDIO";;
132 *) AC_MSG_ERROR([Unknown value $enableval passed to --enable-sim-stdio]);;
133 esac])dnl
134 AC_DEFINE_UNQUOTED([WITH_STDIO], [$sim_stdio], [How to route I/O])
135 AC_MSG_RESULT($sim_stdio)
136
137
138 dnl --enable-sim-trace is for users of the simulator
139 dnl The argument is either a bitmask of things to enable [exactly what is
140 dnl up to the simulator], or is a comma separated list of names of tracing
141 dnl elements to enable. The latter is only supported on simulators that
142 dnl use WITH_TRACE. Default to all tracing but internal debug.
143 AC_MSG_CHECKING([for sim trace settings])
144 sim_trace="~TRACE_debug"
145 AC_ARG_ENABLE(sim-trace,
146 [AS_HELP_STRING([--enable-sim-trace=opts],
147 [Enable tracing of simulated programs])],
148 [case "${enableval}" in
149 yes) sim_trace="-1";;
150 no) sim_trace="0";;
151 [[-0-9]]*)
152 sim_trace="'(${enableval})'";;
153 [[[:lower:]]]*)
154 sim_trace=""
155 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
156 if test x"$sim_trace" = x; then
157 sim_trace="(TRACE_$x"
158 else
159 sim_trace="${sim_trace}|TRACE_$x"
160 fi
161 done
162 sim_trace="$sim_trace)" ;;
163 esac])dnl
164 AC_DEFINE_UNQUOTED([WITH_TRACE], [$sim_trace], [Sim trace settings])
165 AC_MSG_RESULT($sim_trace)
166
167
168 dnl --enable-sim-profile
169 dnl The argument is either a bitmask of things to enable [exactly what is
170 dnl up to the simulator], or is a comma separated list of names of profiling
171 dnl elements to enable. The latter is only supported on simulators that
172 dnl use WITH_PROFILE.
173 AC_MSG_CHECKING([for sim profile settings])
174 profile="1"
175 sim_profile="-1"
176 AC_ARG_ENABLE(sim-profile,
177 [AS_HELP_STRING([--enable-sim-profile=opts], [Enable profiling flags])],
178 [case "${enableval}" in
179 yes) profile="1" sim_profile="-1";;
180 no) profile="0" sim_profile="0";;
181 [[-0-9]]*)
182 profile="(${enableval})" sim_profile="(${enableval})";;
183 [[a-z]]*)
184 profile="1"
185 sim_profile=""
186 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
187 if test x"$sim_profile" = x; then
188 sim_profile="(PROFILE_$x"
189 else
190 sim_profile="${sim_profile}|PROFILE_$x"
191 fi
192 done
193 sim_profile="$sim_profile)" ;;
194 esac])dnl
195 AC_DEFINE_UNQUOTED([PROFILE], [$profile], [Sim profile settings])
196 AC_DEFINE_UNQUOTED([WITH_PROFILE], [$sim_profile], [Sim profile settings])
197 AC_MSG_RESULT($sim_profile)
198
199
200 SIM_AC_OPTION_ASSERT
201 SIM_AC_OPTION_ENVIRONMENT
202 SIM_AC_OPTION_INLINE
203
204 ACX_PKGVERSION([SIM])
205 ACX_BUGURL([https://www.gnu.org/software/gdb/bugs/])
206 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
207 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
208
209 dnl Types used by common code
210 AC_TYPE_SIGNAL
211
212 dnl Detect exe extension
213 AC_EXEEXT
214 ]) dnl End of SIM_AC_COMMON