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