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