New target autoconf-changelog
[deliverable/binutils-gdb.git] / sim / common / aclocal.m4
CommitLineData
80b7b3a5 1# This file contains common code used by all simulators.
8cd89e77
DE
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# The simulator's configure.in should look like:
9#
f2de7dfd
AC
10# dnl Process this file with autoconf to produce a configure script.
11# sinclude(../common/aclocal.m4)
8cd89e77
DE
12# AC_PREREQ(2.5)dnl
13# AC_INIT(Makefile.in)
f2de7dfd 14#
8cd89e77
DE
15# SIM_AC_COMMON
16#
17# ... target specific stuff ...
18#
19# SIM_AC_OUTPUT
80b7b3a5
SG
20
21AC_DEFUN(SIM_AC_COMMON,
22[
23# autoconf.info says this should be called right after AC_INIT.
24AC_CONFIG_HEADER(config.h:config.in)
25
26AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..)
27AC_CANONICAL_SYSTEM
28AC_ARG_PROGRAM
29AC_PROG_CC
30AC_PROG_INSTALL
80b7b3a5
SG
31
32# Put a plausible default for CC_FOR_BUILD in Makefile.
33AC_C_CROSS
34if test "x$cross_compiling" = "xno"; then
35 CC_FOR_BUILD='$(CC)'
36else
37 CC_FOR_BUILD=gcc
38fi
39AC_SUBST(CC_FOR_BUILD)
40
41AC_SUBST(CFLAGS)
42AC_SUBST(HDEFINES)
43AR=${AR-ar}
44AC_SUBST(AR)
45AC_PROG_RANLIB
46
47. ${srcdir}/../../bfd/configure.host
48
a77aa7ec 49dnl Standard (and optional) simulator options.
80b7b3a5
SG
50dnl Eventually all simulators will support these.
51dnl Do not add any here that cannot be supported by all simulators.
52dnl Do not add similar but different options to a particular simulator,
53dnl all shall eventually behave the same way.
a77aa7ec
AC
54dnl
55dnl For optional simulator options, a macro SIM_AC_OPTION_* is defined.
56dnl Simulators that wish to use the relevant option specify the macro
57dnl in the simulator specific configure.in file between the SIM_AC_COMMON
58dnl and SIM_AC_OUTPUT lines.
59
60
61dnl Specify the alignment restrictions of the target architecture.
62dnl Without this option all possible alignment restrictions are accomidated.
63AC_DEFUN(SIM_AC_OPTION_ALIGNMENT,
64[
65AC_ARG_ENABLE(sim-alignment,
66[ --enable-sim-alignment=align Specify strict or nonstrict alignment.],
67[case "${enableval}" in
68 yes | strict | STRICT) sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";;
69 no | nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";;
70 0 | default | DEFAULT) sim_alignment="-DWITH_ALIGNMENT=0";;
71 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment"); sim_alignment="";;
72esac
73if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then
74 echo "Setting alignment flags = $sim_alignment" 6>&1
75fi],[sim_alignment=""])dnl
76AC_SUBST(sim_alignment)
77])dnl
78
79
80dnl Conditionally compile in assertion statements.
81AC_DEFUN(SIM_AC_OPTION_ASSERT,
82[
83AC_ARG_ENABLE(sim-assert,
84[ --enable-sim-assert Specify whether to perform random assertions.],
85[case "${enableval}" in
86 yes) sim_assert="-DWITH_ASSERT=1";;
87 no) sim_assert="-DWITH_ASSERT=0";;
88 *) AC_MSG_ERROR("--enable-sim-assert does not take a value"); sim_assert="";;
89esac
90if test x"$silent" != x"yes" && test x"$sim_assert" != x""; then
91 echo "Setting assert flags = $sim_assert" 6>&1
92fi],[sim_assert=""])dnl
93AC_SUBST(sim_assert)
94])
80b7b3a5 95
f2de7dfd
AC
96
97dnl This is a generic option to enable special byte swapping
98dnl insns on *any* cpu.
99AC_ARG_ENABLE(sim-bswap,
100[ --enable-sim-bswap Use Host specific BSWAP instruction.],
101[case "${enableval}" in
a77aa7ec 102 yes) sim_bswap="-DWITH_BSWAP=1 -DUSE_BSWAP=1";;
f2de7dfd
AC
103 no) sim_bswap="-DWITH_BSWAP=0";;
104 *) AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
105esac
106if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
107 echo "Setting bswap flags = $sim_bswap" 6>&1
108fi],[sim_bswap=""])dnl
109AC_SUBST(sim_bswap)
110
111
80b7b3a5
SG
112AC_ARG_ENABLE(sim-cflags,
113[ --enable-sim-cflags=opts Extra CFLAGS for use in building simulator],
114[case "${enableval}" in
115 yes) sim_cflags="-O2";;
116 trace) AC_MSG_ERROR("Please use --enable-sim-debug instead."); sim_cflags="";;
117 no) sim_cflags="";;
118 *) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
119esac
120if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then
121 echo "Setting sim cflags = $sim_cflags" 6>&1
122fi],[sim_cflags=""])dnl
123AC_SUBST(sim_cflags)
124
f2de7dfd 125
80b7b3a5
SG
126dnl --enable-sim-debug is for developers of the simulator
127dnl the allowable values are work-in-progress
128AC_ARG_ENABLE(sim-debug,
129[ --enable-sim-debug=opts Enable debugging flags],
130[case "${enableval}" in
131 yes) sim_debug="-DDEBUG=7";;
132 no) sim_debug="-DDEBUG=0";;
133 *) sim_debug="-DDEBUG='(${enableval})'";;
134esac
135if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then
136 echo "Setting sim debug = $sim_debug" 6>&1
137fi],[sim_debug=""])dnl
138AC_SUBST(sim_debug)
139
f2de7dfd 140
f2de7dfd
AC
141dnl --enable-sim-endian={yes,no,big,little} is for simulators
142dnl that support both big and little endian targets.
143AC_DEFUN(SIM_AC_OPTION_ENDIAN,
8cd89e77 144[
f2de7dfd
AC
145default_sim_endian="ifelse([$1],,,-DWITH_TARGET_BYTE_ORDER=[$1])"
146AC_ARG_ENABLE(sim-endian,
147[ --enable-sim-endian=endian Specify target byte endian orientation.],
148[case "${enableval}" in
149 yes) case "$target" in
150 *powerpc-*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
151 *powerpcle-*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
152 *) echo "Unknown target $target" 1>&6; sim_endian="-DWITH_TARGET_BYTE_ORDER=0";;
153 esac;;
154 no) sim_endian="-DWITH_TARGET_BYTE_ORDER=0";;
155 b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
156 l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
157 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
158esac
159if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
160 echo "Setting endian flags = $sim_endian" 6>&1
161fi],[sim_endian="${default_sim_endian}"])dnl
a77aa7ec 162AC_SUBST(sim_endian)
f2de7dfd 163])
8cd89e77 164
80b7b3a5 165
f2de7dfd
AC
166dnl --enable-sim-hostendian is for users of the simulator when
167dnl they find that AC_C_BIGENDIAN does not function correctly
168dnl (for instance in a canadian cross)
169AC_DEFUN(SIM_AC_OPTION_HOSTENDIAN,
170[
171AC_ARG_ENABLE(sim-hostendian,
172[ --enable-sim-hostendain=end Specify host byte endian orientation.],
173[case "${enableval}" in
174 no) sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";;
175 b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";;
176 l*|L*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN";;
177 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-hostendian"); sim_hostendian="";;
178esac
179if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
180 echo "Setting hostendian flags = $sim_hostendian" 6>&1
181fi],[
182if test "x$cross_compiling" = "xno"; then
183 AC_C_BIGENDIAN
184 if test $ac_cv_c_bigendian = yes; then
185 sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN"
186 else
187 sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN"
188 fi
189else
190 sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
191fi])dnl
a77aa7ec
AC
192AC_SUBST(sim_hostendian)
193])
194
195
196AC_DEFUN(SIM_AC_OPTION_FLOAT,
197[
198AC_ARG_ENABLE(sim-float,
199[ --enable-sim-float Specify whether to use host floating point or simulate.],
200[case "${enableval}" in
201 yes | hard) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";;
202 no | soft) sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";;
203 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-float"); sim_float="";;
204esac
205if test x"$silent" != x"yes" && test x"$sim_float" != x""; then
206 echo "Setting float flags = $sim_float" 6>&1
207fi],[sim_float=""])dnl
208AC_SUBST(sim_float)
209])
210
211
212AC_DEFUN(SIM_AC_OPTION_HARDWARE,
213[
214AC_ARG_ENABLE(sim-hardware,
215[ --enable-sim-hardware=list Specify the hardware to be included in the build.],
216[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide"
217case "${enableval}" in
218 yes) ;;
219 no) AC_MSG_ERROR("List of hardware must be specified for --enable-sim-hardware"); hardware="";;
220 ,*) hardware="${hardware}${enableval}";;
221 *,) hardware="${enableval}${hardware}";;
222 *) hardware="${enableval}"'';;
223esac
224sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'`
225sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
226if test x"$silent" != x"yes" && test x"$hardware" != x""; then
227 echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
228fi],[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide"
229sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'`
230sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
231if test x"$silent" != x"yes"; then
232 echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
233fi])dnl
234AC_SUBST(sim_hardware)
f2de7dfd
AC
235])
236
80b7b3a5 237
f2de7dfd
AC
238dnl --enable-sim-inline is for users that wish to ramp up the simulator's
239dnl performance by inlining functions.
240AC_DEFUN(SIM_AC_OPTION_INLINE,
241[
242default_sim_inline="ifelse([$1],,,-DDEFAULT_INLINE=[$1])"
243AC_ARG_ENABLE(sim-inline,
244[ --enable-sim-inline=inlines Specify which functions should be inlined.],
245[sim_inline=""
246case "$enableval" in
247 no) sim_inline="-DDEFAULT_INLINE=0";;
248 0) sim_inline="-DDEFAULT_INLINE=0";;
249 yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_INLINE";;
250 1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";;
251 *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
252 new_flag=""
253 case "$x" in
254 *_INLINE=*) new_flag="-D$x";;
255 *=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;;
256 *_INLINE) new_flag="-D$x=ALL_INLINE";;
257 *) new_flag="-D$x""_INLINE=ALL_INLINE";;
258 esac
259 if test x"$sim_inline" = x""; then
260 sim_inline="$new_flag"
261 else
262 sim_inline="$sim_inline $new_flag"
263 fi
264 done;;
265esac
266if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
267 echo "Setting inline flags = $sim_inline" 6>&1
268fi],[if test x"$GCC" != "x" -a x"${default_sim_inline}" != "x" ; then
269 sim_inline="${default_sim_inline}"
270 if test x"$silent" != x"yes"; then
271 echo "Setting inline flags = $sim_inline" 6>&1
272 fi
273else
274 sim_inline=""
275fi])dnl
a77aa7ec
AC
276AC_SUBST(sim_inline)
277])
278
279
280AC_DEFUN(SIM_AC_OPTION_PACKAGES,
281[
282AC_ARG_ENABLE(sim-packages,
283[ --enable-sim-packages=list Specify the packages to be included in the build.],
284[packages=disklabel
285case "${enableval}" in
286 yes) ;;
287 no) AC_MSG_ERROR("List of packages must be specified for --enable-sim-packages"); packages="";;
288 ,*) packages="${packages}${enableval}";;
289 *,) packages="${enableval}${packages}";;
290 *) packages="${enableval}"'';;
291esac
292sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'`
293sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'`
294if test x"$silent" != x"yes" && test x"$packages" != x""; then
295 echo "Setting packages to $sim_pk_src, $sim_pk_obj"
296fi],[packages=disklabel
297sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'`
298sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'`
299if test x"$silent" != x"yes"; then
300 echo "Setting packages to $sim_pk_src, $sim_pk_obj"
301fi])dnl
302AC_SUBST(sim_packages)
303])
304
305
306AC_DEFUN(SIM_AC_OPTION_REGPARM,
307[
308AC_ARG_ENABLE(sim-regparm,
309[ --enable-sim-regparm=nr-parm Pass parameters in registers instead of on the stack - x86/GCC specific.],
310[case "${enableval}" in
311 0*|1*|2*|3*|4*|5*|6*|7*|8*|9*) sim_regparm="-DWITH_REGPARM=${enableval}";;
312 no) sim_regparm="" ;;
313 yes) sim_regparm="-DWITH_REGPARM=3";;
314 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-regparm"); sim_regparm="";;
315esac
316if test x"$silent" != x"yes" && test x"$sim_regparm" != x""; then
317 echo "Setting regparm flags = $sim_regparm" 6>&1
318fi],[sim_regparm=""])dnl
319AC_SUBST(sim_regparm)
320])
321
322
323AC_DEFUN(SIM_AC_OPTION_RESERVED_BITS,
324[
325AC_ARG_ENABLE(sim-reserved-bits,
326[ --enable-sim-reserved-bits Specify whether to check reserved bits in instruction.],
327[case "${enableval}" in
328 yes) sim_reserved_bits="-DWITH_RESERVED_BITS=1";;
329 no) sim_reserved_bits="-DWITH_RESERVED_BITS=0";;
330 *) AC_MSG_ERROR("--enable-sim-reserved-bits does not take a value"); sim_reserved_bits="";;
331esac
332if test x"$silent" != x"yes" && test x"$sim_reserved_bits" != x""; then
333 echo "Setting reserved flags = $sim_reserved_bits" 6>&1
334fi],[sim_reserved_bits=""])dnl
335AC_SUBST(sim_reserved_bits)
336])
337
338
339AC_DEFUN(SIM_AC_OPTION_SMP,
340[
341AC_ARG_ENABLE(sim-smp,
342[ --enable-sim-smp=n Specify number of processors to configure for.],
343[case "${enableval}" in
344 yes) sim_smp="-DWITH_SMP=5" ; sim_igen_smp="-N 5";;
345 no) sim_smp="-DWITH_SMP=0" ; sim_igen_smp="-N 0";;
346 *) sim_smp="-DWITH_SMP=$enableval" ; sim_igen_smp="-N $enableval";;
347esac
348if test x"$silent" != x"yes" && test x"$sim_smp" != x""; then
349 echo "Setting smp flags = $sim_smp" 6>&1
350fi],[sim_smp="-DWITH_SMP=5" ; sim_igen_smp="-N 5"
351if test x"$silent" != x"yes"; then
352 echo "Setting smp flags = $sim_smp" 6>&1
353fi])dnl
354AC_SUBST(sim_smp)
f2de7dfd 355])
80b7b3a5 356
80b7b3a5 357
a77aa7ec
AC
358AC_DEFUN(SIM_AC_OPTION_STDCALL,
359[
360AC_ARG_ENABLE(sim-stdcall,
361[ --enable-sim-stdcall=type Use an alternative function call/return mechanism - x86/GCC specific.],
362[case "${enableval}" in
363 no) sim_stdcall="" ;;
364 std*) sim_stdcall="-DWITH_STDCALL=1";;
365 yes) sim_stdcall="-DWITH_STDCALL=1";;
366 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-stdcall"); sim_stdcall="";;
367esac
368if test x"$silent" != x"yes" && test x"$sim_stdcall" != x""; then
369 echo "Setting function call flags = $sim_stdcall" 6>&1
370fi],[sim_stdcall=""])dnl
371AC_SUBST(sim_stdcall)
372])
373
374
375dnl --enable-sim-trace is for users of the simulator
376dnl the allowable values are work-in-progress
377AC_ARG_ENABLE(sim-trace,
378[ --enable-sim-trace=opts Enable tracing flags],
379[case "${enableval}" in
380 yes) sim_trace="-DTRACE=1 -DWITH_TRACE=1";;
381 no) sim_trace="-DTRACE=0 -DWITH_TRACE=0";;
382 *) sim_trace="-DTRACE='(${enableval})' -DWITH_TRACE='(${enableval})'";;
383esac
384if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then
385 echo "Setting sim trace = $sim_trace" 6>&1
386fi],[sim_trace=""])dnl
387AC_SUBST(sim_trace)
388
389
f2de7dfd
AC
390dnl --enable-sim-warnings is for developers of the simulator.
391dnl it enables extra GCC specific warnings.
392AC_DEFUN(SIM_AC_OPTION_WARNINGS,
393[
394AC_ARG_ENABLE(sim-warnings,
395[ --enable-sim-warnings=opts Extra CFLAGS for turning on compiler warnings except for idecode.o, semantics.o and psim.o],
396[case "${enableval}" in
397 yes) sim_warnings="-Werror -Wall -Wpointer-arith -Wmissing-prototypes -Wmissing-declarations ";;
398 no) sim_warnings="-w";;
399 *) sim_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
400esac
401if test x"$silent" != x"yes" && test x"$sim_warnings" != x""; then
402 echo "Setting warning flags = $sim_warnings" 6>&1
403fi],[sim_warnings=""])dnl
a77aa7ec 404AC_SUBST(sim_warnings)
f2de7dfd 405])
80b7b3a5 406
80b7b3a5 407
a77aa7ec
AC
408AC_DEFUN(SIM_AC_OPTION_XOR_ENDIAN,
409[
410AC_ARG_ENABLE(sim-xor-endian,
411[ --enable-sim-xor-endian=n Specify number bytes involved in PowerPC XOR bi-endian mode (default 8).],
412[case "${enableval}" in
413 yes) sim_xor_endian="-DWITH_XOR_ENDIAN=8";;
414 no) sim_xor_endian="-DWITH_XOR_ENDIAN=0";;
415 *) sim_xor_endian="-DWITH_XOR_ENDIAN=$enableval";;
416esac
417if test x"$silent" != x"yes" && test x"$sim_xor_endian" != x""; then
418 echo "Setting xor-endian flag = $sim_xor_endian" 6>&1
419fi],[sim_xor_endian=""])dnl
420AC_SUBST(sim_xor_endian)
421])
422
423dnl These are available to append to as desired.
424sim_link_files=
425sim_link_links=
426
427dnl Create tconfig.h either from simulator's tconfig.in or default one
428dnl in common.
429sim_link_links=tconfig.h
430if test -f ${srcdir}/tconfig.in
431then
432 sim_link_files=tconfig.in
433else
434 sim_link_files=../common/tconfig.in
435fi
436
437# targ-vals.def points to the libc macro description file.
438case "${target}" in
439*-*-*) TARG_VALS_DEF=../common/nltvals.def ;;
440esac
441sim_link_files="${sim_link_files} ${TARG_VALS_DEF}"
442sim_link_links="${sim_link_links} targ-vals.def"
443
444]) dnl End of SIM_AC_COMMON
80b7b3a5 445
80b7b3a5 446
f2de7dfd
AC
447dnl Generate the Makefile in a target specific directory.
448dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
449dnl so this is a cover macro to tuck the details away of how we cope.
450dnl We cope by having autoconf generate two files and then merge them into
451dnl one afterwards. The two pieces of the common fragment are inserted into
452dnl the target's fragment at the appropriate points.
80b7b3a5 453
f2de7dfd
AC
454AC_DEFUN(SIM_AC_OUTPUT,
455[
80b7b3a5 456AC_LINK_FILES($sim_link_files, $sim_link_links)
f2de7dfd
AC
457AC_OUTPUT(Makefile.sim:Makefile.in Make-common.sim:../common/Make-common.in,
458[case "x$CONFIG_FILES" in xMakefile*)
459 echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
460 rm -f Makesim1.tmp Makesim2.tmp Makefile
461 sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
462 sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
463 sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
464 -e '/^## COMMON_POST_/ r Makesim2.tmp' \
465 <Makefile.sim >Makefile
466 rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
467 ;;
468 esac
80b7b3a5 469 case "x$CONFIG_HEADERS" in xconfig.h:config.in) echo > stamp-h ;; esac
f2de7dfd
AC
470])
471])
This page took 0.048183 seconds and 4 git commands to generate.