]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - sim/common/acinclude.m4
sim: switch to AC_CONFIG_MACRO_DIRS
[thirdparty/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#
50df264d 8# See README-HACKING for more details.
9c082ca8 9
9c082ca8
MF
10AC_DEFUN([SIM_AC_COMMON],
11[
12AC_REQUIRE([AC_PROG_CC])
7a36eeea 13AC_CONFIG_HEADERS([config.h:config.in])
9c082ca8 14AC_CANONICAL_SYSTEM
2232061b 15AC_USE_SYSTEM_EXTENSIONS
0cb8d851 16AC_C_BIGENDIAN
9c082ca8
MF
17AC_ARG_PROGRAM
18AC_PROG_INSTALL
19
20# Put a plausible default for CC_FOR_BUILD in Makefile.
5c887dd5
JB
21if test -z "$CC_FOR_BUILD"; then
22 if test "x$cross_compiling" = "xno"; then
23 CC_FOR_BUILD='$(CC)'
24 else
25 CC_FOR_BUILD=gcc
26 fi
9c082ca8
MF
27fi
28AC_SUBST(CC_FOR_BUILD)
29
30AC_SUBST(CFLAGS)
9c082ca8
MF
31AR=${AR-ar}
32AC_SUBST(AR)
33AC_PROG_RANLIB
34
46f900c0
MF
35# Require C11 or newer. Autoconf-2.70 provides ac_cv_prog_cc_c11 when using
36# AC_PROG_CC, but we're still using Autoconf-2.69, and the newest it understands
37# is C99. So handle it ourselves.
38m4_version_prereq([2.70], [AC_MSG_ERROR([clean this up!])], [:])
39C_DIALECT=
40AC_MSG_CHECKING([whether C11 is supported by default])
41AC_COMPILE_IFELSE([AC_LANG_SOURCE([
42#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
43# error "C11 support not found"
44#endif
45])], [AC_MSG_RESULT([yes])], [
46 AC_MSG_RESULT([no])
47 AC_MSG_CHECKING([for -std=c11 support])
48 ac_save_CC="$CC"
49 CC="$CC -std=c11"
50 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
51#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
52# error "C11 support not found"
53#endif
54])], [
55 AC_MSG_RESULT([yes])
56 CC="$ac_save_CC"
57 C_DIALECT="-std=c11"
58], [AC_MSG_ERROR([C11 is required])])])
59AC_SUBST(C_DIALECT)
60
5f3ef9d0
JB
61# Some of the common include files depend on bfd.h, and bfd.h checks
62# that config.h is included first by testing that the PACKAGE macro
63# is defined.
64PACKAGE=sim
65AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package. ])
66AC_SUBST(PACKAGE)
67
db2e4d67
MF
68# Dependency checking.
69ZW_CREATE_DEPDIR
70ZW_PROG_COMPILER_DEPENDENCIES([CC])
71
72# Check for the 'make' the user wants to use.
73AC_CHECK_PROGS(MAKE, make)
74MAKE_IS_GNU=
75case "`$MAKE --version 2>&1 | sed 1q`" in
76 *GNU*)
77 MAKE_IS_GNU=yes
78 ;;
79esac
80AM_CONDITIONAL(GMAKE, test "$MAKE_IS_GNU" = yes)
81
9c082ca8
MF
82dnl We don't use gettext, but bfd does. So we do the appropriate checks
83dnl to see if there are intl libraries we should link against.
84ALL_LINGUAS=
85ZW_GNU_GETTEXT_SISTER_DIR(../../intl)
86
87# Check for common headers.
68ed2854
MF
88# NB: You can assume C11 headers exist.
89AC_CHECK_HEADERS(unistd.h)
936df756 90AC_CHECK_HEADERS(sys/time.h sys/times.h sys/resource.h sys/mman.h)
9c082ca8 91AC_CHECK_HEADERS(fcntl.h fpu_control.h)
68ed2854 92AC_CHECK_HEADERS(dlfcn.h sys/stat.h)
9c082ca8 93AC_CHECK_FUNCS(getrusage time sigaction __setfpucw)
936df756
MF
94AC_CHECK_FUNCS(mmap munmap lstat truncate ftruncate posix_fallocate)
95AC_CHECK_MEMBERS([[struct stat.st_dev], [struct stat.st_ino],
96[struct stat.st_mode], [struct stat.st_nlink], [struct stat.st_uid],
97[struct stat.st_gid], [struct stat.st_rdev], [struct stat.st_size],
98[struct stat.st_blksize], [struct stat.st_blocks], [struct stat.st_atime],
99[struct stat.st_mtime], [struct stat.st_ctime]], [], [],
100[[#ifdef HAVE_SYS_TYPES_H
101#include <sys/types.h>
102#endif
103#ifdef HAVE_SYS_STAT_H
104#include <sys/stat.h>
105#endif]])
106AC_CHECK_TYPES(socklen_t, [], [],
107[#include <sys/types.h>
108#include <sys/socket.h>
109])
9c082ca8
MF
110
111# Check for socket libraries
112AC_CHECK_LIB(socket, bind)
113AC_CHECK_LIB(nsl, gethostbyname)
114
115# BFD conditionally uses zlib, so we must link it in if libbfd does, by
116# using the same condition.
117AM_ZLIB
118
6bb11ab3
L
119# BFD uses libdl when when plugins enabled.
120AC_PLUGINS
121AM_CONDITIONAL(PLUGINS, test "$plugins" = yes)
122LT_INIT([dlopen])
123AC_SUBST(lt_cv_dlopen_libs)
124
9c082ca8
MF
125dnl Standard (and optional) simulator options.
126dnl Eventually all simulators will support these.
127dnl Do not add any here that cannot be supported by all simulators.
128dnl Do not add similar but different options to a particular simulator,
129dnl all shall eventually behave the same way.
130
131
132dnl We don't use automake, but we still want to support
133dnl --enable-maintainer-mode.
31e6ad7d 134AM_MAINTAINER_MODE
9c082ca8
MF
135
136
9c082ca8
MF
137dnl --enable-sim-debug is for developers of the simulator
138dnl the allowable values are work-in-progress
ce39bd38
MF
139AC_MSG_CHECKING([for sim debug setting])
140sim_debug="0"
9c082ca8 141AC_ARG_ENABLE(sim-debug,
8d0978fb
MF
142[AS_HELP_STRING([--enable-sim-debug=opts],
143 [Enable debugging flags (for developers of the sim itself)])],
9c082ca8 144[case "${enableval}" in
ce39bd38
MF
145 yes) sim_debug="7";;
146 no) sim_debug="0";;
147 *) sim_debug="($enableval)";;
148esac])dnl
149if test "$sim_debug" != "0"; then
150 AC_DEFINE_UNQUOTED([DEBUG], [$sim_debug], [Sim debug setting])
151fi
152AC_DEFINE_UNQUOTED([WITH_DEBUG], [$sim_debug], [Sim debug setting])
153AC_MSG_RESULT($sim_debug)
9c082ca8
MF
154
155
156dnl --enable-sim-stdio is for users of the simulator
157dnl It determines if IO from the program is routed through STDIO (buffered)
ce39bd38
MF
158AC_MSG_CHECKING([for sim stdio debug behavior])
159sim_stdio="0"
9c082ca8 160AC_ARG_ENABLE(sim-stdio,
8d0978fb
MF
161[AS_HELP_STRING([--enable-sim-stdio],
162 [Specify whether to use stdio for console input/output])],
9c082ca8 163[case "${enableval}" in
ce39bd38
MF
164 yes) sim_stdio="DO_USE_STDIO";;
165 no) sim_stdio="DONT_USE_STDIO";;
166 *) AC_MSG_ERROR([Unknown value $enableval passed to --enable-sim-stdio]);;
167esac])dnl
168AC_DEFINE_UNQUOTED([WITH_STDIO], [$sim_stdio], [How to route I/O])
169AC_MSG_RESULT($sim_stdio)
9c082ca8
MF
170
171
172dnl --enable-sim-trace is for users of the simulator
173dnl The argument is either a bitmask of things to enable [exactly what is
174dnl up to the simulator], or is a comma separated list of names of tracing
175dnl elements to enable. The latter is only supported on simulators that
ce39bd38
MF
176dnl use WITH_TRACE. Default to all tracing but internal debug.
177AC_MSG_CHECKING([for sim trace settings])
178sim_trace="~TRACE_debug"
9c082ca8 179AC_ARG_ENABLE(sim-trace,
8d0978fb
MF
180[AS_HELP_STRING([--enable-sim-trace=opts],
181 [Enable tracing of simulated programs])],
9c082ca8 182[case "${enableval}" in
ce39bd38
MF
183 yes) sim_trace="-1";;
184 no) sim_trace="0";;
9c082ca8 185 [[-0-9]]*)
ce39bd38 186 sim_trace="'(${enableval})'";;
509deab2 187 [[[:lower:]]]*)
9c082ca8
MF
188 sim_trace=""
189 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
190 if test x"$sim_trace" = x; then
ce39bd38 191 sim_trace="(TRACE_$x"
9c082ca8
MF
192 else
193 sim_trace="${sim_trace}|TRACE_$x"
194 fi
195 done
ce39bd38
MF
196 sim_trace="$sim_trace)" ;;
197esac])dnl
198AC_DEFINE_UNQUOTED([WITH_TRACE], [$sim_trace], [Sim trace settings])
199AC_MSG_RESULT($sim_trace)
9c082ca8
MF
200
201
202dnl --enable-sim-profile
203dnl The argument is either a bitmask of things to enable [exactly what is
204dnl up to the simulator], or is a comma separated list of names of profiling
205dnl elements to enable. The latter is only supported on simulators that
206dnl use WITH_PROFILE.
ce39bd38
MF
207AC_MSG_CHECKING([for sim profile settings])
208profile="1"
209sim_profile="-1"
9c082ca8 210AC_ARG_ENABLE(sim-profile,
8d0978fb 211[AS_HELP_STRING([--enable-sim-profile=opts], [Enable profiling flags])],
9c082ca8 212[case "${enableval}" in
ce39bd38
MF
213 yes) profile="1" sim_profile="-1";;
214 no) profile="0" sim_profile="0";;
9c082ca8 215 [[-0-9]]*)
ce39bd38 216 profile="(${enableval})" sim_profile="(${enableval})";;
9c082ca8 217 [[a-z]]*)
ce39bd38 218 profile="1"
9c082ca8
MF
219 sim_profile=""
220 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
221 if test x"$sim_profile" = x; then
ce39bd38 222 sim_profile="(PROFILE_$x"
9c082ca8
MF
223 else
224 sim_profile="${sim_profile}|PROFILE_$x"
225 fi
226 done
ce39bd38
MF
227 sim_profile="$sim_profile)" ;;
228esac])dnl
229AC_DEFINE_UNQUOTED([PROFILE], [$profile], [Sim profile settings])
230AC_DEFINE_UNQUOTED([WITH_PROFILE], [$sim_profile], [Sim profile settings])
231AC_MSG_RESULT($sim_profile)
232
9c082ca8 233
35656e95 234SIM_AC_OPTION_ASSERT
16f7876d 235SIM_AC_OPTION_ENVIRONMENT
347fe5bb
MF
236SIM_AC_OPTION_INLINE
237
bf12d44e 238ACX_PKGVERSION([SIM])
dfb856ba 239ACX_BUGURL([https://www.gnu.org/software/gdb/bugs/])
9c082ca8
MF
240AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
241AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
242
243dnl Types used by common code
244AC_TYPE_SIGNAL
245
246dnl Detect exe extension
247AC_EXEEXT
248
9c082ca8
MF
249]) dnl End of SIM_AC_COMMON
250
251
252dnl Additional SIM options that can (optionally) be configured
253dnl For optional simulator options, a macro SIM_AC_OPTION_* is defined.
254dnl Simulators that wish to use the relevant option specify the macro
306f4178 255dnl in the simulator specific configure.ac file between the SIM_AC_COMMON
9c082ca8
MF
256dnl and SIM_AC_OUTPUT lines.
257
258
259dnl Specify the running environment.
306f4178 260dnl If the simulator invokes this in its configure.ac then without this option
9c082ca8
MF
261dnl the default is the user environment and all are runtime selectable.
262dnl If the simulator doesn't invoke this, only the user environment is
263dnl supported.
264dnl ??? Until there is demonstrable value in doing something more complicated,
265dnl let's not.
266AC_DEFUN([SIM_AC_OPTION_ENVIRONMENT],
267[
ce39bd38
MF
268AC_MSG_CHECKING([default sim environment setting])
269sim_environment="ALL_ENVIRONMENT"
9c082ca8 270AC_ARG_ENABLE(sim-environment,
8d0978fb
MF
271[AS_HELP_STRING([--enable-sim-environment=environment],
272 [Specify mixed, user, virtual or operating environment])],
9c082ca8 273[case "${enableval}" in
ce39bd38
MF
274 all | ALL) sim_environment="ALL_ENVIRONMENT";;
275 user | USER) sim_environment="USER_ENVIRONMENT";;
276 virtual | VIRTUAL) sim_environment="VIRTUAL_ENVIRONMENT";;
277 operating | OPERATING) sim_environment="OPERATING_ENVIRONMENT";;
278 *) AC_MSG_ERROR([Unknown value $enableval passed to --enable-sim-environment]);;
279esac])dnl
280AC_DEFINE_UNQUOTED([WITH_ENVIRONMENT], [$sim_environment], [Sim default environment])
281AC_MSG_RESULT($sim_environment)
9c082ca8 282])
9c082ca8
MF
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[
ce39bd38
MF
341AC_MSG_CHECKING([whether to enable sim asserts])
342sim_assert="1"
9c082ca8 343AC_ARG_ENABLE(sim-assert,
8d0978fb
MF
344[AS_HELP_STRING([--enable-sim-assert],
345 [Specify whether to perform random assertions])],
9c082ca8 346[case "${enableval}" in
ce39bd38
MF
347 yes) sim_assert="1";;
348 no) sim_assert="0";;
349 *) AC_MSG_ERROR([--enable-sim-assert does not take a value]);;
350esac])dnl
351AC_DEFINE_UNQUOTED([WITH_ASSERT], [$sim_assert], [Sim assert settings])
352AC_MSG_RESULT($sim_assert)
9c082ca8 353])
9c082ca8
MF
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.
347fe5bb 621dnl Default sims to no inlining.
9c082ca8
MF
622AC_DEFUN([SIM_AC_OPTION_INLINE],
623[
347fe5bb 624sim_inline="-DDEFAULT_INLINE=m4_ifblank([$1],[0],[$1])"
9c082ca8 625AC_ARG_ENABLE(sim-inline,
8d0978fb
MF
626[AS_HELP_STRING([--enable-sim-inline=inlines],
627 [Specify which functions should be inlined])],
9c082ca8
MF
628[sim_inline=""
629case "$enableval" in
630 no) sim_inline="-DDEFAULT_INLINE=0";;
631 0) sim_inline="-DDEFAULT_INLINE=0";;
632 yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_C_INLINE";;
633 1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";;
634 *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
635 new_flag=""
636 case "$x" in
637 *_INLINE=*) new_flag="-D$x";;
638 *=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;;
639 *_INLINE) new_flag="-D$x=ALL_C_INLINE";;
640 *) new_flag="-D$x""_INLINE=ALL_C_INLINE";;
641 esac
642 if test x"$sim_inline" = x""; then
643 sim_inline="$new_flag"
644 else
645 sim_inline="$sim_inline $new_flag"
646 fi
647 done;;
648esac
649if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
650 echo "Setting inline flags = $sim_inline" 6>&1
9c082ca8
MF
651fi])dnl
652])
653AC_SUBST(sim_inline)
654
655
9c082ca8
MF
656AC_DEFUN([SIM_AC_OPTION_RESERVED_BITS],
657[
658default_sim_reserved_bits="ifelse([$1],,1,[$1])"
659AC_ARG_ENABLE(sim-reserved-bits,
8d0978fb
MF
660[AS_HELP_STRING([--enable-sim-reserved-bits],
661 [Specify whether to check reserved bits in instruction])],
9c082ca8
MF
662[case "${enableval}" in
663 yes) sim_reserved_bits="-DWITH_RESERVED_BITS=1";;
664 no) sim_reserved_bits="-DWITH_RESERVED_BITS=0";;
665 *) AC_MSG_ERROR("--enable-sim-reserved-bits does not take a value"); sim_reserved_bits="";;
666esac
667if test x"$silent" != x"yes" && test x"$sim_reserved_bits" != x""; then
668 echo "Setting reserved flags = $sim_reserved_bits" 6>&1
669fi],[sim_reserved_bits="-DWITH_RESERVED_BITS=${default_sim_reserved_bits}"])dnl
670])
671AC_SUBST(sim_reserved_bits)
672
673
674AC_DEFUN([SIM_AC_OPTION_SMP],
675[
ce39bd38 676AC_MSG_CHECKING([number of sim cpus to support])
9c082ca8 677default_sim_smp="ifelse([$1],,5,[$1])"
ce39bd38 678sim_smp="$default_sim_smp""
9c082ca8 679AC_ARG_ENABLE(sim-smp,
8d0978fb
MF
680[AS_HELP_STRING([--enable-sim-smp=n],
681 [Specify number of processors to configure for (default ${default_sim_smp})])],
9c082ca8 682[case "${enableval}" in
ce39bd38
MF
683 yes) sim_smp="5";;
684 no) sim_smp="0";;
685 *) sim_smp="$enableval";;
686esac])dnl
687sim_igen_smp="-N ${sim_smp}"
688AC_DEFINE_UNQUOTED([WITH_SMP], [$sim_smp], [Sim SMP settings])
689AC_MSG_RESULT($sim_smp)
9c082ca8 690])
9c082ca8
MF
691
692
9c082ca8
MF
693AC_DEFUN([SIM_AC_OPTION_XOR_ENDIAN],
694[
ce39bd38 695AC_MSG_CHECKING([for xor endian support])
9c082ca8 696default_sim_xor_endian="ifelse([$1],,8,[$1])"
ce39bd38 697sim_xor_endian="$default_sim_xor_endian"
9c082ca8 698AC_ARG_ENABLE(sim-xor-endian,
8d0978fb
MF
699[AS_HELP_STRING([--enable-sim-xor-endian=n],
700 [Specify number bytes involved in XOR bi-endian mode (default ${default_sim_xor_endian})])],
9c082ca8 701[case "${enableval}" in
ce39bd38
MF
702 yes) sim_xor_endian="8";;
703 no) sim_xor_endian="0";;
704 *) sim_xor_endian="$enableval";;
705esac])dnl
706AC_DEFINE_UNQUOTED([WITH_XOR_ENDIAN], [$sim_xor_endian], [Sim XOR endian settings])
707AC_MSG_RESULT($sim_smp)
9c082ca8 708])
9c082ca8
MF
709
710
711dnl --enable-build-warnings is for developers of the simulator.
712dnl it enables extra GCC specific warnings.
bf470982 713dnl arg[1] Enable -Werror by default? ("yes" or "no")
9c082ca8
MF
714AC_DEFUN([SIM_AC_OPTION_WARNINGS],
715[
ac0aacdf
MF
716AC_ARG_ENABLE(werror,
717 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
718 [case "${enableval}" in
719 yes | y) ERROR_ON_WARNING="yes" ;;
720 no | n) ERROR_ON_WARNING="no" ;;
721 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
722 esac])
723
724# Enable -Werror by default when using gcc
725if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
726 ERROR_ON_WARNING=yes
727fi
728
729WERROR_CFLAGS=""
bf470982
MF
730m4_if(m4_default([$1], [yes]), [yes], [dnl
731 if test "${ERROR_ON_WARNING}" = yes ; then
732 WERROR_CFLAGS="-Werror"
733 fi
734])dnl
ac0aacdf 735
ac0aacdf 736build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
1a8a700e 737-Wpointer-sign \
ac0aacdf 738-Wno-unused -Wunused-value -Wunused-function \
1a8a700e
MF
739-Wno-switch -Wno-char-subscripts -Wmissing-prototypes
740-Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \
741-Wold-style-declaration -Wold-style-definition"
ac0aacdf
MF
742
743# Enable -Wno-format by default when using gcc on mingw since many
744# GCC versions complain about %I64.
745case "${host}" in
746 *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;;
d3685d60 747 *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
ac0aacdf
MF
748esac
749
9c082ca8 750AC_ARG_ENABLE(build-warnings,
ac0aacdf 751AS_HELP_STRING([--enable-build-warnings], [enable build-time compiler warnings if gcc is used]),
9c082ca8
MF
752[case "${enableval}" in
753 yes) ;;
754 no) build_warnings="-w";;
755 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
756 build_warnings="${build_warnings} ${t}";;
757 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
758 build_warnings="${t} ${build_warnings}";;
759 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
760esac
761if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
762 echo "Setting compiler warning flags = $build_warnings" 6>&1
763fi])dnl
764AC_ARG_ENABLE(sim-build-warnings,
ac0aacdf 765AS_HELP_STRING([--enable-sim-build-warnings], [enable SIM specific build-time compiler warnings if gcc is used]),
9c082ca8
MF
766[case "${enableval}" in
767 yes) ;;
768 no) build_warnings="-w";;
769 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
770 build_warnings="${build_warnings} ${t}";;
771 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
772 build_warnings="${t} ${build_warnings}";;
773 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
774esac
775if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
776 echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
777fi])dnl
778WARN_CFLAGS=""
9c082ca8
MF
779if test "x${build_warnings}" != x -a "x$GCC" = xyes
780then
781 AC_MSG_CHECKING(compiler warning flags)
782 # Separate out the -Werror flag as some files just cannot be
783 # compiled with it enabled.
784 for w in ${build_warnings}; do
785 case $w in
786 -Werr*) WERROR_CFLAGS=-Werror ;;
787 *) # Check that GCC accepts it
788 saved_CFLAGS="$CFLAGS"
789 CFLAGS="$CFLAGS $w"
790 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
791 CFLAGS="$saved_CFLAGS"
792 esac
793 done
ac0aacdf 794 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
9c082ca8
MF
795fi
796])
797AC_SUBST(WARN_CFLAGS)
798AC_SUBST(WERROR_CFLAGS)
799
800
801dnl Generate the Makefile in a target specific directory.
802dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
803dnl so this is a cover macro to tuck the details away of how we cope.
804dnl We cope by having autoconf generate two files and then merge them into
805dnl one afterwards. The two pieces of the common fragment are inserted into
806dnl the target's fragment at the appropriate points.
807
808AC_DEFUN([SIM_AC_OUTPUT],
9c70334d
MF
809[dnl
810AC_REQUIRE([SIM_AC_OPTION_WARNINGS])dnl
811
9c082ca8
MF
812dnl Make @cgen_breaks@ non-null only if the sim uses CGEN.
813cgen_breaks=""
814if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
815cgen_breaks="break cgen_rtx_error";
816fi
817AC_SUBST(cgen_breaks)
818AC_CONFIG_FILES(Makefile.sim:Makefile.in)
819AC_CONFIG_FILES(Make-common.sim:../common/Make-common.in)
820AC_CONFIG_FILES(.gdbinit:../common/gdbinit.in)
821AC_CONFIG_COMMANDS([Makefile],
822[echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
823 rm -f Makesim1.tmp Makesim2.tmp Makefile
824 sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
825 sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
826 sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
827 -e '/^## COMMON_POST_/ r Makesim2.tmp' \
828 <Makefile.sim >Makefile
829 rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
830])
831AC_CONFIG_COMMANDS([stamp-h], [echo > stamp-h])
832AC_OUTPUT
833])
834
9c082ca8
MF
835dnl --enable-cgen-maint support
836AC_DEFUN([SIM_AC_OPTION_CGEN_MAINT],
837[
838cgen_maint=no
839dnl Default is to use one in build tree.
840cgen=guile
841cgendir='$(srcdir)/../../cgen'
842dnl Having --enable-maintainer-mode take arguments is another way to go.
843dnl ??? One can argue --with is more appropriate if one wants to specify
844dnl a directory name, but what we're doing here is an enable/disable kind
845dnl of thing and specifying both --enable and --with is klunky.
846dnl If you reeely want this to be --with, go ahead and change it.
847AC_ARG_ENABLE(cgen-maint,
8d0978fb 848[AS_HELP_STRING([--enable-cgen-maint[=DIR]], [build cgen generated files])],
9c082ca8
MF
849[case "${enableval}" in
850 yes) cgen_maint=yes ;;
851 no) cgen_maint=no ;;
852 *)
7fb45a68
AB
853 # Argument is a directory where cgen can be found. In some
854 # future world cgen could be installable, but right now this
855 # is not the case. Instead we assume the directory is a path
856 # to the cgen source tree.
857 cgen_maint=yes
858 if test -r ${enableval}/iformat.scm; then
859 # This looks like a cgen source tree.
860 cgendir=${enableval}
861 else
862 AC_MSG_ERROR(${enableval} doesn't look like a cgen source tree)
863 fi
9c082ca8
MF
864 ;;
865esac])dnl
866dnl AM_CONDITIONAL(CGEN_MAINT, test x${cgen_maint} != xno)
867if test x${cgen_maint} != xno ; then
868 CGEN_MAINT=''
869else
870 CGEN_MAINT='#'
871fi
872AC_SUBST(CGEN_MAINT)
873AC_SUBST(cgendir)
874AC_SUBST(cgen)
875])