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