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