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