301c5ec65cb9a1474191c60422865c575c1a276f
[deliverable/binutils-gdb.git] / sim / common / aclocal.m4
1 # This file contains common code used by all simulators.
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 #
10 # dnl Process this file with autoconf to produce a configure script.
11 # sinclude(../common/aclocal.m4)
12 # AC_PREREQ(2.5)dnl
13 # AC_INIT(Makefile.in)
14 #
15 # SIM_AC_COMMON
16 #
17 # ... target specific stuff ...
18 #
19 # SIM_AC_OUTPUT
20
21 AC_DEFUN(SIM_AC_COMMON,
22 [
23 # autoconf.info says this should be called right after AC_INIT.
24 AC_CONFIG_HEADER(config.h:config.in)
25
26 AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..)
27 AC_CANONICAL_SYSTEM
28 AC_ARG_PROGRAM
29 AC_PROG_CC
30 AC_PROG_INSTALL
31
32 # Put a plausible default for CC_FOR_BUILD in Makefile.
33 AC_C_CROSS
34 if test "x$cross_compiling" = "xno"; then
35 CC_FOR_BUILD='$(CC)'
36 else
37 CC_FOR_BUILD=gcc
38 fi
39 AC_SUBST(CC_FOR_BUILD)
40
41 AC_SUBST(CFLAGS)
42 AC_SUBST(HDEFINES)
43 AR=${AR-ar}
44 AC_SUBST(AR)
45 AC_PROG_RANLIB
46
47 . ${srcdir}/../../bfd/configure.host
48
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.
54
55
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="";;
64 esac
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
68 AC_SUBST(sim_bswap)
69
70
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="";;
76 no) sim_cflags="";;
77 *) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
78 esac
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
82 AC_SUBST(sim_cflags)
83
84
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})'";;
93 esac
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
97 AC_SUBST(sim_debug)
98
99
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})'";;
108 esac
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
112 AC_SUBST(sim_trace)
113
114
115 dnl These are available to append to as desired.
116 sim_link_files=
117 sim_link_links=
118
119 dnl Create tconfig.h either from simulator's tconfig.in or default one
120 dnl in common.
121 sim_link_links=tconfig.h
122 if test -f ${srcdir}/tconfig.in
123 then
124 sim_link_files=tconfig.in
125 else
126 sim_link_files=../common/tconfig.in
127 fi
128
129 # targ-vals.def points to the libc macro description file.
130 case "${target}" in
131 *-*-*) TARG_VALS_DEF=../common/nltvals.def ;;
132 esac
133 sim_link_files="${sim_link_files} ${TARG_VALS_DEF}"
134 sim_link_links="${sim_link_links} targ-vals.def"
135
136 ]) dnl End of SIM_AC_COMMON
137
138
139 dnl Almost standard simulator options.
140 dnl Eventually all simulators will support these.
141
142
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,
146 [
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";;
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="";;
160 esac
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
164 ])
165
166
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,
171 [
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="";;
179 esac
180 if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
181 echo "Setting hostendian flags = $sim_hostendian" 6>&1
182 fi],[
183 if 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
190 else
191 sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
192 fi])dnl
193 ])
194
195
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,
199 [
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.],
203 [sim_inline=""
204 case "$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;;
223 esac
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
230 fi
231 else
232 sim_inline=""
233 fi])dnl
234 ])
235
236
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,
240 [
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"`;;
247 esac
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
251 ])
252
253
254
255
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.
262
263 AC_DEFUN(SIM_AC_OUTPUT,
264 [
265 dnl Optional options
266 AC_SUBST(sim_endian)
267 AC_SUBST(sim_hostendian)
268 AC_SUBST(sim_inline)
269 AC_SUBST(sim_warnings)
270 dnl
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
282 ;;
283 esac
284 case "x$CONFIG_HEADERS" in xconfig.h:config.in) echo > stamp-h ;; esac
285 ])
286 ])
This page took 0.034979 seconds and 4 git commands to generate.