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.in should look like:
10 # dnl Process this file with autoconf to produce a configure script.
11 # sinclude(../common/aclocal.m4)
13 # AC_INIT(Makefile.in)
17 # ... target specific stuff ...
21 # Include global overrides and fixes for Autoconf.
22 m4_include(../../config/override.m4)
23 sinclude([../../config/zlib.m4])
25 AC_DEFUN([SIM_AC_COMMON],
27 # autoconf.info says this should be called right after AC_INIT.
28 AC_CONFIG_HEADER(ifelse([$1],,config.h,[$1]):config.in)
34 # Put a plausible default for CC_FOR_BUILD in Makefile.
35 if test "x$cross_compiling" = "xno"; then
40 AC_SUBST(CC_FOR_BUILD)
48 dnl We don't use gettext, but bfd does. So we do the appropriate checks
49 dnl to see if there are intl libraries we should link against.
51 ZW_GNU_GETTEXT_SISTER_DIR(../../intl)
53 # Check for common headers.
54 # FIXME: Seems to me this can cause problems for i386-windows hosts.
55 # At one point there were hardcoded AC_DEFINE's if ${host} = i386-*-windows*.
56 AC_CHECK_HEADERS(stdlib.h string.h strings.h unistd.h time.h)
57 AC_CHECK_HEADERS(sys/time.h sys/resource.h)
58 AC_CHECK_HEADERS(fcntl.h fpu_control.h)
59 AC_CHECK_HEADERS(dlfcn.h errno.h sys/stat.h)
60 AC_CHECK_FUNCS(getrusage time sigaction __setfpucw)
62 # Check for socket libraries
63 AC_CHECK_LIB(socket, bind)
64 AC_CHECK_LIB(nsl, gethostbyname)
66 . ${srcdir}/../../bfd/configure.host
68 dnl Standard (and optional) simulator options.
69 dnl Eventually all simulators will support these.
70 dnl Do not add any here that cannot be supported by all simulators.
71 dnl Do not add similar but different options to a particular simulator,
72 dnl all shall eventually behave the same way.
75 dnl We don't use automake, but we still want to support
76 dnl --enable-maintainer-mode.
77 USE_MAINTAINER_MODE=no
78 AC_ARG_ENABLE(maintainer-mode,
79 [ --enable-maintainer-mode Enable developer functionality.],
80 [case "${enableval}" in
81 yes) MAINT="" USE_MAINTAINER_MODE=yes ;;
83 *) AC_MSG_ERROR("--enable-maintainer-mode does not take a value"); MAINT="#" ;;
85 if test x"$silent" != x"yes" && test x"$MAINT" = x""; then
86 echo "Setting maintainer mode" 6>&1
91 dnl This is a generic option to enable special byte swapping
92 dnl insns on *any* cpu.
93 AC_ARG_ENABLE(sim-bswap,
94 [ --enable-sim-bswap Use Host specific BSWAP instruction.],
95 [case "${enableval}" in
96 yes) sim_bswap="-DWITH_BSWAP=1 -DUSE_BSWAP=1";;
97 no) sim_bswap="-DWITH_BSWAP=0";;
98 *) AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
100 if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
101 echo "Setting bswap flags = $sim_bswap" 6>&1
102 fi],[sim_bswap=""])dnl
106 AC_ARG_ENABLE(sim-cflags,
107 [ --enable-sim-cflags=opts Extra CFLAGS for use in building simulator],
108 [case "${enableval}" in
109 yes) sim_cflags="-O2 -fomit-frame-pointer";;
110 trace) AC_MSG_ERROR("Please use --enable-sim-debug instead."); sim_cflags="";;
112 *) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
114 if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then
115 echo "Setting sim cflags = $sim_cflags" 6>&1
116 fi],[sim_cflags=""])dnl
120 dnl --enable-sim-debug is for developers of the simulator
121 dnl the allowable values are work-in-progress
122 AC_ARG_ENABLE(sim-debug,
123 [ --enable-sim-debug=opts Enable debugging flags],
124 [case "${enableval}" in
125 yes) sim_debug="-DDEBUG=7 -DWITH_DEBUG=7";;
126 no) sim_debug="-DDEBUG=0 -DWITH_DEBUG=0";;
127 *) sim_debug="-DDEBUG='(${enableval})' -DWITH_DEBUG='(${enableval})'";;
129 if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then
130 echo "Setting sim debug = $sim_debug" 6>&1
131 fi],[sim_debug=""])dnl
135 dnl --enable-sim-stdio is for users of the simulator
136 dnl It determines if IO from the program is routed through STDIO (buffered)
137 AC_ARG_ENABLE(sim-stdio,
138 [ --enable-sim-stdio Specify whether to use stdio for console input/output.],
139 [case "${enableval}" in
140 yes) sim_stdio="-DWITH_STDIO=DO_USE_STDIO";;
141 no) sim_stdio="-DWITH_STDIO=DONT_USE_STDIO";;
142 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-stdio"); sim_stdio="";;
144 if test x"$silent" != x"yes" && test x"$sim_stdio" != x""; then
145 echo "Setting stdio flags = $sim_stdio" 6>&1
146 fi],[sim_stdio=""])dnl
150 dnl --enable-sim-trace is for users of the simulator
151 dnl The argument is either a bitmask of things to enable [exactly what is
152 dnl up to the simulator], or is a comma separated list of names of tracing
153 dnl elements to enable. The latter is only supported on simulators that
155 AC_ARG_ENABLE(sim-trace,
156 [ --enable-sim-trace=opts Enable tracing flags],
157 [case "${enableval}" in
158 yes) sim_trace="-DTRACE=1 -DWITH_TRACE=-1";;
159 no) sim_trace="-DTRACE=0 -DWITH_TRACE=0";;
161 sim_trace="-DTRACE='(${enableval})' -DWITH_TRACE='(${enableval})'";;
164 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
165 if test x"$sim_trace" = x; then
166 sim_trace="-DWITH_TRACE='(TRACE_$x"
168 sim_trace="${sim_trace}|TRACE_$x"
171 sim_trace="$sim_trace)'" ;;
173 if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then
174 echo "Setting sim trace = $sim_trace" 6>&1
175 fi],[sim_trace=""])dnl
179 dnl --enable-sim-profile
180 dnl The argument is either a bitmask of things to enable [exactly what is
181 dnl up to the simulator], or is a comma separated list of names of profiling
182 dnl elements to enable. The latter is only supported on simulators that
183 dnl use WITH_PROFILE.
184 AC_ARG_ENABLE(sim-profile,
185 [ --enable-sim-profile=opts Enable profiling flags],
186 [case "${enableval}" in
187 yes) sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1";;
188 no) sim_profile="-DPROFILE=0 -DWITH_PROFILE=0";;
190 sim_profile="-DPROFILE='(${enableval})' -DWITH_PROFILE='(${enableval})'";;
193 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
194 if test x"$sim_profile" = x; then
195 sim_profile="-DWITH_PROFILE='(PROFILE_$x"
197 sim_profile="${sim_profile}|PROFILE_$x"
200 sim_profile="$sim_profile)'" ;;
202 if test x"$silent" != x"yes" && test x"$sim_profile" != x""; then
203 echo "Setting sim profile = $sim_profile" 6>&1
204 fi],[sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1"])dnl
205 AC_SUBST(sim_profile)
208 dnl Types used by common code
211 dnl Detect exe extension
214 dnl These are available to append to as desired.
218 dnl Create tconfig.h either from simulator's tconfig.in or default one
220 sim_link_links=tconfig.h
221 if test -f ${srcdir}/tconfig.in
223 sim_link_files=tconfig.in
225 sim_link_files=../common/tconfig.in
228 # targ-vals.def points to the libc macro description file.
230 *-*-*) TARG_VALS_DEF=../common/nltvals.def ;;
232 sim_link_files="${sim_link_files} ${TARG_VALS_DEF}"
233 sim_link_links="${sim_link_links} targ-vals.def"
235 ]) dnl End of SIM_AC_COMMON
238 dnl Additional SIM options that can (optionally) be configured
239 dnl For optional simulator options, a macro SIM_AC_OPTION_* is defined.
240 dnl Simulators that wish to use the relevant option specify the macro
241 dnl in the simulator specific configure.in file between the SIM_AC_COMMON
242 dnl and SIM_AC_OUTPUT lines.
245 dnl Specify the running environment.
246 dnl If the simulator invokes this in its configure.in then without this option
247 dnl the default is the user environment and all are runtime selectable.
248 dnl If the simulator doesn't invoke this, only the user environment is
250 dnl ??? Until there is demonstrable value in doing something more complicated,
252 AC_DEFUN([SIM_AC_OPTION_ENVIRONMENT],
254 AC_ARG_ENABLE(sim-environment,
255 [ --enable-sim-environment=environment Specify mixed, user, virtual or operating environment.],
256 [case "${enableval}" in
257 all | ALL) sim_environment="-DWITH_ENVIRONMENT=ALL_ENVIRONMENT";;
258 user | USER) sim_environment="-DWITH_ENVIRONMENT=USER_ENVIRONMENT";;
259 virtual | VIRTUAL) sim_environment="-DWITH_ENVIRONMENT=VIRTUAL_ENVIRONMENT";;
260 operating | OPERATING) sim_environment="-DWITH_ENVIRONMENT=OPERATING_ENVIRONMENT";;
261 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-environment");
264 if test x"$silent" != x"yes" && test x"$sim_environment" != x""; then
265 echo "Setting sim environment = $sim_environment" 6>&1
267 [sim_environment="-DWITH_ENVIRONMENT=ALL_ENVIRONMENT"])dnl
269 AC_SUBST(sim_environment)
272 dnl Specify the alignment restrictions of the target architecture.
273 dnl Without this option all possible alignment restrictions are accommodated.
274 dnl arg[1] is hardwired target alignment
275 dnl arg[2] is default target alignment
276 AC_DEFUN([SIM_AC_OPTION_ALIGNMENT],
277 wire_alignment="[$1]"
278 default_alignment="[$2]"
280 AC_ARG_ENABLE(sim-alignment,
281 [ --enable-sim-alignment=align Specify strict, nonstrict or forced alignment of memory accesses.],
282 [case "${enableval}" in
283 strict | STRICT) sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";;
284 nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";;
285 forced | FORCED) sim_alignment="-DWITH_ALIGNMENT=FORCED_ALIGNMENT";;
286 yes) if test x"$wire_alignment" != x; then
287 sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
289 if test x"$default_alignment" != x; then
290 sim_alignment="-DWITH_ALIGNMENT=${default_alignment}"
292 echo "No hard-wired alignment for target $target" 1>&6
293 sim_alignment="-DWITH_ALIGNMENT=0"
296 no) if test x"$default_alignment" != x; then
297 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
299 if test x"$wire_alignment" != x; then
300 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${wire_alignment}"
302 echo "No default alignment for target $target" 1>&6
303 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=0"
306 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment"); sim_alignment="";;
308 if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then
309 echo "Setting alignment flags = $sim_alignment" 6>&1
311 [if test x"$default_alignment" != x; then
312 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
314 if test x"$wire_alignment" != x; then
315 sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
321 AC_SUBST(sim_alignment)
324 dnl Conditionally compile in assertion statements.
325 AC_DEFUN([SIM_AC_OPTION_ASSERT],
327 AC_ARG_ENABLE(sim-assert,
328 [ --enable-sim-assert Specify whether to perform random assertions.],
329 [case "${enableval}" in
330 yes) sim_assert="-DWITH_ASSERT=1";;
331 no) sim_assert="-DWITH_ASSERT=0";;
332 *) AC_MSG_ERROR("--enable-sim-assert does not take a value"); sim_assert="";;
334 if test x"$silent" != x"yes" && test x"$sim_assert" != x""; then
335 echo "Setting assert flags = $sim_assert" 6>&1
336 fi],[sim_assert=""])dnl
342 dnl --enable-sim-bitsize is for developers of the simulator
343 dnl It specifies the number of BITS in the target.
344 dnl arg[1] is the number of bits in a word
345 dnl arg[2] is the number assigned to the most significant bit
346 dnl arg[3] is the number of bits in an address
347 dnl arg[4] is the number of bits in an OpenFirmware cell.
348 dnl FIXME: this information should be obtained from bfd/archure
349 AC_DEFUN([SIM_AC_OPTION_BITSIZE],
350 wire_word_bitsize="[$1]"
352 wire_address_bitsize="[$3]"
353 wire_cell_bitsize="[$4]"
354 [AC_ARG_ENABLE(sim-bitsize,
355 [ --enable-sim-bitsize=N Specify target bitsize (32 or 64).],
357 case "${enableval}" in
358 64,63 | 64,63,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63";;
359 32,31 | 32,31,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31";;
360 64,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";;
361 32,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";;
362 32) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then
363 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31"
365 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0"
367 64) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then
368 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63"
370 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=0"
372 *) AC_MSG_ERROR("--enable-sim-bitsize was given $enableval. Expected 32 or 64") ;;
375 tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9]]*,*//"`
378 x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=32" ;;
379 x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=64" ;;
380 * ) AC_MSG_ERROR("--enable-sim-bitsize was given address size $enableval. Expected 32 or 64") ;;
383 tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9*]]*,*[[0-9]]*,*//"`
386 x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=32" ;;
387 x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=64" ;;
388 * ) AC_MSG_ERROR("--enable-sim-bitsize was given cell size $enableval. Expected 32 or 64") ;;
390 if test x"$silent" != x"yes" && test x"$sim_bitsize" != x""; then
391 echo "Setting bitsize flags = $sim_bitsize" 6>&1
394 if test x"$wire_word_bitsize" != x; then
395 sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_BITSIZE=$wire_word_bitsize"
397 if test x"$wire_word_msb" != x; then
398 sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_MSB=$wire_word_msb"
400 if test x"$wire_address_bitsize" != x; then
401 sim_bitsize="$sim_bitsize -DWITH_TARGET_ADDRESS_BITSIZE=$wire_address_bitsize"
403 if test x"$wire_cell_bitsize" != x; then
404 sim_bitsize="$sim_bitsize -DWITH_TARGET_CELL_BITSIZE=$wire_cell_bitsize"
407 AC_SUBST(sim_bitsize)
411 dnl --enable-sim-endian={yes,no,big,little} is for simulators
412 dnl that support both big and little endian targets.
413 dnl arg[1] is hardwired target endianness.
414 dnl arg[2] is default target endianness.
415 AC_DEFUN([SIM_AC_OPTION_ENDIAN],
418 default_endian="[$2]"
419 AC_ARG_ENABLE(sim-endian,
420 [ --enable-sim-endian=endian Specify target byte endian orientation.],
421 [case "${enableval}" in
422 b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
423 l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
424 yes) if test x"$wire_endian" != x; then
425 sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}"
427 if test x"$default_endian" != x; then
428 sim_endian="-DWITH_TARGET_BYTE_ORDER=${default_endian}"
430 echo "No hard-wired endian for target $target" 1>&6
431 sim_endian="-DWITH_TARGET_BYTE_ORDER=0"
434 no) if test x"$default_endian" != x; then
435 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}"
437 if test x"$wire_endian" != x; then
438 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${wire_endian}"
440 echo "No default endian for target $target" 1>&6
441 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=0"
444 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
446 if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
447 echo "Setting endian flags = $sim_endian" 6>&1
449 [if test x"$default_endian" != x; then
450 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}"
452 if test x"$wire_endian" != x; then
453 sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}"
462 dnl --enable-sim-hostendian is for users of the simulator when
463 dnl they find that AC_C_BIGENDIAN does not function correctly
464 dnl (for instance in a canadian cross)
465 AC_DEFUN([SIM_AC_OPTION_HOSTENDIAN],
467 AC_ARG_ENABLE(sim-hostendian,
468 [ --enable-sim-hostendian=end Specify host byte endian orientation.],
469 [case "${enableval}" in
470 no) sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";;
471 b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";;
472 l*|L*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN";;
473 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-hostendian"); sim_hostendian="";;
475 if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
476 echo "Setting hostendian flags = $sim_hostendian" 6>&1
478 if test "x$cross_compiling" = "xno"; then
480 if test $ac_cv_c_bigendian = yes; then
481 sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN"
483 sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN"
486 sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
489 AC_SUBST(sim_hostendian)
492 dnl --enable-sim-float is for developers of the simulator
493 dnl It specifies the presence of hardware floating point
494 dnl And optionally the bitsize of the floating point register.
495 dnl arg[1] specifies the presence (or absence) of floating point hardware
496 dnl arg[2] specifies the number of bits in a floating point register
497 AC_DEFUN([SIM_AC_OPTION_FLOAT],
499 default_sim_float="[$1]"
500 default_sim_float_bitsize="[$2]"
501 AC_ARG_ENABLE(sim-float,
502 [ --enable-sim-float Specify that the target processor has floating point hardware.],
503 [case "${enableval}" in
504 yes | hard) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";;
505 no | soft) sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";;
506 32) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=32";;
507 64) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=64";;
508 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-float"); sim_float="";;
510 if test x"$silent" != x"yes" && test x"$sim_float" != x""; then
511 echo "Setting float flags = $sim_float" 6>&1
514 if test x"${default_sim_float}" != x""; then
515 sim_float="-DWITH_FLOATING_POINT=${default_sim_float}"
517 if test x"${default_sim_float_bitsize}" != x""; then
518 sim_float="$sim_float -DWITH_TARGET_FLOATING_POINT_BITSIZE=${default_sim_float_bitsize}"
525 dnl The argument is the default cache size if none is specified.
526 AC_DEFUN([SIM_AC_OPTION_SCACHE],
528 default_sim_scache="ifelse([$1],,0,[$1])"
529 AC_ARG_ENABLE(sim-scache,
530 [ --enable-sim-scache=size 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 [ --enable-sim-default-model=model Specify default model to simulate.],
551 [case "${enableval}" in
552 yes|no) AC_MSG_ERROR("Missing argument to --enable-sim-default-model");;
553 *) sim_default_model="-DWITH_DEFAULT_MODEL='\"${enableval}\"'";;
555 if test x"$silent" != x"yes" && test x"$sim_default_model" != x""; then
556 echo "Setting default model = $sim_default_model" 6>&1
557 fi],[sim_default_model="-DWITH_DEFAULT_MODEL='\"${default_sim_default_model}\"'"])
559 AC_SUBST(sim_default_model)
562 dnl --enable-sim-hardware is for users of the simulator
563 dnl arg[1] Enable sim-hw by default? ("yes" or "no")
564 dnl arg[2] is a space separated list of devices that override the defaults
565 dnl arg[3] is a space separated list of extra target specific devices.
566 AC_DEFUN([SIM_AC_OPTION_HARDWARE],
568 if test x"[$1]" = x"yes"; then
574 hardware="core pal glue"
576 hardware="core pal glue [$3]"
578 sim_hw_cflags="-DWITH_HW=1"
580 sim_hw_objs="\$(SIM_COMMON_HW_OBJS) `echo $sim_hw | sed -e 's/\([[^ ]][[^ ]]*\)/dv-\1.o/g'`"
581 AC_ARG_ENABLE(sim-hardware,
582 [ --enable-sim-hardware=LIST Specify the hardware to be included in the build.],
584 case "${enableval}" in
587 ,*) sim_hw_p=yes; hardware="${hardware} `echo ${enableval} | sed -e 's/,/ /'`";;
588 *,) sim_hw_p=yes; hardware="`echo ${enableval} | sed -e 's/,/ /'` ${hardware}";;
589 *) sim_hw_p=yes; hardware="`echo ${enableval} | sed -e 's/,/ /'`"'';;
591 if test "$sim_hw_p" != yes; 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";;
607 if test x"$silent" != x"yes" && test "$sim_hw_p" = "yes"; then
608 echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
610 if test "$sim_hw_p" != yes; then
612 sim_hw_cflags="-DWITH_HW=0"
615 if test x"$silent" != x"yes"; then
616 echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
619 AC_SUBST(sim_hw_cflags)
620 AC_SUBST(sim_hw_objs)
624 dnl --enable-sim-inline is for users that wish to ramp up the simulator's
625 dnl performance by inlining functions.
626 dnl Guarantee that unconfigured simulators do not do any inlining
627 sim_inline="-DDEFAULT_INLINE=0"
628 AC_DEFUN([SIM_AC_OPTION_INLINE],
630 default_sim_inline="ifelse([$1],,,-DDEFAULT_INLINE=[$1])"
631 AC_ARG_ENABLE(sim-inline,
632 [ --enable-sim-inline=inlines Specify which functions should be inlined.],
635 no) sim_inline="-DDEFAULT_INLINE=0";;
636 0) sim_inline="-DDEFAULT_INLINE=0";;
637 yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_C_INLINE";;
638 1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";;
639 *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
642 *_INLINE=*) new_flag="-D$x";;
643 *=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;;
644 *_INLINE) new_flag="-D$x=ALL_C_INLINE";;
645 *) new_flag="-D$x""_INLINE=ALL_C_INLINE";;
647 if test x"$sim_inline" = x""; then
648 sim_inline="$new_flag"
650 sim_inline="$sim_inline $new_flag"
654 if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
655 echo "Setting inline flags = $sim_inline" 6>&1
657 if test "x$cross_compiling" = "xno"; then
658 if test x"$GCC" != "x" -a x"${default_sim_inline}" != "x" ; then
659 sim_inline="${default_sim_inline}"
660 if test x"$silent" != x"yes"; then
661 echo "Setting inline flags = $sim_inline" 6>&1
667 sim_inline="-DDEFAULT_INLINE=0"
673 AC_DEFUN([SIM_AC_OPTION_PACKAGES],
675 AC_ARG_ENABLE(sim-packages,
676 [ --enable-sim-packages=list Specify the packages to be included in the build.],
678 case "${enableval}" in
680 no) AC_MSG_ERROR("List of packages must be specified for --enable-sim-packages"); packages="";;
681 ,*) packages="${packages}${enableval}";;
682 *,) packages="${enableval}${packages}";;
683 *) packages="${enableval}"'';;
685 sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'`
686 sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'`
687 if test x"$silent" != x"yes" && test x"$packages" != x""; then
688 echo "Setting packages to $sim_pk_src, $sim_pk_obj"
689 fi],[packages=disklabel
690 sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'`
691 sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'`
692 if test x"$silent" != x"yes"; then
693 echo "Setting packages to $sim_pk_src, $sim_pk_obj"
696 AC_SUBST(sim_packages)
699 AC_DEFUN([SIM_AC_OPTION_REGPARM],
701 AC_ARG_ENABLE(sim-regparm,
702 [ --enable-sim-regparm=nr-parm Pass parameters in registers instead of on the stack - x86/GCC specific.],
703 [case "${enableval}" in
704 0*|1*|2*|3*|4*|5*|6*|7*|8*|9*) sim_regparm="-DWITH_REGPARM=${enableval}";;
705 no) sim_regparm="" ;;
706 yes) sim_regparm="-DWITH_REGPARM=3";;
707 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-regparm"); sim_regparm="";;
709 if test x"$silent" != x"yes" && test x"$sim_regparm" != x""; then
710 echo "Setting regparm flags = $sim_regparm" 6>&1
711 fi],[sim_regparm=""])dnl
713 AC_SUBST(sim_regparm)
716 AC_DEFUN([SIM_AC_OPTION_RESERVED_BITS],
718 default_sim_reserved_bits="ifelse([$1],,1,[$1])"
719 AC_ARG_ENABLE(sim-reserved-bits,
720 [ --enable-sim-reserved-bits Specify whether to check reserved bits in instruction.],
721 [case "${enableval}" in
722 yes) sim_reserved_bits="-DWITH_RESERVED_BITS=1";;
723 no) sim_reserved_bits="-DWITH_RESERVED_BITS=0";;
724 *) AC_MSG_ERROR("--enable-sim-reserved-bits does not take a value"); sim_reserved_bits="";;
726 if test x"$silent" != x"yes" && test x"$sim_reserved_bits" != x""; then
727 echo "Setting reserved flags = $sim_reserved_bits" 6>&1
728 fi],[sim_reserved_bits="-DWITH_RESERVED_BITS=${default_sim_reserved_bits}"])dnl
730 AC_SUBST(sim_reserved_bits)
733 AC_DEFUN([SIM_AC_OPTION_SMP],
735 default_sim_smp="ifelse([$1],,5,[$1])"
736 AC_ARG_ENABLE(sim-smp,
737 [ --enable-sim-smp=n Specify number of processors to configure for (default ${default_sim_smp}).],
738 [case "${enableval}" in
739 yes) sim_smp="-DWITH_SMP=5" ; sim_igen_smp="-N 5";;
740 no) sim_smp="-DWITH_SMP=0" ; sim_igen_smp="-N 0";;
741 *) sim_smp="-DWITH_SMP=$enableval" ; sim_igen_smp="-N $enableval";;
743 if test x"$silent" != x"yes" && test x"$sim_smp" != x""; then
744 echo "Setting smp flags = $sim_smp" 6>&1
745 fi],[sim_smp="-DWITH_SMP=${default_sim_smp}" ; sim_igen_smp="-N ${default_sim_smp}"
746 if test x"$silent" != x"yes"; then
747 echo "Setting smp flags = $sim_smp" 6>&1
753 AC_DEFUN([SIM_AC_OPTION_STDCALL],
755 AC_ARG_ENABLE(sim-stdcall,
756 [ --enable-sim-stdcall=type Use an alternative function call/return mechanism - x86/GCC specific.],
757 [case "${enableval}" in
758 no) sim_stdcall="" ;;
759 std*) sim_stdcall="-DWITH_STDCALL=1";;
760 yes) sim_stdcall="-DWITH_STDCALL=1";;
761 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-stdcall"); sim_stdcall="";;
763 if test x"$silent" != x"yes" && test x"$sim_stdcall" != x""; then
764 echo "Setting function call flags = $sim_stdcall" 6>&1
765 fi],[sim_stdcall=""])dnl
767 AC_SUBST(sim_stdcall)
770 AC_DEFUN([SIM_AC_OPTION_XOR_ENDIAN],
772 default_sim_xor_endian="ifelse([$1],,8,[$1])"
773 AC_ARG_ENABLE(sim-xor-endian,
774 [ --enable-sim-xor-endian=n Specify number bytes involved in XOR bi-endian mode (default ${default_sim_xor_endian}).],
775 [case "${enableval}" in
776 yes) sim_xor_endian="-DWITH_XOR_ENDIAN=8";;
777 no) sim_xor_endian="-DWITH_XOR_ENDIAN=0";;
778 *) sim_xor_endian="-DWITH_XOR_ENDIAN=$enableval";;
780 if test x"$silent" != x"yes" && test x"$sim_xor_endian" != x""; then
781 echo "Setting xor-endian flag = $sim_xor_endian" 6>&1
782 fi],[sim_xor_endian="-DWITH_XOR_ENDIAN=${default_sim_xor_endian}"])dnl
784 AC_SUBST(sim_xor_endian)
787 dnl --enable-build-warnings is for developers of the simulator.
788 dnl it enables extra GCC specific warnings.
789 AC_DEFUN([SIM_AC_OPTION_WARNINGS],
791 # NOTE: Don't add -Wall or -Wunused, they both include
792 # -Wunused-parameter which reports bogus warnings.
793 # NOTE: If you add to this list, remember to update
794 # gdb/doc/gdbint.texinfo.
795 build_warnings="-Wimplicit -Wreturn-type -Wcomment -Wtrigraphs \
796 -Wformat -Wparentheses -Wpointer-arith"
797 # GCC supports -Wuninitialized only with -O or -On, n != 0.
798 if test x${CFLAGS+set} = xset; then
802 build_warnings="${build_warnings} -Wuninitialized"
806 build_warnings="${build_warnings} -Wuninitialized"
808 # Up for debate: -Wswitch -Wcomment -trigraphs -Wtrigraphs
809 # -Wunused-function -Wunused-label -Wunused-variable -Wunused-value
810 # -Wchar-subscripts -Wtraditional -Wshadow -Wcast-qual
811 # -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes
812 # -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls
813 # -Woverloaded-virtual -Winline -Werror"
814 AC_ARG_ENABLE(build-warnings,
815 [ --enable-build-warnings Enable build-time compiler warnings if gcc is used],
816 [case "${enableval}" in
818 no) build_warnings="-w";;
819 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
820 build_warnings="${build_warnings} ${t}";;
821 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
822 build_warnings="${t} ${build_warnings}";;
823 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
825 if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
826 echo "Setting compiler warning flags = $build_warnings" 6>&1
828 AC_ARG_ENABLE(sim-build-warnings,
829 [ --enable-gdb-build-warnings Enable SIM specific build-time compiler warnings if gcc is used],
830 [case "${enableval}" in
832 no) build_warnings="-w";;
833 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
834 build_warnings="${build_warnings} ${t}";;
835 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
836 build_warnings="${t} ${build_warnings}";;
837 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
839 if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
840 echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
844 if test "x${build_warnings}" != x -a "x$GCC" = xyes
846 AC_MSG_CHECKING(compiler warning flags)
847 # Separate out the -Werror flag as some files just cannot be
848 # compiled with it enabled.
849 for w in ${build_warnings}; do
851 -Werr*) WERROR_CFLAGS=-Werror ;;
852 *) # Check that GCC accepts it
853 saved_CFLAGS="$CFLAGS"
855 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
856 CFLAGS="$saved_CFLAGS"
859 AC_MSG_RESULT(${WARN_CFLAGS}${WERROR_CFLAGS})
862 AC_SUBST(WARN_CFLAGS)
863 AC_SUBST(WERROR_CFLAGS)
866 dnl Generate the Makefile in a target specific directory.
867 dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
868 dnl so this is a cover macro to tuck the details away of how we cope.
869 dnl We cope by having autoconf generate two files and then merge them into
870 dnl one afterwards. The two pieces of the common fragment are inserted into
871 dnl the target's fragment at the appropriate points.
873 AC_DEFUN([SIM_AC_OUTPUT],
875 AC_LINK_FILES($sim_link_files, $sim_link_links)
876 dnl Make @cgen_breaks@ non-null only if the sim uses CGEN.
878 if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
879 cgen_breaks="break cgen_rtx_error";
881 AC_SUBST(cgen_breaks)
882 AC_CONFIG_FILES(Makefile.sim:Makefile.in)
883 AC_CONFIG_FILES(Make-common.sim:../common/Make-common.in)
884 AC_CONFIG_FILES(.gdbinit:../common/gdbinit.in)
885 AC_CONFIG_COMMANDS([Makefile],
886 [echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
887 rm -f Makesim1.tmp Makesim2.tmp Makefile
888 sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
889 sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
890 sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
891 -e '/^## COMMON_POST_/ r Makesim2.tmp' \
892 <Makefile.sim >Makefile
893 rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
895 AC_CONFIG_COMMANDS([stamp-h], [echo > stamp-h])
899 sinclude(../../config/gettext-sister.m4)
900 sinclude(../../config/acx.m4)
902 dnl --enable-cgen-maint support
903 AC_DEFUN([SIM_AC_OPTION_CGEN_MAINT],
906 dnl Default is to use one in build tree.
908 cgendir='$(srcdir)/../../cgen'
909 dnl Having --enable-maintainer-mode take arguments is another way to go.
910 dnl ??? One can argue --with is more appropriate if one wants to specify
911 dnl a directory name, but what we're doing here is an enable/disable kind
912 dnl of thing and specifying both --enable and --with is klunky.
913 dnl If you reeely want this to be --with, go ahead and change it.
914 AC_ARG_ENABLE(cgen-maint,
915 [ --enable-cgen-maint[=DIR] build cgen generated files],
916 [case "${enableval}" in
917 yes) cgen_maint=yes ;;
920 # argument is cgen install directory (not implemented yet).
921 # Having a `share' directory might be more appropriate for the .scm,
923 cgendir=${cgen_maint}/lib/cgen
927 dnl AM_CONDITIONAL(CGEN_MAINT, test x${cgen_maint} != xno)
928 if test x${cgen_maint} != xno ; then