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