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