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 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";;
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-trace is for users of the simulator
101 dnl the allowable values are work-in-progress
102 AC_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})'";;
109 if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then
110 echo "Setting sim trace = $sim_trace" 6>&1
111 fi],[sim_trace=""])dnl
115 dnl These are available to append to as desired.
119 dnl Create tconfig.h either from simulator's tconfig.in or default one
121 sim_link_links=tconfig.h
122 if test -f ${srcdir}/tconfig.in
124 sim_link_files=tconfig.in
126 sim_link_files=../common/tconfig.in
129 # targ-vals.def points to the libc macro description file.
131 *-*-*) TARG_VALS_DEF=../common/nltvals.def ;;
133 sim_link_files="${sim_link_files} ${TARG_VALS_DEF}"
134 sim_link_links="${sim_link_links} targ-vals.def"
136 ]) dnl End of SIM_AC_COMMON
139 dnl Almost standard simulator options.
140 dnl Eventually all simulators will support these.
143 dnl --enable-sim-endian={yes,no,big,little} is for simulators
144 dnl that support both big and little endian targets.
145 AC_DEFUN(SIM_AC_OPTION_ENDIAN,
147 default_sim_endian="ifelse([$1],,,-DWITH_TARGET_BYTE_ORDER=[$1])"
148 AC_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";;
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="";;
161 if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
162 echo "Setting endian flags = $sim_endian" 6>&1
163 fi],[sim_endian="${default_sim_endian}"])dnl
167 dnl --enable-sim-hostendian is for users of the simulator when
168 dnl they find that AC_C_BIGENDIAN does not function correctly
169 dnl (for instance in a canadian cross)
170 AC_DEFUN(SIM_AC_OPTION_HOSTENDIAN,
172 AC_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="";;
180 if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
181 echo "Setting hostendian flags = $sim_hostendian" 6>&1
183 if test "x$cross_compiling" = "xno"; then
185 if test $ac_cv_c_bigendian = yes; then
186 sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN"
188 sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN"
191 sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
196 dnl --enable-sim-inline is for users that wish to ramp up the simulator's
197 dnl performance by inlining functions.
198 AC_DEFUN(SIM_AC_OPTION_INLINE,
200 default_sim_inline="ifelse([$1],,,-DDEFAULT_INLINE=[$1])"
201 AC_ARG_ENABLE(sim-inline,
202 [ --enable-sim-inline=inlines Specify which functions should be inlined.],
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
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";;
217 if test x"$sim_inline" = x""; then
218 sim_inline="$new_flag"
220 sim_inline="$sim_inline $new_flag"
224 if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
225 echo "Setting inline flags = $sim_inline" 6>&1
226 fi],[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
237 dnl --enable-sim-warnings is for developers of the simulator.
238 dnl it enables extra GCC specific warnings.
239 AC_DEFUN(SIM_AC_OPTION_WARNINGS,
241 AC_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"`;;
248 if test x"$silent" != x"yes" && test x"$sim_warnings" != x""; then
249 echo "Setting warning flags = $sim_warnings" 6>&1
250 fi],[sim_warnings=""])dnl
256 dnl Generate the Makefile in a target specific directory.
257 dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
258 dnl so this is a cover macro to tuck the details away of how we cope.
259 dnl We cope by having autoconf generate two files and then merge them into
260 dnl one afterwards. The two pieces of the common fragment are inserted into
261 dnl the target's fragment at the appropriate points.
263 AC_DEFUN(SIM_AC_OUTPUT,
267 AC_SUBST(sim_hostendian)
269 AC_SUBST(sim_warnings)
271 AC_LINK_FILES($sim_link_files, $sim_link_links)
272 AC_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
284 case "x$CONFIG_HEADERS" in xconfig.h:config.in) echo > stamp-h ;; esac