Cleanup INLINE support for simulators using common framework.
[external/binutils.git] / sim / common / aclocal.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 # sinclude(../common/aclocal.m4)
12 # AC_PREREQ(2.5)dnl
13 # AC_INIT(Makefile.in)
14 #
15 # SIM_AC_COMMON
16 #
17 # ... target specific stuff ...
18 #
19 # SIM_AC_OUTPUT
20
21 AC_DEFUN(SIM_AC_COMMON,
22 [
23 # autoconf.info says this should be called right after AC_INIT.
24 AC_CONFIG_HEADER(ifelse([$1],,config.h,[$1]):config.in)
25
26 AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..)
27 AC_CANONICAL_SYSTEM
28 AC_ARG_PROGRAM
29 AC_PROG_CC
30 AC_PROG_INSTALL
31
32 # Put a plausible default for CC_FOR_BUILD in Makefile.
33 if test "x$cross_compiling" = "xno"; then
34   CC_FOR_BUILD='$(CC)'
35 else
36   CC_FOR_BUILD=gcc
37 fi
38 AC_SUBST(CC_FOR_BUILD)
39
40 AC_SUBST(CFLAGS)
41 AC_SUBST(HDEFINES)
42 AR=${AR-ar}
43 AC_SUBST(AR)
44 AC_PROG_RANLIB
45
46 # Check for common headers.
47 # FIXME: Seems to me this can cause problems for i386-windows hosts.
48 # At one point there were hardcoded AC_DEFINE's if ${host} = i386-*-windows*.
49 AC_CHECK_HEADERS(stdlib.h string.h strings.h unistd.h time.h)
50 AC_CHECK_HEADERS(sys/time.h sys/resource.h)
51 AC_CHECK_HEADERS(fcntl.h fpu_control.h)
52 AC_CHECK_FUNCS(getrusage time sigaction __setfpucw)
53
54 . ${srcdir}/../../bfd/configure.host
55
56 dnl Standard (and optional) simulator options.
57 dnl Eventually all simulators will support these.
58 dnl Do not add any here that cannot be supported by all simulators.
59 dnl Do not add similar but different options to a particular simulator,
60 dnl all shall eventually behave the same way.
61
62
63 dnl We don't use automake, but we still want to support
64 dnl --enable-maintainer-mode.
65 USE_MAINTAINER_MODE=no
66 AC_ARG_ENABLE(maintainer-mode,
67 [  --enable-maintainer-mode             Enable developer functionality.],
68 [case "${enableval}" in
69   yes)  MAINT="" USE_MAINTAINER_MODE=yes ;;
70   no)   MAINT="#" ;;
71   *)    AC_MSG_ERROR("--enable-maintainer-mode does not take a value"); MAINT="#" ;;
72 esac
73 if test x"$silent" != x"yes" && test x"$MAINT" = x""; then
74   echo "Setting maintainer mode" 6>&1
75 fi],[MAINT="#"])dnl
76 AC_SUBST(MAINT)
77
78
79 dnl This is a generic option to enable special byte swapping
80 dnl insns on *any* cpu.
81 AC_ARG_ENABLE(sim-bswap,
82 [  --enable-sim-bswap                   Use Host specific BSWAP instruction.],
83 [case "${enableval}" in
84   yes)  sim_bswap="-DWITH_BSWAP=1 -DUSE_BSWAP=1";;
85   no)   sim_bswap="-DWITH_BSWAP=0";;
86   *)    AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
87 esac
88 if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
89   echo "Setting bswap flags = $sim_bswap" 6>&1
90 fi],[sim_bswap=""])dnl
91 AC_SUBST(sim_bswap)
92
93
94 AC_ARG_ENABLE(sim-cflags,
95 [  --enable-sim-cflags=opts             Extra CFLAGS for use in building simulator],
96 [case "${enableval}" in
97   yes)   sim_cflags="-O2 -fomit-frame-pointer";;
98   trace) AC_MSG_ERROR("Please use --enable-sim-debug instead."); sim_cflags="";;
99   no)    sim_cflags="";;
100   *)     sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
101 esac
102 if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then
103   echo "Setting sim cflags = $sim_cflags" 6>&1
104 fi],[sim_cflags=""])dnl
105 AC_SUBST(sim_cflags)
106
107
108 dnl --enable-sim-debug is for developers of the simulator
109 dnl the allowable values are work-in-progress
110 AC_ARG_ENABLE(sim-debug,
111 [  --enable-sim-debug=opts              Enable debugging flags],
112 [case "${enableval}" in
113   yes) sim_debug="-DDEBUG=7 -DWITH_DEBUG=7";;
114   no)  sim_debug="-DDEBUG=0 -DWITH_DEBUG=0";;
115   *)   sim_debug="-DDEBUG='(${enableval})' -DWITH_DEBUG='(${enableval})'";;
116 esac
117 if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then
118   echo "Setting sim debug = $sim_debug" 6>&1
119 fi],[sim_debug=""])dnl
120 AC_SUBST(sim_debug)
121
122
123 dnl --enable-sim-stdio is for users of the simulator
124 dnl It determines if IO from the program is routed through STDIO (buffered)
125 AC_ARG_ENABLE(sim-stdio,
126 [  --enable-sim-stdio                   Specify whether to use stdio for console input/output.],
127 [case "${enableval}" in
128   yes)  sim_stdio="-DWITH_STDIO=DO_USE_STDIO";;
129   no)   sim_stdio="-DWITH_STDIO=DONT_USE_STDIO";;
130   *)    AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-stdio"); sim_stdio="";;
131 esac
132 if test x"$silent" != x"yes" && test x"$sim_stdio" != x""; then
133   echo "Setting stdio flags = $sim_stdio" 6>&1
134 fi],[sim_stdio=""])dnl
135 AC_SUBST(sim_stdio)
136
137
138 dnl --enable-sim-trace is for users of the simulator
139 dnl The argument is either a bitmask of things to enable [exactly what is
140 dnl up to the simulator], or is a comma separated list of names of tracing
141 dnl elements to enable.  The latter is only supported on simulators that
142 dnl use WITH_TRACE.
143 AC_ARG_ENABLE(sim-trace,
144 [  --enable-sim-trace=opts              Enable tracing flags],
145 [case "${enableval}" in
146   yes)  sim_trace="-DTRACE=1 -DWITH_TRACE=-1";;
147   no)   sim_trace="-DTRACE=0 -DWITH_TRACE=0";;
148   [[-0-9]]*)
149         sim_trace="-DTRACE='(${enableval})' -DWITH_TRACE='(${enableval})'";;
150   [[a-z]]*)
151         sim_trace=""
152         for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
153           if test x"$sim_trace" = x; then
154             sim_trace="-DWITH_TRACE='(TRACE_$x"
155           else
156             sim_trace="${sim_trace}|TRACE_$x"
157           fi
158         done
159         sim_trace="$sim_trace)'" ;;
160 esac
161 if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then
162   echo "Setting sim trace = $sim_trace" 6>&1
163 fi],[sim_trace=""])dnl
164 AC_SUBST(sim_trace)
165
166
167 dnl --enable-sim-profile
168 dnl The argument is either a bitmask of things to enable [exactly what is
169 dnl up to the simulator], or is a comma separated list of names of profiling
170 dnl elements to enable.  The latter is only supported on simulators that
171 dnl use WITH_PROFILE.
172 AC_ARG_ENABLE(sim-profile,
173 [  --enable-sim-profile=opts            Enable profiling flags],
174 [case "${enableval}" in
175   yes)  sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1";;
176   no)   sim_profile="-DPROFILE=0 -DWITH_PROFILE=0";;
177   [[-0-9]]*)
178         sim_profile="-DPROFILE='(${enableval})' -DWITH_PROFILE='(${enableval})'";;
179   [[a-z]]*)
180         sim_profile=""
181         for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
182           if test x"$sim_profile" = x; then
183             sim_profile="-DWITH_PROFILE='(PROFILE_$x"
184           else
185             sim_profile="${sim_profile}|PROFILE_$x"
186           fi
187         done
188         sim_profile="$sim_profile)'" ;;
189 esac
190 if test x"$silent" != x"yes" && test x"$sim_profile" != x""; then
191   echo "Setting sim profile = $sim_profile" 6>&1
192 fi],[sim_profile=""])dnl
193 AC_SUBST(sim_profile)
194
195
196 dnl Types used by common code
197 AC_TYPE_SIGNAL
198
199
200 dnl These are available to append to as desired.
201 sim_link_files=
202 sim_link_links=
203
204 dnl Create tconfig.h either from simulator's tconfig.in or default one
205 dnl in common.
206 sim_link_links=tconfig.h
207 if test -f ${srcdir}/tconfig.in
208 then
209   sim_link_files=tconfig.in
210 else
211   sim_link_files=../common/tconfig.in
212 fi
213
214 # targ-vals.def points to the libc macro description file.
215 case "${target}" in
216 *-*-*) TARG_VALS_DEF=../common/nltvals.def ;;
217 esac
218 sim_link_files="${sim_link_files} ${TARG_VALS_DEF}"
219 sim_link_links="${sim_link_links} targ-vals.def"
220
221 ]) dnl End of SIM_AC_COMMON
222
223
224 dnl Additional SIM options that can (optionally) be configured
225 dnl For optional simulator options, a macro SIM_AC_OPTION_* is defined.
226 dnl Simulators that wish to use the relevant option specify the macro
227 dnl in the simulator specific configure.in file between the SIM_AC_COMMON
228 dnl and SIM_AC_OUTPUT lines.
229
230
231 dnl Specify the running environment.
232 dnl If the simulator invokes this in its configure.in then without this option
233 dnl the default is the user environment and all are runtime selectable.
234 dnl If the simulator doesn't invoke this, only the user environment is
235 dnl supported.
236 dnl ??? Until there is demonstrable value in doing something more complicated,
237 dnl let's not.
238 AC_DEFUN(SIM_AC_OPTION_ENVIRONMENT,
239 [
240 AC_ARG_ENABLE(sim-environment,
241 [  --enable-sim-environment=environment Specify mixed, user, virtual or operating environment.],
242 [case "${enableval}" in
243   all | ALL)             sim_environment="-DWITH_ENVIRONMENT=ALL_ENVIRONMENT";;
244   user | USER)           sim_environment="-DWITH_ENVIRONMENT=USER_ENVIRONMENT";;
245   virtual | VIRTUAL)     sim_environment="-DWITH_ENVIRONMENT=VIRTUAL_ENVIRONMENT";;
246   operating | OPERATING) sim_environment="-DWITH_ENVIRONMENT=OPERATING_ENVIRONMENT";;
247   *)   AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-environment");
248        sim_environment="";;
249 esac
250 if test x"$silent" != x"yes" && test x"$sim_environment" != x""; then
251   echo "Setting sim environment = $sim_environment" 6>&1
252 fi],
253 [sim_environment="-DWITH_ENVIRONMENT=ALL_ENVIRONMENT"])dnl
254 ])
255 AC_SUBST(sim_environment)
256
257
258 dnl Specify the alignment restrictions of the target architecture.
259 dnl Without this option all possible alignment restrictions are accommodated.
260 dnl arg[1] is hardwired target alignment
261 dnl arg[2] is default target alignment
262 AC_DEFUN(SIM_AC_OPTION_ALIGNMENT,
263 wire_alignment="[$1]"
264 default_alignment="[$2]"
265 [
266 AC_ARG_ENABLE(sim-alignment,
267 [  --enable-sim-alignment=align         Specify strict,  nonstrict or forced alignment of memory accesses.],
268 [case "${enableval}" in
269   strict | STRICT)       sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";;
270   nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";;
271   forced | FORCED)       sim_alignment="-DWITH_ALIGNMENT=FORCED_ALIGNMENT";;
272   yes) if test x"$wire_alignment" != x; then
273          sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
274        else
275          if test x"$default_alignment" != x; then
276            sim_alignment="-DWITH_ALIGNMENT=${default_alignment}"
277          else
278            echo "No hard-wired alignment for target $target" 1>&6
279            sim_alignment="-DWITH_ALIGNMENT=0"
280          fi
281        fi;;
282   no)  if test x"$default_alignment" != x; then
283          sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
284        else
285          if test x"$wire_alignment" != x; then
286            sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${wire_alignment}"
287          else
288            echo "No default alignment for target $target" 1>&6
289            sim_alignment="-DWITH_DEFAULT_ALIGNMENT=0"
290          fi
291        fi;;
292   *)   AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment"); sim_alignment="";;
293 esac
294 if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then
295   echo "Setting alignment flags = $sim_alignment" 6>&1
296 fi],
297 [if test x"$default_alignment" != x; then
298   sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
299 else
300   if test x"$wire_alignment" != x; then
301     sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
302   else
303     sim_alignment=
304   fi
305 fi])dnl
306 ])dnl
307 AC_SUBST(sim_alignment)
308
309
310 dnl Conditionally compile in assertion statements.
311 AC_DEFUN(SIM_AC_OPTION_ASSERT,
312 [
313 AC_ARG_ENABLE(sim-assert,
314 [  --enable-sim-assert                  Specify whether to perform random assertions.],
315 [case "${enableval}" in
316   yes)  sim_assert="-DWITH_ASSERT=1";;
317   no)   sim_assert="-DWITH_ASSERT=0";;
318   *)    AC_MSG_ERROR("--enable-sim-assert does not take a value"); sim_assert="";;
319 esac
320 if test x"$silent" != x"yes" && test x"$sim_assert" != x""; then
321   echo "Setting assert flags = $sim_assert" 6>&1
322 fi],[sim_assert=""])dnl
323 ])
324 AC_SUBST(sim_assert)
325
326
327
328 dnl --enable-sim-bitsize is for developers of the simulator
329 dnl It specifies the number of BITS in the target.
330 dnl arg[1] is the number of bits in a word
331 dnl arg[2] is the number assigned to the most significant bit
332 dnl arg[3] is the number of bits in an address
333 dnl arg[4] is the number of bits in an OpenFirmware cell.
334 dnl FIXME: this information should be obtained from bfd/archure
335 AC_DEFUN(SIM_AC_OPTION_BITSIZE,
336 wire_word_bitsize="[$1]"
337 wire_word_msb="[$2]"
338 wire_address_bitsize="[$3]"
339 wire_cell_bitsize="[$4]"
340 [AC_ARG_ENABLE(sim-bitsize,
341 [  --enable-sim-bitsize=N               Specify target bitsize (32 or 64).],
342 [sim_bitsize=
343 case "${enableval}" in
344   64,63 | 64,63,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63";;
345   32,31 | 32,31,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31";;
346   64,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";;
347   32,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";;
348   32) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then
349         sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31"
350       else
351         sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0"
352       fi ;;
353   64) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then
354         sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63"
355       else
356         sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=0"
357       fi ;;
358   *)  AC_MSG_ERROR("--enable-sim-bitsize was given $enableval.  Expected 32 or 64") ;;
359 esac
360 # address bitsize
361 tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9]]*,*//"`
362 case x"${tmp}" in
363   x ) ;;
364   x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=32" ;;
365   x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=64" ;;
366   * ) AC_MSG_ERROR("--enable-sim-bitsize was given address size $enableval.  Expected 32 or 64") ;;
367 esac
368 # cell bitsize
369 tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9*]]*,*[[0-9]]*,*//"`
370 case x"${tmp}" in
371   x ) ;;
372   x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=32" ;;
373   x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=64" ;;
374   * ) AC_MSG_ERROR("--enable-sim-bitsize was given cell size $enableval.  Expected 32 or 64") ;;
375 esac
376 if test x"$silent" != x"yes" && test x"$sim_bitsize" != x""; then
377   echo "Setting bitsize flags = $sim_bitsize" 6>&1
378 fi],
379 [sim_bitsize=""
380 if test x"$wire_word_bitsize" != x; then
381   sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_BITSIZE=$wire_word_bitsize"
382 fi
383 if test x"$wire_word_msb" != x; then
384   sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_MSB=$wire_word_msb"
385 fi
386 if test x"$wire_address_bitsize" != x; then
387   sim_bitsize="$sim_bitsize -DWITH_TARGET_ADDRESS_BITSIZE=$wire_address_bitsize"
388 fi
389 if test x"$wire_cell_bitsize" != x; then
390   sim_bitsize="$sim_bitsize -DWITH_TARGET_CELL_BITSIZE=$wire_cell_bitsize"
391 fi])dnl
392 ])
393 AC_SUBST(sim_bitsize)
394
395
396
397 dnl --enable-sim-endian={yes,no,big,little} is for simulators
398 dnl that support both big and little endian targets.
399 dnl arg[1] is hardwired target endianness.
400 dnl arg[2] is default target endianness.
401 AC_DEFUN(SIM_AC_OPTION_ENDIAN,
402 [
403 wire_endian="[$1]"
404 default_endian="[$2]"
405 AC_ARG_ENABLE(sim-endian,
406 [  --enable-sim-endian=endian           Specify target byte endian orientation.],
407 [case "${enableval}" in
408   b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
409   l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
410   yes)   if test x"$wire_endian" != x; then
411            sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}"
412          else
413            if test x"$default_endian" != x; then
414              sim_endian="-DWITH_TARGET_BYTE_ORDER=${default_endian}"
415            else
416              echo "No hard-wired endian for target $target" 1>&6
417              sim_endian="-DWITH_TARGET_BYTE_ORDER=0"
418            fi
419          fi;;
420   no)    if test x"$default_endian" != x; then
421            sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}"
422          else
423            if test x"$wire_endian" != x; then
424              sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${wire_endian}"
425            else
426              echo "No default endian for target $target" 1>&6
427              sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=0"
428            fi
429          fi;;
430   *)     AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
431 esac
432 if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
433   echo "Setting endian flags = $sim_endian" 6>&1
434 fi],
435 [if test x"$default_endian" != x; then
436   sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}"
437 else
438   if test x"$wire_endian" != x; then
439     sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}"
440   else
441     sim_endian=
442   fi
443 fi])dnl
444 ])
445 AC_SUBST(sim_endian)
446
447
448 dnl --enable-sim-hostendian is for users of the simulator when
449 dnl they find that AC_C_BIGENDIAN does not function correctly
450 dnl (for instance in a canadian cross)
451 AC_DEFUN(SIM_AC_OPTION_HOSTENDIAN,
452 [
453 AC_ARG_ENABLE(sim-hostendian,
454 [  --enable-sim-hostendian=end          Specify host byte endian orientation.],
455 [case "${enableval}" in
456   no)    sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";;
457   b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";;
458   l*|L*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN";;
459   *)     AC_MSG_ERROR("Unknown value $enableval for --enable-sim-hostendian"); sim_hostendian="";;
460 esac
461 if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
462   echo "Setting hostendian flags = $sim_hostendian" 6>&1
463 fi],[
464 if test "x$cross_compiling" = "xno"; then
465   AC_C_BIGENDIAN
466   if test $ac_cv_c_bigendian = yes; then
467     sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN"
468   else
469     sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN"
470   fi
471 else
472   sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
473 fi])dnl
474 ])
475 AC_SUBST(sim_hostendian)
476
477
478 dnl --enable-sim-float is for developers of the simulator
479 dnl It specifies the presence of hardware floating point
480 dnl And optionally the bitsize of the floating point register.
481 dnl arg[1] specifies the presence (or absence) of floating point hardware
482 dnl arg[2] specifies the number of bits in a floating point register
483 AC_DEFUN(SIM_AC_OPTION_FLOAT,
484 [
485 default_sim_float="[$1]"
486 default_sim_float_bitsize="[$2]"
487 AC_ARG_ENABLE(sim-float,
488 [  --enable-sim-float                   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="";;
495 esac
496 if test x"$silent" != x"yes" && test x"$sim_float" != x""; then
497   echo "Setting float flags = $sim_float" 6>&1
498 fi],[
499 sim_float=
500 if test x"${default_sim_float}" != x""; then
501   sim_float="-DWITH_FLOATING_POINT=${default_sim_float}"
502 fi
503 if test x"${default_sim_float_bitsize}" != x""; then
504   sim_float="$sim_float -DWITH_TARGET_FLOATING_POINT_BITSIZE=${default_sim_float_bitsize}"
505 fi
506 ])dnl
507 ])
508 AC_SUBST(sim_float)
509
510
511 dnl The argument is the default cache size if none is specified.
512 AC_DEFUN(SIM_AC_OPTION_SCACHE,
513 [
514 default_sim_scache="ifelse([$1],,0,[$1])"
515 AC_ARG_ENABLE(sim-scache,
516 [  --enable-sim-scache=size             Specify simulator execution cache size.],
517 [case "${enableval}" in
518   yes)  sim_scache="-DWITH_SCACHE=${default_sim_scache}";;
519   no)   sim_scache="-DWITH_SCACHE=0" ;;
520   [[0-9]]*) sim_cache=${enableval};;
521   *)    AC_MSG_ERROR("Bad value $enableval passed to --enable-sim-scache");
522         sim_scache="";;
523 esac
524 if test x"$silent" != x"yes" && test x"$sim_scache" != x""; then
525   echo "Setting scache size = $sim_scache" 6>&1
526 fi],[sim_scache="-DWITH_SCACHE=${default_sim_scache}"])
527 ])
528 AC_SUBST(sim_scache)
529
530
531 dnl The argument is the default model if none is specified.
532 AC_DEFUN(SIM_AC_OPTION_DEFAULT_MODEL,
533 [
534 default_sim_default_model="ifelse([$1],,0,[$1])"
535 AC_ARG_ENABLE(sim-default-model,
536 [  --enable-sim-default-model=model     Specify default model to simulate.],
537 [case "${enableval}" in
538   yes|no) AC_MSG_ERROR("Missing argument to --enable-sim-default-model");;
539   *)    sim_default_model="-DWITH_DEFAULT_MODEL='\"${enableval}\"'";;
540 esac
541 if test x"$silent" != x"yes" && test x"$sim_default_model" != x""; then
542   echo "Setting default model = $sim_default_model" 6>&1
543 fi],[sim_default_model="-DWITH_DEFAULT_MODEL='\"${default_sim_default_model}\"'"])
544 ])
545 AC_SUBST(sim_default_model)
546
547
548 dnl --enable-sim-hardware is for users of the simulator
549 dnl arg[1] is a space separated list of devices that override the defaults
550 dnl arg[2] is a space separated list of extra target specific devices.
551 AC_DEFUN(SIM_AC_OPTION_HARDWARE,
552 [
553 sim_hardware="-DWITH_HW=1"
554 sim_hw_obj="hw-device.o hw-ports.o hw-properties.o hw-base.o hw-tree.o sim-hw.o"
555 hardware="ifelse([$1],,[core pal glue],[$1]) ifelse([$2],,,[$2])"
556 AC_ARG_ENABLE(sim-hardware,
557 [  --enable-sim-hardware=LIST           Specify the hardware to be included in the build.],
558 [
559 case "${enableval}" in
560   yes)  ;;
561   no)   hardware=""; sim_hardware="-DWITH_HW=0"; sim_hw_obj="";;
562   ,*)   hardware="${hardware} `echo ${enableval} | sed -e 's/,/ /'`";;
563   *,)   hardware="`echo ${enableval} | sed -e 's/,/ /'` ${hardware}";;
564   *)    hardware="`echo ${enableval} | sed -e 's/,/ /'`"'';;
565 esac
566 dnl remove duplicates
567 sim_hw=""
568 for i in x $hardware ; do
569   case " $f " in
570     x) ;;
571     *" $i "*) ;;
572     *) sim_hw="$sim_hw $i" ;;
573   esac
574 done
575 sim_hw_obj="$sim_hw_obj `echo $sim_hw | sed -e 's/\([[^ ]][[^ ]]*\)/dv-\1.o/g'`"
576 if test x"$silent" != x"yes" && test x"$hardware" != x""; then
577   echo "Setting hardware to $sim_hardware, $sim_hw, $sim_hw_obj"
578 fi],[
579 sim_hw="$hardware"
580 sim_hw_obj="$sim_hw_obj `echo $sim_hw | sed -e 's/\([[^ ]][[^ ]]*\)/dv-\1.o/g'`"
581 if test x"$silent" != x"yes"; then
582   echo "Setting hardware to $sim_hardware, $sim_hw, $sim_hw_obj"
583 fi])dnl
584 ])
585 AC_SUBST(sim_hardware)
586 AC_SUBST(sim_hw_obj)
587 AC_SUBST(sim_hw)
588
589
590 dnl --enable-sim-inline is for users that wish to ramp up the simulator's
591 dnl performance by inlining functions.
592 dnl Guarantee that unconfigured simulators do not do any inlining
593 sim_inline="-DDEFAULT_INLINE=0"
594 AC_DEFUN(SIM_AC_OPTION_INLINE,
595 [
596 default_sim_inline="ifelse([$1],,,-DDEFAULT_INLINE=[$1])"
597 AC_ARG_ENABLE(sim-inline,
598 [  --enable-sim-inline=inlines          Specify which functions should be inlined.],
599 [sim_inline=""
600 case "$enableval" in
601   no)           sim_inline="-DDEFAULT_INLINE=0";;
602   0)            sim_inline="-DDEFAULT_INLINE=0";;
603   yes | 2)      sim_inline="-DDEFAULT_INLINE=ALL_C_INLINE";;
604   1)            sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";;
605   *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
606        new_flag=""
607        case "$x" in
608          *_INLINE=*)    new_flag="-D$x";;
609          *=*)           new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;;
610          *_INLINE)      new_flag="-D$x=ALL_C_INLINE";;
611          *)             new_flag="-D$x""_INLINE=ALL_C_INLINE";;
612        esac
613        if test x"$sim_inline" = x""; then
614          sim_inline="$new_flag"
615        else
616          sim_inline="$sim_inline $new_flag"
617        fi
618      done;;
619 esac
620 if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
621   echo "Setting inline flags = $sim_inline" 6>&1
622 fi],[if test x"$GCC" != "x" -a x"${default_sim_inline}" != "x" ; then
623   sim_inline="${default_sim_inline}"
624   if test x"$silent" != x"yes"; then
625     echo "Setting inline flags = $sim_inline" 6>&1
626   fi
627 else
628   sim_inline=""
629 fi])dnl
630 ])
631 AC_SUBST(sim_inline)
632
633
634 AC_DEFUN(SIM_AC_OPTION_PACKAGES,
635 [
636 AC_ARG_ENABLE(sim-packages,
637 [  --enable-sim-packages=list           Specify the packages to be included in the build.],
638 [packages=disklabel
639 case "${enableval}" in
640   yes)  ;;
641   no)   AC_MSG_ERROR("List of packages must be specified for --enable-sim-packages"); packages="";;
642   ,*)   packages="${packages}${enableval}";;
643   *,)   packages="${enableval}${packages}";;
644   *)    packages="${enableval}"'';;
645 esac
646 sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'`
647 sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'`
648 if test x"$silent" != x"yes" && test x"$packages" != x""; then
649   echo "Setting packages to $sim_pk_src, $sim_pk_obj"
650 fi],[packages=disklabel
651 sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'`
652 sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'`
653 if test x"$silent" != x"yes"; then
654   echo "Setting packages to $sim_pk_src, $sim_pk_obj"
655 fi])dnl
656 ])
657 AC_SUBST(sim_packages)
658
659
660 AC_DEFUN(SIM_AC_OPTION_REGPARM,
661 [
662 AC_ARG_ENABLE(sim-regparm,
663 [  --enable-sim-regparm=nr-parm         Pass parameters in registers instead of on the stack - x86/GCC specific.],
664 [case "${enableval}" in
665   0*|1*|2*|3*|4*|5*|6*|7*|8*|9*) sim_regparm="-DWITH_REGPARM=${enableval}";;
666   no)                            sim_regparm="" ;;
667   yes)                           sim_regparm="-DWITH_REGPARM=3";;
668   *)   AC_MSG_ERROR("Unknown value $enableval for --enable-sim-regparm"); sim_regparm="";;
669 esac
670 if test x"$silent" != x"yes" && test x"$sim_regparm" != x""; then
671   echo "Setting regparm flags = $sim_regparm" 6>&1
672 fi],[sim_regparm=""])dnl
673 ])
674 AC_SUBST(sim_regparm)
675
676
677 AC_DEFUN(SIM_AC_OPTION_RESERVED_BITS,
678 [
679 default_sim_reserved_bits="ifelse([$1],,1,[$1])"
680 AC_ARG_ENABLE(sim-reserved-bits,
681 [  --enable-sim-reserved-bits           Specify whether to check reserved bits in instruction.],
682 [case "${enableval}" in
683   yes)  sim_reserved_bits="-DWITH_RESERVED_BITS=1";;
684   no)   sim_reserved_bits="-DWITH_RESERVED_BITS=0";;
685   *)    AC_MSG_ERROR("--enable-sim-reserved-bits does not take a value"); sim_reserved_bits="";;
686 esac
687 if test x"$silent" != x"yes" && test x"$sim_reserved_bits" != x""; then
688   echo "Setting reserved flags = $sim_reserved_bits" 6>&1
689 fi],[sim_reserved_bits="-DWITH_RESERVED_BITS=${default_sim_reserved_bits}"])dnl
690 ])
691 AC_SUBST(sim_reserved_bits)
692
693
694 AC_DEFUN(SIM_AC_OPTION_SMP,
695 [
696 default_sim_smp="ifelse([$1],,5,[$1])"
697 AC_ARG_ENABLE(sim-smp,
698 [  --enable-sim-smp=n                   Specify number of processors to configure for (default ${default_sim_smp}).],
699 [case "${enableval}" in
700   yes)  sim_smp="-DWITH_SMP=5" ; sim_igen_smp="-N 5";;
701   no)   sim_smp="-DWITH_SMP=0" ; sim_igen_smp="-N 0";;
702   *)    sim_smp="-DWITH_SMP=$enableval" ; sim_igen_smp="-N $enableval";;
703 esac
704 if test x"$silent" != x"yes" && test x"$sim_smp" != x""; then
705   echo "Setting smp flags = $sim_smp" 6>&1
706 fi],[sim_smp="-DWITH_SMP=${default_sim_smp}" ; sim_igen_smp="-N ${default_sim_smp}"
707 if test x"$silent" != x"yes"; then
708   echo "Setting smp flags = $sim_smp" 6>&1
709 fi])dnl
710 ])
711 AC_SUBST(sim_smp)
712
713
714 AC_DEFUN(SIM_AC_OPTION_STDCALL,
715 [
716 AC_ARG_ENABLE(sim-stdcall,
717 [  --enable-sim-stdcall=type            Use an alternative function call/return mechanism - x86/GCC specific.],
718 [case "${enableval}" in
719   no)           sim_stdcall="" ;;
720   std*)         sim_stdcall="-DWITH_STDCALL=1";;
721   yes)          sim_stdcall="-DWITH_STDCALL=1";;
722   *)   AC_MSG_ERROR("Unknown value $enableval for --enable-sim-stdcall"); sim_stdcall="";;
723 esac
724 if test x"$silent" != x"yes" && test x"$sim_stdcall" != x""; then
725   echo "Setting function call flags = $sim_stdcall" 6>&1
726 fi],[sim_stdcall=""])dnl
727 ])
728 AC_SUBST(sim_stdcall)
729
730
731 AC_DEFUN(SIM_AC_OPTION_XOR_ENDIAN,
732 [
733 default_sim_xor_endian="ifelse([$1],,8,[$1])"
734 AC_ARG_ENABLE(sim-xor-endian,
735 [  --enable-sim-xor-endian=n            Specify number bytes involved in XOR bi-endian mode (default ${default_sim_xor_endian}).],
736 [case "${enableval}" in
737   yes)  sim_xor_endian="-DWITH_XOR_ENDIAN=8";;
738   no)   sim_xor_endian="-DWITH_XOR_ENDIAN=0";;
739   *)    sim_xor_endian="-DWITH_XOR_ENDIAN=$enableval";;
740 esac
741 if test x"$silent" != x"yes" && test x"$sim_xor_endian" != x""; then
742   echo "Setting xor-endian flag = $sim_xor_endian" 6>&1
743 fi],[sim_xor_endian="-DWITH_XOR_ENDIAN=${default_sim_xor_endian}"])dnl
744 ])
745 AC_SUBST(sim_xor_endian)
746
747
748 dnl --enable-sim-warnings is for developers of the simulator.
749 dnl it enables extra GCC specific warnings.
750 AC_DEFUN(SIM_AC_OPTION_WARNINGS,
751 [
752 AC_ARG_ENABLE(sim-warnings,
753 [  --enable-sim-warnings=opts           Extra CFLAGS for turning on compiler warnings],
754 [case "${enableval}" in
755   yes)  sim_warnings="-Werror -Wall -Wpointer-arith -Wmissing-prototypes -Wmissing-declarations ";;
756   no)   sim_warnings="-w";;
757   *)    sim_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
758 esac
759 if test x"$silent" != x"yes" && test x"$sim_warnings" != x""; then
760   echo "Setting warning flags = $sim_warnings" 6>&1
761 fi],[sim_warnings=""])dnl
762 ])
763 AC_SUBST(sim_warnings)
764
765
766 dnl Generate the Makefile in a target specific directory.
767 dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
768 dnl so this is a cover macro to tuck the details away of how we cope.
769 dnl We cope by having autoconf generate two files and then merge them into
770 dnl one afterwards.  The two pieces of the common fragment are inserted into
771 dnl the target's fragment at the appropriate points.
772
773 AC_DEFUN(SIM_AC_OUTPUT,
774 [
775 AC_LINK_FILES($sim_link_files, $sim_link_links)
776 AC_OUTPUT(Makefile.sim:Makefile.in Make-common.sim:../common/Make-common.in .gdbinit:../common/gdbinit.in,
777 [case "x$CONFIG_FILES" in
778  xMakefile*)
779    echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
780    rm -f Makesim1.tmp Makesim2.tmp Makefile
781    sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
782    sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
783    sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
784         -e '/^## COMMON_POST_/ r Makesim2.tmp' \
785         <Makefile.sim >Makefile
786    rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
787    ;;
788  esac
789  case "x$CONFIG_HEADERS" in xconfig.h:config.in) echo > stamp-h ;; esac
790 ])
791 ])