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