sim: dv-cfi: check for log2 support in libm when enabled
[external/binutils.git] / sim / common / acinclude.m4
1 # This file contains common code used by all simulators.
2 #
3 # SIM_AC_COMMON invokes AC macros used by all simulators and by the common
4 # directory.  It is intended to be invoked before any target specific stuff.
5 # SIM_AC_OUTPUT is a cover function to AC_OUTPUT to generate the Makefile.
6 # It is intended to be invoked last.
7 #
8 # The simulator's configure.in should look like:
9 #
10 # dnl Process this file with autoconf to produce a configure script.
11 # AC_PREREQ(2.64)dnl
12 # AC_INIT(Makefile.in)
13 # sinclude(../common/aclocal.m4)
14 #
15 # SIM_AC_COMMON
16 #
17 # ... target specific stuff ...
18 #
19 # SIM_AC_OUTPUT
20
21 # Include global overrides and fixes for Autoconf.
22 m4_include(../../config/override.m4)
23 sinclude([../../config/zlib.m4])
24
25 AC_DEFUN([SIM_AC_COMMON],
26 [
27 AC_REQUIRE([AC_PROG_CC])
28 # autoconf.info says this should be called right after AC_INIT.
29 AC_CONFIG_HEADER(ifelse([$1],,config.h,[$1]):config.in)
30 AC_CANONICAL_SYSTEM
31 AC_ARG_PROGRAM
32 AC_PROG_INSTALL
33
34 # Put a plausible default for CC_FOR_BUILD in Makefile.
35 if test "x$cross_compiling" = "xno"; then
36   CC_FOR_BUILD='$(CC)'
37 else
38   CC_FOR_BUILD=gcc
39 fi
40 AC_SUBST(CC_FOR_BUILD)
41
42 AC_SUBST(CFLAGS)
43 AC_SUBST(HDEFINES)
44 AR=${AR-ar}
45 AC_SUBST(AR)
46 AC_PROG_RANLIB
47
48 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.
50 ALL_LINGUAS=
51 ZW_GNU_GETTEXT_SISTER_DIR(../../intl)
52
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)
61
62 # Check for socket libraries
63 AC_CHECK_LIB(socket, bind)
64 AC_CHECK_LIB(nsl, gethostbyname)
65
66 # BFD conditionally uses zlib, so we must link it in if libbfd does, by
67 # using the same condition.
68 AM_ZLIB
69
70 . ${srcdir}/../../bfd/configure.host
71
72 dnl Standard (and optional) simulator options.
73 dnl Eventually all simulators will support these.
74 dnl Do not add any here that cannot be supported by all simulators.
75 dnl Do not add similar but different options to a particular simulator,
76 dnl all shall eventually behave the same way.
77
78
79 dnl We don't use automake, but we still want to support
80 dnl --enable-maintainer-mode.
81 USE_MAINTAINER_MODE=no
82 AC_ARG_ENABLE(maintainer-mode,
83 [  --enable-maintainer-mode             Enable developer functionality.],
84 [case "${enableval}" in
85   yes)  MAINT="" USE_MAINTAINER_MODE=yes ;;
86   no)   MAINT="#" ;;
87   *)    AC_MSG_ERROR("--enable-maintainer-mode does not take a value"); MAINT="#" ;;
88 esac
89 if test x"$silent" != x"yes" && test x"$MAINT" = x""; then
90   echo "Setting maintainer mode" 6>&1
91 fi],[MAINT="#"])dnl
92 AC_SUBST(MAINT)
93
94
95 dnl This is a generic option to enable special byte swapping
96 dnl insns on *any* cpu.
97 AC_ARG_ENABLE(sim-bswap,
98 [  --enable-sim-bswap                   Use Host specific BSWAP instruction.],
99 [case "${enableval}" in
100   yes)  sim_bswap="-DWITH_BSWAP=1 -DUSE_BSWAP=1";;
101   no)   sim_bswap="-DWITH_BSWAP=0";;
102   *)    AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
103 esac
104 if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
105   echo "Setting bswap flags = $sim_bswap" 6>&1
106 fi],[sim_bswap=""])dnl
107 AC_SUBST(sim_bswap)
108
109
110 AC_ARG_ENABLE(sim-cflags,
111 [  --enable-sim-cflags=opts             Extra CFLAGS for use in building simulator],
112 [case "${enableval}" in
113   yes)   sim_cflags="-O2 -fomit-frame-pointer";;
114   trace) AC_MSG_ERROR("Please use --enable-sim-debug instead."); sim_cflags="";;
115   no)    sim_cflags="";;
116   *)     sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
117 esac
118 if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then
119   echo "Setting sim cflags = $sim_cflags" 6>&1
120 fi],[sim_cflags=""])dnl
121 AC_SUBST(sim_cflags)
122
123
124 dnl --enable-sim-debug is for developers of the simulator
125 dnl the allowable values are work-in-progress
126 AC_ARG_ENABLE(sim-debug,
127 [  --enable-sim-debug=opts              Enable debugging flags],
128 [case "${enableval}" in
129   yes) sim_debug="-DDEBUG=7 -DWITH_DEBUG=7";;
130   no)  sim_debug="-DDEBUG=0 -DWITH_DEBUG=0";;
131   *)   sim_debug="-DDEBUG='(${enableval})' -DWITH_DEBUG='(${enableval})'";;
132 esac
133 if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then
134   echo "Setting sim debug = $sim_debug" 6>&1
135 fi],[sim_debug=""])dnl
136 AC_SUBST(sim_debug)
137
138
139 dnl --enable-sim-stdio is for users of the simulator
140 dnl It determines if IO from the program is routed through STDIO (buffered)
141 AC_ARG_ENABLE(sim-stdio,
142 [  --enable-sim-stdio                   Specify whether to use stdio for console input/output.],
143 [case "${enableval}" in
144   yes)  sim_stdio="-DWITH_STDIO=DO_USE_STDIO";;
145   no)   sim_stdio="-DWITH_STDIO=DONT_USE_STDIO";;
146   *)    AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-stdio"); sim_stdio="";;
147 esac
148 if test x"$silent" != x"yes" && test x"$sim_stdio" != x""; then
149   echo "Setting stdio flags = $sim_stdio" 6>&1
150 fi],[sim_stdio=""])dnl
151 AC_SUBST(sim_stdio)
152
153
154 dnl --enable-sim-trace is for users of the simulator
155 dnl The argument is either a bitmask of things to enable [exactly what is
156 dnl up to the simulator], or is a comma separated list of names of tracing
157 dnl elements to enable.  The latter is only supported on simulators that
158 dnl use WITH_TRACE.
159 AC_ARG_ENABLE(sim-trace,
160 [  --enable-sim-trace=opts              Enable tracing flags],
161 [case "${enableval}" in
162   yes)  sim_trace="-DTRACE=1 -DWITH_TRACE=-1";;
163   no)   sim_trace="-DTRACE=0 -DWITH_TRACE=0";;
164   [[-0-9]]*)
165         sim_trace="-DTRACE='(${enableval})' -DWITH_TRACE='(${enableval})'";;
166   [[a-z]]*)
167         sim_trace=""
168         for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
169           if test x"$sim_trace" = x; then
170             sim_trace="-DWITH_TRACE='(TRACE_$x"
171           else
172             sim_trace="${sim_trace}|TRACE_$x"
173           fi
174         done
175         sim_trace="$sim_trace)'" ;;
176 esac
177 if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then
178   echo "Setting sim trace = $sim_trace" 6>&1
179 fi],[sim_trace=""])dnl
180 AC_SUBST(sim_trace)
181
182
183 dnl --enable-sim-profile
184 dnl The argument is either a bitmask of things to enable [exactly what is
185 dnl up to the simulator], or is a comma separated list of names of profiling
186 dnl elements to enable.  The latter is only supported on simulators that
187 dnl use WITH_PROFILE.
188 AC_ARG_ENABLE(sim-profile,
189 [  --enable-sim-profile=opts            Enable profiling flags],
190 [case "${enableval}" in
191   yes)  sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1";;
192   no)   sim_profile="-DPROFILE=0 -DWITH_PROFILE=0";;
193   [[-0-9]]*)
194         sim_profile="-DPROFILE='(${enableval})' -DWITH_PROFILE='(${enableval})'";;
195   [[a-z]]*)
196         sim_profile=""
197         for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
198           if test x"$sim_profile" = x; then
199             sim_profile="-DWITH_PROFILE='(PROFILE_$x"
200           else
201             sim_profile="${sim_profile}|PROFILE_$x"
202           fi
203         done
204         sim_profile="$sim_profile)'" ;;
205 esac
206 if test x"$silent" != x"yes" && test x"$sim_profile" != x""; then
207   echo "Setting sim profile = $sim_profile" 6>&1
208 fi],[sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1"])dnl
209 AC_SUBST(sim_profile)
210
211 ACX_PKGVERSION([GDB])
212 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
213 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
214 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
215
216 dnl Types used by common code
217 AC_TYPE_SIGNAL
218
219 dnl Detect exe extension
220 AC_EXEEXT
221
222 dnl These are available to append to as desired.
223 sim_link_files=
224 sim_link_links=
225
226 dnl Create tconfig.h either from simulator's tconfig.in or default one
227 dnl in common.
228 sim_link_links=tconfig.h
229 if test -f ${srcdir}/tconfig.in
230 then
231   sim_link_files=tconfig.in
232 else
233   sim_link_files=../common/tconfig.in
234 fi
235
236 # targ-vals.def points to the libc macro description file.
237 case "${target}" in
238 *-*-*) TARG_VALS_DEF=../common/nltvals.def ;;
239 esac
240 sim_link_files="${sim_link_files} ${TARG_VALS_DEF}"
241 sim_link_links="${sim_link_links} targ-vals.def"
242
243 ]) dnl End of SIM_AC_COMMON
244
245
246 dnl Additional SIM options that can (optionally) be configured
247 dnl For optional simulator options, a macro SIM_AC_OPTION_* is defined.
248 dnl Simulators that wish to use the relevant option specify the macro
249 dnl in the simulator specific configure.in file between the SIM_AC_COMMON
250 dnl and SIM_AC_OUTPUT lines.
251
252
253 dnl Specify the running environment.
254 dnl If the simulator invokes this in its configure.in then without this option
255 dnl the default is the user environment and all are runtime selectable.
256 dnl If the simulator doesn't invoke this, only the user environment is
257 dnl supported.
258 dnl ??? Until there is demonstrable value in doing something more complicated,
259 dnl let's not.
260 AC_DEFUN([SIM_AC_OPTION_ENVIRONMENT],
261 [
262 AC_ARG_ENABLE(sim-environment,
263 [  --enable-sim-environment=environment Specify mixed, user, virtual or operating environment.],
264 [case "${enableval}" in
265   all | ALL)             sim_environment="-DWITH_ENVIRONMENT=ALL_ENVIRONMENT";;
266   user | USER)           sim_environment="-DWITH_ENVIRONMENT=USER_ENVIRONMENT";;
267   virtual | VIRTUAL)     sim_environment="-DWITH_ENVIRONMENT=VIRTUAL_ENVIRONMENT";;
268   operating | OPERATING) sim_environment="-DWITH_ENVIRONMENT=OPERATING_ENVIRONMENT";;
269   *)   AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-environment");
270        sim_environment="";;
271 esac
272 if test x"$silent" != x"yes" && test x"$sim_environment" != x""; then
273   echo "Setting sim environment = $sim_environment" 6>&1
274 fi],
275 [sim_environment="-DWITH_ENVIRONMENT=ALL_ENVIRONMENT"])dnl
276 ])
277 AC_SUBST(sim_environment)
278
279
280 dnl Specify the alignment restrictions of the target architecture.
281 dnl Without this option all possible alignment restrictions are accommodated.
282 dnl arg[1] is hardwired target alignment
283 dnl arg[2] is default target alignment
284 AC_DEFUN([SIM_AC_OPTION_ALIGNMENT],
285 wire_alignment="[$1]"
286 default_alignment="[$2]"
287 [
288 AC_ARG_ENABLE(sim-alignment,
289 [  --enable-sim-alignment=align         Specify strict,  nonstrict or forced alignment of memory accesses.],
290 [case "${enableval}" in
291   strict | STRICT)       sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";;
292   nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";;
293   forced | FORCED)       sim_alignment="-DWITH_ALIGNMENT=FORCED_ALIGNMENT";;
294   yes) if test x"$wire_alignment" != x; then
295          sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
296        else
297          if test x"$default_alignment" != x; then
298            sim_alignment="-DWITH_ALIGNMENT=${default_alignment}"
299          else
300            echo "No hard-wired alignment for target $target" 1>&6
301            sim_alignment="-DWITH_ALIGNMENT=0"
302          fi
303        fi;;
304   no)  if test x"$default_alignment" != x; then
305          sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
306        else
307          if test x"$wire_alignment" != x; then
308            sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${wire_alignment}"
309          else
310            echo "No default alignment for target $target" 1>&6
311            sim_alignment="-DWITH_DEFAULT_ALIGNMENT=0"
312          fi
313        fi;;
314   *)   AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment"); sim_alignment="";;
315 esac
316 if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then
317   echo "Setting alignment flags = $sim_alignment" 6>&1
318 fi],
319 [if test x"$default_alignment" != x; then
320   sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
321 else
322   if test x"$wire_alignment" != x; then
323     sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
324   else
325     sim_alignment=
326   fi
327 fi])dnl
328 ])dnl
329 AC_SUBST(sim_alignment)
330
331
332 dnl Conditionally compile in assertion statements.
333 AC_DEFUN([SIM_AC_OPTION_ASSERT],
334 [
335 AC_ARG_ENABLE(sim-assert,
336 [  --enable-sim-assert                  Specify whether to perform random assertions.],
337 [case "${enableval}" in
338   yes)  sim_assert="-DWITH_ASSERT=1";;
339   no)   sim_assert="-DWITH_ASSERT=0";;
340   *)    AC_MSG_ERROR("--enable-sim-assert does not take a value"); sim_assert="";;
341 esac
342 if test x"$silent" != x"yes" && test x"$sim_assert" != x""; then
343   echo "Setting assert flags = $sim_assert" 6>&1
344 fi],[sim_assert=""])dnl
345 ])
346 AC_SUBST(sim_assert)
347
348
349
350 dnl --enable-sim-bitsize is for developers of the simulator
351 dnl It specifies the number of BITS in the target.
352 dnl arg[1] is the number of bits in a word
353 dnl arg[2] is the number assigned to the most significant bit
354 dnl arg[3] is the number of bits in an address
355 dnl arg[4] is the number of bits in an OpenFirmware cell.
356 dnl FIXME: this information should be obtained from bfd/archure
357 AC_DEFUN([SIM_AC_OPTION_BITSIZE],
358 wire_word_bitsize="[$1]"
359 wire_word_msb="[$2]"
360 wire_address_bitsize="[$3]"
361 wire_cell_bitsize="[$4]"
362 [AC_ARG_ENABLE(sim-bitsize,
363 [  --enable-sim-bitsize=N               Specify target bitsize (32 or 64).],
364 [sim_bitsize=
365 case "${enableval}" in
366   64,63 | 64,63,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63";;
367   32,31 | 32,31,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31";;
368   64,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";;
369   32,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";;
370   32) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then
371         sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31"
372       else
373         sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0"
374       fi ;;
375   64) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then
376         sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63"
377       else
378         sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=0"
379       fi ;;
380   *)  AC_MSG_ERROR("--enable-sim-bitsize was given $enableval.  Expected 32 or 64") ;;
381 esac
382 # address bitsize
383 tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9]]*,*//"`
384 case x"${tmp}" in
385   x ) ;;
386   x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=32" ;;
387   x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=64" ;;
388   * ) AC_MSG_ERROR("--enable-sim-bitsize was given address size $enableval.  Expected 32 or 64") ;;
389 esac
390 # cell bitsize
391 tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9*]]*,*[[0-9]]*,*//"`
392 case x"${tmp}" in
393   x ) ;;
394   x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=32" ;;
395   x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=64" ;;
396   * ) AC_MSG_ERROR("--enable-sim-bitsize was given cell size $enableval.  Expected 32 or 64") ;;
397 esac
398 if test x"$silent" != x"yes" && test x"$sim_bitsize" != x""; then
399   echo "Setting bitsize flags = $sim_bitsize" 6>&1
400 fi],
401 [sim_bitsize=""
402 if test x"$wire_word_bitsize" != x; then
403   sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_BITSIZE=$wire_word_bitsize"
404 fi
405 if test x"$wire_word_msb" != x; then
406   sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_MSB=$wire_word_msb"
407 fi
408 if test x"$wire_address_bitsize" != x; then
409   sim_bitsize="$sim_bitsize -DWITH_TARGET_ADDRESS_BITSIZE=$wire_address_bitsize"
410 fi
411 if test x"$wire_cell_bitsize" != x; then
412   sim_bitsize="$sim_bitsize -DWITH_TARGET_CELL_BITSIZE=$wire_cell_bitsize"
413 fi])dnl
414 ])
415 AC_SUBST(sim_bitsize)
416
417
418
419 dnl --enable-sim-endian={yes,no,big,little} is for simulators
420 dnl that support both big and little endian targets.
421 dnl arg[1] is hardwired target endianness.
422 dnl arg[2] is default target endianness.
423 AC_DEFUN([SIM_AC_OPTION_ENDIAN],
424 [
425 wire_endian="[$1]"
426 default_endian="[$2]"
427 AC_ARG_ENABLE(sim-endian,
428 [  --enable-sim-endian=endian           Specify target byte endian orientation.],
429 [case "${enableval}" in
430   b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
431   l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
432   yes)   if test x"$wire_endian" != x; then
433            sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}"
434          else
435            if test x"$default_endian" != x; then
436              sim_endian="-DWITH_TARGET_BYTE_ORDER=${default_endian}"
437            else
438              echo "No hard-wired endian for target $target" 1>&6
439              sim_endian="-DWITH_TARGET_BYTE_ORDER=0"
440            fi
441          fi;;
442   no)    if test x"$default_endian" != x; then
443            sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}"
444          else
445            if test x"$wire_endian" != x; then
446              sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${wire_endian}"
447            else
448              echo "No default endian for target $target" 1>&6
449              sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=0"
450            fi
451          fi;;
452   *)     AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
453 esac
454 if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
455   echo "Setting endian flags = $sim_endian" 6>&1
456 fi],
457 [if test x"$default_endian" != x; then
458   sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}"
459 else
460   if test x"$wire_endian" != x; then
461     sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}"
462   else
463     sim_endian=
464   fi
465 fi])dnl
466 ])
467 AC_SUBST(sim_endian)
468
469
470 dnl --enable-sim-hostendian is for users of the simulator when
471 dnl they find that AC_C_BIGENDIAN does not function correctly
472 dnl (for instance in a canadian cross)
473 AC_DEFUN([SIM_AC_OPTION_HOSTENDIAN],
474 [
475 AC_ARG_ENABLE(sim-hostendian,
476 [  --enable-sim-hostendian=end          Specify host byte endian orientation.],
477 [case "${enableval}" in
478   no)    sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";;
479   b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";;
480   l*|L*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN";;
481   *)     AC_MSG_ERROR("Unknown value $enableval for --enable-sim-hostendian"); sim_hostendian="";;
482 esac
483 if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
484   echo "Setting hostendian flags = $sim_hostendian" 6>&1
485 fi],[
486 if test "x$cross_compiling" = "xno"; then
487   AC_C_BIGENDIAN
488   if test $ac_cv_c_bigendian = yes; then
489     sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN"
490   else
491     sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN"
492   fi
493 else
494   sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
495 fi])dnl
496 ])
497 AC_SUBST(sim_hostendian)
498
499
500 dnl --enable-sim-float is for developers of the simulator
501 dnl It specifies the presence of hardware floating point
502 dnl And optionally the bitsize of the floating point register.
503 dnl arg[1] specifies the presence (or absence) of floating point hardware
504 dnl arg[2] specifies the number of bits in a floating point register
505 AC_DEFUN([SIM_AC_OPTION_FLOAT],
506 [
507 default_sim_float="[$1]"
508 default_sim_float_bitsize="[$2]"
509 AC_ARG_ENABLE(sim-float,
510 [  --enable-sim-float                   Specify that the target processor has floating point hardware.],
511 [case "${enableval}" in
512   yes | hard)   sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";;
513   no | soft)    sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";;
514   32)           sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=32";;
515   64)           sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=64";;
516   *)            AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-float"); sim_float="";;
517 esac
518 if test x"$silent" != x"yes" && test x"$sim_float" != x""; then
519   echo "Setting float flags = $sim_float" 6>&1
520 fi],[
521 sim_float=
522 if test x"${default_sim_float}" != x""; then
523   sim_float="-DWITH_FLOATING_POINT=${default_sim_float}"
524 fi
525 if test x"${default_sim_float_bitsize}" != x""; then
526   sim_float="$sim_float -DWITH_TARGET_FLOATING_POINT_BITSIZE=${default_sim_float_bitsize}"
527 fi
528 ])dnl
529 ])
530 AC_SUBST(sim_float)
531
532
533 dnl The argument is the default cache size if none is specified.
534 AC_DEFUN([SIM_AC_OPTION_SCACHE],
535 [
536 default_sim_scache="ifelse([$1],,0,[$1])"
537 AC_ARG_ENABLE(sim-scache,
538 [  --enable-sim-scache=size             Specify simulator execution cache size.],
539 [case "${enableval}" in
540   yes)  sim_scache="-DWITH_SCACHE=${default_sim_scache}";;
541   no)   sim_scache="-DWITH_SCACHE=0" ;;
542   [[0-9]]*) sim_scache="-DWITH_SCACHE=${enableval}";;
543   *)    AC_MSG_ERROR("Bad value $enableval passed to --enable-sim-scache");
544         sim_scache="";;
545 esac
546 if test x"$silent" != x"yes" && test x"$sim_scache" != x""; then
547   echo "Setting scache size = $sim_scache" 6>&1
548 fi],[sim_scache="-DWITH_SCACHE=${default_sim_scache}"])
549 ])
550 AC_SUBST(sim_scache)
551
552
553 dnl The argument is the default model if none is specified.
554 AC_DEFUN([SIM_AC_OPTION_DEFAULT_MODEL],
555 [
556 default_sim_default_model="ifelse([$1],,0,[$1])"
557 AC_ARG_ENABLE(sim-default-model,
558 [  --enable-sim-default-model=model     Specify default model to simulate.],
559 [case "${enableval}" in
560   yes|no) AC_MSG_ERROR("Missing argument to --enable-sim-default-model");;
561   *)    sim_default_model="-DWITH_DEFAULT_MODEL='\"${enableval}\"'";;
562 esac
563 if test x"$silent" != x"yes" && test x"$sim_default_model" != x""; then
564   echo "Setting default model = $sim_default_model" 6>&1
565 fi],[sim_default_model="-DWITH_DEFAULT_MODEL='\"${default_sim_default_model}\"'"])
566 ])
567 AC_SUBST(sim_default_model)
568
569
570 dnl --enable-sim-hardware is for users of the simulator
571 dnl arg[1] Enable sim-hw by default? ("yes" or "no")
572 dnl arg[2] is a space separated list of devices that override the defaults
573 dnl arg[3] is a space separated list of extra target specific devices.
574 AC_DEFUN([SIM_AC_OPTION_HARDWARE],
575 [
576 if test x"[$1]" = x"yes"; then
577   sim_hw_p=yes
578 else
579   sim_hw_p=no
580 fi
581 if test "[$2]"; then
582   hardware="[$2]"
583 else
584   hardware="cfi core pal glue"
585 fi
586 hardware="$hardware [$3]"
587 sim_hw_cflags="-DWITH_HW=1"
588 sim_hw="$hardware"
589 sim_hw_objs="\$(SIM_COMMON_HW_OBJS) `echo $sim_hw | sed -e 's/\([[^ ]][[^ ]]*\)/dv-\1.o/g'`"
590 AC_ARG_ENABLE(sim-hardware,
591 [  --enable-sim-hardware=LIST           Specify the hardware to be included in the build.],
592 [
593 case "${enableval}" in
594   yes)  sim_hw_p=yes;;
595   no)   sim_hw_p=no;;
596   ,*)   sim_hw_p=yes; hardware="${hardware} `echo ${enableval} | sed -e 's/,/ /'`";;
597   *,)   sim_hw_p=yes; hardware="`echo ${enableval} | sed -e 's/,/ /'` ${hardware}";;
598   *)    sim_hw_p=yes; hardware="`echo ${enableval} | sed -e 's/,/ /'`"'';;
599 esac
600 if test "$sim_hw_p" != yes; then
601   sim_hw_objs=
602   sim_hw_cflags="-DWITH_HW=0"
603   sim_hw=
604 else
605   sim_hw_cflags="-DWITH_HW=1"
606   # remove duplicates
607   sim_hw=""
608   sim_hw_objs="\$(SIM_COMMON_HW_OBJS)"
609   for i in $hardware ; do
610     case " $sim_hw " in
611       *" $i "*) ;;
612       *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";;
613     esac
614   done
615 fi
616 if test x"$silent" != x"yes" && test "$sim_hw_p" = "yes"; then
617   echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
618 fi],[
619 if test "$sim_hw_p" != yes; then
620   sim_hw_objs=
621   sim_hw_cflags="-DWITH_HW=0"
622   sim_hw=
623 fi
624 if test x"$silent" != x"yes"; then
625   echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
626 fi])
627 dnl Some devices require extra libraries.
628 case " $hardware " in
629   *" cfi "*) AC_CHECK_LIB(m, log2);;
630 esac
631 ])
632 AC_SUBST(sim_hw_cflags)
633 AC_SUBST(sim_hw_objs)
634 AC_SUBST(sim_hw)
635
636
637 dnl --enable-sim-inline is for users that wish to ramp up the simulator's
638 dnl performance by inlining functions.
639 dnl Guarantee that unconfigured simulators do not do any inlining
640 sim_inline="-DDEFAULT_INLINE=0"
641 AC_DEFUN([SIM_AC_OPTION_INLINE],
642 [
643 default_sim_inline="ifelse([$1],,,-DDEFAULT_INLINE=[$1])"
644 AC_ARG_ENABLE(sim-inline,
645 [  --enable-sim-inline=inlines          Specify which functions should be inlined.],
646 [sim_inline=""
647 case "$enableval" in
648   no)           sim_inline="-DDEFAULT_INLINE=0";;
649   0)            sim_inline="-DDEFAULT_INLINE=0";;
650   yes | 2)      sim_inline="-DDEFAULT_INLINE=ALL_C_INLINE";;
651   1)            sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";;
652   *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
653        new_flag=""
654        case "$x" in
655          *_INLINE=*)    new_flag="-D$x";;
656          *=*)           new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;;
657          *_INLINE)      new_flag="-D$x=ALL_C_INLINE";;
658          *)             new_flag="-D$x""_INLINE=ALL_C_INLINE";;
659        esac
660        if test x"$sim_inline" = x""; then
661          sim_inline="$new_flag"
662        else
663          sim_inline="$sim_inline $new_flag"
664        fi
665      done;;
666 esac
667 if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
668   echo "Setting inline flags = $sim_inline" 6>&1
669 fi],[
670 if test "x$cross_compiling" = "xno"; then
671   if test x"$GCC" != "x" -a x"${default_sim_inline}" != "x" ; then
672     sim_inline="${default_sim_inline}"
673     if test x"$silent" != x"yes"; then
674       echo "Setting inline flags = $sim_inline" 6>&1
675     fi
676   else
677     sim_inline=""
678   fi
679 else
680   sim_inline="-DDEFAULT_INLINE=0"
681 fi])dnl
682 ])
683 AC_SUBST(sim_inline)
684
685
686 AC_DEFUN([SIM_AC_OPTION_PACKAGES],
687 [
688 AC_ARG_ENABLE(sim-packages,
689 [  --enable-sim-packages=list           Specify the packages to be included in the build.],
690 [packages=disklabel
691 case "${enableval}" in
692   yes)  ;;
693   no)   AC_MSG_ERROR("List of packages must be specified for --enable-sim-packages"); packages="";;
694   ,*)   packages="${packages}${enableval}";;
695   *,)   packages="${enableval}${packages}";;
696   *)    packages="${enableval}"'';;
697 esac
698 sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'`
699 sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'`
700 if test x"$silent" != x"yes" && test x"$packages" != x""; then
701   echo "Setting packages to $sim_pk_src, $sim_pk_obj"
702 fi],[packages=disklabel
703 sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'`
704 sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'`
705 if test x"$silent" != x"yes"; then
706   echo "Setting packages to $sim_pk_src, $sim_pk_obj"
707 fi])dnl
708 ])
709 AC_SUBST(sim_packages)
710
711
712 AC_DEFUN([SIM_AC_OPTION_REGPARM],
713 [
714 AC_ARG_ENABLE(sim-regparm,
715 [  --enable-sim-regparm=nr-parm         Pass parameters in registers instead of on the stack - x86/GCC specific.],
716 [case "${enableval}" in
717   0*|1*|2*|3*|4*|5*|6*|7*|8*|9*) sim_regparm="-DWITH_REGPARM=${enableval}";;
718   no)                            sim_regparm="" ;;
719   yes)                           sim_regparm="-DWITH_REGPARM=3";;
720   *)   AC_MSG_ERROR("Unknown value $enableval for --enable-sim-regparm"); sim_regparm="";;
721 esac
722 if test x"$silent" != x"yes" && test x"$sim_regparm" != x""; then
723   echo "Setting regparm flags = $sim_regparm" 6>&1
724 fi],[sim_regparm=""])dnl
725 ])
726 AC_SUBST(sim_regparm)
727
728
729 AC_DEFUN([SIM_AC_OPTION_RESERVED_BITS],
730 [
731 default_sim_reserved_bits="ifelse([$1],,1,[$1])"
732 AC_ARG_ENABLE(sim-reserved-bits,
733 [  --enable-sim-reserved-bits           Specify whether to check reserved bits in instruction.],
734 [case "${enableval}" in
735   yes)  sim_reserved_bits="-DWITH_RESERVED_BITS=1";;
736   no)   sim_reserved_bits="-DWITH_RESERVED_BITS=0";;
737   *)    AC_MSG_ERROR("--enable-sim-reserved-bits does not take a value"); sim_reserved_bits="";;
738 esac
739 if test x"$silent" != x"yes" && test x"$sim_reserved_bits" != x""; then
740   echo "Setting reserved flags = $sim_reserved_bits" 6>&1
741 fi],[sim_reserved_bits="-DWITH_RESERVED_BITS=${default_sim_reserved_bits}"])dnl
742 ])
743 AC_SUBST(sim_reserved_bits)
744
745
746 AC_DEFUN([SIM_AC_OPTION_SMP],
747 [
748 default_sim_smp="ifelse([$1],,5,[$1])"
749 AC_ARG_ENABLE(sim-smp,
750 [  --enable-sim-smp=n                   Specify number of processors to configure for (default ${default_sim_smp}).],
751 [case "${enableval}" in
752   yes)  sim_smp="-DWITH_SMP=5" ; sim_igen_smp="-N 5";;
753   no)   sim_smp="-DWITH_SMP=0" ; sim_igen_smp="-N 0";;
754   *)    sim_smp="-DWITH_SMP=$enableval" ; sim_igen_smp="-N $enableval";;
755 esac
756 if test x"$silent" != x"yes" && test x"$sim_smp" != x""; then
757   echo "Setting smp flags = $sim_smp" 6>&1
758 fi],[sim_smp="-DWITH_SMP=${default_sim_smp}" ; sim_igen_smp="-N ${default_sim_smp}"
759 if test x"$silent" != x"yes"; then
760   echo "Setting smp flags = $sim_smp" 6>&1
761 fi])dnl
762 ])
763 AC_SUBST(sim_smp)
764
765
766 AC_DEFUN([SIM_AC_OPTION_STDCALL],
767 [
768 AC_ARG_ENABLE(sim-stdcall,
769 [  --enable-sim-stdcall=type            Use an alternative function call/return mechanism - x86/GCC specific.],
770 [case "${enableval}" in
771   no)           sim_stdcall="" ;;
772   std*)         sim_stdcall="-DWITH_STDCALL=1";;
773   yes)          sim_stdcall="-DWITH_STDCALL=1";;
774   *)   AC_MSG_ERROR("Unknown value $enableval for --enable-sim-stdcall"); sim_stdcall="";;
775 esac
776 if test x"$silent" != x"yes" && test x"$sim_stdcall" != x""; then
777   echo "Setting function call flags = $sim_stdcall" 6>&1
778 fi],[sim_stdcall=""])dnl
779 ])
780 AC_SUBST(sim_stdcall)
781
782
783 AC_DEFUN([SIM_AC_OPTION_XOR_ENDIAN],
784 [
785 default_sim_xor_endian="ifelse([$1],,8,[$1])"
786 AC_ARG_ENABLE(sim-xor-endian,
787 [  --enable-sim-xor-endian=n            Specify number bytes involved in XOR bi-endian mode (default ${default_sim_xor_endian}).],
788 [case "${enableval}" in
789   yes)  sim_xor_endian="-DWITH_XOR_ENDIAN=8";;
790   no)   sim_xor_endian="-DWITH_XOR_ENDIAN=0";;
791   *)    sim_xor_endian="-DWITH_XOR_ENDIAN=$enableval";;
792 esac
793 if test x"$silent" != x"yes" && test x"$sim_xor_endian" != x""; then
794   echo "Setting xor-endian flag = $sim_xor_endian" 6>&1
795 fi],[sim_xor_endian="-DWITH_XOR_ENDIAN=${default_sim_xor_endian}"])dnl
796 ])
797 AC_SUBST(sim_xor_endian)
798
799
800 dnl --enable-build-warnings is for developers of the simulator.
801 dnl it enables extra GCC specific warnings.
802 AC_DEFUN([SIM_AC_OPTION_WARNINGS],
803 [
804 # NOTE: Don't add -Wall or -Wunused, they both include
805 # -Wunused-parameter which reports bogus warnings.
806 # NOTE: If you add to this list, remember to update
807 # gdb/doc/gdbint.texinfo.
808 build_warnings="-Wimplicit -Wreturn-type -Wcomment -Wtrigraphs \
809 -Wformat -Wparentheses -Wpointer-arith"
810 # GCC supports -Wuninitialized only with -O or -On, n != 0.
811 if test x${CFLAGS+set} = xset; then
812   case "${CFLAGS}" in
813     *"-O0"* ) ;;
814     *"-O"* )
815       build_warnings="${build_warnings} -Wuninitialized"
816     ;;
817   esac
818 else
819   build_warnings="${build_warnings} -Wuninitialized"
820 fi
821 # Up for debate: -Wswitch -Wcomment -trigraphs -Wtrigraphs
822 # -Wunused-function -Wunused-label -Wunused-variable -Wunused-value
823 # -Wchar-subscripts -Wtraditional -Wshadow -Wcast-qual
824 # -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes
825 # -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls
826 # -Woverloaded-virtual -Winline -Werror"
827 AC_ARG_ENABLE(build-warnings,
828 [  --enable-build-warnings Enable build-time compiler warnings if gcc is used],
829 [case "${enableval}" in
830   yes)  ;;
831   no)   build_warnings="-w";;
832   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
833         build_warnings="${build_warnings} ${t}";;
834   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
835         build_warnings="${t} ${build_warnings}";;
836   *)    build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
837 esac
838 if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
839   echo "Setting compiler warning flags = $build_warnings" 6>&1
840 fi])dnl
841 AC_ARG_ENABLE(sim-build-warnings,
842 [  --enable-gdb-build-warnings Enable SIM specific build-time compiler warnings if gcc is used],
843 [case "${enableval}" in
844   yes)  ;;
845   no)   build_warnings="-w";;
846   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
847         build_warnings="${build_warnings} ${t}";;
848   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
849         build_warnings="${t} ${build_warnings}";;
850   *)    build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
851 esac
852 if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
853   echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
854 fi])dnl
855 WARN_CFLAGS=""
856 WERROR_CFLAGS=""
857 if test "x${build_warnings}" != x -a "x$GCC" = xyes
858 then
859     AC_MSG_CHECKING(compiler warning flags)
860     # Separate out the -Werror flag as some files just cannot be
861     # compiled with it enabled.
862     for w in ${build_warnings}; do
863         case $w in
864         -Werr*) WERROR_CFLAGS=-Werror ;;
865         *) # Check that GCC accepts it
866             saved_CFLAGS="$CFLAGS"
867             CFLAGS="$CFLAGS $w"
868             AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
869             CFLAGS="$saved_CFLAGS"
870         esac
871     done
872     AC_MSG_RESULT(${WARN_CFLAGS}${WERROR_CFLAGS})
873 fi
874 ])
875 AC_SUBST(WARN_CFLAGS)
876 AC_SUBST(WERROR_CFLAGS)
877
878
879 dnl Generate the Makefile in a target specific directory.
880 dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
881 dnl so this is a cover macro to tuck the details away of how we cope.
882 dnl We cope by having autoconf generate two files and then merge them into
883 dnl one afterwards.  The two pieces of the common fragment are inserted into
884 dnl the target's fragment at the appropriate points.
885
886 AC_DEFUN([SIM_AC_OUTPUT],
887 [
888 AC_LINK_FILES($sim_link_files, $sim_link_links)
889 dnl Make @cgen_breaks@ non-null only if the sim uses CGEN.
890 cgen_breaks=""
891 if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
892 cgen_breaks="break cgen_rtx_error";
893 fi
894 AC_SUBST(cgen_breaks)
895 AC_CONFIG_FILES(Makefile.sim:Makefile.in)
896 AC_CONFIG_FILES(Make-common.sim:../common/Make-common.in)
897 AC_CONFIG_FILES(.gdbinit:../common/gdbinit.in)
898 AC_CONFIG_COMMANDS([Makefile],
899 [echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
900  rm -f Makesim1.tmp Makesim2.tmp Makefile
901  sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
902  sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
903  sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
904         -e '/^## COMMON_POST_/ r Makesim2.tmp' \
905         <Makefile.sim >Makefile
906  rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
907 ])
908 AC_CONFIG_COMMANDS([stamp-h], [echo > stamp-h])
909 AC_OUTPUT
910 ])
911
912 sinclude(../../config/gettext-sister.m4)
913 sinclude(../../config/acx.m4)
914
915 dnl --enable-cgen-maint support
916 AC_DEFUN([SIM_AC_OPTION_CGEN_MAINT],
917 [
918 cgen_maint=no
919 dnl Default is to use one in build tree.
920 cgen=guile
921 cgendir='$(srcdir)/../../cgen'
922 dnl Having --enable-maintainer-mode take arguments is another way to go.
923 dnl ??? One can argue --with is more appropriate if one wants to specify
924 dnl a directory name, but what we're doing here is an enable/disable kind
925 dnl of thing and specifying both --enable and --with is klunky.
926 dnl If you reeely want this to be --with, go ahead and change it.
927 AC_ARG_ENABLE(cgen-maint,
928 [  --enable-cgen-maint[=DIR]    build cgen generated files],
929 [case "${enableval}" in
930   yes)  cgen_maint=yes ;;
931   no)   cgen_maint=no ;;
932   *)
933         # argument is cgen install directory (not implemented yet).
934         # Having a `share' directory might be more appropriate for the .scm,
935         # .cpu, etc. files.
936         cgendir=${cgen_maint}/lib/cgen
937         cgen=guile
938         ;;
939 esac])dnl
940 dnl AM_CONDITIONAL(CGEN_MAINT, test x${cgen_maint} != xno)
941 if test x${cgen_maint} != xno ; then
942   CGEN_MAINT=''
943 else
944   CGEN_MAINT='#'
945 fi
946 AC_SUBST(CGEN_MAINT)
947 AC_SUBST(cgendir)
948 AC_SUBST(cgen)
949 ])