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)
47 # Require C11 or newer. Autoconf-2.70 provides ac_cv_prog_cc_c11 when using
48 # AC_PROG_CC, but we're still using Autoconf-2.69, and the newest it understands
49 # is C99. So handle it ourselves.
50 m4_version_prereq([2.70], [AC_MSG_ERROR([clean this up!])], [:])
52 AC_MSG_CHECKING([whether C11 is supported by default])
53 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
54 #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
55 # error "C11 support not found"
57 ])], [AC_MSG_RESULT([yes])], [
59 AC_MSG_CHECKING([for -std=c11 support])
62 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
63 #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
64 # error "C11 support not found"
70 ], [AC_MSG_ERROR([C11 is required])])])
73 # Some of the common include files depend on bfd.h, and bfd.h checks
74 # that config.h is included first by testing that the PACKAGE macro
77 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package. ])
80 # Dependency checking.
82 ZW_PROG_COMPILER_DEPENDENCIES([CC])
84 # Check for the 'make' the user wants to use.
85 AC_CHECK_PROGS(MAKE, make)
87 case "`$MAKE --version 2>&1 | sed 1q`" in
92 AM_CONDITIONAL(GMAKE, test "$MAKE_IS_GNU" = yes)
94 dnl We don't use gettext, but bfd does. So we do the appropriate checks
95 dnl to see if there are intl libraries we should link against.
97 ZW_GNU_GETTEXT_SISTER_DIR(../../intl)
99 # Check for common headers.
100 # NB: You can assume C11 headers exist.
101 AC_CHECK_HEADERS(unistd.h)
102 AC_CHECK_HEADERS(sys/time.h sys/times.h sys/resource.h sys/mman.h)
103 AC_CHECK_HEADERS(fcntl.h fpu_control.h)
104 AC_CHECK_HEADERS(dlfcn.h sys/stat.h)
105 AC_CHECK_FUNCS(getrusage time sigaction __setfpucw)
106 AC_CHECK_FUNCS(mmap munmap lstat truncate ftruncate posix_fallocate)
107 AC_CHECK_MEMBERS([[struct stat.st_dev], [struct stat.st_ino],
108 [struct stat.st_mode], [struct stat.st_nlink], [struct stat.st_uid],
109 [struct stat.st_gid], [struct stat.st_rdev], [struct stat.st_size],
110 [struct stat.st_blksize], [struct stat.st_blocks], [struct stat.st_atime],
111 [struct stat.st_mtime], [struct stat.st_ctime]], [], [],
112 [[#ifdef HAVE_SYS_TYPES_H
113 #include <sys/types.h>
115 #ifdef HAVE_SYS_STAT_H
116 #include <sys/stat.h>
118 AC_CHECK_TYPES(socklen_t, [], [],
119 [#include <sys/types.h>
120 #include <sys/socket.h>
123 # Check for socket libraries
124 AC_CHECK_LIB(socket, bind)
125 AC_CHECK_LIB(nsl, gethostbyname)
127 # BFD conditionally uses zlib, so we must link it in if libbfd does, by
128 # using the same condition.
131 # BFD uses libdl when when plugins enabled.
133 AM_CONDITIONAL(PLUGINS, test "$plugins" = yes)
135 AC_SUBST(lt_cv_dlopen_libs)
137 dnl Standard (and optional) simulator options.
138 dnl Eventually all simulators will support these.
139 dnl Do not add any here that cannot be supported by all simulators.
140 dnl Do not add similar but different options to a particular simulator,
141 dnl all shall eventually behave the same way.
144 dnl We don't use automake, but we still want to support
145 dnl --enable-maintainer-mode.
149 dnl --enable-sim-debug is for developers of the simulator
150 dnl the allowable values are work-in-progress
151 AC_MSG_CHECKING([for sim debug setting])
153 AC_ARG_ENABLE(sim-debug,
154 [AS_HELP_STRING([--enable-sim-debug=opts],
155 [Enable debugging flags (for developers of the sim itself)])],
156 [case "${enableval}" in
159 *) sim_debug="($enableval)";;
161 if test "$sim_debug" != "0"; then
162 AC_DEFINE_UNQUOTED([DEBUG], [$sim_debug], [Sim debug setting])
164 AC_DEFINE_UNQUOTED([WITH_DEBUG], [$sim_debug], [Sim debug setting])
165 AC_MSG_RESULT($sim_debug)
168 dnl --enable-sim-stdio is for users of the simulator
169 dnl It determines if IO from the program is routed through STDIO (buffered)
170 AC_MSG_CHECKING([for sim stdio debug behavior])
172 AC_ARG_ENABLE(sim-stdio,
173 [AS_HELP_STRING([--enable-sim-stdio],
174 [Specify whether to use stdio for console input/output])],
175 [case "${enableval}" in
176 yes) sim_stdio="DO_USE_STDIO";;
177 no) sim_stdio="DONT_USE_STDIO";;
178 *) AC_MSG_ERROR([Unknown value $enableval passed to --enable-sim-stdio]);;
180 AC_DEFINE_UNQUOTED([WITH_STDIO], [$sim_stdio], [How to route I/O])
181 AC_MSG_RESULT($sim_stdio)
184 dnl --enable-sim-trace is for users of the simulator
185 dnl The argument is either a bitmask of things to enable [exactly what is
186 dnl up to the simulator], or is a comma separated list of names of tracing
187 dnl elements to enable. The latter is only supported on simulators that
188 dnl use WITH_TRACE. Default to all tracing but internal debug.
189 AC_MSG_CHECKING([for sim trace settings])
190 sim_trace="~TRACE_debug"
191 AC_ARG_ENABLE(sim-trace,
192 [AS_HELP_STRING([--enable-sim-trace=opts],
193 [Enable tracing of simulated programs])],
194 [case "${enableval}" in
195 yes) sim_trace="-1";;
198 sim_trace="'(${enableval})'";;
201 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
202 if test x"$sim_trace" = x; then
203 sim_trace="(TRACE_$x"
205 sim_trace="${sim_trace}|TRACE_$x"
208 sim_trace="$sim_trace)" ;;
210 AC_DEFINE_UNQUOTED([WITH_TRACE], [$sim_trace], [Sim trace settings])
211 AC_MSG_RESULT($sim_trace)
214 dnl --enable-sim-profile
215 dnl The argument is either a bitmask of things to enable [exactly what is
216 dnl up to the simulator], or is a comma separated list of names of profiling
217 dnl elements to enable. The latter is only supported on simulators that
218 dnl use WITH_PROFILE.
219 AC_MSG_CHECKING([for sim profile settings])
222 AC_ARG_ENABLE(sim-profile,
223 [AS_HELP_STRING([--enable-sim-profile=opts], [Enable profiling flags])],
224 [case "${enableval}" in
225 yes) profile="1" sim_profile="-1";;
226 no) profile="0" sim_profile="0";;
228 profile="(${enableval})" sim_profile="(${enableval})";;
232 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
233 if test x"$sim_profile" = x; then
234 sim_profile="(PROFILE_$x"
236 sim_profile="${sim_profile}|PROFILE_$x"
239 sim_profile="$sim_profile)" ;;
241 AC_DEFINE_UNQUOTED([PROFILE], [$profile], [Sim profile settings])
242 AC_DEFINE_UNQUOTED([WITH_PROFILE], [$sim_profile], [Sim profile settings])
243 AC_MSG_RESULT($sim_profile)
247 SIM_AC_OPTION_ENVIRONMENT
250 ACX_PKGVERSION([SIM])
251 ACX_BUGURL([https://www.gnu.org/software/gdb/bugs/])
252 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
253 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
255 dnl Types used by common code
258 dnl Detect exe extension
261 ]) dnl End of SIM_AC_COMMON
264 dnl Additional SIM options that can (optionally) be configured
265 dnl For optional simulator options, a macro SIM_AC_OPTION_* is defined.
266 dnl Simulators that wish to use the relevant option specify the macro
267 dnl in the simulator specific configure.ac file between the SIM_AC_COMMON
268 dnl and SIM_AC_OUTPUT lines.
271 dnl Specify the running environment.
272 dnl If the simulator invokes this in its configure.ac then without this option
273 dnl the default is the user environment and all are runtime selectable.
274 dnl If the simulator doesn't invoke this, only the user environment is
276 dnl ??? Until there is demonstrable value in doing something more complicated,
278 AC_DEFUN([SIM_AC_OPTION_ENVIRONMENT],
280 AC_MSG_CHECKING([default sim environment setting])
281 sim_environment="ALL_ENVIRONMENT"
282 AC_ARG_ENABLE(sim-environment,
283 [AS_HELP_STRING([--enable-sim-environment=environment],
284 [Specify mixed, user, virtual or operating environment])],
285 [case "${enableval}" in
286 all | ALL) sim_environment="ALL_ENVIRONMENT";;
287 user | USER) sim_environment="USER_ENVIRONMENT";;
288 virtual | VIRTUAL) sim_environment="VIRTUAL_ENVIRONMENT";;
289 operating | OPERATING) sim_environment="OPERATING_ENVIRONMENT";;
290 *) AC_MSG_ERROR([Unknown value $enableval passed to --enable-sim-environment]);;
292 AC_DEFINE_UNQUOTED([WITH_ENVIRONMENT], [$sim_environment], [Sim default environment])
293 AC_MSG_RESULT($sim_environment)
297 dnl Specify the alignment restrictions of the target architecture.
298 dnl Without this option all possible alignment restrictions are accommodated.
299 dnl arg[1] is hardwired target alignment
300 dnl arg[2] is default target alignment
301 AC_DEFUN([SIM_AC_OPTION_ALIGNMENT],
302 wire_alignment="[$1]"
303 default_alignment="[$2]"
305 AC_ARG_ENABLE(sim-alignment,
306 [AS_HELP_STRING([--enable-sim-alignment=align],
307 [Specify strict, nonstrict or forced alignment of memory accesses])],
308 [case "${enableval}" in
309 strict | STRICT) sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";;
310 nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";;
311 forced | FORCED) sim_alignment="-DWITH_ALIGNMENT=FORCED_ALIGNMENT";;
312 yes) if test x"$wire_alignment" != x; then
313 sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
315 if test x"$default_alignment" != x; then
316 sim_alignment="-DWITH_ALIGNMENT=${default_alignment}"
318 echo "No hard-wired alignment for target $target" 1>&6
319 sim_alignment="-DWITH_ALIGNMENT=0"
322 no) if test x"$default_alignment" != x; then
323 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
325 if test x"$wire_alignment" != x; then
326 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${wire_alignment}"
328 echo "No default alignment for target $target" 1>&6
329 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=0"
332 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment"); sim_alignment="";;
334 if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then
335 echo "Setting alignment flags = $sim_alignment" 6>&1
337 [if test x"$default_alignment" != x; then
338 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
340 if test x"$wire_alignment" != x; then
341 sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
347 AC_SUBST(sim_alignment)
350 dnl Conditionally compile in assertion statements.
351 AC_DEFUN([SIM_AC_OPTION_ASSERT],
353 AC_MSG_CHECKING([whether to enable sim asserts])
355 AC_ARG_ENABLE(sim-assert,
356 [AS_HELP_STRING([--enable-sim-assert],
357 [Specify whether to perform random assertions])],
358 [case "${enableval}" in
359 yes) sim_assert="1";;
361 *) AC_MSG_ERROR([--enable-sim-assert does not take a value]);;
363 AC_DEFINE_UNQUOTED([WITH_ASSERT], [$sim_assert], [Sim assert settings])
364 AC_MSG_RESULT($sim_assert)
369 dnl --enable-sim-bitsize is for developers of the simulator
370 dnl It specifies the number of BITS in the target.
371 dnl arg[1] is the number of bits in a word
372 dnl arg[2] is the number assigned to the most significant bit
373 dnl arg[3] is the number of bits in an address
374 dnl arg[4] is the number of bits in an OpenFirmware cell.
375 dnl FIXME: this information should be obtained from bfd/archure
376 AC_DEFUN([SIM_AC_OPTION_BITSIZE],
377 wire_word_bitsize="[$1]"
379 wire_address_bitsize="[$3]"
380 wire_cell_bitsize="[$4]"
381 [AC_ARG_ENABLE(sim-bitsize,
382 [AS_HELP_STRING([--enable-sim-bitsize=N], [Specify target bitsize (32 or 64)])],
384 case "${enableval}" in
385 64,63 | 64,63,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63";;
386 32,31 | 32,31,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31";;
387 64,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";;
388 32,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";;
389 32) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then
390 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31"
392 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0"
394 64) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then
395 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63"
397 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=0"
399 *) AC_MSG_ERROR("--enable-sim-bitsize was given $enableval. Expected 32 or 64") ;;
402 tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9]]*,*//"`
405 x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=32" ;;
406 x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=64" ;;
407 * ) AC_MSG_ERROR("--enable-sim-bitsize was given address size $enableval. Expected 32 or 64") ;;
410 tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9*]]*,*[[0-9]]*,*//"`
413 x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=32" ;;
414 x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=64" ;;
415 * ) AC_MSG_ERROR("--enable-sim-bitsize was given cell size $enableval. Expected 32 or 64") ;;
417 if test x"$silent" != x"yes" && test x"$sim_bitsize" != x""; then
418 echo "Setting bitsize flags = $sim_bitsize" 6>&1
421 if test x"$wire_word_bitsize" != x; then
422 sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_BITSIZE=$wire_word_bitsize"
424 if test x"$wire_word_msb" != x; then
425 sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_MSB=$wire_word_msb"
427 if test x"$wire_address_bitsize" != x; then
428 sim_bitsize="$sim_bitsize -DWITH_TARGET_ADDRESS_BITSIZE=$wire_address_bitsize"
430 if test x"$wire_cell_bitsize" != x; then
431 sim_bitsize="$sim_bitsize -DWITH_TARGET_CELL_BITSIZE=$wire_cell_bitsize"
434 AC_SUBST(sim_bitsize)
438 dnl --enable-sim-endian={yes,no,big,little} is for simulators
439 dnl that support both big and little endian targets.
440 dnl arg[1] is hardwired target endianness.
441 dnl arg[2] is default target endianness.
442 AC_DEFUN([SIM_AC_OPTION_ENDIAN],
445 default_endian="[$2]"
446 AC_ARG_ENABLE(sim-endian,
447 [AS_HELP_STRING([--enable-sim-endian=endian],
448 [Specify target byte endian orientation])],
449 [case "${enableval}" in
450 b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_BIG";;
451 l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_LITTLE";;
452 yes) if test x"$wire_endian" != x; then
453 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
455 if test x"$default_endian" != x; then
456 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
458 echo "No hard-wired endian for target $target" 1>&6
459 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
462 no) if test x"$default_endian" != x; then
463 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
465 if test x"$wire_endian" != x; then
466 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
468 echo "No default endian for target $target" 1>&6
469 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
472 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
474 if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
475 echo "Setting endian flags = $sim_endian" 6>&1
477 [if test x"$default_endian" != x; then
478 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
480 if test x"$wire_endian" != x; then
481 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
490 dnl --enable-sim-float is for developers of the simulator
491 dnl It specifies the presence of hardware floating point
492 dnl And optionally the bitsize of the floating point register.
493 dnl arg[1] specifies the presence (or absence) of floating point hardware
494 dnl arg[2] specifies the number of bits in a floating point register
495 AC_DEFUN([SIM_AC_OPTION_FLOAT],
497 default_sim_float="[$1]"
498 default_sim_float_bitsize="[$2]"
499 AC_ARG_ENABLE(sim-float,
500 [AS_HELP_STRING([--enable-sim-float],
501 [Specify that the target processor has floating point hardware])],
502 [case "${enableval}" in
503 yes | hard) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";;
504 no | soft) sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";;
505 32) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=32";;
506 64) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=64";;
507 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-float"); sim_float="";;
509 if test x"$silent" != x"yes" && test x"$sim_float" != x""; then
510 echo "Setting float flags = $sim_float" 6>&1
513 if test x"${default_sim_float}" != x""; then
514 sim_float="-DWITH_FLOATING_POINT=${default_sim_float}"
516 if test x"${default_sim_float_bitsize}" != x""; then
517 sim_float="$sim_float -DWITH_TARGET_FLOATING_POINT_BITSIZE=${default_sim_float_bitsize}"
524 dnl The argument is the default cache size if none is specified.
525 AC_DEFUN([SIM_AC_OPTION_SCACHE],
527 default_sim_scache="ifelse([$1],,0,[$1])"
528 AC_ARG_ENABLE(sim-scache,
529 [AS_HELP_STRING([--enable-sim-scache=size],
530 [Specify simulator execution cache size])],
531 [case "${enableval}" in
532 yes) sim_scache="-DWITH_SCACHE=${default_sim_scache}";;
533 no) sim_scache="-DWITH_SCACHE=0" ;;
534 [[0-9]]*) sim_scache="-DWITH_SCACHE=${enableval}";;
535 *) AC_MSG_ERROR("Bad value $enableval passed to --enable-sim-scache");
538 if test x"$silent" != x"yes" && test x"$sim_scache" != x""; then
539 echo "Setting scache size = $sim_scache" 6>&1
540 fi],[sim_scache="-DWITH_SCACHE=${default_sim_scache}"])
545 dnl The argument is the default model if none is specified.
546 AC_DEFUN([SIM_AC_OPTION_DEFAULT_MODEL],
548 default_sim_default_model="ifelse([$1],,0,[$1])"
549 AC_ARG_ENABLE(sim-default-model,
550 [AS_HELP_STRING([--enable-sim-default-model=model],
551 [Specify default model to simulate])],
552 [case "${enableval}" in
553 yes|no) AC_MSG_ERROR("Missing argument to --enable-sim-default-model");;
554 *) sim_default_model="-DWITH_DEFAULT_MODEL='\"${enableval}\"'";;
556 if test x"$silent" != x"yes" && test x"$sim_default_model" != x""; then
557 echo "Setting default model = $sim_default_model" 6>&1
558 fi],[sim_default_model="-DWITH_DEFAULT_MODEL='\"${default_sim_default_model}\"'"])
560 AC_SUBST(sim_default_model)
563 dnl --enable-sim-hardware is for users of the simulator
564 dnl arg[1] Enable sim-hw by default? ("yes" or "no")
565 dnl arg[2] is a space separated list of devices that override the defaults
566 dnl arg[3] is a space separated list of extra target specific devices.
567 AC_DEFUN([SIM_AC_OPTION_HARDWARE],
572 hardware="cfi core pal glue"
574 hardware="$hardware [$3]"
576 sim_hw_cflags="-DWITH_HW=1"
578 sim_hw_objs="\$(SIM_COMMON_HW_OBJS) `echo $sim_hw | sed -e 's/\([[^ ]][[^ ]]*\)/dv-\1.o/g'`"
580 AC_ARG_ENABLE(sim-hardware,
581 [AS_HELP_STRING([--enable-sim-hardware=LIST],
582 [Specify the hardware to be included in the build.])],
583 ,[enable_sim_hardware="[$1]"])
584 case ${enable_sim_hardware} in
586 ,*) hardware="${hardware} `echo ${enableval} | sed -e 's/,/ /'`";;
587 *,) hardware="`echo ${enableval} | sed -e 's/,/ /'` ${hardware}";;
588 *) hardware="`echo ${enableval} | sed -e 's/,/ /'`"'';;
591 if test "$enable_sim_hardware" = no; then
593 sim_hw_cflags="-DWITH_HW=0"
596 sim_hw_cflags="-DWITH_HW=1"
599 sim_hw_objs="\$(SIM_COMMON_HW_OBJS)"
600 for i in $hardware ; do
603 *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";;
606 # mingw does not support sockser
609 *) # TODO: We don't add dv-sockser to sim_hw as it is not a "real" device
610 # that you instatiate. Instead, other code will call into it directly.
611 # At some point, we should convert it over.
612 sim_hw_objs="$sim_hw_objs dv-sockser.o"
614 [HAVE_DV_SOCKSER], 1, [Define if dv-sockser is usable.])
617 if test x"$silent" != x"yes"; then
618 echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
620 dnl Some devices require extra libraries.
621 case " $hardware " in
622 *" cfi "*) AC_CHECK_LIB(m, log2);;
626 AC_SUBST(sim_hw_cflags)
627 AC_SUBST(sim_hw_objs)
631 dnl --enable-sim-inline is for users that wish to ramp up the simulator's
632 dnl performance by inlining functions.
633 dnl Default sims to no inlining.
634 AC_DEFUN([SIM_AC_OPTION_INLINE],
636 sim_inline="-DDEFAULT_INLINE=m4_ifblank([$1],[0],[$1])"
637 AC_ARG_ENABLE(sim-inline,
638 [AS_HELP_STRING([--enable-sim-inline=inlines],
639 [Specify which functions should be inlined])],
642 no) sim_inline="-DDEFAULT_INLINE=0";;
643 0) sim_inline="-DDEFAULT_INLINE=0";;
644 yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_C_INLINE";;
645 1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";;
646 *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
649 *_INLINE=*) new_flag="-D$x";;
650 *=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;;
651 *_INLINE) new_flag="-D$x=ALL_C_INLINE";;
652 *) new_flag="-D$x""_INLINE=ALL_C_INLINE";;
654 if test x"$sim_inline" = x""; then
655 sim_inline="$new_flag"
657 sim_inline="$sim_inline $new_flag"
661 if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
662 echo "Setting inline flags = $sim_inline" 6>&1
668 AC_DEFUN([SIM_AC_OPTION_RESERVED_BITS],
670 default_sim_reserved_bits="ifelse([$1],,1,[$1])"
671 AC_ARG_ENABLE(sim-reserved-bits,
672 [AS_HELP_STRING([--enable-sim-reserved-bits],
673 [Specify whether to check reserved bits in instruction])],
674 [case "${enableval}" in
675 yes) sim_reserved_bits="-DWITH_RESERVED_BITS=1";;
676 no) sim_reserved_bits="-DWITH_RESERVED_BITS=0";;
677 *) AC_MSG_ERROR("--enable-sim-reserved-bits does not take a value"); sim_reserved_bits="";;
679 if test x"$silent" != x"yes" && test x"$sim_reserved_bits" != x""; then
680 echo "Setting reserved flags = $sim_reserved_bits" 6>&1
681 fi],[sim_reserved_bits="-DWITH_RESERVED_BITS=${default_sim_reserved_bits}"])dnl
683 AC_SUBST(sim_reserved_bits)
686 AC_DEFUN([SIM_AC_OPTION_SMP],
688 AC_MSG_CHECKING([number of sim cpus to support])
689 default_sim_smp="ifelse([$1],,5,[$1])"
690 sim_smp="$default_sim_smp""
691 AC_ARG_ENABLE(sim-smp,
692 [AS_HELP_STRING([--enable-sim-smp=n],
693 [Specify number of processors to configure for (default ${default_sim_smp})])],
694 [case "${enableval}" in
697 *) sim_smp="$enableval";;
699 sim_igen_smp="-N ${sim_smp}"
700 AC_DEFINE_UNQUOTED([WITH_SMP], [$sim_smp], [Sim SMP settings])
701 AC_MSG_RESULT($sim_smp)
705 AC_DEFUN([SIM_AC_OPTION_XOR_ENDIAN],
707 AC_MSG_CHECKING([for xor endian support])
708 default_sim_xor_endian="ifelse([$1],,8,[$1])"
709 sim_xor_endian="$default_sim_xor_endian"
710 AC_ARG_ENABLE(sim-xor-endian,
711 [AS_HELP_STRING([--enable-sim-xor-endian=n],
712 [Specify number bytes involved in XOR bi-endian mode (default ${default_sim_xor_endian})])],
713 [case "${enableval}" in
714 yes) sim_xor_endian="8";;
715 no) sim_xor_endian="0";;
716 *) sim_xor_endian="$enableval";;
718 AC_DEFINE_UNQUOTED([WITH_XOR_ENDIAN], [$sim_xor_endian], [Sim XOR endian settings])
719 AC_MSG_RESULT($sim_smp)
723 dnl --enable-build-warnings is for developers of the simulator.
724 dnl it enables extra GCC specific warnings.
725 dnl arg[1] Enable -Werror by default? ("yes" or "no")
726 AC_DEFUN([SIM_AC_OPTION_WARNINGS],
728 AC_ARG_ENABLE(werror,
729 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
730 [case "${enableval}" in
731 yes | y) ERROR_ON_WARNING="yes" ;;
732 no | n) ERROR_ON_WARNING="no" ;;
733 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
736 # Enable -Werror by default when using gcc
737 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
742 m4_if(m4_default([$1], [yes]), [yes], [dnl
743 if test "${ERROR_ON_WARNING}" = yes ; then
744 WERROR_CFLAGS="-Werror"
748 build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
750 -Wno-unused -Wunused-value -Wunused-function \
751 -Wno-switch -Wno-char-subscripts -Wmissing-prototypes
752 -Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \
753 -Wold-style-declaration -Wold-style-definition"
755 # Enable -Wno-format by default when using gcc on mingw since many
756 # GCC versions complain about %I64.
758 *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;;
759 *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
762 AC_ARG_ENABLE(build-warnings,
763 AS_HELP_STRING([--enable-build-warnings], [enable build-time compiler warnings if gcc is used]),
764 [case "${enableval}" in
766 no) build_warnings="-w";;
767 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
768 build_warnings="${build_warnings} ${t}";;
769 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
770 build_warnings="${t} ${build_warnings}";;
771 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
773 if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
774 echo "Setting compiler warning flags = $build_warnings" 6>&1
776 AC_ARG_ENABLE(sim-build-warnings,
777 AS_HELP_STRING([--enable-sim-build-warnings], [enable SIM specific build-time compiler warnings if gcc is used]),
778 [case "${enableval}" in
780 no) build_warnings="-w";;
781 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
782 build_warnings="${build_warnings} ${t}";;
783 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
784 build_warnings="${t} ${build_warnings}";;
785 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
787 if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
788 echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
791 if test "x${build_warnings}" != x -a "x$GCC" = xyes
793 AC_MSG_CHECKING(compiler warning flags)
794 # Separate out the -Werror flag as some files just cannot be
795 # compiled with it enabled.
796 for w in ${build_warnings}; do
798 -Werr*) WERROR_CFLAGS=-Werror ;;
799 *) # Check that GCC accepts it
800 saved_CFLAGS="$CFLAGS"
802 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
803 CFLAGS="$saved_CFLAGS"
806 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
809 AC_SUBST(WARN_CFLAGS)
810 AC_SUBST(WERROR_CFLAGS)
813 dnl Generate the Makefile in a target specific directory.
814 dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
815 dnl so this is a cover macro to tuck the details away of how we cope.
816 dnl We cope by having autoconf generate two files and then merge them into
817 dnl one afterwards. The two pieces of the common fragment are inserted into
818 dnl the target's fragment at the appropriate points.
820 AC_DEFUN([SIM_AC_OUTPUT],
822 AC_REQUIRE([SIM_AC_OPTION_WARNINGS])dnl
824 dnl Make @cgen_breaks@ non-null only if the sim uses CGEN.
826 if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
827 cgen_breaks="break cgen_rtx_error";
829 AC_SUBST(cgen_breaks)
830 AC_CONFIG_FILES(Makefile.sim:Makefile.in)
831 AC_CONFIG_FILES(Make-common.sim:../common/Make-common.in)
832 AC_CONFIG_FILES(.gdbinit:../common/gdbinit.in)
833 AC_CONFIG_COMMANDS([Makefile],
834 [echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
835 rm -f Makesim1.tmp Makesim2.tmp Makefile
836 sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
837 sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
838 sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
839 -e '/^## COMMON_POST_/ r Makesim2.tmp' \
840 <Makefile.sim >Makefile
841 rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
843 AC_CONFIG_COMMANDS([stamp-h], [echo > stamp-h])
847 sinclude(../../config/gettext-sister.m4)
848 sinclude(../../config/acx.m4)
850 dnl --enable-cgen-maint support
851 AC_DEFUN([SIM_AC_OPTION_CGEN_MAINT],
854 dnl Default is to use one in build tree.
856 cgendir='$(srcdir)/../../cgen'
857 dnl Having --enable-maintainer-mode take arguments is another way to go.
858 dnl ??? One can argue --with is more appropriate if one wants to specify
859 dnl a directory name, but what we're doing here is an enable/disable kind
860 dnl of thing and specifying both --enable and --with is klunky.
861 dnl If you reeely want this to be --with, go ahead and change it.
862 AC_ARG_ENABLE(cgen-maint,
863 [AS_HELP_STRING([--enable-cgen-maint[=DIR]], [build cgen generated files])],
864 [case "${enableval}" in
865 yes) cgen_maint=yes ;;
868 # Argument is a directory where cgen can be found. In some
869 # future world cgen could be installable, but right now this
870 # is not the case. Instead we assume the directory is a path
871 # to the cgen source tree.
873 if test -r ${enableval}/iformat.scm; then
874 # This looks like a cgen source tree.
877 AC_MSG_ERROR(${enableval} doesn't look like a cgen source tree)
881 dnl AM_CONDITIONAL(CGEN_MAINT, test x${cgen_maint} != xno)
882 if test x${cgen_maint} != xno ; then