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 # The simulator's configure.ac should look like:
10 # dnl Process this file with autoconf to produce a configure script.
12 # AC_INIT(Makefile.in)
13 # sinclude(../common/aclocal.m4)
17 # ... target specific stuff ...
21 # Include global overrides and fixes for Autoconf.
22 m4_include(../../config/override.m4)
23 sinclude([../../config/zlib.m4])
24 m4_include([../../config/plugins.m4])
25 m4_include([../../libtool.m4])
26 m4_include([../../ltoptions.m4])
27 m4_include([../../ltsugar.m4])
28 m4_include([../../ltversion.m4])
29 m4_include([../../lt~obsolete.m4])
30 sinclude([../../config/depstand.m4])
32 AC_DEFUN([SIM_AC_COMMON],
34 AC_REQUIRE([AC_PROG_CC])
35 # autoconf.info says this should be called right after AC_INIT.
36 AC_CONFIG_HEADER(ifelse([$1],,config.h,[$1]):config.in)
38 AC_USE_SYSTEM_EXTENSIONS
43 # Put a plausible default for CC_FOR_BUILD in Makefile.
44 if test "x$cross_compiling" = "xno"; then
49 AC_SUBST(CC_FOR_BUILD)
57 # Some of the common include files depend on bfd.h, and bfd.h checks
58 # that config.h is included first by testing that the PACKAGE macro
61 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package. ])
64 # Dependency checking.
66 ZW_PROG_COMPILER_DEPENDENCIES([CC])
68 # Check for the 'make' the user wants to use.
69 AC_CHECK_PROGS(MAKE, make)
71 case "`$MAKE --version 2>&1 | sed 1q`" in
76 AM_CONDITIONAL(GMAKE, test "$MAKE_IS_GNU" = yes)
78 dnl We don't use gettext, but bfd does. So we do the appropriate checks
79 dnl to see if there are intl libraries we should link against.
81 ZW_GNU_GETTEXT_SISTER_DIR(../../intl)
83 # Check for common headers.
84 # FIXME: Seems to me this can cause problems for i386-windows hosts.
85 # At one point there were hardcoded AC_DEFINE's if ${host} = i386-*-windows*.
86 AC_CHECK_HEADERS(stdlib.h string.h strings.h unistd.h time.h)
87 AC_CHECK_HEADERS(sys/time.h sys/times.h sys/resource.h sys/mman.h)
88 AC_CHECK_HEADERS(fcntl.h fpu_control.h)
89 AC_CHECK_HEADERS(dlfcn.h errno.h sys/stat.h)
90 AC_CHECK_FUNCS(getrusage time sigaction __setfpucw)
91 AC_CHECK_FUNCS(mmap munmap lstat truncate ftruncate posix_fallocate)
92 AC_CHECK_MEMBERS([[struct stat.st_dev], [struct stat.st_ino],
93 [struct stat.st_mode], [struct stat.st_nlink], [struct stat.st_uid],
94 [struct stat.st_gid], [struct stat.st_rdev], [struct stat.st_size],
95 [struct stat.st_blksize], [struct stat.st_blocks], [struct stat.st_atime],
96 [struct stat.st_mtime], [struct stat.st_ctime]], [], [],
97 [[#ifdef HAVE_SYS_TYPES_H
98 #include <sys/types.h>
100 #ifdef HAVE_SYS_STAT_H
101 #include <sys/stat.h>
103 AC_CHECK_TYPES(socklen_t, [], [],
104 [#include <sys/types.h>
105 #include <sys/socket.h>
108 # Check for socket libraries
109 AC_CHECK_LIB(socket, bind)
110 AC_CHECK_LIB(nsl, gethostbyname)
112 # BFD conditionally uses zlib, so we must link it in if libbfd does, by
113 # using the same condition.
116 # BFD uses libdl when when plugins enabled.
118 AM_CONDITIONAL(PLUGINS, test "$plugins" = yes)
120 AC_SUBST(lt_cv_dlopen_libs)
122 . ${srcdir}/../../bfd/configure.host
124 dnl Standard (and optional) simulator options.
125 dnl Eventually all simulators will support these.
126 dnl Do not add any here that cannot be supported by all simulators.
127 dnl Do not add similar but different options to a particular simulator,
128 dnl all shall eventually behave the same way.
131 dnl We don't use automake, but we still want to support
132 dnl --enable-maintainer-mode.
136 dnl --enable-sim-debug is for developers of the simulator
137 dnl the allowable values are work-in-progress
138 AC_MSG_CHECKING([for sim debug setting])
140 AC_ARG_ENABLE(sim-debug,
141 [AS_HELP_STRING([--enable-sim-debug=opts],
142 [Enable debugging flags (for developers of the sim itself)])],
143 [case "${enableval}" in
146 *) sim_debug="($enableval)";;
148 if test "$sim_debug" != "0"; then
149 AC_DEFINE_UNQUOTED([DEBUG], [$sim_debug], [Sim debug setting])
151 AC_DEFINE_UNQUOTED([WITH_DEBUG], [$sim_debug], [Sim debug setting])
152 AC_MSG_RESULT($sim_debug)
155 dnl --enable-sim-stdio is for users of the simulator
156 dnl It determines if IO from the program is routed through STDIO (buffered)
157 AC_MSG_CHECKING([for sim stdio debug behavior])
159 AC_ARG_ENABLE(sim-stdio,
160 [AS_HELP_STRING([--enable-sim-stdio],
161 [Specify whether to use stdio for console input/output])],
162 [case "${enableval}" in
163 yes) sim_stdio="DO_USE_STDIO";;
164 no) sim_stdio="DONT_USE_STDIO";;
165 *) AC_MSG_ERROR([Unknown value $enableval passed to --enable-sim-stdio]);;
167 AC_DEFINE_UNQUOTED([WITH_STDIO], [$sim_stdio], [How to route I/O])
168 AC_MSG_RESULT($sim_stdio)
171 dnl --enable-sim-trace is for users of the simulator
172 dnl The argument is either a bitmask of things to enable [exactly what is
173 dnl up to the simulator], or is a comma separated list of names of tracing
174 dnl elements to enable. The latter is only supported on simulators that
175 dnl use WITH_TRACE. Default to all tracing but internal debug.
176 AC_MSG_CHECKING([for sim trace settings])
177 sim_trace="~TRACE_debug"
178 AC_ARG_ENABLE(sim-trace,
179 [AS_HELP_STRING([--enable-sim-trace=opts],
180 [Enable tracing of simulated programs])],
181 [case "${enableval}" in
182 yes) sim_trace="-1";;
185 sim_trace="'(${enableval})'";;
188 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
189 if test x"$sim_trace" = x; then
190 sim_trace="(TRACE_$x"
192 sim_trace="${sim_trace}|TRACE_$x"
195 sim_trace="$sim_trace)" ;;
197 AC_DEFINE_UNQUOTED([WITH_TRACE], [$sim_trace], [Sim trace settings])
198 AC_MSG_RESULT($sim_trace)
201 dnl --enable-sim-profile
202 dnl The argument is either a bitmask of things to enable [exactly what is
203 dnl up to the simulator], or is a comma separated list of names of profiling
204 dnl elements to enable. The latter is only supported on simulators that
205 dnl use WITH_PROFILE.
206 AC_MSG_CHECKING([for sim profile settings])
209 AC_ARG_ENABLE(sim-profile,
210 [AS_HELP_STRING([--enable-sim-profile=opts], [Enable profiling flags])],
211 [case "${enableval}" in
212 yes) profile="1" sim_profile="-1";;
213 no) profile="0" sim_profile="0";;
215 profile="(${enableval})" sim_profile="(${enableval})";;
219 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
220 if test x"$sim_profile" = x; then
221 sim_profile="(PROFILE_$x"
223 sim_profile="${sim_profile}|PROFILE_$x"
226 sim_profile="$sim_profile)" ;;
228 AC_DEFINE_UNQUOTED([PROFILE], [$profile], [Sim profile settings])
229 AC_DEFINE_UNQUOTED([WITH_PROFILE], [$sim_profile], [Sim profile settings])
230 AC_MSG_RESULT($sim_profile)
234 SIM_AC_OPTION_ENVIRONMENT
237 ACX_PKGVERSION([SIM])
238 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
239 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
240 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
242 dnl Types used by common code
245 dnl Detect exe extension
248 ]) dnl End of SIM_AC_COMMON
251 dnl Additional SIM options that can (optionally) be configured
252 dnl For optional simulator options, a macro SIM_AC_OPTION_* is defined.
253 dnl Simulators that wish to use the relevant option specify the macro
254 dnl in the simulator specific configure.ac file between the SIM_AC_COMMON
255 dnl and SIM_AC_OUTPUT lines.
258 dnl Specify the running environment.
259 dnl If the simulator invokes this in its configure.ac then without this option
260 dnl the default is the user environment and all are runtime selectable.
261 dnl If the simulator doesn't invoke this, only the user environment is
263 dnl ??? Until there is demonstrable value in doing something more complicated,
265 AC_DEFUN([SIM_AC_OPTION_ENVIRONMENT],
267 AC_MSG_CHECKING([default sim environment setting])
268 sim_environment="ALL_ENVIRONMENT"
269 AC_ARG_ENABLE(sim-environment,
270 [AS_HELP_STRING([--enable-sim-environment=environment],
271 [Specify mixed, user, virtual or operating environment])],
272 [case "${enableval}" in
273 all | ALL) sim_environment="ALL_ENVIRONMENT";;
274 user | USER) sim_environment="USER_ENVIRONMENT";;
275 virtual | VIRTUAL) sim_environment="VIRTUAL_ENVIRONMENT";;
276 operating | OPERATING) sim_environment="OPERATING_ENVIRONMENT";;
277 *) AC_MSG_ERROR([Unknown value $enableval passed to --enable-sim-environment]);;
279 AC_DEFINE_UNQUOTED([WITH_ENVIRONMENT], [$sim_environment], [Sim default environment])
280 AC_MSG_RESULT($sim_environment)
284 dnl Specify the alignment restrictions of the target architecture.
285 dnl Without this option all possible alignment restrictions are accommodated.
286 dnl arg[1] is hardwired target alignment
287 dnl arg[2] is default target alignment
288 AC_DEFUN([SIM_AC_OPTION_ALIGNMENT],
289 wire_alignment="[$1]"
290 default_alignment="[$2]"
292 AC_ARG_ENABLE(sim-alignment,
293 [AS_HELP_STRING([--enable-sim-alignment=align],
294 [Specify strict, nonstrict or forced alignment of memory accesses])],
295 [case "${enableval}" in
296 strict | STRICT) sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";;
297 nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";;
298 forced | FORCED) sim_alignment="-DWITH_ALIGNMENT=FORCED_ALIGNMENT";;
299 yes) if test x"$wire_alignment" != x; then
300 sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
302 if test x"$default_alignment" != x; then
303 sim_alignment="-DWITH_ALIGNMENT=${default_alignment}"
305 echo "No hard-wired alignment for target $target" 1>&6
306 sim_alignment="-DWITH_ALIGNMENT=0"
309 no) if test x"$default_alignment" != x; then
310 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
312 if test x"$wire_alignment" != x; then
313 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${wire_alignment}"
315 echo "No default alignment for target $target" 1>&6
316 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=0"
319 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment"); sim_alignment="";;
321 if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then
322 echo "Setting alignment flags = $sim_alignment" 6>&1
324 [if test x"$default_alignment" != x; then
325 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
327 if test x"$wire_alignment" != x; then
328 sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
334 AC_SUBST(sim_alignment)
337 dnl Conditionally compile in assertion statements.
338 AC_DEFUN([SIM_AC_OPTION_ASSERT],
340 AC_MSG_CHECKING([whether to enable sim asserts])
342 AC_ARG_ENABLE(sim-assert,
343 [AS_HELP_STRING([--enable-sim-assert],
344 [Specify whether to perform random assertions])],
345 [case "${enableval}" in
346 yes) sim_assert="1";;
348 *) AC_MSG_ERROR([--enable-sim-assert does not take a value]);;
350 AC_DEFINE_UNQUOTED([WITH_ASSERT], [$sim_assert], [Sim assert settings])
351 AC_MSG_RESULT($sim_assert)
356 dnl --enable-sim-bitsize is for developers of the simulator
357 dnl It specifies the number of BITS in the target.
358 dnl arg[1] is the number of bits in a word
359 dnl arg[2] is the number assigned to the most significant bit
360 dnl arg[3] is the number of bits in an address
361 dnl arg[4] is the number of bits in an OpenFirmware cell.
362 dnl FIXME: this information should be obtained from bfd/archure
363 AC_DEFUN([SIM_AC_OPTION_BITSIZE],
364 wire_word_bitsize="[$1]"
366 wire_address_bitsize="[$3]"
367 wire_cell_bitsize="[$4]"
368 [AC_ARG_ENABLE(sim-bitsize,
369 [AS_HELP_STRING([--enable-sim-bitsize=N], [Specify target bitsize (32 or 64)])],
371 case "${enableval}" in
372 64,63 | 64,63,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63";;
373 32,31 | 32,31,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31";;
374 64,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";;
375 32,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";;
376 32) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then
377 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31"
379 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0"
381 64) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then
382 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63"
384 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=0"
386 *) AC_MSG_ERROR("--enable-sim-bitsize was given $enableval. Expected 32 or 64") ;;
389 tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9]]*,*//"`
392 x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=32" ;;
393 x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=64" ;;
394 * ) AC_MSG_ERROR("--enable-sim-bitsize was given address size $enableval. Expected 32 or 64") ;;
397 tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9*]]*,*[[0-9]]*,*//"`
400 x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=32" ;;
401 x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=64" ;;
402 * ) AC_MSG_ERROR("--enable-sim-bitsize was given cell size $enableval. Expected 32 or 64") ;;
404 if test x"$silent" != x"yes" && test x"$sim_bitsize" != x""; then
405 echo "Setting bitsize flags = $sim_bitsize" 6>&1
408 if test x"$wire_word_bitsize" != x; then
409 sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_BITSIZE=$wire_word_bitsize"
411 if test x"$wire_word_msb" != x; then
412 sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_MSB=$wire_word_msb"
414 if test x"$wire_address_bitsize" != x; then
415 sim_bitsize="$sim_bitsize -DWITH_TARGET_ADDRESS_BITSIZE=$wire_address_bitsize"
417 if test x"$wire_cell_bitsize" != x; then
418 sim_bitsize="$sim_bitsize -DWITH_TARGET_CELL_BITSIZE=$wire_cell_bitsize"
421 AC_SUBST(sim_bitsize)
425 dnl --enable-sim-endian={yes,no,big,little} is for simulators
426 dnl that support both big and little endian targets.
427 dnl arg[1] is hardwired target endianness.
428 dnl arg[2] is default target endianness.
429 AC_DEFUN([SIM_AC_OPTION_ENDIAN],
432 default_endian="[$2]"
433 AC_ARG_ENABLE(sim-endian,
434 [AS_HELP_STRING([--enable-sim-endian=endian],
435 [Specify target byte endian orientation])],
436 [case "${enableval}" in
437 b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_BIG";;
438 l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_LITTLE";;
439 yes) if test x"$wire_endian" != x; then
440 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
442 if test x"$default_endian" != x; then
443 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
445 echo "No hard-wired endian for target $target" 1>&6
446 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
449 no) if test x"$default_endian" != x; then
450 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
452 if test x"$wire_endian" != x; then
453 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
455 echo "No default endian for target $target" 1>&6
456 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
459 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
461 if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
462 echo "Setting endian flags = $sim_endian" 6>&1
464 [if test x"$default_endian" != x; then
465 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
467 if test x"$wire_endian" != x; then
468 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
477 dnl --enable-sim-float is for developers of the simulator
478 dnl It specifies the presence of hardware floating point
479 dnl And optionally the bitsize of the floating point register.
480 dnl arg[1] specifies the presence (or absence) of floating point hardware
481 dnl arg[2] specifies the number of bits in a floating point register
482 AC_DEFUN([SIM_AC_OPTION_FLOAT],
484 default_sim_float="[$1]"
485 default_sim_float_bitsize="[$2]"
486 AC_ARG_ENABLE(sim-float,
487 [AS_HELP_STRING([--enable-sim-float],
488 [Specify that the target processor has floating point hardware])],
489 [case "${enableval}" in
490 yes | hard) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";;
491 no | soft) sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";;
492 32) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=32";;
493 64) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=64";;
494 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-float"); sim_float="";;
496 if test x"$silent" != x"yes" && test x"$sim_float" != x""; then
497 echo "Setting float flags = $sim_float" 6>&1
500 if test x"${default_sim_float}" != x""; then
501 sim_float="-DWITH_FLOATING_POINT=${default_sim_float}"
503 if test x"${default_sim_float_bitsize}" != x""; then
504 sim_float="$sim_float -DWITH_TARGET_FLOATING_POINT_BITSIZE=${default_sim_float_bitsize}"
511 dnl The argument is the default cache size if none is specified.
512 AC_DEFUN([SIM_AC_OPTION_SCACHE],
514 default_sim_scache="ifelse([$1],,0,[$1])"
515 AC_ARG_ENABLE(sim-scache,
516 [AS_HELP_STRING([--enable-sim-scache=size],
517 [Specify simulator execution cache size])],
518 [case "${enableval}" in
519 yes) sim_scache="-DWITH_SCACHE=${default_sim_scache}";;
520 no) sim_scache="-DWITH_SCACHE=0" ;;
521 [[0-9]]*) sim_scache="-DWITH_SCACHE=${enableval}";;
522 *) AC_MSG_ERROR("Bad value $enableval passed to --enable-sim-scache");
525 if test x"$silent" != x"yes" && test x"$sim_scache" != x""; then
526 echo "Setting scache size = $sim_scache" 6>&1
527 fi],[sim_scache="-DWITH_SCACHE=${default_sim_scache}"])
532 dnl The argument is the default model if none is specified.
533 AC_DEFUN([SIM_AC_OPTION_DEFAULT_MODEL],
535 default_sim_default_model="ifelse([$1],,0,[$1])"
536 AC_ARG_ENABLE(sim-default-model,
537 [AS_HELP_STRING([--enable-sim-default-model=model],
538 [Specify default model to simulate])],
539 [case "${enableval}" in
540 yes|no) AC_MSG_ERROR("Missing argument to --enable-sim-default-model");;
541 *) sim_default_model="-DWITH_DEFAULT_MODEL='\"${enableval}\"'";;
543 if test x"$silent" != x"yes" && test x"$sim_default_model" != x""; then
544 echo "Setting default model = $sim_default_model" 6>&1
545 fi],[sim_default_model="-DWITH_DEFAULT_MODEL='\"${default_sim_default_model}\"'"])
547 AC_SUBST(sim_default_model)
550 dnl --enable-sim-hardware is for users of the simulator
551 dnl arg[1] Enable sim-hw by default? ("yes" or "no")
552 dnl arg[2] is a space separated list of devices that override the defaults
553 dnl arg[3] is a space separated list of extra target specific devices.
554 AC_DEFUN([SIM_AC_OPTION_HARDWARE],
559 hardware="cfi core pal glue"
561 hardware="$hardware [$3]"
563 sim_hw_cflags="-DWITH_HW=1"
565 sim_hw_objs="\$(SIM_COMMON_HW_OBJS) `echo $sim_hw | sed -e 's/\([[^ ]][[^ ]]*\)/dv-\1.o/g'`"
567 AC_ARG_ENABLE(sim-hardware,
568 [AS_HELP_STRING([--enable-sim-hardware=LIST],
569 [Specify the hardware to be included in the build.])],
570 ,[enable_sim_hardware="[$1]"])
571 case ${enable_sim_hardware} in
573 ,*) hardware="${hardware} `echo ${enableval} | sed -e 's/,/ /'`";;
574 *,) hardware="`echo ${enableval} | sed -e 's/,/ /'` ${hardware}";;
575 *) hardware="`echo ${enableval} | sed -e 's/,/ /'`"'';;
578 if test "$enable_sim_hardware" = no; then
580 sim_hw_cflags="-DWITH_HW=0"
583 sim_hw_cflags="-DWITH_HW=1"
586 sim_hw_objs="\$(SIM_COMMON_HW_OBJS)"
587 for i in $hardware ; do
590 *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";;
593 # mingw does not support sockser
596 *) # TODO: We don't add dv-sockser to sim_hw as it is not a "real" device
597 # that you instatiate. Instead, other code will call into it directly.
598 # At some point, we should convert it over.
599 sim_hw_objs="$sim_hw_objs dv-sockser.o"
601 [HAVE_DV_SOCKSER], 1, [Define if dv-sockser is usable.])
604 if test x"$silent" != x"yes"; then
605 echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
607 dnl Some devices require extra libraries.
608 case " $hardware " in
609 *" cfi "*) AC_CHECK_LIB(m, log2);;
613 AC_SUBST(sim_hw_cflags)
614 AC_SUBST(sim_hw_objs)
618 dnl --enable-sim-inline is for users that wish to ramp up the simulator's
619 dnl performance by inlining functions.
620 dnl Default sims to no inlining.
621 AC_DEFUN([SIM_AC_OPTION_INLINE],
623 sim_inline="-DDEFAULT_INLINE=m4_ifblank([$1],[0],[$1])"
624 AC_ARG_ENABLE(sim-inline,
625 [AS_HELP_STRING([--enable-sim-inline=inlines],
626 [Specify which functions should be inlined])],
629 no) sim_inline="-DDEFAULT_INLINE=0";;
630 0) sim_inline="-DDEFAULT_INLINE=0";;
631 yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_C_INLINE";;
632 1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";;
633 *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
636 *_INLINE=*) new_flag="-D$x";;
637 *=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;;
638 *_INLINE) new_flag="-D$x=ALL_C_INLINE";;
639 *) new_flag="-D$x""_INLINE=ALL_C_INLINE";;
641 if test x"$sim_inline" = x""; then
642 sim_inline="$new_flag"
644 sim_inline="$sim_inline $new_flag"
648 if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
649 echo "Setting inline flags = $sim_inline" 6>&1
655 AC_DEFUN([SIM_AC_OPTION_RESERVED_BITS],
657 default_sim_reserved_bits="ifelse([$1],,1,[$1])"
658 AC_ARG_ENABLE(sim-reserved-bits,
659 [AS_HELP_STRING([--enable-sim-reserved-bits],
660 [Specify whether to check reserved bits in instruction])],
661 [case "${enableval}" in
662 yes) sim_reserved_bits="-DWITH_RESERVED_BITS=1";;
663 no) sim_reserved_bits="-DWITH_RESERVED_BITS=0";;
664 *) AC_MSG_ERROR("--enable-sim-reserved-bits does not take a value"); sim_reserved_bits="";;
666 if test x"$silent" != x"yes" && test x"$sim_reserved_bits" != x""; then
667 echo "Setting reserved flags = $sim_reserved_bits" 6>&1
668 fi],[sim_reserved_bits="-DWITH_RESERVED_BITS=${default_sim_reserved_bits}"])dnl
670 AC_SUBST(sim_reserved_bits)
673 AC_DEFUN([SIM_AC_OPTION_SMP],
675 AC_MSG_CHECKING([number of sim cpus to support])
676 default_sim_smp="ifelse([$1],,5,[$1])"
677 sim_smp="$default_sim_smp""
678 AC_ARG_ENABLE(sim-smp,
679 [AS_HELP_STRING([--enable-sim-smp=n],
680 [Specify number of processors to configure for (default ${default_sim_smp})])],
681 [case "${enableval}" in
684 *) sim_smp="$enableval";;
686 sim_igen_smp="-N ${sim_smp}"
687 AC_DEFINE_UNQUOTED([WITH_SMP], [$sim_smp], [Sim SMP settings])
688 AC_MSG_RESULT($sim_smp)
692 AC_DEFUN([SIM_AC_OPTION_XOR_ENDIAN],
694 AC_MSG_CHECKING([for xor endian support])
695 default_sim_xor_endian="ifelse([$1],,8,[$1])"
696 sim_xor_endian="$default_sim_xor_endian"
697 AC_ARG_ENABLE(sim-xor-endian,
698 [AS_HELP_STRING([--enable-sim-xor-endian=n],
699 [Specify number bytes involved in XOR bi-endian mode (default ${default_sim_xor_endian})])],
700 [case "${enableval}" in
701 yes) sim_xor_endian="8";;
702 no) sim_xor_endian="0";;
703 *) sim_xor_endian="$enableval";;
705 AC_DEFINE_UNQUOTED([WITH_XOR_ENDIAN], [$sim_xor_endian], [Sim XOR endian settings])
706 AC_MSG_RESULT($sim_smp)
710 dnl --enable-build-warnings is for developers of the simulator.
711 dnl it enables extra GCC specific warnings.
712 AC_DEFUN([SIM_AC_OPTION_WARNINGS],
714 AC_ARG_ENABLE(werror,
715 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
716 [case "${enableval}" in
717 yes | y) ERROR_ON_WARNING="yes" ;;
718 no | n) ERROR_ON_WARNING="no" ;;
719 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
722 # Enable -Werror by default when using gcc
723 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
728 if test "${ERROR_ON_WARNING}" = yes ; then
729 # NOTE: Disabled in the sim dir due to most sims generating warnings.
730 # WERROR_CFLAGS="-Werror"
734 build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
736 -Wno-unused -Wunused-value -Wunused-function \
737 -Wno-switch -Wno-char-subscripts -Wmissing-prototypes
738 -Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \
739 -Wold-style-declaration -Wold-style-definition"
741 # Enable -Wno-format by default when using gcc on mingw since many
742 # GCC versions complain about %I64.
744 *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;;
745 *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
748 AC_ARG_ENABLE(build-warnings,
749 AS_HELP_STRING([--enable-build-warnings], [enable build-time compiler warnings if gcc is used]),
750 [case "${enableval}" in
752 no) build_warnings="-w";;
753 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
754 build_warnings="${build_warnings} ${t}";;
755 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
756 build_warnings="${t} ${build_warnings}";;
757 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
759 if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
760 echo "Setting compiler warning flags = $build_warnings" 6>&1
762 AC_ARG_ENABLE(sim-build-warnings,
763 AS_HELP_STRING([--enable-sim-build-warnings], [enable SIM specific 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 GDB specific compiler warning flags = $build_warnings" 6>&1
777 if test "x${build_warnings}" != x -a "x$GCC" = xyes
779 AC_MSG_CHECKING(compiler warning flags)
780 # Separate out the -Werror flag as some files just cannot be
781 # compiled with it enabled.
782 for w in ${build_warnings}; do
784 -Werr*) WERROR_CFLAGS=-Werror ;;
785 *) # Check that GCC accepts it
786 saved_CFLAGS="$CFLAGS"
788 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
789 CFLAGS="$saved_CFLAGS"
792 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
795 AC_SUBST(WARN_CFLAGS)
796 AC_SUBST(WERROR_CFLAGS)
799 dnl Generate the Makefile in a target specific directory.
800 dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
801 dnl so this is a cover macro to tuck the details away of how we cope.
802 dnl We cope by having autoconf generate two files and then merge them into
803 dnl one afterwards. The two pieces of the common fragment are inserted into
804 dnl the target's fragment at the appropriate points.
806 AC_DEFUN([SIM_AC_OUTPUT],
808 dnl Make @cgen_breaks@ non-null only if the sim uses CGEN.
810 if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
811 cgen_breaks="break cgen_rtx_error";
813 AC_SUBST(cgen_breaks)
814 AC_CONFIG_FILES(Makefile.sim:Makefile.in)
815 AC_CONFIG_FILES(Make-common.sim:../common/Make-common.in)
816 AC_CONFIG_FILES(.gdbinit:../common/gdbinit.in)
817 AC_CONFIG_COMMANDS([Makefile],
818 [echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
819 rm -f Makesim1.tmp Makesim2.tmp Makefile
820 sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
821 sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
822 sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
823 -e '/^## COMMON_POST_/ r Makesim2.tmp' \
824 <Makefile.sim >Makefile
825 rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
827 AC_CONFIG_COMMANDS([stamp-h], [echo > stamp-h])
831 sinclude(../../config/gettext-sister.m4)
832 sinclude(../../config/acx.m4)
834 dnl --enable-cgen-maint support
835 AC_DEFUN([SIM_AC_OPTION_CGEN_MAINT],
838 dnl Default is to use one in build tree.
840 cgendir='$(srcdir)/../../cgen'
841 dnl Having --enable-maintainer-mode take arguments is another way to go.
842 dnl ??? One can argue --with is more appropriate if one wants to specify
843 dnl a directory name, but what we're doing here is an enable/disable kind
844 dnl of thing and specifying both --enable and --with is klunky.
845 dnl If you reeely want this to be --with, go ahead and change it.
846 AC_ARG_ENABLE(cgen-maint,
847 [AS_HELP_STRING([--enable-cgen-maint[=DIR]], [build cgen generated files])],
848 [case "${enableval}" in
849 yes) cgen_maint=yes ;;
852 # argument is cgen install directory (not implemented yet).
853 # Having a `share' directory might be more appropriate for the .scm,
855 cgendir=${cgen_maint}/lib/cgen
859 dnl AM_CONDITIONAL(CGEN_MAINT, test x${cgen_maint} != xno)
860 if test x${cgen_maint} != xno ; then