]>
Commit | Line | Data |
---|---|---|
760b3e8b MF |
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], | |
c2783492 MF |
23 | [dnl |
24 | SIM_AC_TOOLCHAIN | |
760b3e8b | 25 | AC_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. | |
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. | |
2c2645d7 MF |
55 | AC_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 |
66 | AC_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 |
78 | AC_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]]) | |
89 | AC_CHECK_TYPES(socklen_t, [], [], | |
90 | [#include <sys/types.h> | |
91 | #include <sys/socket.h> | |
92 | ]) | |
93 | ||
94 | # Check for socket libraries | |
95 | AC_CHECK_LIB(socket, bind) | |
96 | AC_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. | |
100 | AM_ZLIB | |
101 | ||
102 | # BFD uses libdl when when plugins enabled. | |
103 | AC_PLUGINS | |
104 | AM_CONDITIONAL(PLUGINS, test "$plugins" = yes) | |
105 | LT_INIT([dlopen]) | |
106 | AC_SUBST(lt_cv_dlopen_libs) | |
107 | ||
108 | dnl Standard (and optional) simulator options. | |
109 | dnl Eventually all simulators will support these. | |
110 | dnl Do not add any here that cannot be supported by all simulators. | |
111 | dnl Do not add similar but different options to a particular simulator, | |
112 | dnl all shall eventually behave the same way. | |
113 | ||
114 | ||
115 | dnl We don't use automake, but we still want to support | |
116 | dnl --enable-maintainer-mode. | |
117 | AM_MAINTAINER_MODE | |
118 | ||
119 | ||
120 | dnl --enable-sim-debug is for developers of the simulator | |
121 | dnl the allowable values are work-in-progress | |
122 | AC_MSG_CHECKING([for sim debug setting]) | |
123 | sim_debug="0" | |
124 | AC_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)";; | |
131 | esac])dnl | |
132 | if test "$sim_debug" != "0"; then | |
133 | AC_DEFINE_UNQUOTED([DEBUG], [$sim_debug], [Sim debug setting]) | |
134 | fi | |
135 | AC_DEFINE_UNQUOTED([WITH_DEBUG], [$sim_debug], [Sim debug setting]) | |
136 | AC_MSG_RESULT($sim_debug) | |
137 | ||
138 | ||
139 | dnl --enable-sim-stdio is for users of the simulator | |
140 | dnl It determines if IO from the program is routed through STDIO (buffered) | |
141 | AC_MSG_CHECKING([for sim stdio debug behavior]) | |
142 | sim_stdio="0" | |
143 | AC_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]);; | |
150 | esac])dnl | |
151 | AC_DEFINE_UNQUOTED([WITH_STDIO], [$sim_stdio], [How to route I/O]) | |
152 | AC_MSG_RESULT($sim_stdio) | |
153 | ||
154 | ||
155 | dnl --enable-sim-trace is for users of the simulator | |
156 | dnl The argument is either a bitmask of things to enable [exactly what is | |
157 | dnl up to the simulator], or is a comma separated list of names of tracing | |
158 | dnl elements to enable. The latter is only supported on simulators that | |
159 | dnl use WITH_TRACE. Default to all tracing but internal debug. | |
160 | AC_MSG_CHECKING([for sim trace settings]) | |
161 | sim_trace="~TRACE_debug" | |
162 | AC_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)" ;; | |
180 | esac])dnl | |
181 | AC_DEFINE_UNQUOTED([WITH_TRACE], [$sim_trace], [Sim trace settings]) | |
182 | AC_MSG_RESULT($sim_trace) | |
183 | ||
184 | ||
185 | dnl --enable-sim-profile | |
186 | dnl The argument is either a bitmask of things to enable [exactly what is | |
187 | dnl up to the simulator], or is a comma separated list of names of profiling | |
188 | dnl elements to enable. The latter is only supported on simulators that | |
189 | dnl use WITH_PROFILE. | |
190 | AC_MSG_CHECKING([for sim profile settings]) | |
191 | profile="1" | |
192 | sim_profile="-1" | |
193 | AC_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)" ;; | |
211 | esac])dnl | |
212 | AC_DEFINE_UNQUOTED([PROFILE], [$profile], [Sim profile settings]) | |
213 | AC_DEFINE_UNQUOTED([WITH_PROFILE], [$sim_profile], [Sim profile settings]) | |
214 | AC_MSG_RESULT($sim_profile) | |
215 | ||
216 | ||
217 | SIM_AC_OPTION_ASSERT | |
218 | SIM_AC_OPTION_ENVIRONMENT | |
219 | SIM_AC_OPTION_INLINE | |
220 | ||
221 | ACX_PKGVERSION([SIM]) | |
222 | ACX_BUGURL([https://www.gnu.org/software/gdb/bugs/]) | |
223 | AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description]) | |
224 | AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address]) | |
225 | ||
226 | dnl Types used by common code | |
227 | AC_TYPE_SIGNAL | |
228 | ||
229 | dnl Detect exe extension | |
230 | AC_EXEEXT | |
231 | ]) dnl End of SIM_AC_COMMON |