1 # This file contains common code used by all simulators.
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.
8 # The simulator's configure.in should look like:
10 # dnl Process this file with autoconf to produce a configure script.
11 # sinclude(../common/aclocal.m4)
13 # AC_INIT(Makefile.in)
17 # ... target specific stuff ...
21 AC_DEFUN(SIM_AC_COMMON,
23 # autoconf.info says this should be called right after AC_INIT.
24 AC_CONFIG_HEADER(config.h:config.in)
26 AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..)
32 # Put a plausible default for CC_FOR_BUILD in Makefile.
34 if test "x$cross_compiling" = "xno"; then
39 AC_SUBST(CC_FOR_BUILD)
47 # Check for common headers.
48 AC_CHECK_HEADERS(stdlib.h string.h strings.h unistd.h)
50 . ${srcdir}/../../bfd/configure.host
52 dnl Standard (and optional) simulator options.
53 dnl Eventually all simulators will support these.
54 dnl Do not add any here that cannot be supported by all simulators.
55 dnl Do not add similar but different options to a particular simulator,
56 dnl all shall eventually behave the same way.
59 dnl This is a generic option to enable special byte swapping
60 dnl insns on *any* cpu.
61 AC_ARG_ENABLE(sim-bswap,
62 [ --enable-sim-bswap Use Host specific BSWAP instruction.],
63 [case "${enableval}" in
64 yes) sim_bswap="-DWITH_BSWAP=1 -DUSE_BSWAP=1";;
65 no) sim_bswap="-DWITH_BSWAP=0";;
66 *) AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
68 if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
69 echo "Setting bswap flags = $sim_bswap" 6>&1
70 fi],[sim_bswap=""])dnl
74 AC_ARG_ENABLE(sim-cflags,
75 [ --enable-sim-cflags=opts Extra CFLAGS for use in building simulator],
76 [case "${enableval}" in
77 yes) sim_cflags="-O2";;
78 trace) AC_MSG_ERROR("Please use --enable-sim-debug instead."); sim_cflags="";;
80 *) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
82 if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then
83 echo "Setting sim cflags = $sim_cflags" 6>&1
84 fi],[sim_cflags=""])dnl
88 dnl --enable-sim-debug is for developers of the simulator
89 dnl the allowable values are work-in-progress
90 AC_ARG_ENABLE(sim-debug,
91 [ --enable-sim-debug=opts Enable debugging flags],
92 [case "${enableval}" in
93 yes) sim_debug="-DDEBUG=7 -DWITH_DEBUG=7";;
94 no) sim_debug="-DDEBUG=0 -DWITH_DEBUG=0";;
95 *) sim_debug="-DDEBUG='(${enableval})' -DWITH_DEBUG='(${enableval})'";;
97 if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then
98 echo "Setting sim debug = $sim_debug" 6>&1
99 fi],[sim_debug=""])dnl
103 dnl --enable-sim-stdio is for users of the simulator
104 dnl It determines if IO from the program is routed through STDIO (buffered)
105 AC_ARG_ENABLE(sim-stdio,
106 [ --enable-sim-stdio Specify whether to use stdio for console input/output.],
107 [case "${enableval}" in
108 yes) sim_stdio="-DWITH_STDIO=DO_USE_STDIO";;
109 no) sim_stdio="-DWITH_STDIO=DONT_USE_STDIO";;
110 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-stdio"); sim_stdio="";;
112 if test x"$silent" != x"yes" && test x"$sim_stdio" != x""; then
113 echo "Setting stdio flags = $sim_stdio" 6>&1
114 fi],[sim_stdio=""])dnl
118 dnl --enable-sim-trace is for users of the simulator
119 dnl the allowable values are work-in-progress
120 AC_ARG_ENABLE(sim-trace,
121 [ --enable-sim-trace=opts Enable tracing flags],
122 [case "${enableval}" in
123 yes) sim_trace="-DTRACE=1 -DWITH_TRACE=1";;
124 no) sim_trace="-DTRACE=0 -DWITH_TRACE=0";;
125 *) sim_trace="-DTRACE='(${enableval})' -DWITH_TRACE='(${enableval})'";;
127 if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then
128 echo "Setting sim trace = $sim_trace" 6>&1
129 fi],[sim_trace=""])dnl
133 dnl These are available to append to as desired.
137 dnl Create tconfig.h either from simulator's tconfig.in or default one
139 sim_link_links=tconfig.h
140 if test -f ${srcdir}/tconfig.in
142 sim_link_files=tconfig.in
144 sim_link_files=../common/tconfig.in
147 # targ-vals.def points to the libc macro description file.
149 *-*-*) TARG_VALS_DEF=../common/nltvals.def ;;
151 sim_link_files="${sim_link_files} ${TARG_VALS_DEF}"
152 sim_link_links="${sim_link_links} targ-vals.def"
154 ]) dnl End of SIM_AC_COMMON
157 dnl Additional SIM options that can (optionally) be configured
158 dnl For optional simulator options, a macro SIM_AC_OPTION_* is defined.
159 dnl Simulators that wish to use the relevant option specify the macro
160 dnl in the simulator specific configure.in file between the SIM_AC_COMMON
161 dnl and SIM_AC_OUTPUT lines.
164 dnl Specify the alignment restrictions of the target architecture.
165 dnl Without this option all possible alignment restrictions are accomidated.
166 AC_DEFUN(SIM_AC_OPTION_ALIGNMENT,
168 AC_ARG_ENABLE(sim-alignment,
169 [ --enable-sim-alignment=align Specify strict or nonstrict alignment.],
170 [case "${enableval}" in
171 yes | strict | STRICT) sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";;
172 no | nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";;
173 0 | default | DEFAULT) sim_alignment="-DWITH_ALIGNMENT=0";;
174 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment"); sim_alignment="";;
176 if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then
177 echo "Setting alignment flags = $sim_alignment" 6>&1
178 fi],[sim_alignment=""])dnl
179 AC_SUBST(sim_alignment)
183 dnl Conditionally compile in assertion statements.
184 AC_DEFUN(SIM_AC_OPTION_ASSERT,
186 AC_ARG_ENABLE(sim-assert,
187 [ --enable-sim-assert Specify whether to perform random assertions.],
188 [case "${enableval}" in
189 yes) sim_assert="-DWITH_ASSERT=1";;
190 no) sim_assert="-DWITH_ASSERT=0";;
191 *) AC_MSG_ERROR("--enable-sim-assert does not take a value"); sim_assert="";;
193 if test x"$silent" != x"yes" && test x"$sim_assert" != x""; then
194 echo "Setting assert flags = $sim_assert" 6>&1
195 fi],[sim_assert=""])dnl
200 dnl --enable-sim-endian={yes,no,big,little} is for simulators
201 dnl that support both big and little endian targets.
202 AC_DEFUN(SIM_AC_OPTION_ENDIAN,
204 default_sim_endian="ifelse([$1],,,-DWITH_TARGET_BYTE_ORDER=[$1])"
205 AC_ARG_ENABLE(sim-endian,
206 [ --enable-sim-endian=endian Specify target byte endian orientation.],
207 [case "${enableval}" in
208 yes) case "$target" in
209 *powerpc-*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
210 *powerpcle-*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
211 *) echo "Unknown target $target" 1>&6; sim_endian="-DWITH_TARGET_BYTE_ORDER=0";;
213 no) sim_endian="-DWITH_TARGET_BYTE_ORDER=0";;
214 b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
215 l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
216 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
218 if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
219 echo "Setting endian flags = $sim_endian" 6>&1
220 fi],[sim_endian="${default_sim_endian}"])dnl
225 dnl --enable-sim-hostendian is for users of the simulator when
226 dnl they find that AC_C_BIGENDIAN does not function correctly
227 dnl (for instance in a canadian cross)
228 AC_DEFUN(SIM_AC_OPTION_HOSTENDIAN,
230 AC_ARG_ENABLE(sim-hostendian,
231 [ --enable-sim-hostendain=end Specify host byte endian orientation.],
232 [case "${enableval}" in
233 no) sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";;
234 b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";;
235 l*|L*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN";;
236 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-hostendian"); sim_hostendian="";;
238 if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
239 echo "Setting hostendian flags = $sim_hostendian" 6>&1
241 if test "x$cross_compiling" = "xno"; then
243 if test $ac_cv_c_bigendian = yes; then
244 sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN"
246 sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN"
249 sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
251 AC_SUBST(sim_hostendian)
255 AC_DEFUN(SIM_AC_OPTION_FLOAT,
257 default_sim_floating_point="ifelse([$1],,0,[$1])"
258 AC_ARG_ENABLE(sim-float,
259 [ --enable-sim-float Specify that the target processor has floating point hardware.],
260 [case "${enableval}" in
261 yes | hard) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";;
262 no | soft) sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";;
263 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-float"); sim_float="";;
265 if test x"$silent" != x"yes" && test x"$sim_float" != x""; then
266 echo "Setting float flags = $sim_float" 6>&1
267 fi],[sim_float="-DWITH_FLOATING_POINT=${default_sim_floating_point}"])dnl
272 AC_DEFUN(SIM_AC_OPTION_HARDWARE,
274 AC_ARG_ENABLE(sim-hardware,
275 [ --enable-sim-hardware=list Specify the hardware to be included in the build.],
276 [hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide"
277 case "${enableval}" in
279 no) AC_MSG_ERROR("List of hardware must be specified for --enable-sim-hardware"); hardware="";;
280 ,*) hardware="${hardware}${enableval}";;
281 *,) hardware="${enableval}${hardware}";;
282 *) hardware="${enableval}"'';;
284 sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'`
285 sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
286 if test x"$silent" != x"yes" && test x"$hardware" != x""; then
287 echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
288 fi],[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide"
289 sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'`
290 sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
291 if test x"$silent" != x"yes"; then
292 echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
294 AC_SUBST(sim_hardware)
298 dnl --enable-sim-inline is for users that wish to ramp up the simulator's
299 dnl performance by inlining functions.
300 AC_DEFUN(SIM_AC_OPTION_INLINE,
302 default_sim_inline="ifelse([$1],,,-DDEFAULT_INLINE=[$1])"
303 AC_ARG_ENABLE(sim-inline,
304 [ --enable-sim-inline=inlines Specify which functions should be inlined.],
307 no) sim_inline="-DDEFAULT_INLINE=0";;
308 0) sim_inline="-DDEFAULT_INLINE=0";;
309 yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_INLINE";;
310 1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";;
311 *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
314 *_INLINE=*) new_flag="-D$x";;
315 *=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;;
316 *_INLINE) new_flag="-D$x=ALL_INLINE";;
317 *) new_flag="-D$x""_INLINE=ALL_INLINE";;
319 if test x"$sim_inline" = x""; then
320 sim_inline="$new_flag"
322 sim_inline="$sim_inline $new_flag"
326 if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
327 echo "Setting inline flags = $sim_inline" 6>&1
328 fi],[if test x"$GCC" != "x" -a x"${default_sim_inline}" != "x" ; then
329 sim_inline="${default_sim_inline}"
330 if test x"$silent" != x"yes"; then
331 echo "Setting inline flags = $sim_inline" 6>&1
340 AC_DEFUN(SIM_AC_OPTION_PACKAGES,
342 AC_ARG_ENABLE(sim-packages,
343 [ --enable-sim-packages=list Specify the packages to be included in the build.],
345 case "${enableval}" in
347 no) AC_MSG_ERROR("List of packages must be specified for --enable-sim-packages"); packages="";;
348 ,*) packages="${packages}${enableval}";;
349 *,) packages="${enableval}${packages}";;
350 *) packages="${enableval}"'';;
352 sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'`
353 sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'`
354 if test x"$silent" != x"yes" && test x"$packages" != x""; then
355 echo "Setting packages to $sim_pk_src, $sim_pk_obj"
356 fi],[packages=disklabel
357 sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'`
358 sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'`
359 if test x"$silent" != x"yes"; then
360 echo "Setting packages to $sim_pk_src, $sim_pk_obj"
362 AC_SUBST(sim_packages)
366 AC_DEFUN(SIM_AC_OPTION_REGPARM,
368 AC_ARG_ENABLE(sim-regparm,
369 [ --enable-sim-regparm=nr-parm Pass parameters in registers instead of on the stack - x86/GCC specific.],
370 [case "${enableval}" in
371 0*|1*|2*|3*|4*|5*|6*|7*|8*|9*) sim_regparm="-DWITH_REGPARM=${enableval}";;
372 no) sim_regparm="" ;;
373 yes) sim_regparm="-DWITH_REGPARM=3";;
374 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-regparm"); sim_regparm="";;
376 if test x"$silent" != x"yes" && test x"$sim_regparm" != x""; then
377 echo "Setting regparm flags = $sim_regparm" 6>&1
378 fi],[sim_regparm=""])dnl
379 AC_SUBST(sim_regparm)
383 AC_DEFUN(SIM_AC_OPTION_RESERVED_BITS,
385 default_sim_reserved_bits="ifelse([$1],,1,[$1])"
386 AC_ARG_ENABLE(sim-reserved-bits,
387 [ --enable-sim-reserved-bits Specify whether to check reserved bits in instruction.],
388 [case "${enableval}" in
389 yes) sim_reserved_bits="-DWITH_RESERVED_BITS=1";;
390 no) sim_reserved_bits="-DWITH_RESERVED_BITS=0";;
391 *) AC_MSG_ERROR("--enable-sim-reserved-bits does not take a value"); sim_reserved_bits="";;
393 if test x"$silent" != x"yes" && test x"$sim_reserved_bits" != x""; then
394 echo "Setting reserved flags = $sim_reserved_bits" 6>&1
395 fi],[sim_reserved_bits="-DWITH_RESERVED_BITS=${default_sim_reserved_bits}"])dnl
396 AC_SUBST(sim_reserved_bits)
400 AC_DEFUN(SIM_AC_OPTION_SMP,
402 default_sim_smp="ifelse([$1],,5,[$1])"
403 AC_ARG_ENABLE(sim-smp,
404 [ --enable-sim-smp=n Specify number of processors to configure for (default ${default_sim_smp}).],
405 [case "${enableval}" in
406 yes) sim_smp="-DWITH_SMP=5" ; sim_igen_smp="-N 5";;
407 no) sim_smp="-DWITH_SMP=0" ; sim_igen_smp="-N 0";;
408 *) sim_smp="-DWITH_SMP=$enableval" ; sim_igen_smp="-N $enableval";;
410 if test x"$silent" != x"yes" && test x"$sim_smp" != x""; then
411 echo "Setting smp flags = $sim_smp" 6>&1
412 fi],[sim_smp="-DWITH_SMP=${default_sim_smp}" ; sim_igen_smp="-N ${default_sim_smp}"
413 if test x"$silent" != x"yes"; then
414 echo "Setting smp flags = $sim_smp" 6>&1
420 AC_DEFUN(SIM_AC_OPTION_STDCALL,
422 AC_ARG_ENABLE(sim-stdcall,
423 [ --enable-sim-stdcall=type Use an alternative function call/return mechanism - x86/GCC specific.],
424 [case "${enableval}" in
425 no) sim_stdcall="" ;;
426 std*) sim_stdcall="-DWITH_STDCALL=1";;
427 yes) sim_stdcall="-DWITH_STDCALL=1";;
428 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-stdcall"); sim_stdcall="";;
430 if test x"$silent" != x"yes" && test x"$sim_stdcall" != x""; then
431 echo "Setting function call flags = $sim_stdcall" 6>&1
432 fi],[sim_stdcall=""])dnl
433 AC_SUBST(sim_stdcall)
437 AC_DEFUN(SIM_AC_OPTION_XOR_ENDIAN,
439 default_sim_xor_endian="ifelse([$1],,8,[$1])"
440 AC_ARG_ENABLE(sim-xor-endian,
441 [ --enable-sim-xor-endian=n Specify number bytes involved in XOR bi-endian mode (default ${default_sim_xor_endian}).],
442 [case "${enableval}" in
443 yes) sim_xor_endian="-DWITH_XOR_ENDIAN=8";;
444 no) sim_xor_endian="-DWITH_XOR_ENDIAN=0";;
445 *) sim_xor_endian="-DWITH_XOR_ENDIAN=$enableval";;
447 if test x"$silent" != x"yes" && test x"$sim_xor_endian" != x""; then
448 echo "Setting xor-endian flag = $sim_xor_endian" 6>&1
449 fi],[sim_xor_endian="-DWITH_XOR_ENDIAN=${default_sim_xor_endian}"])dnl
450 AC_SUBST(sim_xor_endian)
454 dnl --enable-sim-warnings is for developers of the simulator.
455 dnl it enables extra GCC specific warnings.
456 AC_DEFUN(SIM_AC_OPTION_WARNINGS,
458 AC_ARG_ENABLE(sim-warnings,
459 [ --enable-sim-warnings=opts Extra CFLAGS for turning on compiler warnings except for idecode.o, semantics.o and psim.o],
460 [case "${enableval}" in
461 yes) sim_warnings="-Werror -Wall -Wpointer-arith -Wmissing-prototypes -Wmissing-declarations ";;
462 no) sim_warnings="-w";;
463 *) sim_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
465 if test x"$silent" != x"yes" && test x"$sim_warnings" != x""; then
466 echo "Setting warning flags = $sim_warnings" 6>&1
467 fi],[sim_warnings=""])dnl
468 AC_SUBST(sim_warnings)
472 dnl Generate the Makefile in a target specific directory.
473 dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
474 dnl so this is a cover macro to tuck the details away of how we cope.
475 dnl We cope by having autoconf generate two files and then merge them into
476 dnl one afterwards. The two pieces of the common fragment are inserted into
477 dnl the target's fragment at the appropriate points.
479 AC_DEFUN(SIM_AC_OUTPUT,
481 AC_LINK_FILES($sim_link_files, $sim_link_links)
482 AC_OUTPUT(Makefile.sim:Makefile.in Make-common.sim:../common/Make-common.in,
483 [case "x$CONFIG_FILES" in xMakefile*)
484 echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
485 rm -f Makesim1.tmp Makesim2.tmp Makefile
486 sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
487 sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
488 sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
489 -e '/^## COMMON_POST_/ r Makesim2.tmp' \
490 <Makefile.sim >Makefile
491 rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
494 case "x$CONFIG_HEADERS" in xconfig.h:config.in) echo > stamp-h ;; esac