Add a number of per-simulator options: hostendian, endian, inline, warnings.
[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
49dnl Standard simulator options.
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.
54
f2de7dfd
AC
55
56dnl This is a generic option to enable special byte swapping
57dnl insns on *any* cpu.
58AC_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";;
62 no) sim_bswap="-DWITH_BSWAP=0";;
63 *) AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
64esac
65if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
66 echo "Setting bswap flags = $sim_bswap" 6>&1
67fi],[sim_bswap=""])dnl
68AC_SUBST(sim_bswap)
69
70
80b7b3a5
SG
71AC_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="";;
76 no) sim_cflags="";;
77 *) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
78esac
79if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then
80 echo "Setting sim cflags = $sim_cflags" 6>&1
81fi],[sim_cflags=""])dnl
82AC_SUBST(sim_cflags)
83
f2de7dfd 84
80b7b3a5
SG
85dnl --enable-sim-debug is for developers of the simulator
86dnl the allowable values are work-in-progress
87AC_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})'";;
93esac
94if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then
95 echo "Setting sim debug = $sim_debug" 6>&1
96fi],[sim_debug=""])dnl
97AC_SUBST(sim_debug)
98
f2de7dfd 99
80b7b3a5
SG
100dnl --enable-sim-trace is for users of the simulator
101dnl the allowable values are work-in-progress
102AC_ARG_ENABLE(sim-trace,
103[ --enable-sim-trace=opts Enable tracing flags],
104[case "${enableval}" in
105 yes) sim_trace="-DTRACE=1";;
106 no) sim_trace="-DTRACE=0";;
107 *) sim_trace="-DTRACE='(${enableval})'";;
108esac
109if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then
110 echo "Setting sim trace = $sim_trace" 6>&1
111fi],[sim_trace=""])dnl
112AC_SUBST(sim_trace)
113
80b7b3a5
SG
114
115dnl These are available to append to as desired.
116sim_link_files=
117sim_link_links=
118
119dnl Create tconfig.h either from simulator's tconfig.in or default one
120dnl in common.
121sim_link_links=tconfig.h
122if test -f ${srcdir}/tconfig.in
123then
124 sim_link_files=tconfig.in
125else
126 sim_link_files=../common/tconfig.in
127fi
128
f2de7dfd 129# targ-vals.def points to the libc macro description file.
80b7b3a5 130case "${target}" in
f2de7dfd 131*-*-*) TARG_VALS_DEF=../common/nltvals.def ;;
80b7b3a5 132esac
f2de7dfd
AC
133sim_link_files="${sim_link_files} ${TARG_VALS_DEF}"
134sim_link_links="${sim_link_links} targ-vals.def"
80b7b3a5 135
8cd89e77
DE
136]) dnl End of SIM_AC_COMMON
137
8cd89e77 138
f2de7dfd
AC
139dnl Almost standard simulator options.
140dnl Eventually all simulators will support these.
141
142
143dnl --enable-sim-endian={yes,no,big,little} is for simulators
144dnl that support both big and little endian targets.
145AC_DEFUN(SIM_AC_OPTION_ENDIAN,
8cd89e77 146[
f2de7dfd
AC
147default_sim_endian="ifelse([$1],,,-DWITH_TARGET_BYTE_ORDER=[$1])"
148AC_ARG_ENABLE(sim-endian,
149[ --enable-sim-endian=endian Specify target byte endian orientation.],
150[case "${enableval}" in
151 yes) case "$target" in
152 *powerpc-*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
153 *powerpcle-*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
154 *) echo "Unknown target $target" 1>&6; sim_endian="-DWITH_TARGET_BYTE_ORDER=0";;
155 esac;;
156 no) sim_endian="-DWITH_TARGET_BYTE_ORDER=0";;
157 b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
158 l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
159 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
160esac
161if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
162 echo "Setting endian flags = $sim_endian" 6>&1
163fi],[sim_endian="${default_sim_endian}"])dnl
164])
8cd89e77 165
80b7b3a5 166
f2de7dfd
AC
167dnl --enable-sim-hostendian is for users of the simulator when
168dnl they find that AC_C_BIGENDIAN does not function correctly
169dnl (for instance in a canadian cross)
170AC_DEFUN(SIM_AC_OPTION_HOSTENDIAN,
171[
172AC_ARG_ENABLE(sim-hostendian,
173[ --enable-sim-hostendain=end Specify host byte endian orientation.],
174[case "${enableval}" in
175 no) sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";;
176 b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";;
177 l*|L*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN";;
178 *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-hostendian"); sim_hostendian="";;
179esac
180if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
181 echo "Setting hostendian flags = $sim_hostendian" 6>&1
182fi],[
183if test "x$cross_compiling" = "xno"; then
184 AC_C_BIGENDIAN
185 if test $ac_cv_c_bigendian = yes; then
186 sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN"
187 else
188 sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN"
189 fi
190else
191 sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
192fi])dnl
193])
194
80b7b3a5 195
f2de7dfd
AC
196dnl --enable-sim-inline is for users that wish to ramp up the simulator's
197dnl performance by inlining functions.
198AC_DEFUN(SIM_AC_OPTION_INLINE,
199[
200default_sim_inline="ifelse([$1],,,-DDEFAULT_INLINE=[$1])"
201AC_ARG_ENABLE(sim-inline,
202[ --enable-sim-inline=inlines Specify which functions should be inlined.],
203[sim_inline=""
204case "$enableval" in
205 no) sim_inline="-DDEFAULT_INLINE=0";;
206 0) sim_inline="-DDEFAULT_INLINE=0";;
207 yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_INLINE";;
208 1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";;
209 *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
210 new_flag=""
211 case "$x" in
212 *_INLINE=*) new_flag="-D$x";;
213 *=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;;
214 *_INLINE) new_flag="-D$x=ALL_INLINE";;
215 *) new_flag="-D$x""_INLINE=ALL_INLINE";;
216 esac
217 if test x"$sim_inline" = x""; then
218 sim_inline="$new_flag"
219 else
220 sim_inline="$sim_inline $new_flag"
221 fi
222 done;;
223esac
224if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
225 echo "Setting inline flags = $sim_inline" 6>&1
226fi],[if test x"$GCC" != "x" -a x"${default_sim_inline}" != "x" ; then
227 sim_inline="${default_sim_inline}"
228 if test x"$silent" != x"yes"; then
229 echo "Setting inline flags = $sim_inline" 6>&1
230 fi
231else
232 sim_inline=""
233fi])dnl
234])
80b7b3a5 235
80b7b3a5 236
f2de7dfd
AC
237dnl --enable-sim-warnings is for developers of the simulator.
238dnl it enables extra GCC specific warnings.
239AC_DEFUN(SIM_AC_OPTION_WARNINGS,
240[
241AC_ARG_ENABLE(sim-warnings,
242[ --enable-sim-warnings=opts Extra CFLAGS for turning on compiler warnings except for idecode.o, semantics.o and psim.o],
243[case "${enableval}" in
244 yes) sim_warnings="-Werror -Wall -Wpointer-arith -Wmissing-prototypes -Wmissing-declarations ";;
245 no) sim_warnings="-w";;
246 *) sim_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
247esac
248if test x"$silent" != x"yes" && test x"$sim_warnings" != x""; then
249 echo "Setting warning flags = $sim_warnings" 6>&1
250fi],[sim_warnings=""])dnl
251])
80b7b3a5 252
80b7b3a5 253
80b7b3a5 254
80b7b3a5 255
f2de7dfd
AC
256dnl Generate the Makefile in a target specific directory.
257dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
258dnl so this is a cover macro to tuck the details away of how we cope.
259dnl We cope by having autoconf generate two files and then merge them into
260dnl one afterwards. The two pieces of the common fragment are inserted into
261dnl the target's fragment at the appropriate points.
80b7b3a5 262
f2de7dfd
AC
263AC_DEFUN(SIM_AC_OUTPUT,
264[
265dnl Optional options
266AC_SUBST(sim_endian)
267AC_SUBST(sim_hostendian)
268AC_SUBST(sim_inline)
269AC_SUBST(sim_warnings)
270dnl
80b7b3a5 271AC_LINK_FILES($sim_link_files, $sim_link_links)
f2de7dfd
AC
272AC_OUTPUT(Makefile.sim:Makefile.in Make-common.sim:../common/Make-common.in,
273[case "x$CONFIG_FILES" in xMakefile*)
274 echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
275 rm -f Makesim1.tmp Makesim2.tmp Makefile
276 sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
277 sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
278 sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
279 -e '/^## COMMON_POST_/ r Makesim2.tmp' \
280 <Makefile.sim >Makefile
281 rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
282 ;;
283 esac
80b7b3a5 284 case "x$CONFIG_HEADERS" in xconfig.h:config.in) echo > stamp-h ;; esac
f2de7dfd
AC
285])
286])
This page took 0.03837 seconds and 4 git commands to generate.