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