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