Commit | Line | Data |
---|---|---|
9c082ca8 MF |
1 | # This file contains common code used by all simulators. |
2 | # | |
3 | # SIM_AC_COMMON invokes AC macros used by all simulators and by the common | |
4 | # directory. It is intended to be invoked before any target specific stuff. | |
5 | # SIM_AC_OUTPUT is a cover function to AC_OUTPUT to generate the Makefile. | |
6 | # It is intended to be invoked last. | |
7 | # | |
50df264d | 8 | # See README-HACKING for more details. |
9c082ca8 | 9 | |
9c082ca8 MF |
10 | AC_DEFUN([SIM_AC_COMMON], |
11 | [ | |
12 | AC_REQUIRE([AC_PROG_CC]) | |
7a36eeea | 13 | AC_CONFIG_HEADERS([config.h:config.in]) |
9c082ca8 | 14 | AC_CANONICAL_SYSTEM |
2232061b | 15 | AC_USE_SYSTEM_EXTENSIONS |
0cb8d851 | 16 | AC_C_BIGENDIAN |
9c082ca8 MF |
17 | AC_ARG_PROGRAM |
18 | AC_PROG_INSTALL | |
19 | ||
20 | # Put a plausible default for CC_FOR_BUILD in Makefile. | |
5c887dd5 JB |
21 | if test -z "$CC_FOR_BUILD"; then |
22 | if test "x$cross_compiling" = "xno"; then | |
23 | CC_FOR_BUILD='$(CC)' | |
24 | else | |
25 | CC_FOR_BUILD=gcc | |
26 | fi | |
9c082ca8 MF |
27 | fi |
28 | AC_SUBST(CC_FOR_BUILD) | |
29 | ||
30 | AC_SUBST(CFLAGS) | |
9c082ca8 MF |
31 | AR=${AR-ar} |
32 | AC_SUBST(AR) | |
33 | AC_PROG_RANLIB | |
34 | ||
46f900c0 MF |
35 | # Require C11 or newer. Autoconf-2.70 provides ac_cv_prog_cc_c11 when using |
36 | # AC_PROG_CC, but we're still using Autoconf-2.69, and the newest it understands | |
37 | # is C99. So handle it ourselves. | |
38 | m4_version_prereq([2.70], [AC_MSG_ERROR([clean this up!])], [:]) | |
39 | C_DIALECT= | |
40 | AC_MSG_CHECKING([whether C11 is supported by default]) | |
41 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([ | |
42 | #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L | |
43 | # error "C11 support not found" | |
44 | #endif | |
45 | ])], [AC_MSG_RESULT([yes])], [ | |
46 | AC_MSG_RESULT([no]) | |
47 | AC_MSG_CHECKING([for -std=c11 support]) | |
48 | ac_save_CC="$CC" | |
49 | CC="$CC -std=c11" | |
50 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([ | |
51 | #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L | |
52 | # error "C11 support not found" | |
53 | #endif | |
54 | ])], [ | |
55 | AC_MSG_RESULT([yes]) | |
56 | CC="$ac_save_CC" | |
57 | C_DIALECT="-std=c11" | |
58 | ], [AC_MSG_ERROR([C11 is required])])]) | |
59 | AC_SUBST(C_DIALECT) | |
60 | ||
5f3ef9d0 JB |
61 | # Some of the common include files depend on bfd.h, and bfd.h checks |
62 | # that config.h is included first by testing that the PACKAGE macro | |
63 | # is defined. | |
64 | PACKAGE=sim | |
65 | AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package. ]) | |
66 | AC_SUBST(PACKAGE) | |
67 | ||
db2e4d67 MF |
68 | # Dependency checking. |
69 | ZW_CREATE_DEPDIR | |
70 | ZW_PROG_COMPILER_DEPENDENCIES([CC]) | |
71 | ||
72 | # Check for the 'make' the user wants to use. | |
73 | AC_CHECK_PROGS(MAKE, make) | |
74 | MAKE_IS_GNU= | |
75 | case "`$MAKE --version 2>&1 | sed 1q`" in | |
76 | *GNU*) | |
77 | MAKE_IS_GNU=yes | |
78 | ;; | |
79 | esac | |
80 | AM_CONDITIONAL(GMAKE, test "$MAKE_IS_GNU" = yes) | |
81 | ||
9c082ca8 MF |
82 | dnl We don't use gettext, but bfd does. So we do the appropriate checks |
83 | dnl to see if there are intl libraries we should link against. | |
84 | ALL_LINGUAS= | |
85 | ZW_GNU_GETTEXT_SISTER_DIR(../../intl) | |
86 | ||
87 | # Check for common headers. | |
68ed2854 MF |
88 | # NB: You can assume C11 headers exist. |
89 | AC_CHECK_HEADERS(unistd.h) | |
936df756 | 90 | AC_CHECK_HEADERS(sys/time.h sys/times.h sys/resource.h sys/mman.h) |
9c082ca8 | 91 | AC_CHECK_HEADERS(fcntl.h fpu_control.h) |
68ed2854 | 92 | AC_CHECK_HEADERS(dlfcn.h sys/stat.h) |
9c082ca8 | 93 | AC_CHECK_FUNCS(getrusage time sigaction __setfpucw) |
936df756 MF |
94 | AC_CHECK_FUNCS(mmap munmap lstat truncate ftruncate posix_fallocate) |
95 | AC_CHECK_MEMBERS([[struct stat.st_dev], [struct stat.st_ino], | |
96 | [struct stat.st_mode], [struct stat.st_nlink], [struct stat.st_uid], | |
97 | [struct stat.st_gid], [struct stat.st_rdev], [struct stat.st_size], | |
98 | [struct stat.st_blksize], [struct stat.st_blocks], [struct stat.st_atime], | |
99 | [struct stat.st_mtime], [struct stat.st_ctime]], [], [], | |
100 | [[#ifdef HAVE_SYS_TYPES_H | |
101 | #include <sys/types.h> | |
102 | #endif | |
103 | #ifdef HAVE_SYS_STAT_H | |
104 | #include <sys/stat.h> | |
105 | #endif]]) | |
106 | AC_CHECK_TYPES(socklen_t, [], [], | |
107 | [#include <sys/types.h> | |
108 | #include <sys/socket.h> | |
109 | ]) | |
9c082ca8 MF |
110 | |
111 | # Check for socket libraries | |
112 | AC_CHECK_LIB(socket, bind) | |
113 | AC_CHECK_LIB(nsl, gethostbyname) | |
114 | ||
115 | # BFD conditionally uses zlib, so we must link it in if libbfd does, by | |
116 | # using the same condition. | |
117 | AM_ZLIB | |
118 | ||
6bb11ab3 L |
119 | # BFD uses libdl when when plugins enabled. |
120 | AC_PLUGINS | |
121 | AM_CONDITIONAL(PLUGINS, test "$plugins" = yes) | |
122 | LT_INIT([dlopen]) | |
123 | AC_SUBST(lt_cv_dlopen_libs) | |
124 | ||
9c082ca8 MF |
125 | dnl Standard (and optional) simulator options. |
126 | dnl Eventually all simulators will support these. | |
127 | dnl Do not add any here that cannot be supported by all simulators. | |
128 | dnl Do not add similar but different options to a particular simulator, | |
129 | dnl all shall eventually behave the same way. | |
130 | ||
131 | ||
132 | dnl We don't use automake, but we still want to support | |
133 | dnl --enable-maintainer-mode. | |
31e6ad7d | 134 | AM_MAINTAINER_MODE |
9c082ca8 MF |
135 | |
136 | ||
9c082ca8 MF |
137 | dnl --enable-sim-debug is for developers of the simulator |
138 | dnl the allowable values are work-in-progress | |
ce39bd38 MF |
139 | AC_MSG_CHECKING([for sim debug setting]) |
140 | sim_debug="0" | |
9c082ca8 | 141 | AC_ARG_ENABLE(sim-debug, |
8d0978fb MF |
142 | [AS_HELP_STRING([--enable-sim-debug=opts], |
143 | [Enable debugging flags (for developers of the sim itself)])], | |
9c082ca8 | 144 | [case "${enableval}" in |
ce39bd38 MF |
145 | yes) sim_debug="7";; |
146 | no) sim_debug="0";; | |
147 | *) sim_debug="($enableval)";; | |
148 | esac])dnl | |
149 | if test "$sim_debug" != "0"; then | |
150 | AC_DEFINE_UNQUOTED([DEBUG], [$sim_debug], [Sim debug setting]) | |
151 | fi | |
152 | AC_DEFINE_UNQUOTED([WITH_DEBUG], [$sim_debug], [Sim debug setting]) | |
153 | AC_MSG_RESULT($sim_debug) | |
9c082ca8 MF |
154 | |
155 | ||
156 | dnl --enable-sim-stdio is for users of the simulator | |
157 | dnl It determines if IO from the program is routed through STDIO (buffered) | |
ce39bd38 MF |
158 | AC_MSG_CHECKING([for sim stdio debug behavior]) |
159 | sim_stdio="0" | |
9c082ca8 | 160 | AC_ARG_ENABLE(sim-stdio, |
8d0978fb MF |
161 | [AS_HELP_STRING([--enable-sim-stdio], |
162 | [Specify whether to use stdio for console input/output])], | |
9c082ca8 | 163 | [case "${enableval}" in |
ce39bd38 MF |
164 | yes) sim_stdio="DO_USE_STDIO";; |
165 | no) sim_stdio="DONT_USE_STDIO";; | |
166 | *) AC_MSG_ERROR([Unknown value $enableval passed to --enable-sim-stdio]);; | |
167 | esac])dnl | |
168 | AC_DEFINE_UNQUOTED([WITH_STDIO], [$sim_stdio], [How to route I/O]) | |
169 | AC_MSG_RESULT($sim_stdio) | |
9c082ca8 MF |
170 | |
171 | ||
172 | dnl --enable-sim-trace is for users of the simulator | |
173 | dnl The argument is either a bitmask of things to enable [exactly what is | |
174 | dnl up to the simulator], or is a comma separated list of names of tracing | |
175 | dnl elements to enable. The latter is only supported on simulators that | |
ce39bd38 MF |
176 | dnl use WITH_TRACE. Default to all tracing but internal debug. |
177 | AC_MSG_CHECKING([for sim trace settings]) | |
178 | sim_trace="~TRACE_debug" | |
9c082ca8 | 179 | AC_ARG_ENABLE(sim-trace, |
8d0978fb MF |
180 | [AS_HELP_STRING([--enable-sim-trace=opts], |
181 | [Enable tracing of simulated programs])], | |
9c082ca8 | 182 | [case "${enableval}" in |
ce39bd38 MF |
183 | yes) sim_trace="-1";; |
184 | no) sim_trace="0";; | |
9c082ca8 | 185 | [[-0-9]]*) |
ce39bd38 | 186 | sim_trace="'(${enableval})'";; |
509deab2 | 187 | [[[:lower:]]]*) |
9c082ca8 MF |
188 | sim_trace="" |
189 | for x in `echo "$enableval" | sed -e "s/,/ /g"`; do | |
190 | if test x"$sim_trace" = x; then | |
ce39bd38 | 191 | sim_trace="(TRACE_$x" |
9c082ca8 MF |
192 | else |
193 | sim_trace="${sim_trace}|TRACE_$x" | |
194 | fi | |
195 | done | |
ce39bd38 MF |
196 | sim_trace="$sim_trace)" ;; |
197 | esac])dnl | |
198 | AC_DEFINE_UNQUOTED([WITH_TRACE], [$sim_trace], [Sim trace settings]) | |
199 | AC_MSG_RESULT($sim_trace) | |
9c082ca8 MF |
200 | |
201 | ||
202 | dnl --enable-sim-profile | |
203 | dnl The argument is either a bitmask of things to enable [exactly what is | |
204 | dnl up to the simulator], or is a comma separated list of names of profiling | |
205 | dnl elements to enable. The latter is only supported on simulators that | |
206 | dnl use WITH_PROFILE. | |
ce39bd38 MF |
207 | AC_MSG_CHECKING([for sim profile settings]) |
208 | profile="1" | |
209 | sim_profile="-1" | |
9c082ca8 | 210 | AC_ARG_ENABLE(sim-profile, |
8d0978fb | 211 | [AS_HELP_STRING([--enable-sim-profile=opts], [Enable profiling flags])], |
9c082ca8 | 212 | [case "${enableval}" in |
ce39bd38 MF |
213 | yes) profile="1" sim_profile="-1";; |
214 | no) profile="0" sim_profile="0";; | |
9c082ca8 | 215 | [[-0-9]]*) |
ce39bd38 | 216 | profile="(${enableval})" sim_profile="(${enableval})";; |
9c082ca8 | 217 | [[a-z]]*) |
ce39bd38 | 218 | profile="1" |
9c082ca8 MF |
219 | sim_profile="" |
220 | for x in `echo "$enableval" | sed -e "s/,/ /g"`; do | |
221 | if test x"$sim_profile" = x; then | |
ce39bd38 | 222 | sim_profile="(PROFILE_$x" |
9c082ca8 MF |
223 | else |
224 | sim_profile="${sim_profile}|PROFILE_$x" | |
225 | fi | |
226 | done | |
ce39bd38 MF |
227 | sim_profile="$sim_profile)" ;; |
228 | esac])dnl | |
229 | AC_DEFINE_UNQUOTED([PROFILE], [$profile], [Sim profile settings]) | |
230 | AC_DEFINE_UNQUOTED([WITH_PROFILE], [$sim_profile], [Sim profile settings]) | |
231 | AC_MSG_RESULT($sim_profile) | |
232 | ||
9c082ca8 | 233 | |
35656e95 | 234 | SIM_AC_OPTION_ASSERT |
16f7876d | 235 | SIM_AC_OPTION_ENVIRONMENT |
347fe5bb MF |
236 | SIM_AC_OPTION_INLINE |
237 | ||
bf12d44e | 238 | ACX_PKGVERSION([SIM]) |
dfb856ba | 239 | ACX_BUGURL([https://www.gnu.org/software/gdb/bugs/]) |
9c082ca8 MF |
240 | AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description]) |
241 | AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address]) | |
242 | ||
243 | dnl Types used by common code | |
244 | AC_TYPE_SIGNAL | |
245 | ||
246 | dnl Detect exe extension | |
247 | AC_EXEEXT | |
248 | ||
9c082ca8 MF |
249 | ]) dnl End of SIM_AC_COMMON |
250 | ||
251 | ||
252 | dnl Additional SIM options that can (optionally) be configured | |
253 | dnl For optional simulator options, a macro SIM_AC_OPTION_* is defined. | |
254 | dnl Simulators that wish to use the relevant option specify the macro | |
306f4178 | 255 | dnl in the simulator specific configure.ac file between the SIM_AC_COMMON |
9c082ca8 MF |
256 | dnl and SIM_AC_OUTPUT lines. |
257 | ||
258 | ||
259 | dnl Specify the running environment. | |
306f4178 | 260 | dnl If the simulator invokes this in its configure.ac then without this option |
9c082ca8 MF |
261 | dnl the default is the user environment and all are runtime selectable. |
262 | dnl If the simulator doesn't invoke this, only the user environment is | |
263 | dnl supported. | |
264 | dnl ??? Until there is demonstrable value in doing something more complicated, | |
265 | dnl let's not. | |
266 | AC_DEFUN([SIM_AC_OPTION_ENVIRONMENT], | |
267 | [ | |
ce39bd38 MF |
268 | AC_MSG_CHECKING([default sim environment setting]) |
269 | sim_environment="ALL_ENVIRONMENT" | |
9c082ca8 | 270 | AC_ARG_ENABLE(sim-environment, |
8d0978fb MF |
271 | [AS_HELP_STRING([--enable-sim-environment=environment], |
272 | [Specify mixed, user, virtual or operating environment])], | |
9c082ca8 | 273 | [case "${enableval}" in |
ce39bd38 MF |
274 | all | ALL) sim_environment="ALL_ENVIRONMENT";; |
275 | user | USER) sim_environment="USER_ENVIRONMENT";; | |
276 | virtual | VIRTUAL) sim_environment="VIRTUAL_ENVIRONMENT";; | |
277 | operating | OPERATING) sim_environment="OPERATING_ENVIRONMENT";; | |
278 | *) AC_MSG_ERROR([Unknown value $enableval passed to --enable-sim-environment]);; | |
279 | esac])dnl | |
280 | AC_DEFINE_UNQUOTED([WITH_ENVIRONMENT], [$sim_environment], [Sim default environment]) | |
281 | AC_MSG_RESULT($sim_environment) | |
9c082ca8 | 282 | ]) |
9c082ca8 MF |
283 | |
284 | ||
285 | dnl Specify the alignment restrictions of the target architecture. | |
286 | dnl Without this option all possible alignment restrictions are accommodated. | |
287 | dnl arg[1] is hardwired target alignment | |
288 | dnl arg[2] is default target alignment | |
289 | AC_DEFUN([SIM_AC_OPTION_ALIGNMENT], | |
290 | wire_alignment="[$1]" | |
291 | default_alignment="[$2]" | |
292 | [ | |
293 | AC_ARG_ENABLE(sim-alignment, | |
8d0978fb MF |
294 | [AS_HELP_STRING([--enable-sim-alignment=align], |
295 | [Specify strict, nonstrict or forced alignment of memory accesses])], | |
9c082ca8 MF |
296 | [case "${enableval}" in |
297 | strict | STRICT) sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";; | |
298 | nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";; | |
299 | forced | FORCED) sim_alignment="-DWITH_ALIGNMENT=FORCED_ALIGNMENT";; | |
300 | yes) if test x"$wire_alignment" != x; then | |
301 | sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}" | |
302 | else | |
303 | if test x"$default_alignment" != x; then | |
304 | sim_alignment="-DWITH_ALIGNMENT=${default_alignment}" | |
305 | else | |
306 | echo "No hard-wired alignment for target $target" 1>&6 | |
307 | sim_alignment="-DWITH_ALIGNMENT=0" | |
308 | fi | |
309 | fi;; | |
310 | no) if test x"$default_alignment" != x; then | |
311 | sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}" | |
312 | else | |
313 | if test x"$wire_alignment" != x; then | |
314 | sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${wire_alignment}" | |
315 | else | |
316 | echo "No default alignment for target $target" 1>&6 | |
317 | sim_alignment="-DWITH_DEFAULT_ALIGNMENT=0" | |
318 | fi | |
319 | fi;; | |
320 | *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment"); sim_alignment="";; | |
321 | esac | |
322 | if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then | |
323 | echo "Setting alignment flags = $sim_alignment" 6>&1 | |
324 | fi], | |
325 | [if test x"$default_alignment" != x; then | |
326 | sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}" | |
327 | else | |
328 | if test x"$wire_alignment" != x; then | |
329 | sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}" | |
330 | else | |
331 | sim_alignment= | |
332 | fi | |
333 | fi])dnl | |
334 | ])dnl | |
335 | AC_SUBST(sim_alignment) | |
336 | ||
337 | ||
338 | dnl Conditionally compile in assertion statements. | |
339 | AC_DEFUN([SIM_AC_OPTION_ASSERT], | |
340 | [ | |
ce39bd38 MF |
341 | AC_MSG_CHECKING([whether to enable sim asserts]) |
342 | sim_assert="1" | |
9c082ca8 | 343 | AC_ARG_ENABLE(sim-assert, |
8d0978fb MF |
344 | [AS_HELP_STRING([--enable-sim-assert], |
345 | [Specify whether to perform random assertions])], | |
9c082ca8 | 346 | [case "${enableval}" in |
ce39bd38 MF |
347 | yes) sim_assert="1";; |
348 | no) sim_assert="0";; | |
349 | *) AC_MSG_ERROR([--enable-sim-assert does not take a value]);; | |
350 | esac])dnl | |
351 | AC_DEFINE_UNQUOTED([WITH_ASSERT], [$sim_assert], [Sim assert settings]) | |
352 | AC_MSG_RESULT($sim_assert) | |
9c082ca8 | 353 | ]) |
9c082ca8 MF |
354 | |
355 | ||
356 | ||
357 | dnl --enable-sim-bitsize is for developers of the simulator | |
358 | dnl It specifies the number of BITS in the target. | |
359 | dnl arg[1] is the number of bits in a word | |
360 | dnl arg[2] is the number assigned to the most significant bit | |
361 | dnl arg[3] is the number of bits in an address | |
362 | dnl arg[4] is the number of bits in an OpenFirmware cell. | |
363 | dnl FIXME: this information should be obtained from bfd/archure | |
364 | AC_DEFUN([SIM_AC_OPTION_BITSIZE], | |
365 | wire_word_bitsize="[$1]" | |
366 | wire_word_msb="[$2]" | |
367 | wire_address_bitsize="[$3]" | |
368 | wire_cell_bitsize="[$4]" | |
369 | [AC_ARG_ENABLE(sim-bitsize, | |
8d0978fb | 370 | [AS_HELP_STRING([--enable-sim-bitsize=N], [Specify target bitsize (32 or 64)])], |
9c082ca8 MF |
371 | [sim_bitsize= |
372 | case "${enableval}" in | |
373 | 64,63 | 64,63,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63";; | |
374 | 32,31 | 32,31,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31";; | |
375 | 64,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";; | |
376 | 32,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";; | |
377 | 32) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then | |
378 | sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31" | |
379 | else | |
380 | sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0" | |
381 | fi ;; | |
382 | 64) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then | |
383 | sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63" | |
384 | else | |
385 | sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=0" | |
386 | fi ;; | |
387 | *) AC_MSG_ERROR("--enable-sim-bitsize was given $enableval. Expected 32 or 64") ;; | |
388 | esac | |
389 | # address bitsize | |
390 | tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9]]*,*//"` | |
391 | case x"${tmp}" in | |
392 | x ) ;; | |
393 | x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=32" ;; | |
394 | x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=64" ;; | |
395 | * ) AC_MSG_ERROR("--enable-sim-bitsize was given address size $enableval. Expected 32 or 64") ;; | |
396 | esac | |
397 | # cell bitsize | |
398 | tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9*]]*,*[[0-9]]*,*//"` | |
399 | case x"${tmp}" in | |
400 | x ) ;; | |
401 | x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=32" ;; | |
402 | x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=64" ;; | |
403 | * ) AC_MSG_ERROR("--enable-sim-bitsize was given cell size $enableval. Expected 32 or 64") ;; | |
404 | esac | |
405 | if test x"$silent" != x"yes" && test x"$sim_bitsize" != x""; then | |
406 | echo "Setting bitsize flags = $sim_bitsize" 6>&1 | |
407 | fi], | |
408 | [sim_bitsize="" | |
409 | if test x"$wire_word_bitsize" != x; then | |
410 | sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_BITSIZE=$wire_word_bitsize" | |
411 | fi | |
412 | if test x"$wire_word_msb" != x; then | |
413 | sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_MSB=$wire_word_msb" | |
414 | fi | |
415 | if test x"$wire_address_bitsize" != x; then | |
416 | sim_bitsize="$sim_bitsize -DWITH_TARGET_ADDRESS_BITSIZE=$wire_address_bitsize" | |
417 | fi | |
418 | if test x"$wire_cell_bitsize" != x; then | |
419 | sim_bitsize="$sim_bitsize -DWITH_TARGET_CELL_BITSIZE=$wire_cell_bitsize" | |
420 | fi])dnl | |
421 | ]) | |
422 | AC_SUBST(sim_bitsize) | |
423 | ||
424 | ||
425 | ||
426 | dnl --enable-sim-endian={yes,no,big,little} is for simulators | |
427 | dnl that support both big and little endian targets. | |
428 | dnl arg[1] is hardwired target endianness. | |
429 | dnl arg[2] is default target endianness. | |
430 | AC_DEFUN([SIM_AC_OPTION_ENDIAN], | |
431 | [ | |
432 | wire_endian="[$1]" | |
433 | default_endian="[$2]" | |
434 | AC_ARG_ENABLE(sim-endian, | |
8d0978fb MF |
435 | [AS_HELP_STRING([--enable-sim-endian=endian], |
436 | [Specify target byte endian orientation])], | |
9c082ca8 | 437 | [case "${enableval}" in |
1ac72f06 MF |
438 | b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_BIG";; |
439 | l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_LITTLE";; | |
9c082ca8 | 440 | yes) if test x"$wire_endian" != x; then |
1ac72f06 | 441 | sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}" |
9c082ca8 | 442 | else |
1ac72f06 MF |
443 | if test x"$default_endian" != x; then |
444 | sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}" | |
9c082ca8 MF |
445 | else |
446 | echo "No hard-wired endian for target $target" 1>&6 | |
1ac72f06 | 447 | sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN" |
9c082ca8 MF |
448 | fi |
449 | fi;; | |
450 | no) if test x"$default_endian" != x; then | |
1ac72f06 | 451 | sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}" |
9c082ca8 MF |
452 | else |
453 | if test x"$wire_endian" != x; then | |
1ac72f06 | 454 | sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}" |
9c082ca8 MF |
455 | else |
456 | echo "No default endian for target $target" 1>&6 | |
1ac72f06 | 457 | sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN" |
9c082ca8 MF |
458 | fi |
459 | fi;; | |
460 | *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";; | |
461 | esac | |
462 | if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then | |
463 | echo "Setting endian flags = $sim_endian" 6>&1 | |
464 | fi], | |
465 | [if test x"$default_endian" != x; then | |
1ac72f06 | 466 | sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}" |
9c082ca8 MF |
467 | else |
468 | if test x"$wire_endian" != x; then | |
1ac72f06 | 469 | sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}" |
9c082ca8 MF |
470 | else |
471 | sim_endian= | |
472 | fi | |
473 | fi])dnl | |
474 | ]) | |
475 | AC_SUBST(sim_endian) | |
476 | ||
477 | ||
9c082ca8 MF |
478 | dnl --enable-sim-float is for developers of the simulator |
479 | dnl It specifies the presence of hardware floating point | |
480 | dnl And optionally the bitsize of the floating point register. | |
481 | dnl arg[1] specifies the presence (or absence) of floating point hardware | |
482 | dnl arg[2] specifies the number of bits in a floating point register | |
483 | AC_DEFUN([SIM_AC_OPTION_FLOAT], | |
484 | [ | |
485 | default_sim_float="[$1]" | |
486 | default_sim_float_bitsize="[$2]" | |
487 | AC_ARG_ENABLE(sim-float, | |
8d0978fb MF |
488 | [AS_HELP_STRING([--enable-sim-float], |
489 | [Specify that the target processor has floating point hardware])], | |
9c082ca8 MF |
490 | [case "${enableval}" in |
491 | yes | hard) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";; | |
492 | no | soft) sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";; | |
493 | 32) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=32";; | |
494 | 64) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=64";; | |
495 | *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-float"); sim_float="";; | |
496 | esac | |
497 | if test x"$silent" != x"yes" && test x"$sim_float" != x""; then | |
498 | echo "Setting float flags = $sim_float" 6>&1 | |
499 | fi],[ | |
500 | sim_float= | |
501 | if test x"${default_sim_float}" != x""; then | |
502 | sim_float="-DWITH_FLOATING_POINT=${default_sim_float}" | |
503 | fi | |
504 | if test x"${default_sim_float_bitsize}" != x""; then | |
505 | sim_float="$sim_float -DWITH_TARGET_FLOATING_POINT_BITSIZE=${default_sim_float_bitsize}" | |
506 | fi | |
507 | ])dnl | |
508 | ]) | |
509 | AC_SUBST(sim_float) | |
510 | ||
511 | ||
512 | dnl The argument is the default cache size if none is specified. | |
513 | AC_DEFUN([SIM_AC_OPTION_SCACHE], | |
514 | [ | |
515 | default_sim_scache="ifelse([$1],,0,[$1])" | |
516 | AC_ARG_ENABLE(sim-scache, | |
8d0978fb MF |
517 | [AS_HELP_STRING([--enable-sim-scache=size], |
518 | [Specify simulator execution cache size])], | |
9c082ca8 MF |
519 | [case "${enableval}" in |
520 | yes) sim_scache="-DWITH_SCACHE=${default_sim_scache}";; | |
521 | no) sim_scache="-DWITH_SCACHE=0" ;; | |
522 | [[0-9]]*) sim_scache="-DWITH_SCACHE=${enableval}";; | |
523 | *) AC_MSG_ERROR("Bad value $enableval passed to --enable-sim-scache"); | |
524 | sim_scache="";; | |
525 | esac | |
526 | if test x"$silent" != x"yes" && test x"$sim_scache" != x""; then | |
527 | echo "Setting scache size = $sim_scache" 6>&1 | |
528 | fi],[sim_scache="-DWITH_SCACHE=${default_sim_scache}"]) | |
529 | ]) | |
530 | AC_SUBST(sim_scache) | |
531 | ||
532 | ||
533 | dnl The argument is the default model if none is specified. | |
534 | AC_DEFUN([SIM_AC_OPTION_DEFAULT_MODEL], | |
535 | [ | |
536 | default_sim_default_model="ifelse([$1],,0,[$1])" | |
537 | AC_ARG_ENABLE(sim-default-model, | |
8d0978fb MF |
538 | [AS_HELP_STRING([--enable-sim-default-model=model], |
539 | [Specify default model to simulate])], | |
9c082ca8 MF |
540 | [case "${enableval}" in |
541 | yes|no) AC_MSG_ERROR("Missing argument to --enable-sim-default-model");; | |
542 | *) sim_default_model="-DWITH_DEFAULT_MODEL='\"${enableval}\"'";; | |
543 | esac | |
544 | if test x"$silent" != x"yes" && test x"$sim_default_model" != x""; then | |
545 | echo "Setting default model = $sim_default_model" 6>&1 | |
546 | fi],[sim_default_model="-DWITH_DEFAULT_MODEL='\"${default_sim_default_model}\"'"]) | |
547 | ]) | |
548 | AC_SUBST(sim_default_model) | |
549 | ||
550 | ||
551 | dnl --enable-sim-hardware is for users of the simulator | |
64dd13df | 552 | dnl arg[1] Enable sim-hw by default? ("yes" or "no") |
9c082ca8 MF |
553 | dnl arg[2] is a space separated list of devices that override the defaults |
554 | dnl arg[3] is a space separated list of extra target specific devices. | |
555 | AC_DEFUN([SIM_AC_OPTION_HARDWARE], | |
556 | [ | |
9c082ca8 MF |
557 | if test "[$2]"; then |
558 | hardware="[$2]" | |
559 | else | |
560 | hardware="cfi core pal glue" | |
561 | fi | |
562 | hardware="$hardware [$3]" | |
1517bd27 | 563 | |
9c082ca8 MF |
564 | sim_hw_cflags="-DWITH_HW=1" |
565 | sim_hw="$hardware" | |
566 | sim_hw_objs="\$(SIM_COMMON_HW_OBJS) `echo $sim_hw | sed -e 's/\([[^ ]][[^ ]]*\)/dv-\1.o/g'`" | |
1517bd27 | 567 | |
9c082ca8 | 568 | AC_ARG_ENABLE(sim-hardware, |
1517bd27 | 569 | [AS_HELP_STRING([--enable-sim-hardware=LIST], |
30452bbe MF |
570 | [Specify the hardware to be included in the build.])], |
571 | ,[enable_sim_hardware="[$1]"]) | |
1517bd27 | 572 | case ${enable_sim_hardware} in |
64dd13df MF |
573 | yes|no) ;; |
574 | ,*) hardware="${hardware} `echo ${enableval} | sed -e 's/,/ /'`";; | |
575 | *,) hardware="`echo ${enableval} | sed -e 's/,/ /'` ${hardware}";; | |
576 | *) hardware="`echo ${enableval} | sed -e 's/,/ /'`"'';; | |
9c082ca8 | 577 | esac |
1517bd27 | 578 | |
64dd13df | 579 | if test "$enable_sim_hardware" = no; then |
9c082ca8 MF |
580 | sim_hw_objs= |
581 | sim_hw_cflags="-DWITH_HW=0" | |
582 | sim_hw= | |
583 | else | |
584 | sim_hw_cflags="-DWITH_HW=1" | |
585 | # remove duplicates | |
586 | sim_hw="" | |
587 | sim_hw_objs="\$(SIM_COMMON_HW_OBJS)" | |
588 | for i in $hardware ; do | |
589 | case " $sim_hw " in | |
590 | *" $i "*) ;; | |
591 | *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";; | |
592 | esac | |
593 | done | |
3fd38161 | 594 | # mingw does not support sockser |
3fd38161 JS |
595 | case ${host} in |
596 | *mingw*) ;; | |
49cd1634 MF |
597 | *) # TODO: We don't add dv-sockser to sim_hw as it is not a "real" device |
598 | # that you instatiate. Instead, other code will call into it directly. | |
599 | # At some point, we should convert it over. | |
600 | sim_hw_objs="$sim_hw_objs dv-sockser.o" | |
3fd38161 JS |
601 | AC_DEFINE_UNQUOTED( |
602 | [HAVE_DV_SOCKSER], 1, [Define if dv-sockser is usable.]) | |
603 | ;; | |
604 | esac | |
1517bd27 MF |
605 | if test x"$silent" != x"yes"; then |
606 | echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs" | |
3fd38161 | 607 | fi |
1517bd27 MF |
608 | dnl Some devices require extra libraries. |
609 | case " $hardware " in | |
610 | *" cfi "*) AC_CHECK_LIB(m, log2);; | |
611 | esac | |
9c082ca8 | 612 | fi |
9c082ca8 MF |
613 | ]) |
614 | AC_SUBST(sim_hw_cflags) | |
615 | AC_SUBST(sim_hw_objs) | |
616 | AC_SUBST(sim_hw) | |
617 | ||
618 | ||
619 | dnl --enable-sim-inline is for users that wish to ramp up the simulator's | |
620 | dnl performance by inlining functions. | |
347fe5bb | 621 | dnl Default sims to no inlining. |
9c082ca8 MF |
622 | AC_DEFUN([SIM_AC_OPTION_INLINE], |
623 | [ | |
347fe5bb | 624 | sim_inline="-DDEFAULT_INLINE=m4_ifblank([$1],[0],[$1])" |
9c082ca8 | 625 | AC_ARG_ENABLE(sim-inline, |
8d0978fb MF |
626 | [AS_HELP_STRING([--enable-sim-inline=inlines], |
627 | [Specify which functions should be inlined])], | |
9c082ca8 MF |
628 | [sim_inline="" |
629 | case "$enableval" in | |
630 | no) sim_inline="-DDEFAULT_INLINE=0";; | |
631 | 0) sim_inline="-DDEFAULT_INLINE=0";; | |
632 | yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_C_INLINE";; | |
633 | 1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";; | |
634 | *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do | |
635 | new_flag="" | |
636 | case "$x" in | |
637 | *_INLINE=*) new_flag="-D$x";; | |
638 | *=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;; | |
639 | *_INLINE) new_flag="-D$x=ALL_C_INLINE";; | |
640 | *) new_flag="-D$x""_INLINE=ALL_C_INLINE";; | |
641 | esac | |
642 | if test x"$sim_inline" = x""; then | |
643 | sim_inline="$new_flag" | |
644 | else | |
645 | sim_inline="$sim_inline $new_flag" | |
646 | fi | |
647 | done;; | |
648 | esac | |
649 | if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then | |
650 | echo "Setting inline flags = $sim_inline" 6>&1 | |
9c082ca8 MF |
651 | fi])dnl |
652 | ]) | |
653 | AC_SUBST(sim_inline) | |
654 | ||
655 | ||
9c082ca8 MF |
656 | AC_DEFUN([SIM_AC_OPTION_RESERVED_BITS], |
657 | [ | |
658 | default_sim_reserved_bits="ifelse([$1],,1,[$1])" | |
659 | AC_ARG_ENABLE(sim-reserved-bits, | |
8d0978fb MF |
660 | [AS_HELP_STRING([--enable-sim-reserved-bits], |
661 | [Specify whether to check reserved bits in instruction])], | |
9c082ca8 MF |
662 | [case "${enableval}" in |
663 | yes) sim_reserved_bits="-DWITH_RESERVED_BITS=1";; | |
664 | no) sim_reserved_bits="-DWITH_RESERVED_BITS=0";; | |
665 | *) AC_MSG_ERROR("--enable-sim-reserved-bits does not take a value"); sim_reserved_bits="";; | |
666 | esac | |
667 | if test x"$silent" != x"yes" && test x"$sim_reserved_bits" != x""; then | |
668 | echo "Setting reserved flags = $sim_reserved_bits" 6>&1 | |
669 | fi],[sim_reserved_bits="-DWITH_RESERVED_BITS=${default_sim_reserved_bits}"])dnl | |
670 | ]) | |
671 | AC_SUBST(sim_reserved_bits) | |
672 | ||
673 | ||
674 | AC_DEFUN([SIM_AC_OPTION_SMP], | |
675 | [ | |
ce39bd38 | 676 | AC_MSG_CHECKING([number of sim cpus to support]) |
9c082ca8 | 677 | default_sim_smp="ifelse([$1],,5,[$1])" |
ce39bd38 | 678 | sim_smp="$default_sim_smp"" |
9c082ca8 | 679 | AC_ARG_ENABLE(sim-smp, |
8d0978fb MF |
680 | [AS_HELP_STRING([--enable-sim-smp=n], |
681 | [Specify number of processors to configure for (default ${default_sim_smp})])], | |
9c082ca8 | 682 | [case "${enableval}" in |
ce39bd38 MF |
683 | yes) sim_smp="5";; |
684 | no) sim_smp="0";; | |
685 | *) sim_smp="$enableval";; | |
686 | esac])dnl | |
687 | sim_igen_smp="-N ${sim_smp}" | |
688 | AC_DEFINE_UNQUOTED([WITH_SMP], [$sim_smp], [Sim SMP settings]) | |
689 | AC_MSG_RESULT($sim_smp) | |
9c082ca8 | 690 | ]) |
9c082ca8 MF |
691 | |
692 | ||
9c082ca8 MF |
693 | AC_DEFUN([SIM_AC_OPTION_XOR_ENDIAN], |
694 | [ | |
ce39bd38 | 695 | AC_MSG_CHECKING([for xor endian support]) |
9c082ca8 | 696 | default_sim_xor_endian="ifelse([$1],,8,[$1])" |
ce39bd38 | 697 | sim_xor_endian="$default_sim_xor_endian" |
9c082ca8 | 698 | AC_ARG_ENABLE(sim-xor-endian, |
8d0978fb MF |
699 | [AS_HELP_STRING([--enable-sim-xor-endian=n], |
700 | [Specify number bytes involved in XOR bi-endian mode (default ${default_sim_xor_endian})])], | |
9c082ca8 | 701 | [case "${enableval}" in |
ce39bd38 MF |
702 | yes) sim_xor_endian="8";; |
703 | no) sim_xor_endian="0";; | |
704 | *) sim_xor_endian="$enableval";; | |
705 | esac])dnl | |
706 | AC_DEFINE_UNQUOTED([WITH_XOR_ENDIAN], [$sim_xor_endian], [Sim XOR endian settings]) | |
707 | AC_MSG_RESULT($sim_smp) | |
9c082ca8 | 708 | ]) |
9c082ca8 MF |
709 | |
710 | ||
711 | dnl --enable-build-warnings is for developers of the simulator. | |
712 | dnl it enables extra GCC specific warnings. | |
bf470982 | 713 | dnl arg[1] Enable -Werror by default? ("yes" or "no") |
9c082ca8 MF |
714 | AC_DEFUN([SIM_AC_OPTION_WARNINGS], |
715 | [ | |
ac0aacdf MF |
716 | AC_ARG_ENABLE(werror, |
717 | AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]), | |
718 | [case "${enableval}" in | |
719 | yes | y) ERROR_ON_WARNING="yes" ;; | |
720 | no | n) ERROR_ON_WARNING="no" ;; | |
721 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;; | |
722 | esac]) | |
723 | ||
724 | # Enable -Werror by default when using gcc | |
725 | if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then | |
726 | ERROR_ON_WARNING=yes | |
727 | fi | |
728 | ||
729 | WERROR_CFLAGS="" | |
bf470982 MF |
730 | m4_if(m4_default([$1], [yes]), [yes], [dnl |
731 | if test "${ERROR_ON_WARNING}" = yes ; then | |
732 | WERROR_CFLAGS="-Werror" | |
733 | fi | |
734 | ])dnl | |
ac0aacdf | 735 | |
ac0aacdf | 736 | build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \ |
1a8a700e | 737 | -Wpointer-sign \ |
ac0aacdf | 738 | -Wno-unused -Wunused-value -Wunused-function \ |
1a8a700e MF |
739 | -Wno-switch -Wno-char-subscripts -Wmissing-prototypes |
740 | -Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \ | |
741 | -Wold-style-declaration -Wold-style-definition" | |
ac0aacdf MF |
742 | |
743 | # Enable -Wno-format by default when using gcc on mingw since many | |
744 | # GCC versions complain about %I64. | |
745 | case "${host}" in | |
746 | *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;; | |
d3685d60 | 747 | *) build_warnings="$build_warnings -Wformat-nonliteral" ;; |
ac0aacdf MF |
748 | esac |
749 | ||
9c082ca8 | 750 | AC_ARG_ENABLE(build-warnings, |
ac0aacdf | 751 | AS_HELP_STRING([--enable-build-warnings], [enable build-time compiler warnings if gcc is used]), |
9c082ca8 MF |
752 | [case "${enableval}" in |
753 | yes) ;; | |
754 | no) build_warnings="-w";; | |
755 | ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"` | |
756 | build_warnings="${build_warnings} ${t}";; | |
757 | *,) t=`echo "${enableval}" | sed -e "s/,/ /g"` | |
758 | build_warnings="${t} ${build_warnings}";; | |
759 | *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;; | |
760 | esac | |
761 | if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then | |
762 | echo "Setting compiler warning flags = $build_warnings" 6>&1 | |
763 | fi])dnl | |
764 | AC_ARG_ENABLE(sim-build-warnings, | |
ac0aacdf | 765 | AS_HELP_STRING([--enable-sim-build-warnings], [enable SIM specific build-time compiler warnings if gcc is used]), |
9c082ca8 MF |
766 | [case "${enableval}" in |
767 | yes) ;; | |
768 | no) build_warnings="-w";; | |
769 | ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"` | |
770 | build_warnings="${build_warnings} ${t}";; | |
771 | *,) t=`echo "${enableval}" | sed -e "s/,/ /g"` | |
772 | build_warnings="${t} ${build_warnings}";; | |
773 | *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;; | |
774 | esac | |
775 | if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then | |
776 | echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1 | |
777 | fi])dnl | |
778 | WARN_CFLAGS="" | |
9c082ca8 MF |
779 | if test "x${build_warnings}" != x -a "x$GCC" = xyes |
780 | then | |
781 | AC_MSG_CHECKING(compiler warning flags) | |
782 | # Separate out the -Werror flag as some files just cannot be | |
783 | # compiled with it enabled. | |
784 | for w in ${build_warnings}; do | |
785 | case $w in | |
786 | -Werr*) WERROR_CFLAGS=-Werror ;; | |
787 | *) # Check that GCC accepts it | |
788 | saved_CFLAGS="$CFLAGS" | |
789 | CFLAGS="$CFLAGS $w" | |
790 | AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",) | |
791 | CFLAGS="$saved_CFLAGS" | |
792 | esac | |
793 | done | |
ac0aacdf | 794 | AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS}) |
9c082ca8 MF |
795 | fi |
796 | ]) | |
797 | AC_SUBST(WARN_CFLAGS) | |
798 | AC_SUBST(WERROR_CFLAGS) | |
799 | ||
800 | ||
801 | dnl Generate the Makefile in a target specific directory. | |
802 | dnl Substitutions aren't performed on the file in AC_SUBST_FILE, | |
803 | dnl so this is a cover macro to tuck the details away of how we cope. | |
804 | dnl We cope by having autoconf generate two files and then merge them into | |
805 | dnl one afterwards. The two pieces of the common fragment are inserted into | |
806 | dnl the target's fragment at the appropriate points. | |
807 | ||
808 | AC_DEFUN([SIM_AC_OUTPUT], | |
9c70334d MF |
809 | [dnl |
810 | AC_REQUIRE([SIM_AC_OPTION_WARNINGS])dnl | |
811 | ||
9c082ca8 MF |
812 | dnl Make @cgen_breaks@ non-null only if the sim uses CGEN. |
813 | cgen_breaks="" | |
814 | if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then | |
815 | cgen_breaks="break cgen_rtx_error"; | |
816 | fi | |
817 | AC_SUBST(cgen_breaks) | |
818 | AC_CONFIG_FILES(Makefile.sim:Makefile.in) | |
819 | AC_CONFIG_FILES(Make-common.sim:../common/Make-common.in) | |
820 | AC_CONFIG_FILES(.gdbinit:../common/gdbinit.in) | |
821 | AC_CONFIG_COMMANDS([Makefile], | |
822 | [echo "Merging Makefile.sim+Make-common.sim into Makefile ..." | |
823 | rm -f Makesim1.tmp Makesim2.tmp Makefile | |
824 | sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp | |
825 | sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp | |
826 | sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \ | |
827 | -e '/^## COMMON_POST_/ r Makesim2.tmp' \ | |
828 | <Makefile.sim >Makefile | |
829 | rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp | |
830 | ]) | |
831 | AC_CONFIG_COMMANDS([stamp-h], [echo > stamp-h]) | |
832 | AC_OUTPUT | |
833 | ]) | |
834 | ||
9c082ca8 MF |
835 | dnl --enable-cgen-maint support |
836 | AC_DEFUN([SIM_AC_OPTION_CGEN_MAINT], | |
837 | [ | |
838 | cgen_maint=no | |
839 | dnl Default is to use one in build tree. | |
840 | cgen=guile | |
841 | cgendir='$(srcdir)/../../cgen' | |
842 | dnl Having --enable-maintainer-mode take arguments is another way to go. | |
843 | dnl ??? One can argue --with is more appropriate if one wants to specify | |
844 | dnl a directory name, but what we're doing here is an enable/disable kind | |
845 | dnl of thing and specifying both --enable and --with is klunky. | |
846 | dnl If you reeely want this to be --with, go ahead and change it. | |
847 | AC_ARG_ENABLE(cgen-maint, | |
8d0978fb | 848 | [AS_HELP_STRING([--enable-cgen-maint[=DIR]], [build cgen generated files])], |
9c082ca8 MF |
849 | [case "${enableval}" in |
850 | yes) cgen_maint=yes ;; | |
851 | no) cgen_maint=no ;; | |
852 | *) | |
7fb45a68 AB |
853 | # Argument is a directory where cgen can be found. In some |
854 | # future world cgen could be installable, but right now this | |
855 | # is not the case. Instead we assume the directory is a path | |
856 | # to the cgen source tree. | |
857 | cgen_maint=yes | |
858 | if test -r ${enableval}/iformat.scm; then | |
859 | # This looks like a cgen source tree. | |
860 | cgendir=${enableval} | |
861 | else | |
862 | AC_MSG_ERROR(${enableval} doesn't look like a cgen source tree) | |
863 | fi | |
9c082ca8 MF |
864 | ;; |
865 | esac])dnl | |
866 | dnl AM_CONDITIONAL(CGEN_MAINT, test x${cgen_maint} != xno) | |
867 | if test x${cgen_maint} != xno ; then | |
868 | CGEN_MAINT='' | |
869 | else | |
870 | CGEN_MAINT='#' | |
871 | fi | |
872 | AC_SUBST(CGEN_MAINT) | |
873 | AC_SUBST(cgendir) | |
874 | AC_SUBST(cgen) | |
875 | ]) |