MIPS/GAS: Don't convert RELA JALR relocations on R6
[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)
936df756 87AC_CHECK_HEADERS(sys/time.h sys/times.h sys/resource.h sys/mman.h)
9c082ca8
MF
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)
936df756
MF
91AC_CHECK_FUNCS(mmap munmap lstat truncate ftruncate posix_fallocate)
92AC_CHECK_MEMBERS([[struct stat.st_dev], [struct stat.st_ino],
93[struct stat.st_mode], [struct stat.st_nlink], [struct stat.st_uid],
94[struct stat.st_gid], [struct stat.st_rdev], [struct stat.st_size],
95[struct stat.st_blksize], [struct stat.st_blocks], [struct stat.st_atime],
96[struct stat.st_mtime], [struct stat.st_ctime]], [], [],
97[[#ifdef HAVE_SYS_TYPES_H
98#include <sys/types.h>
99#endif
100#ifdef HAVE_SYS_STAT_H
101#include <sys/stat.h>
102#endif]])
103AC_CHECK_TYPES(socklen_t, [], [],
104[#include <sys/types.h>
105#include <sys/socket.h>
106])
9c082ca8
MF
107
108# Check for socket libraries
109AC_CHECK_LIB(socket, bind)
110AC_CHECK_LIB(nsl, gethostbyname)
111
112# BFD conditionally uses zlib, so we must link it in if libbfd does, by
113# using the same condition.
114AM_ZLIB
115
6bb11ab3
L
116# BFD uses libdl when when plugins enabled.
117AC_PLUGINS
118AM_CONDITIONAL(PLUGINS, test "$plugins" = yes)
119LT_INIT([dlopen])
120AC_SUBST(lt_cv_dlopen_libs)
121
9c082ca8
MF
122. ${srcdir}/../../bfd/configure.host
123
124dnl Standard (and optional) simulator options.
125dnl Eventually all simulators will support these.
126dnl Do not add any here that cannot be supported by all simulators.
127dnl Do not add similar but different options to a particular simulator,
128dnl all shall eventually behave the same way.
129
130
131dnl We don't use automake, but we still want to support
132dnl --enable-maintainer-mode.
31e6ad7d 133AM_MAINTAINER_MODE
9c082ca8
MF
134
135
9c082ca8
MF
136dnl --enable-sim-debug is for developers of the simulator
137dnl the allowable values are work-in-progress
ce39bd38
MF
138AC_MSG_CHECKING([for sim debug setting])
139sim_debug="0"
9c082ca8 140AC_ARG_ENABLE(sim-debug,
8d0978fb
MF
141[AS_HELP_STRING([--enable-sim-debug=opts],
142 [Enable debugging flags (for developers of the sim itself)])],
9c082ca8 143[case "${enableval}" in
ce39bd38
MF
144 yes) sim_debug="7";;
145 no) sim_debug="0";;
146 *) sim_debug="($enableval)";;
147esac])dnl
148if test "$sim_debug" != "0"; then
149 AC_DEFINE_UNQUOTED([DEBUG], [$sim_debug], [Sim debug setting])
150fi
151AC_DEFINE_UNQUOTED([WITH_DEBUG], [$sim_debug], [Sim debug setting])
152AC_MSG_RESULT($sim_debug)
9c082ca8
MF
153
154
155dnl --enable-sim-stdio is for users of the simulator
156dnl It determines if IO from the program is routed through STDIO (buffered)
ce39bd38
MF
157AC_MSG_CHECKING([for sim stdio debug behavior])
158sim_stdio="0"
9c082ca8 159AC_ARG_ENABLE(sim-stdio,
8d0978fb
MF
160[AS_HELP_STRING([--enable-sim-stdio],
161 [Specify whether to use stdio for console input/output])],
9c082ca8 162[case "${enableval}" in
ce39bd38
MF
163 yes) sim_stdio="DO_USE_STDIO";;
164 no) sim_stdio="DONT_USE_STDIO";;
165 *) AC_MSG_ERROR([Unknown value $enableval passed to --enable-sim-stdio]);;
166esac])dnl
167AC_DEFINE_UNQUOTED([WITH_STDIO], [$sim_stdio], [How to route I/O])
168AC_MSG_RESULT($sim_stdio)
9c082ca8
MF
169
170
171dnl --enable-sim-trace is for users of the simulator
172dnl The argument is either a bitmask of things to enable [exactly what is
173dnl up to the simulator], or is a comma separated list of names of tracing
174dnl elements to enable. The latter is only supported on simulators that
ce39bd38
MF
175dnl use WITH_TRACE. Default to all tracing but internal debug.
176AC_MSG_CHECKING([for sim trace settings])
177sim_trace="~TRACE_debug"
9c082ca8 178AC_ARG_ENABLE(sim-trace,
8d0978fb
MF
179[AS_HELP_STRING([--enable-sim-trace=opts],
180 [Enable tracing of simulated programs])],
9c082ca8 181[case "${enableval}" in
ce39bd38
MF
182 yes) sim_trace="-1";;
183 no) sim_trace="0";;
9c082ca8 184 [[-0-9]]*)
ce39bd38 185 sim_trace="'(${enableval})'";;
509deab2 186 [[[:lower:]]]*)
9c082ca8
MF
187 sim_trace=""
188 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
189 if test x"$sim_trace" = x; then
ce39bd38 190 sim_trace="(TRACE_$x"
9c082ca8
MF
191 else
192 sim_trace="${sim_trace}|TRACE_$x"
193 fi
194 done
ce39bd38
MF
195 sim_trace="$sim_trace)" ;;
196esac])dnl
197AC_DEFINE_UNQUOTED([WITH_TRACE], [$sim_trace], [Sim trace settings])
198AC_MSG_RESULT($sim_trace)
9c082ca8
MF
199
200
201dnl --enable-sim-profile
202dnl The argument is either a bitmask of things to enable [exactly what is
203dnl up to the simulator], or is a comma separated list of names of profiling
204dnl elements to enable. The latter is only supported on simulators that
205dnl use WITH_PROFILE.
ce39bd38
MF
206AC_MSG_CHECKING([for sim profile settings])
207profile="1"
208sim_profile="-1"
9c082ca8 209AC_ARG_ENABLE(sim-profile,
8d0978fb 210[AS_HELP_STRING([--enable-sim-profile=opts], [Enable profiling flags])],
9c082ca8 211[case "${enableval}" in
ce39bd38
MF
212 yes) profile="1" sim_profile="-1";;
213 no) profile="0" sim_profile="0";;
9c082ca8 214 [[-0-9]]*)
ce39bd38 215 profile="(${enableval})" sim_profile="(${enableval})";;
9c082ca8 216 [[a-z]]*)
ce39bd38 217 profile="1"
9c082ca8
MF
218 sim_profile=""
219 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
220 if test x"$sim_profile" = x; then
ce39bd38 221 sim_profile="(PROFILE_$x"
9c082ca8
MF
222 else
223 sim_profile="${sim_profile}|PROFILE_$x"
224 fi
225 done
ce39bd38
MF
226 sim_profile="$sim_profile)" ;;
227esac])dnl
228AC_DEFINE_UNQUOTED([PROFILE], [$profile], [Sim profile settings])
229AC_DEFINE_UNQUOTED([WITH_PROFILE], [$sim_profile], [Sim profile settings])
230AC_MSG_RESULT($sim_profile)
231
9c082ca8 232
35656e95 233SIM_AC_OPTION_ASSERT
16f7876d 234SIM_AC_OPTION_ENVIRONMENT
347fe5bb
MF
235SIM_AC_OPTION_INLINE
236
bf12d44e 237ACX_PKGVERSION([SIM])
9c082ca8
MF
238ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
239AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
240AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
241
242dnl Types used by common code
243AC_TYPE_SIGNAL
244
245dnl Detect exe extension
246AC_EXEEXT
247
9c082ca8
MF
248]) dnl End of SIM_AC_COMMON
249
250
251dnl Additional SIM options that can (optionally) be configured
252dnl For optional simulator options, a macro SIM_AC_OPTION_* is defined.
253dnl Simulators that wish to use the relevant option specify the macro
306f4178 254dnl in the simulator specific configure.ac file between the SIM_AC_COMMON
9c082ca8
MF
255dnl and SIM_AC_OUTPUT lines.
256
257
258dnl Specify the running environment.
306f4178 259dnl If the simulator invokes this in its configure.ac then without this option
9c082ca8
MF
260dnl the default is the user environment and all are runtime selectable.
261dnl If the simulator doesn't invoke this, only the user environment is
262dnl supported.
263dnl ??? Until there is demonstrable value in doing something more complicated,
264dnl let's not.
265AC_DEFUN([SIM_AC_OPTION_ENVIRONMENT],
266[
ce39bd38
MF
267AC_MSG_CHECKING([default sim environment setting])
268sim_environment="ALL_ENVIRONMENT"
9c082ca8 269AC_ARG_ENABLE(sim-environment,
8d0978fb
MF
270[AS_HELP_STRING([--enable-sim-environment=environment],
271 [Specify mixed, user, virtual or operating environment])],
9c082ca8 272[case "${enableval}" in
ce39bd38
MF
273 all | ALL) sim_environment="ALL_ENVIRONMENT";;
274 user | USER) sim_environment="USER_ENVIRONMENT";;
275 virtual | VIRTUAL) sim_environment="VIRTUAL_ENVIRONMENT";;
276 operating | OPERATING) sim_environment="OPERATING_ENVIRONMENT";;
277 *) AC_MSG_ERROR([Unknown value $enableval passed to --enable-sim-environment]);;
278esac])dnl
279AC_DEFINE_UNQUOTED([WITH_ENVIRONMENT], [$sim_environment], [Sim default environment])
280AC_MSG_RESULT($sim_environment)
9c082ca8 281])
9c082ca8
MF
282
283
284dnl Specify the alignment restrictions of the target architecture.
285dnl Without this option all possible alignment restrictions are accommodated.
286dnl arg[1] is hardwired target alignment
287dnl arg[2] is default target alignment
288AC_DEFUN([SIM_AC_OPTION_ALIGNMENT],
289wire_alignment="[$1]"
290default_alignment="[$2]"
291[
292AC_ARG_ENABLE(sim-alignment,
8d0978fb
MF
293[AS_HELP_STRING([--enable-sim-alignment=align],
294 [Specify strict, nonstrict or forced alignment of memory accesses])],
9c082ca8
MF
295[case "${enableval}" in
296 strict | STRICT) sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";;
297 nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";;
298 forced | FORCED) sim_alignment="-DWITH_ALIGNMENT=FORCED_ALIGNMENT";;
299 yes) if test x"$wire_alignment" != x; then
300 sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
301 else
302 if test x"$default_alignment" != x; then
303 sim_alignment="-DWITH_ALIGNMENT=${default_alignment}"
304 else
305 echo "No hard-wired alignment for target $target" 1>&6
306 sim_alignment="-DWITH_ALIGNMENT=0"
307 fi
308 fi;;
309 no) if test x"$default_alignment" != x; then
310 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
311 else
312 if test x"$wire_alignment" != x; then
313 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${wire_alignment}"
314 else
315 echo "No default alignment for target $target" 1>&6
316 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=0"
317 fi
318 fi;;
319 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment"); sim_alignment="";;
320esac
321if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then
322 echo "Setting alignment flags = $sim_alignment" 6>&1
323fi],
324[if test x"$default_alignment" != x; then
325 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
326else
327 if test x"$wire_alignment" != x; then
328 sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
329 else
330 sim_alignment=
331 fi
332fi])dnl
333])dnl
334AC_SUBST(sim_alignment)
335
336
337dnl Conditionally compile in assertion statements.
338AC_DEFUN([SIM_AC_OPTION_ASSERT],
339[
ce39bd38
MF
340AC_MSG_CHECKING([whether to enable sim asserts])
341sim_assert="1"
9c082ca8 342AC_ARG_ENABLE(sim-assert,
8d0978fb
MF
343[AS_HELP_STRING([--enable-sim-assert],
344 [Specify whether to perform random assertions])],
9c082ca8 345[case "${enableval}" in
ce39bd38
MF
346 yes) sim_assert="1";;
347 no) sim_assert="0";;
348 *) AC_MSG_ERROR([--enable-sim-assert does not take a value]);;
349esac])dnl
350AC_DEFINE_UNQUOTED([WITH_ASSERT], [$sim_assert], [Sim assert settings])
351AC_MSG_RESULT($sim_assert)
9c082ca8 352])
9c082ca8
MF
353
354
355
356dnl --enable-sim-bitsize is for developers of the simulator
357dnl It specifies the number of BITS in the target.
358dnl arg[1] is the number of bits in a word
359dnl arg[2] is the number assigned to the most significant bit
360dnl arg[3] is the number of bits in an address
361dnl arg[4] is the number of bits in an OpenFirmware cell.
362dnl FIXME: this information should be obtained from bfd/archure
363AC_DEFUN([SIM_AC_OPTION_BITSIZE],
364wire_word_bitsize="[$1]"
365wire_word_msb="[$2]"
366wire_address_bitsize="[$3]"
367wire_cell_bitsize="[$4]"
368[AC_ARG_ENABLE(sim-bitsize,
8d0978fb 369[AS_HELP_STRING([--enable-sim-bitsize=N], [Specify target bitsize (32 or 64)])],
9c082ca8
MF
370[sim_bitsize=
371case "${enableval}" in
372 64,63 | 64,63,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63";;
373 32,31 | 32,31,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31";;
374 64,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";;
375 32,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";;
376 32) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then
377 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31"
378 else
379 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0"
380 fi ;;
381 64) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then
382 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63"
383 else
384 sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=0"
385 fi ;;
386 *) AC_MSG_ERROR("--enable-sim-bitsize was given $enableval. Expected 32 or 64") ;;
387esac
388# address bitsize
389tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9]]*,*//"`
390case x"${tmp}" in
391 x ) ;;
392 x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=32" ;;
393 x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=64" ;;
394 * ) AC_MSG_ERROR("--enable-sim-bitsize was given address size $enableval. Expected 32 or 64") ;;
395esac
396# cell bitsize
397tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9*]]*,*[[0-9]]*,*//"`
398case x"${tmp}" in
399 x ) ;;
400 x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=32" ;;
401 x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=64" ;;
402 * ) AC_MSG_ERROR("--enable-sim-bitsize was given cell size $enableval. Expected 32 or 64") ;;
403esac
404if test x"$silent" != x"yes" && test x"$sim_bitsize" != x""; then
405 echo "Setting bitsize flags = $sim_bitsize" 6>&1
406fi],
407[sim_bitsize=""
408if test x"$wire_word_bitsize" != x; then
409 sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_BITSIZE=$wire_word_bitsize"
410fi
411if test x"$wire_word_msb" != x; then
412 sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_MSB=$wire_word_msb"
413fi
414if test x"$wire_address_bitsize" != x; then
415 sim_bitsize="$sim_bitsize -DWITH_TARGET_ADDRESS_BITSIZE=$wire_address_bitsize"
416fi
417if test x"$wire_cell_bitsize" != x; then
418 sim_bitsize="$sim_bitsize -DWITH_TARGET_CELL_BITSIZE=$wire_cell_bitsize"
419fi])dnl
420])
421AC_SUBST(sim_bitsize)
422
423
424
425dnl --enable-sim-endian={yes,no,big,little} is for simulators
426dnl that support both big and little endian targets.
427dnl arg[1] is hardwired target endianness.
428dnl arg[2] is default target endianness.
429AC_DEFUN([SIM_AC_OPTION_ENDIAN],
430[
431wire_endian="[$1]"
432default_endian="[$2]"
433AC_ARG_ENABLE(sim-endian,
8d0978fb
MF
434[AS_HELP_STRING([--enable-sim-endian=endian],
435 [Specify target byte endian orientation])],
9c082ca8 436[case "${enableval}" in
1ac72f06
MF
437 b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_BIG";;
438 l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_LITTLE";;
9c082ca8 439 yes) if test x"$wire_endian" != x; then
1ac72f06 440 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
9c082ca8 441 else
1ac72f06
MF
442 if test x"$default_endian" != x; then
443 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
9c082ca8
MF
444 else
445 echo "No hard-wired endian for target $target" 1>&6
1ac72f06 446 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
9c082ca8
MF
447 fi
448 fi;;
449 no) if test x"$default_endian" != x; then
1ac72f06 450 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
9c082ca8
MF
451 else
452 if test x"$wire_endian" != x; then
1ac72f06 453 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
9c082ca8
MF
454 else
455 echo "No default endian for target $target" 1>&6
1ac72f06 456 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
9c082ca8
MF
457 fi
458 fi;;
459 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
460esac
461if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
462 echo "Setting endian flags = $sim_endian" 6>&1
463fi],
464[if test x"$default_endian" != x; then
1ac72f06 465 sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
9c082ca8
MF
466else
467 if test x"$wire_endian" != x; then
1ac72f06 468 sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
9c082ca8
MF
469 else
470 sim_endian=
471 fi
472fi])dnl
473])
474AC_SUBST(sim_endian)
475
476
9c082ca8
MF
477dnl --enable-sim-float is for developers of the simulator
478dnl It specifies the presence of hardware floating point
479dnl And optionally the bitsize of the floating point register.
480dnl arg[1] specifies the presence (or absence) of floating point hardware
481dnl arg[2] specifies the number of bits in a floating point register
482AC_DEFUN([SIM_AC_OPTION_FLOAT],
483[
484default_sim_float="[$1]"
485default_sim_float_bitsize="[$2]"
486AC_ARG_ENABLE(sim-float,
8d0978fb
MF
487[AS_HELP_STRING([--enable-sim-float],
488 [Specify that the target processor has floating point hardware])],
9c082ca8
MF
489[case "${enableval}" in
490 yes | hard) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";;
491 no | soft) sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";;
492 32) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=32";;
493 64) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=64";;
494 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-float"); sim_float="";;
495esac
496if test x"$silent" != x"yes" && test x"$sim_float" != x""; then
497 echo "Setting float flags = $sim_float" 6>&1
498fi],[
499sim_float=
500if test x"${default_sim_float}" != x""; then
501 sim_float="-DWITH_FLOATING_POINT=${default_sim_float}"
502fi
503if test x"${default_sim_float_bitsize}" != x""; then
504 sim_float="$sim_float -DWITH_TARGET_FLOATING_POINT_BITSIZE=${default_sim_float_bitsize}"
505fi
506])dnl
507])
508AC_SUBST(sim_float)
509
510
511dnl The argument is the default cache size if none is specified.
512AC_DEFUN([SIM_AC_OPTION_SCACHE],
513[
514default_sim_scache="ifelse([$1],,0,[$1])"
515AC_ARG_ENABLE(sim-scache,
8d0978fb
MF
516[AS_HELP_STRING([--enable-sim-scache=size],
517 [Specify simulator execution cache size])],
9c082ca8
MF
518[case "${enableval}" in
519 yes) sim_scache="-DWITH_SCACHE=${default_sim_scache}";;
520 no) sim_scache="-DWITH_SCACHE=0" ;;
521 [[0-9]]*) sim_scache="-DWITH_SCACHE=${enableval}";;
522 *) AC_MSG_ERROR("Bad value $enableval passed to --enable-sim-scache");
523 sim_scache="";;
524esac
525if test x"$silent" != x"yes" && test x"$sim_scache" != x""; then
526 echo "Setting scache size = $sim_scache" 6>&1
527fi],[sim_scache="-DWITH_SCACHE=${default_sim_scache}"])
528])
529AC_SUBST(sim_scache)
530
531
532dnl The argument is the default model if none is specified.
533AC_DEFUN([SIM_AC_OPTION_DEFAULT_MODEL],
534[
535default_sim_default_model="ifelse([$1],,0,[$1])"
536AC_ARG_ENABLE(sim-default-model,
8d0978fb
MF
537[AS_HELP_STRING([--enable-sim-default-model=model],
538 [Specify default model to simulate])],
9c082ca8
MF
539[case "${enableval}" in
540 yes|no) AC_MSG_ERROR("Missing argument to --enable-sim-default-model");;
541 *) sim_default_model="-DWITH_DEFAULT_MODEL='\"${enableval}\"'";;
542esac
543if test x"$silent" != x"yes" && test x"$sim_default_model" != x""; then
544 echo "Setting default model = $sim_default_model" 6>&1
545fi],[sim_default_model="-DWITH_DEFAULT_MODEL='\"${default_sim_default_model}\"'"])
546])
547AC_SUBST(sim_default_model)
548
549
550dnl --enable-sim-hardware is for users of the simulator
64dd13df 551dnl arg[1] Enable sim-hw by default? ("yes" or "no")
9c082ca8
MF
552dnl arg[2] is a space separated list of devices that override the defaults
553dnl arg[3] is a space separated list of extra target specific devices.
554AC_DEFUN([SIM_AC_OPTION_HARDWARE],
555[
9c082ca8
MF
556if test "[$2]"; then
557 hardware="[$2]"
558else
559 hardware="cfi core pal glue"
560fi
561hardware="$hardware [$3]"
1517bd27 562
9c082ca8
MF
563sim_hw_cflags="-DWITH_HW=1"
564sim_hw="$hardware"
565sim_hw_objs="\$(SIM_COMMON_HW_OBJS) `echo $sim_hw | sed -e 's/\([[^ ]][[^ ]]*\)/dv-\1.o/g'`"
1517bd27 566
9c082ca8 567AC_ARG_ENABLE(sim-hardware,
1517bd27 568 [AS_HELP_STRING([--enable-sim-hardware=LIST],
30452bbe
MF
569 [Specify the hardware to be included in the build.])],
570 ,[enable_sim_hardware="[$1]"])
1517bd27 571case ${enable_sim_hardware} in
64dd13df
MF
572 yes|no) ;;
573 ,*) hardware="${hardware} `echo ${enableval} | sed -e 's/,/ /'`";;
574 *,) hardware="`echo ${enableval} | sed -e 's/,/ /'` ${hardware}";;
575 *) hardware="`echo ${enableval} | sed -e 's/,/ /'`"'';;
9c082ca8 576esac
1517bd27 577
64dd13df 578if test "$enable_sim_hardware" = no; then
9c082ca8
MF
579 sim_hw_objs=
580 sim_hw_cflags="-DWITH_HW=0"
581 sim_hw=
582else
583 sim_hw_cflags="-DWITH_HW=1"
584 # remove duplicates
585 sim_hw=""
586 sim_hw_objs="\$(SIM_COMMON_HW_OBJS)"
587 for i in $hardware ; do
588 case " $sim_hw " in
589 *" $i "*) ;;
590 *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";;
591 esac
592 done
3fd38161 593 # mingw does not support sockser
3fd38161
JS
594 case ${host} in
595 *mingw*) ;;
49cd1634
MF
596 *) # TODO: We don't add dv-sockser to sim_hw as it is not a "real" device
597 # that you instatiate. Instead, other code will call into it directly.
598 # At some point, we should convert it over.
599 sim_hw_objs="$sim_hw_objs dv-sockser.o"
3fd38161
JS
600 AC_DEFINE_UNQUOTED(
601 [HAVE_DV_SOCKSER], 1, [Define if dv-sockser is usable.])
602 ;;
603 esac
1517bd27
MF
604 if test x"$silent" != x"yes"; then
605 echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
3fd38161 606 fi
1517bd27
MF
607 dnl Some devices require extra libraries.
608 case " $hardware " in
609 *" cfi "*) AC_CHECK_LIB(m, log2);;
610 esac
9c082ca8 611fi
9c082ca8
MF
612])
613AC_SUBST(sim_hw_cflags)
614AC_SUBST(sim_hw_objs)
615AC_SUBST(sim_hw)
616
617
618dnl --enable-sim-inline is for users that wish to ramp up the simulator's
619dnl performance by inlining functions.
347fe5bb 620dnl Default sims to no inlining.
9c082ca8
MF
621AC_DEFUN([SIM_AC_OPTION_INLINE],
622[
347fe5bb 623sim_inline="-DDEFAULT_INLINE=m4_ifblank([$1],[0],[$1])"
9c082ca8 624AC_ARG_ENABLE(sim-inline,
8d0978fb
MF
625[AS_HELP_STRING([--enable-sim-inline=inlines],
626 [Specify which functions should be inlined])],
9c082ca8
MF
627[sim_inline=""
628case "$enableval" in
629 no) sim_inline="-DDEFAULT_INLINE=0";;
630 0) sim_inline="-DDEFAULT_INLINE=0";;
631 yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_C_INLINE";;
632 1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";;
633 *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
634 new_flag=""
635 case "$x" in
636 *_INLINE=*) new_flag="-D$x";;
637 *=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;;
638 *_INLINE) new_flag="-D$x=ALL_C_INLINE";;
639 *) new_flag="-D$x""_INLINE=ALL_C_INLINE";;
640 esac
641 if test x"$sim_inline" = x""; then
642 sim_inline="$new_flag"
643 else
644 sim_inline="$sim_inline $new_flag"
645 fi
646 done;;
647esac
648if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
649 echo "Setting inline flags = $sim_inline" 6>&1
9c082ca8
MF
650fi])dnl
651])
652AC_SUBST(sim_inline)
653
654
9c082ca8
MF
655AC_DEFUN([SIM_AC_OPTION_RESERVED_BITS],
656[
657default_sim_reserved_bits="ifelse([$1],,1,[$1])"
658AC_ARG_ENABLE(sim-reserved-bits,
8d0978fb
MF
659[AS_HELP_STRING([--enable-sim-reserved-bits],
660 [Specify whether to check reserved bits in instruction])],
9c082ca8
MF
661[case "${enableval}" in
662 yes) sim_reserved_bits="-DWITH_RESERVED_BITS=1";;
663 no) sim_reserved_bits="-DWITH_RESERVED_BITS=0";;
664 *) AC_MSG_ERROR("--enable-sim-reserved-bits does not take a value"); sim_reserved_bits="";;
665esac
666if test x"$silent" != x"yes" && test x"$sim_reserved_bits" != x""; then
667 echo "Setting reserved flags = $sim_reserved_bits" 6>&1
668fi],[sim_reserved_bits="-DWITH_RESERVED_BITS=${default_sim_reserved_bits}"])dnl
669])
670AC_SUBST(sim_reserved_bits)
671
672
673AC_DEFUN([SIM_AC_OPTION_SMP],
674[
ce39bd38 675AC_MSG_CHECKING([number of sim cpus to support])
9c082ca8 676default_sim_smp="ifelse([$1],,5,[$1])"
ce39bd38 677sim_smp="$default_sim_smp""
9c082ca8 678AC_ARG_ENABLE(sim-smp,
8d0978fb
MF
679[AS_HELP_STRING([--enable-sim-smp=n],
680 [Specify number of processors to configure for (default ${default_sim_smp})])],
9c082ca8 681[case "${enableval}" in
ce39bd38
MF
682 yes) sim_smp="5";;
683 no) sim_smp="0";;
684 *) sim_smp="$enableval";;
685esac])dnl
686sim_igen_smp="-N ${sim_smp}"
687AC_DEFINE_UNQUOTED([WITH_SMP], [$sim_smp], [Sim SMP settings])
688AC_MSG_RESULT($sim_smp)
9c082ca8 689])
9c082ca8
MF
690
691
9c082ca8
MF
692AC_DEFUN([SIM_AC_OPTION_XOR_ENDIAN],
693[
ce39bd38 694AC_MSG_CHECKING([for xor endian support])
9c082ca8 695default_sim_xor_endian="ifelse([$1],,8,[$1])"
ce39bd38 696sim_xor_endian="$default_sim_xor_endian"
9c082ca8 697AC_ARG_ENABLE(sim-xor-endian,
8d0978fb
MF
698[AS_HELP_STRING([--enable-sim-xor-endian=n],
699 [Specify number bytes involved in XOR bi-endian mode (default ${default_sim_xor_endian})])],
9c082ca8 700[case "${enableval}" in
ce39bd38
MF
701 yes) sim_xor_endian="8";;
702 no) sim_xor_endian="0";;
703 *) sim_xor_endian="$enableval";;
704esac])dnl
705AC_DEFINE_UNQUOTED([WITH_XOR_ENDIAN], [$sim_xor_endian], [Sim XOR endian settings])
706AC_MSG_RESULT($sim_smp)
9c082ca8 707])
9c082ca8
MF
708
709
710dnl --enable-build-warnings is for developers of the simulator.
711dnl it enables extra GCC specific warnings.
712AC_DEFUN([SIM_AC_OPTION_WARNINGS],
713[
ac0aacdf
MF
714AC_ARG_ENABLE(werror,
715 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
716 [case "${enableval}" in
717 yes | y) ERROR_ON_WARNING="yes" ;;
718 no | n) ERROR_ON_WARNING="no" ;;
719 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
720 esac])
721
722# Enable -Werror by default when using gcc
723if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
724 ERROR_ON_WARNING=yes
725fi
726
727WERROR_CFLAGS=""
728if test "${ERROR_ON_WARNING}" = yes ; then
729# NOTE: Disabled in the sim dir due to most sims generating warnings.
730# WERROR_CFLAGS="-Werror"
731 true
9c082ca8 732fi
ac0aacdf 733
ac0aacdf 734build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
1a8a700e 735-Wpointer-sign \
ac0aacdf 736-Wno-unused -Wunused-value -Wunused-function \
1a8a700e
MF
737-Wno-switch -Wno-char-subscripts -Wmissing-prototypes
738-Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \
739-Wold-style-declaration -Wold-style-definition"
ac0aacdf
MF
740
741# Enable -Wno-format by default when using gcc on mingw since many
742# GCC versions complain about %I64.
743case "${host}" in
744 *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;;
d3685d60 745 *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
ac0aacdf
MF
746esac
747
9c082ca8 748AC_ARG_ENABLE(build-warnings,
ac0aacdf 749AS_HELP_STRING([--enable-build-warnings], [enable build-time compiler warnings if gcc is used]),
9c082ca8
MF
750[case "${enableval}" in
751 yes) ;;
752 no) build_warnings="-w";;
753 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
754 build_warnings="${build_warnings} ${t}";;
755 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
756 build_warnings="${t} ${build_warnings}";;
757 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
758esac
759if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
760 echo "Setting compiler warning flags = $build_warnings" 6>&1
761fi])dnl
762AC_ARG_ENABLE(sim-build-warnings,
ac0aacdf 763AS_HELP_STRING([--enable-sim-build-warnings], [enable SIM specific build-time compiler warnings if gcc is used]),
9c082ca8
MF
764[case "${enableval}" in
765 yes) ;;
766 no) build_warnings="-w";;
767 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
768 build_warnings="${build_warnings} ${t}";;
769 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
770 build_warnings="${t} ${build_warnings}";;
771 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
772esac
773if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
774 echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
775fi])dnl
776WARN_CFLAGS=""
9c082ca8
MF
777if test "x${build_warnings}" != x -a "x$GCC" = xyes
778then
779 AC_MSG_CHECKING(compiler warning flags)
780 # Separate out the -Werror flag as some files just cannot be
781 # compiled with it enabled.
782 for w in ${build_warnings}; do
783 case $w in
784 -Werr*) WERROR_CFLAGS=-Werror ;;
785 *) # Check that GCC accepts it
786 saved_CFLAGS="$CFLAGS"
787 CFLAGS="$CFLAGS $w"
788 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
789 CFLAGS="$saved_CFLAGS"
790 esac
791 done
ac0aacdf 792 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
9c082ca8
MF
793fi
794])
795AC_SUBST(WARN_CFLAGS)
796AC_SUBST(WERROR_CFLAGS)
797
798
799dnl Generate the Makefile in a target specific directory.
800dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
801dnl so this is a cover macro to tuck the details away of how we cope.
802dnl We cope by having autoconf generate two files and then merge them into
803dnl one afterwards. The two pieces of the common fragment are inserted into
804dnl the target's fragment at the appropriate points.
805
806AC_DEFUN([SIM_AC_OUTPUT],
807[
9c082ca8
MF
808dnl Make @cgen_breaks@ non-null only if the sim uses CGEN.
809cgen_breaks=""
810if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
811cgen_breaks="break cgen_rtx_error";
812fi
813AC_SUBST(cgen_breaks)
814AC_CONFIG_FILES(Makefile.sim:Makefile.in)
815AC_CONFIG_FILES(Make-common.sim:../common/Make-common.in)
816AC_CONFIG_FILES(.gdbinit:../common/gdbinit.in)
817AC_CONFIG_COMMANDS([Makefile],
818[echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
819 rm -f Makesim1.tmp Makesim2.tmp Makefile
820 sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
821 sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
822 sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
823 -e '/^## COMMON_POST_/ r Makesim2.tmp' \
824 <Makefile.sim >Makefile
825 rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
826])
827AC_CONFIG_COMMANDS([stamp-h], [echo > stamp-h])
828AC_OUTPUT
829])
830
831sinclude(../../config/gettext-sister.m4)
832sinclude(../../config/acx.m4)
833
834dnl --enable-cgen-maint support
835AC_DEFUN([SIM_AC_OPTION_CGEN_MAINT],
836[
837cgen_maint=no
838dnl Default is to use one in build tree.
839cgen=guile
840cgendir='$(srcdir)/../../cgen'
841dnl Having --enable-maintainer-mode take arguments is another way to go.
842dnl ??? One can argue --with is more appropriate if one wants to specify
843dnl a directory name, but what we're doing here is an enable/disable kind
844dnl of thing and specifying both --enable and --with is klunky.
845dnl If you reeely want this to be --with, go ahead and change it.
846AC_ARG_ENABLE(cgen-maint,
8d0978fb 847[AS_HELP_STRING([--enable-cgen-maint[=DIR]], [build cgen generated files])],
9c082ca8
MF
848[case "${enableval}" in
849 yes) cgen_maint=yes ;;
850 no) cgen_maint=no ;;
851 *)
852 # argument is cgen install directory (not implemented yet).
853 # Having a `share' directory might be more appropriate for the .scm,
854 # .cpu, etc. files.
855 cgendir=${cgen_maint}/lib/cgen
856 cgen=guile
857 ;;
858esac])dnl
859dnl AM_CONDITIONAL(CGEN_MAINT, test x${cgen_maint} != xno)
860if test x${cgen_maint} != xno ; then
861 CGEN_MAINT=''
862else
863 CGEN_MAINT='#'
864fi
865AC_SUBST(CGEN_MAINT)
866AC_SUBST(cgendir)
867AC_SUBST(cgen)
868])
This page took 0.258478 seconds and 4 git commands to generate.