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 | |
412c4e94 AC |
329 | dnl arg[3] is the number of bits in an address |
330 | dnl arg[4] is the number of bits in an OpenFirmware cell. | |
462cfbc4 DE |
331 | dnl FIXME: this information should be obtained from bfd/archure |
332 | AC_DEFUN(SIM_AC_OPTION_BITSIZE, | |
412c4e94 AC |
333 | wire_word_bitsize="[$1]" |
334 | wire_word_msb="[$2]" | |
335 | wire_address_bitsize="[$3]" | |
336 | wire_cell_bitsize="[$4]" | |
462cfbc4 | 337 | [AC_ARG_ENABLE(sim-bitsize, |
412c4e94 AC |
338 | [ --enable-sim-bitsize=N Specify target bitsize (32 or 64).], |
339 | [sim_bitsize= | |
340 | case "${enableval}" in | |
341 | 64,63 | 64,63,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63";; | |
342 | 32,31 | 32,31,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31";; | |
343 | 64,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";; | |
344 | 32,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";; | |
345 | 32) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then | |
462cfbc4 DE |
346 | sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31" |
347 | else | |
348 | sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0" | |
349 | fi ;; | |
412c4e94 | 350 | 64) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then |
462cfbc4 DE |
351 | sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63" |
352 | else | |
353 | sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=0" | |
354 | fi ;; | |
412c4e94 AC |
355 | *) AC_MSG_ERROR("--enable-sim-bitsize was given $enableval. Expected 32 or 64") ;; |
356 | esac | |
357 | # address bitsize | |
358 | tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9]]*,*//"` | |
359 | case x"${tmp}" in | |
360 | x ) ;; | |
361 | x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=32" ;; | |
362 | x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=64" ;; | |
363 | * ) AC_MSG_ERROR("--enable-sim-bitsize was given address size $enableval. Expected 32 or 64") ;; | |
364 | esac | |
365 | # cell bitsize | |
366 | tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9*]]*,*[[0-9]]*,*//"` | |
367 | case x"${tmp}" in | |
368 | x ) ;; | |
369 | x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=32" ;; | |
370 | x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=64" ;; | |
371 | * ) AC_MSG_ERROR("--enable-sim-bitsize was given cell size $enableval. Expected 32 or 64") ;; | |
462cfbc4 DE |
372 | esac |
373 | if test x"$silent" != x"yes" && test x"$sim_bitsize" != x""; then | |
374 | echo "Setting bitsize flags = $sim_bitsize" 6>&1 | |
375 | fi], | |
376 | [sim_bitsize="" | |
412c4e94 AC |
377 | if test x"$wire_word_bitsize" != x; then |
378 | sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_BITSIZE=$wire_word_bitsize" | |
379 | fi | |
380 | if test x"$wire_word_msb" != x; then | |
381 | sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_MSB=$wire_word_msb" | |
382 | fi | |
383 | if test x"$wire_address_bitsize" != x; then | |
384 | sim_bitsize="$sim_bitsize -DWITH_TARGET_ADDRESS_BITSIZE=$wire_address_bitsize" | |
462cfbc4 | 385 | fi |
412c4e94 AC |
386 | if test x"$wire_cell_bitsize" != x; then |
387 | sim_bitsize="$sim_bitsize -DWITH_TARGET_CELL_BITSIZE=$wire_cell_bitsize" | |
462cfbc4 DE |
388 | fi])dnl |
389 | ]) | |
390 | AC_SUBST(sim_bitsize) | |
391 | ||
392 | ||
393 | ||
f2de7dfd AC |
394 | dnl --enable-sim-endian={yes,no,big,little} is for simulators |
395 | dnl that support both big and little endian targets. | |
247fccde AC |
396 | dnl arg[1] is hardwired target endianness. |
397 | dnl arg[2] is default target endianness. | |
f2de7dfd | 398 | AC_DEFUN(SIM_AC_OPTION_ENDIAN, |
8cd89e77 | 399 | [ |
92f91d1f AC |
400 | wire_endian="[$1]" |
401 | default_endian="[$2]" | |
f2de7dfd AC |
402 | AC_ARG_ENABLE(sim-endian, |
403 | [ --enable-sim-endian=endian Specify target byte endian orientation.], | |
404 | [case "${enableval}" in | |
f2de7dfd AC |
405 | b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";; |
406 | l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";; | |
247fccde AC |
407 | yes) if test x"$wire_endian" != x; then |
408 | sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}" | |
409 | else | |
92f91d1f AC |
410 | if test x"$default_endian" != x; then |
411 | sim_endian="-DWITH_TARGET_BYTE_ORDER=${default_endian}" | |
412 | else | |
413 | echo "No hard-wired endian for target $target" 1>&6 | |
414 | sim_endian="-DWITH_TARGET_BYTE_ORDER=0" | |
415 | fi | |
247fccde AC |
416 | fi;; |
417 | no) if test x"$default_endian" != x; then | |
418 | sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}" | |
419 | else | |
92f91d1f AC |
420 | if test x"$wire_endian" != x; then |
421 | sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${wire_endian}" | |
422 | else | |
423 | echo "No default endian for target $target" 1>&6 | |
424 | sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=0" | |
425 | fi | |
247fccde | 426 | fi;; |
f2de7dfd AC |
427 | *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";; |
428 | esac | |
429 | if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then | |
430 | echo "Setting endian flags = $sim_endian" 6>&1 | |
92f91d1f AC |
431 | fi], |
432 | [if test x"$default_endian" != x; then | |
433 | sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}" | |
434 | else | |
435 | if test x"$wire_endian" != x; then | |
436 | sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}" | |
437 | else | |
438 | sim_endian= | |
439 | fi | |
440 | fi])dnl | |
f2de7dfd | 441 | ]) |
92f91d1f | 442 | AC_SUBST(sim_endian) |
8cd89e77 | 443 | |
80b7b3a5 | 444 | |
f2de7dfd AC |
445 | dnl --enable-sim-hostendian is for users of the simulator when |
446 | dnl they find that AC_C_BIGENDIAN does not function correctly | |
447 | dnl (for instance in a canadian cross) | |
448 | AC_DEFUN(SIM_AC_OPTION_HOSTENDIAN, | |
449 | [ | |
450 | AC_ARG_ENABLE(sim-hostendian, | |
462cfbc4 | 451 | [ --enable-sim-hostendian=end Specify host byte endian orientation.], |
f2de7dfd AC |
452 | [case "${enableval}" in |
453 | no) sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";; | |
454 | b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";; | |
455 | l*|L*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN";; | |
456 | *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-hostendian"); sim_hostendian="";; | |
457 | esac | |
458 | if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then | |
459 | echo "Setting hostendian flags = $sim_hostendian" 6>&1 | |
460 | fi],[ | |
461 | if test "x$cross_compiling" = "xno"; then | |
462 | AC_C_BIGENDIAN | |
463 | if test $ac_cv_c_bigendian = yes; then | |
464 | sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN" | |
465 | else | |
466 | sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN" | |
467 | fi | |
468 | else | |
469 | sim_hostendian="-DWITH_HOST_BYTE_ORDER=0" | |
470 | fi])dnl | |
a77aa7ec | 471 | ]) |
92f91d1f | 472 | AC_SUBST(sim_hostendian) |
a77aa7ec AC |
473 | |
474 | ||
475 | AC_DEFUN(SIM_AC_OPTION_FLOAT, | |
476 | [ | |
a35e91c3 | 477 | default_sim_floating_point="ifelse([$1],,0,[$1])" |
a77aa7ec | 478 | AC_ARG_ENABLE(sim-float, |
a35e91c3 | 479 | [ --enable-sim-float Specify that the target processor has floating point hardware.], |
a77aa7ec AC |
480 | [case "${enableval}" in |
481 | yes | hard) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";; | |
482 | no | soft) sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";; | |
483 | *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-float"); sim_float="";; | |
484 | esac | |
485 | if test x"$silent" != x"yes" && test x"$sim_float" != x""; then | |
486 | echo "Setting float flags = $sim_float" 6>&1 | |
a35e91c3 | 487 | fi],[sim_float="-DWITH_FLOATING_POINT=${default_sim_floating_point}"])dnl |
a77aa7ec | 488 | ]) |
92f91d1f | 489 | AC_SUBST(sim_float) |
a77aa7ec AC |
490 | |
491 | ||
247fccde AC |
492 | dnl The argument is the default cache size if none is specified. |
493 | AC_DEFUN(SIM_AC_OPTION_SCACHE, | |
494 | [ | |
495 | default_sim_scache="ifelse([$1],,0,[$1])" | |
496 | AC_ARG_ENABLE(sim-scache, | |
497 | [ --enable-sim-scache=size Specify simulator execution cache size.], | |
498 | [case "${enableval}" in | |
499 | yes) sim_scache="-DWITH_SCACHE=${default_sim_scache}";; | |
462cfbc4 | 500 | no) sim_scache="-DWITH_SCACHE=0" ;; |
247fccde AC |
501 | [[0-9]]*) sim_cache=${enableval};; |
502 | *) AC_MSG_ERROR("Bad value $enableval passed to --enable-sim-scache"); | |
503 | sim_scache="";; | |
504 | esac | |
505 | if test x"$silent" != x"yes" && test x"$sim_scache" != x""; then | |
506 | echo "Setting scache size = $sim_scache" 6>&1 | |
507 | fi],[sim_scache="-DWITH_SCACHE=${default_sim_scache}"]) | |
247fccde | 508 | ]) |
92f91d1f | 509 | AC_SUBST(sim_scache) |
247fccde AC |
510 | |
511 | ||
512 | dnl The argument is the default model if none is specified. | |
513 | AC_DEFUN(SIM_AC_OPTION_DEFAULT_MODEL, | |
514 | [ | |
515 | default_sim_default_model="ifelse([$1],,0,[$1])" | |
516 | AC_ARG_ENABLE(sim-default-model, | |
517 | [ --enable-sim-default-model=model Specify default model to simulate.], | |
518 | [case "${enableval}" in | |
519 | yes|no) AC_MSG_ERROR("Missing argument to --enable-sim-default-model");; | |
520 | *) sim_default_model="-DWITH_DEFAULT_MODEL='\"${enableval}\"'";; | |
521 | esac | |
522 | if test x"$silent" != x"yes" && test x"$sim_default_model" != x""; then | |
523 | echo "Setting default model = $sim_default_model" 6>&1 | |
524 | fi],[sim_default_model="-DWITH_DEFAULT_MODEL='\"${default_sim_default_model}\"'"]) | |
247fccde | 525 | ]) |
92f91d1f | 526 | AC_SUBST(sim_default_model) |
247fccde AC |
527 | |
528 | ||
a77aa7ec AC |
529 | AC_DEFUN(SIM_AC_OPTION_HARDWARE, |
530 | [ | |
531 | AC_ARG_ENABLE(sim-hardware, | |
532 | [ --enable-sim-hardware=list Specify the hardware to be included in the build.], | |
533 | [hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide" | |
534 | case "${enableval}" in | |
535 | yes) ;; | |
536 | no) AC_MSG_ERROR("List of hardware must be specified for --enable-sim-hardware"); hardware="";; | |
537 | ,*) hardware="${hardware}${enableval}";; | |
538 | *,) hardware="${enableval}${hardware}";; | |
539 | *) hardware="${enableval}"'';; | |
540 | esac | |
541 | sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'` | |
542 | sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'` | |
543 | if test x"$silent" != x"yes" && test x"$hardware" != x""; then | |
544 | echo "Setting hardware to $sim_hw_src, $sim_hw_obj" | |
545 | fi],[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide" | |
546 | sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'` | |
547 | sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'` | |
548 | if test x"$silent" != x"yes"; then | |
549 | echo "Setting hardware to $sim_hw_src, $sim_hw_obj" | |
550 | fi])dnl | |
f2de7dfd | 551 | ]) |
92f91d1f | 552 | AC_SUBST(sim_hardware) |
f2de7dfd | 553 | |
80b7b3a5 | 554 | |
f2de7dfd AC |
555 | dnl --enable-sim-inline is for users that wish to ramp up the simulator's |
556 | dnl performance by inlining functions. | |
557 | AC_DEFUN(SIM_AC_OPTION_INLINE, | |
558 | [ | |
559 | default_sim_inline="ifelse([$1],,,-DDEFAULT_INLINE=[$1])" | |
560 | AC_ARG_ENABLE(sim-inline, | |
561 | [ --enable-sim-inline=inlines Specify which functions should be inlined.], | |
562 | [sim_inline="" | |
563 | case "$enableval" in | |
564 | no) sim_inline="-DDEFAULT_INLINE=0";; | |
565 | 0) sim_inline="-DDEFAULT_INLINE=0";; | |
566 | yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_INLINE";; | |
567 | 1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";; | |
568 | *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do | |
569 | new_flag="" | |
570 | case "$x" in | |
571 | *_INLINE=*) new_flag="-D$x";; | |
572 | *=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;; | |
573 | *_INLINE) new_flag="-D$x=ALL_INLINE";; | |
574 | *) new_flag="-D$x""_INLINE=ALL_INLINE";; | |
575 | esac | |
576 | if test x"$sim_inline" = x""; then | |
577 | sim_inline="$new_flag" | |
578 | else | |
579 | sim_inline="$sim_inline $new_flag" | |
580 | fi | |
581 | done;; | |
582 | esac | |
583 | if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then | |
584 | echo "Setting inline flags = $sim_inline" 6>&1 | |
585 | fi],[if test x"$GCC" != "x" -a x"${default_sim_inline}" != "x" ; then | |
586 | sim_inline="${default_sim_inline}" | |
587 | if test x"$silent" != x"yes"; then | |
588 | echo "Setting inline flags = $sim_inline" 6>&1 | |
589 | fi | |
590 | else | |
591 | sim_inline="" | |
592 | fi])dnl | |
a77aa7ec | 593 | ]) |
92f91d1f | 594 | AC_SUBST(sim_inline) |
a77aa7ec AC |
595 | |
596 | ||
597 | AC_DEFUN(SIM_AC_OPTION_PACKAGES, | |
598 | [ | |
599 | AC_ARG_ENABLE(sim-packages, | |
600 | [ --enable-sim-packages=list Specify the packages to be included in the build.], | |
601 | [packages=disklabel | |
602 | case "${enableval}" in | |
603 | yes) ;; | |
604 | no) AC_MSG_ERROR("List of packages must be specified for --enable-sim-packages"); packages="";; | |
605 | ,*) packages="${packages}${enableval}";; | |
606 | *,) packages="${enableval}${packages}";; | |
607 | *) packages="${enableval}"'';; | |
608 | esac | |
609 | sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'` | |
610 | sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'` | |
611 | if test x"$silent" != x"yes" && test x"$packages" != x""; then | |
612 | echo "Setting packages to $sim_pk_src, $sim_pk_obj" | |
613 | fi],[packages=disklabel | |
614 | sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'` | |
615 | sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'` | |
616 | if test x"$silent" != x"yes"; then | |
617 | echo "Setting packages to $sim_pk_src, $sim_pk_obj" | |
618 | fi])dnl | |
a77aa7ec | 619 | ]) |
92f91d1f | 620 | AC_SUBST(sim_packages) |
a77aa7ec AC |
621 | |
622 | ||
623 | AC_DEFUN(SIM_AC_OPTION_REGPARM, | |
624 | [ | |
625 | AC_ARG_ENABLE(sim-regparm, | |
626 | [ --enable-sim-regparm=nr-parm Pass parameters in registers instead of on the stack - x86/GCC specific.], | |
627 | [case "${enableval}" in | |
628 | 0*|1*|2*|3*|4*|5*|6*|7*|8*|9*) sim_regparm="-DWITH_REGPARM=${enableval}";; | |
629 | no) sim_regparm="" ;; | |
630 | yes) sim_regparm="-DWITH_REGPARM=3";; | |
631 | *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-regparm"); sim_regparm="";; | |
632 | esac | |
633 | if test x"$silent" != x"yes" && test x"$sim_regparm" != x""; then | |
634 | echo "Setting regparm flags = $sim_regparm" 6>&1 | |
635 | fi],[sim_regparm=""])dnl | |
a77aa7ec | 636 | ]) |
92f91d1f | 637 | AC_SUBST(sim_regparm) |
a77aa7ec AC |
638 | |
639 | ||
640 | AC_DEFUN(SIM_AC_OPTION_RESERVED_BITS, | |
641 | [ | |
a35e91c3 | 642 | default_sim_reserved_bits="ifelse([$1],,1,[$1])" |
a77aa7ec AC |
643 | AC_ARG_ENABLE(sim-reserved-bits, |
644 | [ --enable-sim-reserved-bits Specify whether to check reserved bits in instruction.], | |
645 | [case "${enableval}" in | |
646 | yes) sim_reserved_bits="-DWITH_RESERVED_BITS=1";; | |
647 | no) sim_reserved_bits="-DWITH_RESERVED_BITS=0";; | |
648 | *) AC_MSG_ERROR("--enable-sim-reserved-bits does not take a value"); sim_reserved_bits="";; | |
649 | esac | |
650 | if test x"$silent" != x"yes" && test x"$sim_reserved_bits" != x""; then | |
651 | echo "Setting reserved flags = $sim_reserved_bits" 6>&1 | |
a35e91c3 | 652 | fi],[sim_reserved_bits="-DWITH_RESERVED_BITS=${default_sim_reserved_bits}"])dnl |
a77aa7ec | 653 | ]) |
92f91d1f | 654 | AC_SUBST(sim_reserved_bits) |
a77aa7ec AC |
655 | |
656 | ||
657 | AC_DEFUN(SIM_AC_OPTION_SMP, | |
658 | [ | |
a35e91c3 | 659 | default_sim_smp="ifelse([$1],,5,[$1])" |
a77aa7ec | 660 | AC_ARG_ENABLE(sim-smp, |
a35e91c3 | 661 | [ --enable-sim-smp=n Specify number of processors to configure for (default ${default_sim_smp}).], |
a77aa7ec AC |
662 | [case "${enableval}" in |
663 | yes) sim_smp="-DWITH_SMP=5" ; sim_igen_smp="-N 5";; | |
664 | no) sim_smp="-DWITH_SMP=0" ; sim_igen_smp="-N 0";; | |
665 | *) sim_smp="-DWITH_SMP=$enableval" ; sim_igen_smp="-N $enableval";; | |
666 | esac | |
667 | if test x"$silent" != x"yes" && test x"$sim_smp" != x""; then | |
668 | echo "Setting smp flags = $sim_smp" 6>&1 | |
a35e91c3 | 669 | fi],[sim_smp="-DWITH_SMP=${default_sim_smp}" ; sim_igen_smp="-N ${default_sim_smp}" |
a77aa7ec AC |
670 | if test x"$silent" != x"yes"; then |
671 | echo "Setting smp flags = $sim_smp" 6>&1 | |
672 | fi])dnl | |
f2de7dfd | 673 | ]) |
92f91d1f | 674 | AC_SUBST(sim_smp) |
80b7b3a5 | 675 | |
80b7b3a5 | 676 | |
a77aa7ec AC |
677 | AC_DEFUN(SIM_AC_OPTION_STDCALL, |
678 | [ | |
679 | AC_ARG_ENABLE(sim-stdcall, | |
680 | [ --enable-sim-stdcall=type Use an alternative function call/return mechanism - x86/GCC specific.], | |
681 | [case "${enableval}" in | |
682 | no) sim_stdcall="" ;; | |
683 | std*) sim_stdcall="-DWITH_STDCALL=1";; | |
684 | yes) sim_stdcall="-DWITH_STDCALL=1";; | |
685 | *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-stdcall"); sim_stdcall="";; | |
686 | esac | |
687 | if test x"$silent" != x"yes" && test x"$sim_stdcall" != x""; then | |
688 | echo "Setting function call flags = $sim_stdcall" 6>&1 | |
689 | fi],[sim_stdcall=""])dnl | |
a77aa7ec | 690 | ]) |
92f91d1f | 691 | AC_SUBST(sim_stdcall) |
a77aa7ec AC |
692 | |
693 | ||
a35e91c3 AC |
694 | AC_DEFUN(SIM_AC_OPTION_XOR_ENDIAN, |
695 | [ | |
696 | default_sim_xor_endian="ifelse([$1],,8,[$1])" | |
697 | AC_ARG_ENABLE(sim-xor-endian, | |
698 | [ --enable-sim-xor-endian=n Specify number bytes involved in XOR bi-endian mode (default ${default_sim_xor_endian}).], | |
a77aa7ec | 699 | [case "${enableval}" in |
a35e91c3 AC |
700 | yes) sim_xor_endian="-DWITH_XOR_ENDIAN=8";; |
701 | no) sim_xor_endian="-DWITH_XOR_ENDIAN=0";; | |
702 | *) sim_xor_endian="-DWITH_XOR_ENDIAN=$enableval";; | |
a77aa7ec | 703 | esac |
a35e91c3 AC |
704 | if test x"$silent" != x"yes" && test x"$sim_xor_endian" != x""; then |
705 | echo "Setting xor-endian flag = $sim_xor_endian" 6>&1 | |
706 | fi],[sim_xor_endian="-DWITH_XOR_ENDIAN=${default_sim_xor_endian}"])dnl | |
a35e91c3 | 707 | ]) |
92f91d1f | 708 | AC_SUBST(sim_xor_endian) |
a77aa7ec AC |
709 | |
710 | ||
f2de7dfd AC |
711 | dnl --enable-sim-warnings is for developers of the simulator. |
712 | dnl it enables extra GCC specific warnings. | |
713 | AC_DEFUN(SIM_AC_OPTION_WARNINGS, | |
714 | [ | |
715 | AC_ARG_ENABLE(sim-warnings, | |
88117054 | 716 | [ --enable-sim-warnings=opts Extra CFLAGS for turning on compiler warnings], |
f2de7dfd AC |
717 | [case "${enableval}" in |
718 | yes) sim_warnings="-Werror -Wall -Wpointer-arith -Wmissing-prototypes -Wmissing-declarations ";; | |
719 | no) sim_warnings="-w";; | |
720 | *) sim_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;; | |
721 | esac | |
722 | if test x"$silent" != x"yes" && test x"$sim_warnings" != x""; then | |
723 | echo "Setting warning flags = $sim_warnings" 6>&1 | |
724 | fi],[sim_warnings=""])dnl | |
725 | ]) | |
92f91d1f | 726 | AC_SUBST(sim_warnings) |
80b7b3a5 | 727 | |
80b7b3a5 | 728 | |
f2de7dfd AC |
729 | dnl Generate the Makefile in a target specific directory. |
730 | dnl Substitutions aren't performed on the file in AC_SUBST_FILE, | |
731 | dnl so this is a cover macro to tuck the details away of how we cope. | |
732 | dnl We cope by having autoconf generate two files and then merge them into | |
733 | dnl one afterwards. The two pieces of the common fragment are inserted into | |
734 | dnl the target's fragment at the appropriate points. | |
80b7b3a5 | 735 | |
f2de7dfd AC |
736 | AC_DEFUN(SIM_AC_OUTPUT, |
737 | [ | |
80b7b3a5 | 738 | AC_LINK_FILES($sim_link_files, $sim_link_links) |
88d5f8e8 DE |
739 | AC_OUTPUT(Makefile.sim:Makefile.in Make-common.sim:../common/Make-common.in .gdbinit:../common/gdbinit.in, |
740 | [case "x$CONFIG_FILES" in | |
741 | xMakefile*) | |
f2de7dfd AC |
742 | echo "Merging Makefile.sim+Make-common.sim into Makefile ..." |
743 | rm -f Makesim1.tmp Makesim2.tmp Makefile | |
744 | sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp | |
745 | sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp | |
746 | sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \ | |
747 | -e '/^## COMMON_POST_/ r Makesim2.tmp' \ | |
748 | <Makefile.sim >Makefile | |
749 | rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp | |
750 | ;; | |
751 | esac | |
80b7b3a5 | 752 | case "x$CONFIG_HEADERS" in xconfig.h:config.in) echo > stamp-h ;; esac |
f2de7dfd AC |
753 | ]) |
754 | ]) |