1 # This file contains common code used by all simulators.
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.
8 # See README-HACKING for more details.
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])
21 AC_DEFUN([SIM_AC_COMMON],
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)
27 AC_USE_SYSTEM_EXTENSIONS
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
40 AC_SUBST(CC_FOR_BUILD)
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!])], [:])
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"
58 ])], [AC_MSG_RESULT([yes])], [
60 AC_MSG_CHECKING([for -std=c11 support])
63 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
64 #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
65 # error "C11 support not found"
71 ], [AC_MSG_ERROR([C11 is required])])])
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
78 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package. ])
81 # Dependency checking.
83 ZW_PROG_COMPILER_DEPENDENCIES([CC])
85 # Check for the 'make' the user wants to use.
86 AC_CHECK_PROGS(MAKE, make)
88 case "`$MAKE --version 2>&1 | sed 1q`" in
93 AM_CONDITIONAL(GMAKE, test "$MAKE_IS_GNU" = yes)
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.
98 ZW_GNU_GETTEXT_SISTER_DIR(../../intl)
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>
116 #ifdef HAVE_SYS_STAT_H
117 #include <sys/stat.h>
119 AC_CHECK_TYPES(socklen_t, [], [],
120 [#include <sys/types.h>
121 #include <sys/socket.h>
124 # Check for socket libraries
125 AC_CHECK_LIB(socket, bind)
126 AC_CHECK_LIB(nsl, gethostbyname)
128 # BFD conditionally uses zlib, so we must link it in if libbfd does, by
129 # using the same condition.
132 # BFD uses libdl when when plugins enabled.
134 AM_CONDITIONAL(PLUGINS, test "$plugins" = yes)
136 AC_SUBST(lt_cv_dlopen_libs)
138 . ${srcdir}/../../bfd/configure.host
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.
147 dnl We don't use automake, but we still want to support
148 dnl --enable-maintainer-mode.
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])
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
162 *) sim_debug="($enableval)";;
164 if test "$sim_debug" != "0"; then
165 AC_DEFINE_UNQUOTED([DEBUG], [$sim_debug], [Sim debug setting])
167 AC_DEFINE_UNQUOTED([WITH_DEBUG], [$sim_debug], [Sim debug setting])
168 AC_MSG_RESULT($sim_debug)
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])
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]);;
183 AC_DEFINE_UNQUOTED([WITH_STDIO], [$sim_stdio], [How to route I/O])
184 AC_MSG_RESULT($sim_stdio)
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";;
201 sim_trace="'(${enableval})'";;
204 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
205 if test x"$sim_trace" = x; then
206 sim_trace="(TRACE_$x"
208 sim_trace="${sim_trace}|TRACE_$x"
211 sim_trace="$sim_trace)" ;;
213 AC_DEFINE_UNQUOTED([WITH_TRACE], [$sim_trace], [Sim trace settings])
214 AC_MSG_RESULT($sim_trace)
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])
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";;
231 profile="(${enableval})" sim_profile="(${enableval})";;
235 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
236 if test x"$sim_profile" = x; then
237 sim_profile="(PROFILE_$x"
239 sim_profile="${sim_profile}|PROFILE_$x"
242 sim_profile="$sim_profile)" ;;
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)
250 SIM_AC_OPTION_ENVIRONMENT
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])
258 dnl Types used by common code
261 dnl Detect exe extension
264 ]) dnl End of SIM_AC_COMMON
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.
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
279 dnl ??? Until there is demonstrable value in doing something more complicated,
281 AC_DEFUN([SIM_AC_OPTION_ENVIRONMENT],
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]);;
295 AC_DEFINE_UNQUOTED([WITH_ENVIRONMENT], [$sim_environment], [Sim default environment])
296 AC_MSG_RESULT($sim_environment)
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]"
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}"
318 if test x"$default_alignment" != x; then
319 sim_alignment="-DWITH_ALIGNMENT=${default_alignment}"
321 echo "No hard-wired alignment for target $target" 1>&6
322 sim_alignment="-DWITH_ALIGNMENT=0"
325 no) if test x"$default_alignment" != x; then
326 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
328 if test x"$wire_alignment" != x; then
329 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${wire_alignment}"
331 echo "No default alignment for target $target" 1>&6
332 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=0"
335 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment"); sim_alignment="";;
337 if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then
338 echo "Setting alignment flags = $sim_alignment" 6>&1
340 [if test x"$default_alignment" != x; then
341 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
343 if test x"$wire_alignment" != x; then
344 sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
350 AC_SUBST(sim_alignment)
353 dnl Conditionally compile in assertion statements.
354 AC_DEFUN([SIM_AC_OPTION_ASSERT],
356 AC_MSG_CHECKING([whether to enable sim asserts])
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";;
364 *) AC_MSG_ERROR([--enable-sim-assert does not take a value]);;
366 AC_DEFINE_UNQUOTED([WITH_ASSERT], [$sim_assert], [Sim assert settings])
367 AC_MSG_RESULT($sim_assert)
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]"
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)])],
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"
395 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0"
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"
400 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=0"
402 *) AC_MSG_ERROR("--enable-sim-bitsize was given $enableval. Expected 32 or 64") ;;
405 tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9]]*,*//"`
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") ;;
413 tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9*]]*,*[[0-9]]*,*//"`
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") ;;
420 if test x"$silent" != x"yes" && test x"$sim_bitsize" != x""; then
421 echo "Setting bitsize flags = $sim_bitsize" 6>&1
424 if test x"$wire_word_bitsize" != x; then
425 sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_BITSIZE=$wire_word_bitsize"
427 if test x"$wire_word_msb" != x; then
428 sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_MSB=$wire_word_msb"
430 if test x"$wire_address_bitsize" != x; then
431 sim_bitsize="$sim_bitsize -DWITH_TARGET_ADDRESS_BITSIZE=$wire_address_bitsize"
433 if test x"$wire_cell_bitsize" != x; then
434 sim_bitsize="$sim_bitsize -DWITH_TARGET_CELL_BITSIZE=$wire_cell_bitsize"
437 AC_SUBST(sim_bitsize)
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],
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}"
458 if test x"$default_endian" != x; then
459 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
461 echo "No hard-wired endian for target $target" 1>&6
462 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
465 no) if test x"$default_endian" != x; then
466 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
468 if test x"$wire_endian" != x; then
469 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
471 echo "No default endian for target $target" 1>&6
472 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
475 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
477 if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
478 echo "Setting endian flags = $sim_endian" 6>&1
480 [if test x"$default_endian" != x; then
481 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
483 if test x"$wire_endian" != x; then
484 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
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],
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="";;
512 if test x"$silent" != x"yes" && test x"$sim_float" != x""; then
513 echo "Setting float flags = $sim_float" 6>&1
516 if test x"${default_sim_float}" != x""; then
517 sim_float="-DWITH_FLOATING_POINT=${default_sim_float}"
519 if test x"${default_sim_float_bitsize}" != x""; then
520 sim_float="$sim_float -DWITH_TARGET_FLOATING_POINT_BITSIZE=${default_sim_float_bitsize}"
527 dnl The argument is the default cache size if none is specified.
528 AC_DEFUN([SIM_AC_OPTION_SCACHE],
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");
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}"])
548 dnl The argument is the default model if none is specified.
549 AC_DEFUN([SIM_AC_OPTION_DEFAULT_MODEL],
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}\"'";;
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}\"'"])
563 AC_SUBST(sim_default_model)
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],
575 hardware="cfi core pal glue"
577 hardware="$hardware [$3]"
579 sim_hw_cflags="-DWITH_HW=1"
581 sim_hw_objs="\$(SIM_COMMON_HW_OBJS) `echo $sim_hw | sed -e 's/\([[^ ]][[^ ]]*\)/dv-\1.o/g'`"
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
589 ,*) hardware="${hardware} `echo ${enableval} | sed -e 's/,/ /'`";;
590 *,) hardware="`echo ${enableval} | sed -e 's/,/ /'` ${hardware}";;
591 *) hardware="`echo ${enableval} | sed -e 's/,/ /'`"'';;
594 if test "$enable_sim_hardware" = no; then
596 sim_hw_cflags="-DWITH_HW=0"
599 sim_hw_cflags="-DWITH_HW=1"
602 sim_hw_objs="\$(SIM_COMMON_HW_OBJS)"
603 for i in $hardware ; do
606 *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";;
609 # mingw does not support sockser
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"
617 [HAVE_DV_SOCKSER], 1, [Define if dv-sockser is usable.])
620 if test x"$silent" != x"yes"; then
621 echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
623 dnl Some devices require extra libraries.
624 case " $hardware " in
625 *" cfi "*) AC_CHECK_LIB(m, log2);;
629 AC_SUBST(sim_hw_cflags)
630 AC_SUBST(sim_hw_objs)
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],
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])],
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
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";;
657 if test x"$sim_inline" = x""; then
658 sim_inline="$new_flag"
660 sim_inline="$sim_inline $new_flag"
664 if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
665 echo "Setting inline flags = $sim_inline" 6>&1
671 AC_DEFUN([SIM_AC_OPTION_RESERVED_BITS],
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="";;
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
686 AC_SUBST(sim_reserved_bits)
689 AC_DEFUN([SIM_AC_OPTION_SMP],
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
700 *) sim_smp="$enableval";;
702 sim_igen_smp="-N ${sim_smp}"
703 AC_DEFINE_UNQUOTED([WITH_SMP], [$sim_smp], [Sim SMP settings])
704 AC_MSG_RESULT($sim_smp)
708 AC_DEFUN([SIM_AC_OPTION_XOR_ENDIAN],
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";;
721 AC_DEFINE_UNQUOTED([WITH_XOR_ENDIAN], [$sim_xor_endian], [Sim XOR endian settings])
722 AC_MSG_RESULT($sim_smp)
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],
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) ;;
739 # Enable -Werror by default when using gcc
740 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
745 m4_if(m4_default([$1], [yes]), [yes], [dnl
746 if test "${ERROR_ON_WARNING}" = yes ; then
747 WERROR_CFLAGS="-Werror"
751 build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
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"
758 # Enable -Wno-format by default when using gcc on mingw since many
759 # GCC versions complain about %I64.
761 *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;;
762 *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
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
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"`;;
776 if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
777 echo "Setting compiler warning flags = $build_warnings" 6>&1
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
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"`;;
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
794 if test "x${build_warnings}" != x -a "x$GCC" = xyes
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
801 -Werr*) WERROR_CFLAGS=-Werror ;;
802 *) # Check that GCC accepts it
803 saved_CFLAGS="$CFLAGS"
805 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
806 CFLAGS="$saved_CFLAGS"
809 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
812 AC_SUBST(WARN_CFLAGS)
813 AC_SUBST(WERROR_CFLAGS)
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.
823 AC_DEFUN([SIM_AC_OUTPUT],
825 AC_REQUIRE([SIM_AC_OPTION_WARNINGS])dnl
827 dnl Make @cgen_breaks@ non-null only if the sim uses CGEN.
829 if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
830 cgen_breaks="break cgen_rtx_error";
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
846 AC_CONFIG_COMMANDS([stamp-h], [echo > stamp-h])
850 sinclude(../../config/gettext-sister.m4)
851 sinclude(../../config/acx.m4)
853 dnl --enable-cgen-maint support
854 AC_DEFUN([SIM_AC_OPTION_CGEN_MAINT],
857 dnl Default is to use one in build tree.
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 ;;
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.
876 if test -r ${enableval}/iformat.scm; then
877 # This looks like a cgen source tree.
880 AC_MSG_ERROR(${enableval} doesn't look like a cgen source tree)
884 dnl AM_CONDITIONAL(CGEN_MAINT, test x${cgen_maint} != xno)
885 if test x${cgen_maint} != xno ; then