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 . ${srcdir}/../../bfd/configure.host
49 dnl Standard (and optional) simulator options.
50 dnl Eventually all simulators will support these.
51 dnl Do not add any here that cannot be supported by all simulators.
52 dnl Do not add similar but different options to a particular simulator,
53 dnl all shall eventually behave the same way.
56 dnl This is a generic option to enable special byte swapping
57 dnl insns on *any* cpu.
58 AC_ARG_ENABLE(sim-bswap,
59 [ --enable-sim-bswap Use Host specific BSWAP instruction.],
60 [case "${enableval}" in
61 yes) sim_bswap="-DWITH_BSWAP=1 -DUSE_BSWAP=1";;
62 no) sim_bswap="-DWITH_BSWAP=0";;
63 *) AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
65 if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
66 echo "Setting bswap flags = $sim_bswap" 6>&1
67 fi],[sim_bswap=""])dnl
71 AC_ARG_ENABLE(sim-cflags,
72 [ --enable-sim-cflags=opts Extra CFLAGS for use in building simulator],
73 [case "${enableval}" in
74 yes) sim_cflags="-O2";;
75 trace) AC_MSG_ERROR("Please use --enable-sim-debug instead."); sim_cflags="";;
77 *) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
79 if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then
80 echo "Setting sim cflags = $sim_cflags" 6>&1
81 fi],[sim_cflags=""])dnl
85 dnl --enable-sim-debug is for developers of the simulator
86 dnl the allowable values are work-in-progress
87 AC_ARG_ENABLE(sim-debug,
88 [ --enable-sim-debug=opts Enable debugging flags],
89 [case "${enableval}" in
90 yes) sim_debug="-DDEBUG=7";;
91 no) sim_debug="-DDEBUG=0";;
92 *) sim_debug="-DDEBUG='(${enableval})'";;
94 if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then
95 echo "Setting sim debug = $sim_debug" 6>&1
96 fi],[sim_debug=""])dnl
100 dnl --enable-sim-stdio is for users of the simulator
101 dnl It determines if IO from the program is routed through STDIO (buffered)
102 AC_ARG_ENABLE(sim-stdio,
103 [ --enable-sim-stdio Specify whether to use stdio for console input/output.],
104 [case "${enableval}" in
105 yes) sim_stdio="-DWITH_STDIO=DO_USE_STDIO";;
106 no) sim_stdio="-DWITH_STDIO=DONT_USE_STDIO";;
107 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-stdio"); sim_stdio="";;
109 if test x"$silent" != x"yes" && test x"$sim_stdio" != x""; then
110 echo "Setting stdio flags = $sim_stdio" 6>&1
111 fi],[sim_stdio=""])dnl
115 dnl --enable-sim-trace is for users of the simulator
116 dnl the allowable values are work-in-progress
117 AC_ARG_ENABLE(sim-trace,
118 [ --enable-sim-trace=opts Enable tracing flags],
119 [case "${enableval}" in
120 yes) sim_trace="-DTRACE=1 -DWITH_TRACE=1";;
121 no) sim_trace="-DTRACE=0 -DWITH_TRACE=0";;
122 *) sim_trace="-DTRACE='(${enableval})' -DWITH_TRACE='(${enableval})'";;
124 if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then
125 echo "Setting sim trace = $sim_trace" 6>&1
126 fi],[sim_trace=""])dnl
130 dnl These are available to append to as desired.
134 dnl Create tconfig.h either from simulator's tconfig.in or default one
136 sim_link_links=tconfig.h
137 if test -f ${srcdir}/tconfig.in
139 sim_link_files=tconfig.in
141 sim_link_files=../common/tconfig.in
144 # targ-vals.def points to the libc macro description file.
146 *-*-*) TARG_VALS_DEF=../common/nltvals.def ;;
148 sim_link_files="${sim_link_files} ${TARG_VALS_DEF}"
149 sim_link_links="${sim_link_links} targ-vals.def"
151 ]) dnl End of SIM_AC_COMMON
154 dnl Additional SIM options that can (optionally) be configured
155 dnl For optional simulator options, a macro SIM_AC_OPTION_* is defined.
156 dnl Simulators that wish to use the relevant option specify the macro
157 dnl in the simulator specific configure.in file between the SIM_AC_COMMON
158 dnl and SIM_AC_OUTPUT lines.
161 dnl Specify the alignment restrictions of the target architecture.
162 dnl Without this option all possible alignment restrictions are accomidated.
163 AC_DEFUN(SIM_AC_OPTION_ALIGNMENT,
165 AC_ARG_ENABLE(sim-alignment,
166 [ --enable-sim-alignment=align Specify strict or nonstrict alignment.],
167 [case "${enableval}" in
168 yes | strict | STRICT) sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";;
169 no | nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";;
170 0 | default | DEFAULT) sim_alignment="-DWITH_ALIGNMENT=0";;
171 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment"); sim_alignment="";;
173 if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then
174 echo "Setting alignment flags = $sim_alignment" 6>&1
175 fi],[sim_alignment=""])dnl
176 AC_SUBST(sim_alignment)
180 dnl Conditionally compile in assertion statements.
181 AC_DEFUN(SIM_AC_OPTION_ASSERT,
183 AC_ARG_ENABLE(sim-assert,
184 [ --enable-sim-assert Specify whether to perform random assertions.],
185 [case "${enableval}" in
186 yes) sim_assert="-DWITH_ASSERT=1";;
187 no) sim_assert="-DWITH_ASSERT=0";;
188 *) AC_MSG_ERROR("--enable-sim-assert does not take a value"); sim_assert="";;
190 if test x"$silent" != x"yes" && test x"$sim_assert" != x""; then
191 echo "Setting assert flags = $sim_assert" 6>&1
192 fi],[sim_assert=""])dnl
197 dnl --enable-sim-endian={yes,no,big,little} is for simulators
198 dnl that support both big and little endian targets.
199 AC_DEFUN(SIM_AC_OPTION_ENDIAN,
201 default_sim_endian="ifelse([$1],,,-DWITH_TARGET_BYTE_ORDER=[$1])"
202 AC_ARG_ENABLE(sim-endian,
203 [ --enable-sim-endian=endian Specify target byte endian orientation.],
204 [case "${enableval}" in
205 yes) case "$target" in
206 *powerpc-*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
207 *powerpcle-*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
208 *) echo "Unknown target $target" 1>&6; sim_endian="-DWITH_TARGET_BYTE_ORDER=0";;
210 no) sim_endian="-DWITH_TARGET_BYTE_ORDER=0";;
211 b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
212 l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
213 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
215 if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
216 echo "Setting endian flags = $sim_endian" 6>&1
217 fi],[sim_endian="${default_sim_endian}"])dnl
222 dnl --enable-sim-hostendian is for users of the simulator when
223 dnl they find that AC_C_BIGENDIAN does not function correctly
224 dnl (for instance in a canadian cross)
225 AC_DEFUN(SIM_AC_OPTION_HOSTENDIAN,
227 AC_ARG_ENABLE(sim-hostendian,
228 [ --enable-sim-hostendain=end Specify host byte endian orientation.],
229 [case "${enableval}" in
230 no) sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";;
231 b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";;
232 l*|L*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN";;
233 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-hostendian"); sim_hostendian="";;
235 if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
236 echo "Setting hostendian flags = $sim_hostendian" 6>&1
238 if test "x$cross_compiling" = "xno"; then
240 if test $ac_cv_c_bigendian = yes; then
241 sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN"
243 sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN"
246 sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
248 AC_SUBST(sim_hostendian)
252 AC_DEFUN(SIM_AC_OPTION_FLOAT,
254 default_sim_floating_point="ifelse([$1],,0,[$1])"
255 AC_ARG_ENABLE(sim-float,
256 [ --enable-sim-float Specify that the target processor has floating point hardware.],
257 [case "${enableval}" in
258 yes | hard) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";;
259 no | soft) sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";;
260 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-float"); sim_float="";;
262 if test x"$silent" != x"yes" && test x"$sim_float" != x""; then
263 echo "Setting float flags = $sim_float" 6>&1
264 fi],[sim_float="-DWITH_FLOATING_POINT=${default_sim_floating_point}"])dnl
269 AC_DEFUN(SIM_AC_OPTION_HARDWARE,
271 AC_ARG_ENABLE(sim-hardware,
272 [ --enable-sim-hardware=list Specify the hardware to be included in the build.],
273 [hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide"
274 case "${enableval}" in
276 no) AC_MSG_ERROR("List of hardware must be specified for --enable-sim-hardware"); hardware="";;
277 ,*) hardware="${hardware}${enableval}";;
278 *,) hardware="${enableval}${hardware}";;
279 *) hardware="${enableval}"'';;
281 sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'`
282 sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
283 if test x"$silent" != x"yes" && test x"$hardware" != x""; then
284 echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
285 fi],[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide"
286 sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'`
287 sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
288 if test x"$silent" != x"yes"; then
289 echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
291 AC_SUBST(sim_hardware)
295 dnl --enable-sim-inline is for users that wish to ramp up the simulator's
296 dnl performance by inlining functions.
297 AC_DEFUN(SIM_AC_OPTION_INLINE,
299 default_sim_inline="ifelse([$1],,,-DDEFAULT_INLINE=[$1])"
300 AC_ARG_ENABLE(sim-inline,
301 [ --enable-sim-inline=inlines Specify which functions should be inlined.],
304 no) sim_inline="-DDEFAULT_INLINE=0";;
305 0) sim_inline="-DDEFAULT_INLINE=0";;
306 yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_INLINE";;
307 1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";;
308 *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
311 *_INLINE=*) new_flag="-D$x";;
312 *=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;;
313 *_INLINE) new_flag="-D$x=ALL_INLINE";;
314 *) new_flag="-D$x""_INLINE=ALL_INLINE";;
316 if test x"$sim_inline" = x""; then
317 sim_inline="$new_flag"
319 sim_inline="$sim_inline $new_flag"
323 if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
324 echo "Setting inline flags = $sim_inline" 6>&1
325 fi],[if test x"$GCC" != "x" -a x"${default_sim_inline}" != "x" ; then
326 sim_inline="${default_sim_inline}"
327 if test x"$silent" != x"yes"; then
328 echo "Setting inline flags = $sim_inline" 6>&1
337 AC_DEFUN(SIM_AC_OPTION_PACKAGES,
339 AC_ARG_ENABLE(sim-packages,
340 [ --enable-sim-packages=list Specify the packages to be included in the build.],
342 case "${enableval}" in
344 no) AC_MSG_ERROR("List of packages must be specified for --enable-sim-packages"); packages="";;
345 ,*) packages="${packages}${enableval}";;
346 *,) packages="${enableval}${packages}";;
347 *) packages="${enableval}"'';;
349 sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'`
350 sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'`
351 if test x"$silent" != x"yes" && test x"$packages" != x""; then
352 echo "Setting packages to $sim_pk_src, $sim_pk_obj"
353 fi],[packages=disklabel
354 sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'`
355 sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'`
356 if test x"$silent" != x"yes"; then
357 echo "Setting packages to $sim_pk_src, $sim_pk_obj"
359 AC_SUBST(sim_packages)
363 AC_DEFUN(SIM_AC_OPTION_REGPARM,
365 AC_ARG_ENABLE(sim-regparm,
366 [ --enable-sim-regparm=nr-parm Pass parameters in registers instead of on the stack - x86/GCC specific.],
367 [case "${enableval}" in
368 0*|1*|2*|3*|4*|5*|6*|7*|8*|9*) sim_regparm="-DWITH_REGPARM=${enableval}";;
369 no) sim_regparm="" ;;
370 yes) sim_regparm="-DWITH_REGPARM=3";;
371 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-regparm"); sim_regparm="";;
373 if test x"$silent" != x"yes" && test x"$sim_regparm" != x""; then
374 echo "Setting regparm flags = $sim_regparm" 6>&1
375 fi],[sim_regparm=""])dnl
376 AC_SUBST(sim_regparm)
380 AC_DEFUN(SIM_AC_OPTION_RESERVED_BITS,
382 default_sim_reserved_bits="ifelse([$1],,1,[$1])"
383 AC_ARG_ENABLE(sim-reserved-bits,
384 [ --enable-sim-reserved-bits Specify whether to check reserved bits in instruction.],
385 [case "${enableval}" in
386 yes) sim_reserved_bits="-DWITH_RESERVED_BITS=1";;
387 no) sim_reserved_bits="-DWITH_RESERVED_BITS=0";;
388 *) AC_MSG_ERROR("--enable-sim-reserved-bits does not take a value"); sim_reserved_bits="";;
390 if test x"$silent" != x"yes" && test x"$sim_reserved_bits" != x""; then
391 echo "Setting reserved flags = $sim_reserved_bits" 6>&1
392 fi],[sim_reserved_bits="-DWITH_RESERVED_BITS=${default_sim_reserved_bits}"])dnl
393 AC_SUBST(sim_reserved_bits)
397 AC_DEFUN(SIM_AC_OPTION_SMP,
399 default_sim_smp="ifelse([$1],,5,[$1])"
400 AC_ARG_ENABLE(sim-smp,
401 [ --enable-sim-smp=n Specify number of processors to configure for (default ${default_sim_smp}).],
402 [case "${enableval}" in
403 yes) sim_smp="-DWITH_SMP=5" ; sim_igen_smp="-N 5";;
404 no) sim_smp="-DWITH_SMP=0" ; sim_igen_smp="-N 0";;
405 *) sim_smp="-DWITH_SMP=$enableval" ; sim_igen_smp="-N $enableval";;
407 if test x"$silent" != x"yes" && test x"$sim_smp" != x""; then
408 echo "Setting smp flags = $sim_smp" 6>&1
409 fi],[sim_smp="-DWITH_SMP=${default_sim_smp}" ; sim_igen_smp="-N ${default_sim_smp}"
410 if test x"$silent" != x"yes"; then
411 echo "Setting smp flags = $sim_smp" 6>&1
417 AC_DEFUN(SIM_AC_OPTION_STDCALL,
419 AC_ARG_ENABLE(sim-stdcall,
420 [ --enable-sim-stdcall=type Use an alternative function call/return mechanism - x86/GCC specific.],
421 [case "${enableval}" in
422 no) sim_stdcall="" ;;
423 std*) sim_stdcall="-DWITH_STDCALL=1";;
424 yes) sim_stdcall="-DWITH_STDCALL=1";;
425 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-stdcall"); sim_stdcall="";;
427 if test x"$silent" != x"yes" && test x"$sim_stdcall" != x""; then
428 echo "Setting function call flags = $sim_stdcall" 6>&1
429 fi],[sim_stdcall=""])dnl
430 AC_SUBST(sim_stdcall)
434 AC_DEFUN(SIM_AC_OPTION_XOR_ENDIAN,
436 default_sim_xor_endian="ifelse([$1],,8,[$1])"
437 AC_ARG_ENABLE(sim-xor-endian,
438 [ --enable-sim-xor-endian=n Specify number bytes involved in XOR bi-endian mode (default ${default_sim_xor_endian}).],
439 [case "${enableval}" in
440 yes) sim_xor_endian="-DWITH_XOR_ENDIAN=8";;
441 no) sim_xor_endian="-DWITH_XOR_ENDIAN=0";;
442 *) sim_xor_endian="-DWITH_XOR_ENDIAN=$enableval";;
444 if test x"$silent" != x"yes" && test x"$sim_xor_endian" != x""; then
445 echo "Setting xor-endian flag = $sim_xor_endian" 6>&1
446 fi],[sim_xor_endian="-DWITH_XOR_ENDIAN=${default_sim_xor_endian}"])dnl
447 AC_SUBST(sim_xor_endian)
451 dnl --enable-sim-warnings is for developers of the simulator.
452 dnl it enables extra GCC specific warnings.
453 AC_DEFUN(SIM_AC_OPTION_WARNINGS,
455 AC_ARG_ENABLE(sim-warnings,
456 [ --enable-sim-warnings=opts Extra CFLAGS for turning on compiler warnings except for idecode.o, semantics.o and psim.o],
457 [case "${enableval}" in
458 yes) sim_warnings="-Werror -Wall -Wpointer-arith -Wmissing-prototypes -Wmissing-declarations ";;
459 no) sim_warnings="-w";;
460 *) sim_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
462 if test x"$silent" != x"yes" && test x"$sim_warnings" != x""; then
463 echo "Setting warning flags = $sim_warnings" 6>&1
464 fi],[sim_warnings=""])dnl
465 AC_SUBST(sim_warnings)
469 dnl Generate the Makefile in a target specific directory.
470 dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
471 dnl so this is a cover macro to tuck the details away of how we cope.
472 dnl We cope by having autoconf generate two files and then merge them into
473 dnl one afterwards. The two pieces of the common fragment are inserted into
474 dnl the target's fragment at the appropriate points.
476 AC_DEFUN(SIM_AC_OUTPUT,
478 AC_LINK_FILES($sim_link_files, $sim_link_links)
479 AC_OUTPUT(Makefile.sim:Makefile.in Make-common.sim:../common/Make-common.in,
480 [case "x$CONFIG_FILES" in xMakefile*)
481 echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
482 rm -f Makesim1.tmp Makesim2.tmp Makefile
483 sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
484 sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
485 sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
486 -e '/^## COMMON_POST_/ r Makesim2.tmp' \
487 <Makefile.sim >Makefile
488 rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
491 case "x$CONFIG_HEADERS" in xconfig.h:config.in) echo > stamp-h ;; esac