Commit | Line | Data |
---|---|---|
9c082ca8 MF |
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 | # | |
306f4178 | 8 | # The simulator's configure.ac should look like: |
9c082ca8 MF |
9 | # |
10 | # dnl Process this file with autoconf to produce a configure script. | |
11 | # AC_PREREQ(2.64)dnl | |
12 | # AC_INIT(Makefile.in) | |
13 | # sinclude(../common/aclocal.m4) | |
14 | # | |
15 | # SIM_AC_COMMON | |
16 | # | |
17 | # ... target specific stuff ... | |
18 | # | |
19 | # SIM_AC_OUTPUT | |
20 | ||
21 | # Include global overrides and fixes for Autoconf. | |
22 | m4_include(../../config/override.m4) | |
23 | sinclude([../../config/zlib.m4]) | |
6bb11ab3 L |
24 | m4_include([../../config/plugins.m4]) |
25 | m4_include([../../libtool.m4]) | |
26 | m4_include([../../ltoptions.m4]) | |
27 | m4_include([../../ltsugar.m4]) | |
28 | m4_include([../../ltversion.m4]) | |
29 | m4_include([../../lt~obsolete.m4]) | |
db2e4d67 | 30 | sinclude([../../config/depstand.m4]) |
9c082ca8 MF |
31 | |
32 | AC_DEFUN([SIM_AC_COMMON], | |
33 | [ | |
34 | AC_REQUIRE([AC_PROG_CC]) | |
35 | # autoconf.info says this should be called right after AC_INIT. | |
36 | AC_CONFIG_HEADER(ifelse([$1],,config.h,[$1]):config.in) | |
37 | AC_CANONICAL_SYSTEM | |
2232061b | 38 | AC_USE_SYSTEM_EXTENSIONS |
0cb8d851 | 39 | AC_C_BIGENDIAN |
9c082ca8 MF |
40 | AC_ARG_PROGRAM |
41 | AC_PROG_INSTALL | |
42 | ||
43 | # Put a plausible default for CC_FOR_BUILD in Makefile. | |
44 | if test "x$cross_compiling" = "xno"; then | |
45 | CC_FOR_BUILD='$(CC)' | |
46 | else | |
47 | CC_FOR_BUILD=gcc | |
48 | fi | |
49 | AC_SUBST(CC_FOR_BUILD) | |
50 | ||
51 | AC_SUBST(CFLAGS) | |
52 | AC_SUBST(HDEFINES) | |
53 | AR=${AR-ar} | |
54 | AC_SUBST(AR) | |
55 | AC_PROG_RANLIB | |
56 | ||
5f3ef9d0 JB |
57 | # Some of the common include files depend on bfd.h, and bfd.h checks |
58 | # that config.h is included first by testing that the PACKAGE macro | |
59 | # is defined. | |
60 | PACKAGE=sim | |
61 | AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package. ]) | |
62 | AC_SUBST(PACKAGE) | |
63 | ||
db2e4d67 MF |
64 | # Dependency checking. |
65 | ZW_CREATE_DEPDIR | |
66 | ZW_PROG_COMPILER_DEPENDENCIES([CC]) | |
67 | ||
68 | # Check for the 'make' the user wants to use. | |
69 | AC_CHECK_PROGS(MAKE, make) | |
70 | MAKE_IS_GNU= | |
71 | case "`$MAKE --version 2>&1 | sed 1q`" in | |
72 | *GNU*) | |
73 | MAKE_IS_GNU=yes | |
74 | ;; | |
75 | esac | |
76 | AM_CONDITIONAL(GMAKE, test "$MAKE_IS_GNU" = yes) | |
77 | ||
9c082ca8 MF |
78 | dnl We don't use gettext, but bfd does. So we do the appropriate checks |
79 | dnl to see if there are intl libraries we should link against. | |
80 | ALL_LINGUAS= | |
81 | ZW_GNU_GETTEXT_SISTER_DIR(../../intl) | |
82 | ||
83 | # Check for common headers. | |
84 | # FIXME: Seems to me this can cause problems for i386-windows hosts. | |
85 | # At one point there were hardcoded AC_DEFINE's if ${host} = i386-*-windows*. | |
86 | AC_CHECK_HEADERS(stdlib.h string.h strings.h unistd.h time.h) | |
87 | AC_CHECK_HEADERS(sys/time.h sys/resource.h) | |
88 | AC_CHECK_HEADERS(fcntl.h fpu_control.h) | |
89 | AC_CHECK_HEADERS(dlfcn.h errno.h sys/stat.h) | |
90 | AC_CHECK_FUNCS(getrusage time sigaction __setfpucw) | |
91 | ||
92 | # Check for socket libraries | |
93 | AC_CHECK_LIB(socket, bind) | |
94 | AC_CHECK_LIB(nsl, gethostbyname) | |
95 | ||
96 | # BFD conditionally uses zlib, so we must link it in if libbfd does, by | |
97 | # using the same condition. | |
98 | AM_ZLIB | |
99 | ||
6bb11ab3 L |
100 | # BFD uses libdl when when plugins enabled. |
101 | AC_PLUGINS | |
102 | AM_CONDITIONAL(PLUGINS, test "$plugins" = yes) | |
103 | LT_INIT([dlopen]) | |
104 | AC_SUBST(lt_cv_dlopen_libs) | |
105 | ||
9c082ca8 MF |
106 | . ${srcdir}/../../bfd/configure.host |
107 | ||
108 | dnl Standard (and optional) simulator options. | |
109 | dnl Eventually all simulators will support these. | |
110 | dnl Do not add any here that cannot be supported by all simulators. | |
111 | dnl Do not add similar but different options to a particular simulator, | |
112 | dnl all shall eventually behave the same way. | |
113 | ||
114 | ||
115 | dnl We don't use automake, but we still want to support | |
116 | dnl --enable-maintainer-mode. | |
31e6ad7d | 117 | AM_MAINTAINER_MODE |
9c082ca8 MF |
118 | |
119 | ||
9c082ca8 | 120 | AC_ARG_ENABLE(sim-cflags, |
8d0978fb MF |
121 | [AS_HELP_STRING([--enable-sim-cflags=opts], |
122 | [Extra CFLAGS for use in building simulator])], | |
9c082ca8 MF |
123 | [case "${enableval}" in |
124 | yes) sim_cflags="-O2 -fomit-frame-pointer";; | |
125 | trace) AC_MSG_ERROR("Please use --enable-sim-debug instead."); sim_cflags="";; | |
126 | no) sim_cflags="";; | |
127 | *) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;; | |
128 | esac | |
129 | if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then | |
130 | echo "Setting sim cflags = $sim_cflags" 6>&1 | |
131 | fi],[sim_cflags=""])dnl | |
132 | AC_SUBST(sim_cflags) | |
133 | ||
134 | ||
135 | dnl --enable-sim-debug is for developers of the simulator | |
136 | dnl the allowable values are work-in-progress | |
137 | AC_ARG_ENABLE(sim-debug, | |
8d0978fb MF |
138 | [AS_HELP_STRING([--enable-sim-debug=opts], |
139 | [Enable debugging flags (for developers of the sim itself)])], | |
9c082ca8 MF |
140 | [case "${enableval}" in |
141 | yes) sim_debug="-DDEBUG=7 -DWITH_DEBUG=7";; | |
142 | no) sim_debug="-DDEBUG=0 -DWITH_DEBUG=0";; | |
143 | *) sim_debug="-DDEBUG='(${enableval})' -DWITH_DEBUG='(${enableval})'";; | |
144 | esac | |
145 | if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then | |
146 | echo "Setting sim debug = $sim_debug" 6>&1 | |
147 | fi],[sim_debug=""])dnl | |
148 | AC_SUBST(sim_debug) | |
149 | ||
150 | ||
151 | dnl --enable-sim-stdio is for users of the simulator | |
152 | dnl It determines if IO from the program is routed through STDIO (buffered) | |
153 | AC_ARG_ENABLE(sim-stdio, | |
8d0978fb MF |
154 | [AS_HELP_STRING([--enable-sim-stdio], |
155 | [Specify whether to use stdio for console input/output])], | |
9c082ca8 MF |
156 | [case "${enableval}" in |
157 | yes) sim_stdio="-DWITH_STDIO=DO_USE_STDIO";; | |
158 | no) sim_stdio="-DWITH_STDIO=DONT_USE_STDIO";; | |
159 | *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-stdio"); sim_stdio="";; | |
160 | esac | |
161 | if test x"$silent" != x"yes" && test x"$sim_stdio" != x""; then | |
162 | echo "Setting stdio flags = $sim_stdio" 6>&1 | |
163 | fi],[sim_stdio=""])dnl | |
164 | AC_SUBST(sim_stdio) | |
165 | ||
166 | ||
167 | dnl --enable-sim-trace is for users of the simulator | |
168 | dnl The argument is either a bitmask of things to enable [exactly what is | |
169 | dnl up to the simulator], or is a comma separated list of names of tracing | |
170 | dnl elements to enable. The latter is only supported on simulators that | |
171 | dnl use WITH_TRACE. | |
172 | AC_ARG_ENABLE(sim-trace, | |
8d0978fb MF |
173 | [AS_HELP_STRING([--enable-sim-trace=opts], |
174 | [Enable tracing of simulated programs])], | |
9c082ca8 | 175 | [case "${enableval}" in |
a3487082 MF |
176 | yes) sim_trace="-DWITH_TRACE=-1";; |
177 | no) sim_trace="-DWITH_TRACE=0";; | |
9c082ca8 | 178 | [[-0-9]]*) |
a3487082 | 179 | sim_trace="-DWITH_TRACE='(${enableval})'";; |
509deab2 | 180 | [[[:lower:]]]*) |
9c082ca8 MF |
181 | sim_trace="" |
182 | for x in `echo "$enableval" | sed -e "s/,/ /g"`; do | |
183 | if test x"$sim_trace" = x; then | |
184 | sim_trace="-DWITH_TRACE='(TRACE_$x" | |
185 | else | |
186 | sim_trace="${sim_trace}|TRACE_$x" | |
187 | fi | |
188 | done | |
189 | sim_trace="$sim_trace)'" ;; | |
190 | esac | |
191 | if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then | |
192 | echo "Setting sim trace = $sim_trace" 6>&1 | |
193 | fi],[sim_trace=""])dnl | |
194 | AC_SUBST(sim_trace) | |
195 | ||
196 | ||
197 | dnl --enable-sim-profile | |
198 | dnl The argument is either a bitmask of things to enable [exactly what is | |
199 | dnl up to the simulator], or is a comma separated list of names of profiling | |
200 | dnl elements to enable. The latter is only supported on simulators that | |
201 | dnl use WITH_PROFILE. | |
202 | AC_ARG_ENABLE(sim-profile, | |
8d0978fb | 203 | [AS_HELP_STRING([--enable-sim-profile=opts], [Enable profiling flags])], |
9c082ca8 MF |
204 | [case "${enableval}" in |
205 | yes) sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1";; | |
206 | no) sim_profile="-DPROFILE=0 -DWITH_PROFILE=0";; | |
207 | [[-0-9]]*) | |
208 | sim_profile="-DPROFILE='(${enableval})' -DWITH_PROFILE='(${enableval})'";; | |
209 | [[a-z]]*) | |
210 | sim_profile="" | |
211 | for x in `echo "$enableval" | sed -e "s/,/ /g"`; do | |
212 | if test x"$sim_profile" = x; then | |
213 | sim_profile="-DWITH_PROFILE='(PROFILE_$x" | |
214 | else | |
215 | sim_profile="${sim_profile}|PROFILE_$x" | |
216 | fi | |
217 | done | |
218 | sim_profile="$sim_profile)'" ;; | |
219 | esac | |
220 | if test x"$silent" != x"yes" && test x"$sim_profile" != x""; then | |
221 | echo "Setting sim profile = $sim_profile" 6>&1 | |
222 | fi],[sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1"])dnl | |
223 | AC_SUBST(sim_profile) | |
224 | ||
bf12d44e | 225 | ACX_PKGVERSION([SIM]) |
9c082ca8 MF |
226 | ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/]) |
227 | AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description]) | |
228 | AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address]) | |
229 | ||
230 | dnl Types used by common code | |
231 | AC_TYPE_SIGNAL | |
232 | ||
233 | dnl Detect exe extension | |
234 | AC_EXEEXT | |
235 | ||
236 | dnl These are available to append to as desired. | |
237 | sim_link_files= | |
238 | sim_link_links= | |
239 | ||
9c082ca8 MF |
240 | # targ-vals.def points to the libc macro description file. |
241 | case "${target}" in | |
242 | *-*-*) TARG_VALS_DEF=../common/nltvals.def ;; | |
243 | esac | |
244 | sim_link_files="${sim_link_files} ${TARG_VALS_DEF}" | |
245 | sim_link_links="${sim_link_links} targ-vals.def" | |
246 | ||
247 | ]) dnl End of SIM_AC_COMMON | |
248 | ||
249 | ||
250 | dnl Additional SIM options that can (optionally) be configured | |
251 | dnl For optional simulator options, a macro SIM_AC_OPTION_* is defined. | |
252 | dnl Simulators that wish to use the relevant option specify the macro | |
306f4178 | 253 | dnl in the simulator specific configure.ac file between the SIM_AC_COMMON |
9c082ca8 MF |
254 | dnl and SIM_AC_OUTPUT lines. |
255 | ||
256 | ||
257 | dnl Specify the running environment. | |
306f4178 | 258 | dnl If the simulator invokes this in its configure.ac then without this option |
9c082ca8 MF |
259 | dnl the default is the user environment and all are runtime selectable. |
260 | dnl If the simulator doesn't invoke this, only the user environment is | |
261 | dnl supported. | |
262 | dnl ??? Until there is demonstrable value in doing something more complicated, | |
263 | dnl let's not. | |
264 | AC_DEFUN([SIM_AC_OPTION_ENVIRONMENT], | |
265 | [ | |
266 | AC_ARG_ENABLE(sim-environment, | |
8d0978fb MF |
267 | [AS_HELP_STRING([--enable-sim-environment=environment], |
268 | [Specify mixed, user, virtual or operating environment])], | |
9c082ca8 MF |
269 | [case "${enableval}" in |
270 | all | ALL) sim_environment="-DWITH_ENVIRONMENT=ALL_ENVIRONMENT";; | |
271 | user | USER) sim_environment="-DWITH_ENVIRONMENT=USER_ENVIRONMENT";; | |
272 | virtual | VIRTUAL) sim_environment="-DWITH_ENVIRONMENT=VIRTUAL_ENVIRONMENT";; | |
273 | operating | OPERATING) sim_environment="-DWITH_ENVIRONMENT=OPERATING_ENVIRONMENT";; | |
274 | *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-environment"); | |
275 | sim_environment="";; | |
276 | esac | |
277 | if test x"$silent" != x"yes" && test x"$sim_environment" != x""; then | |
278 | echo "Setting sim environment = $sim_environment" 6>&1 | |
279 | fi], | |
280 | [sim_environment="-DWITH_ENVIRONMENT=ALL_ENVIRONMENT"])dnl | |
281 | ]) | |
282 | AC_SUBST(sim_environment) | |
283 | ||
284 | ||
285 | dnl Specify the alignment restrictions of the target architecture. | |
286 | dnl Without this option all possible alignment restrictions are accommodated. | |
287 | dnl arg[1] is hardwired target alignment | |
288 | dnl arg[2] is default target alignment | |
289 | AC_DEFUN([SIM_AC_OPTION_ALIGNMENT], | |
290 | wire_alignment="[$1]" | |
291 | default_alignment="[$2]" | |
292 | [ | |
293 | AC_ARG_ENABLE(sim-alignment, | |
8d0978fb MF |
294 | [AS_HELP_STRING([--enable-sim-alignment=align], |
295 | [Specify strict, nonstrict or forced alignment of memory accesses])], | |
9c082ca8 MF |
296 | [case "${enableval}" in |
297 | strict | STRICT) sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";; | |
298 | nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";; | |
299 | forced | FORCED) sim_alignment="-DWITH_ALIGNMENT=FORCED_ALIGNMENT";; | |
300 | yes) if test x"$wire_alignment" != x; then | |
301 | sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}" | |
302 | else | |
303 | if test x"$default_alignment" != x; then | |
304 | sim_alignment="-DWITH_ALIGNMENT=${default_alignment}" | |
305 | else | |
306 | echo "No hard-wired alignment for target $target" 1>&6 | |
307 | sim_alignment="-DWITH_ALIGNMENT=0" | |
308 | fi | |
309 | fi;; | |
310 | no) if test x"$default_alignment" != x; then | |
311 | sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}" | |
312 | else | |
313 | if test x"$wire_alignment" != x; then | |
314 | sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${wire_alignment}" | |
315 | else | |
316 | echo "No default alignment for target $target" 1>&6 | |
317 | sim_alignment="-DWITH_DEFAULT_ALIGNMENT=0" | |
318 | fi | |
319 | fi;; | |
320 | *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment"); sim_alignment="";; | |
321 | esac | |
322 | if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then | |
323 | echo "Setting alignment flags = $sim_alignment" 6>&1 | |
324 | fi], | |
325 | [if test x"$default_alignment" != x; then | |
326 | sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}" | |
327 | else | |
328 | if test x"$wire_alignment" != x; then | |
329 | sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}" | |
330 | else | |
331 | sim_alignment= | |
332 | fi | |
333 | fi])dnl | |
334 | ])dnl | |
335 | AC_SUBST(sim_alignment) | |
336 | ||
337 | ||
338 | dnl Conditionally compile in assertion statements. | |
339 | AC_DEFUN([SIM_AC_OPTION_ASSERT], | |
340 | [ | |
341 | AC_ARG_ENABLE(sim-assert, | |
8d0978fb MF |
342 | [AS_HELP_STRING([--enable-sim-assert], |
343 | [Specify whether to perform random assertions])], | |
9c082ca8 MF |
344 | [case "${enableval}" in |
345 | yes) sim_assert="-DWITH_ASSERT=1";; | |
346 | no) sim_assert="-DWITH_ASSERT=0";; | |
347 | *) AC_MSG_ERROR("--enable-sim-assert does not take a value"); sim_assert="";; | |
348 | esac | |
349 | if test x"$silent" != x"yes" && test x"$sim_assert" != x""; then | |
350 | echo "Setting assert flags = $sim_assert" 6>&1 | |
351 | fi],[sim_assert=""])dnl | |
352 | ]) | |
353 | AC_SUBST(sim_assert) | |
354 | ||
355 | ||
356 | ||
357 | dnl --enable-sim-bitsize is for developers of the simulator | |
358 | dnl It specifies the number of BITS in the target. | |
359 | dnl arg[1] is the number of bits in a word | |
360 | dnl arg[2] is the number assigned to the most significant bit | |
361 | dnl arg[3] is the number of bits in an address | |
362 | dnl arg[4] is the number of bits in an OpenFirmware cell. | |
363 | dnl FIXME: this information should be obtained from bfd/archure | |
364 | AC_DEFUN([SIM_AC_OPTION_BITSIZE], | |
365 | wire_word_bitsize="[$1]" | |
366 | wire_word_msb="[$2]" | |
367 | wire_address_bitsize="[$3]" | |
368 | wire_cell_bitsize="[$4]" | |
369 | [AC_ARG_ENABLE(sim-bitsize, | |
8d0978fb | 370 | [AS_HELP_STRING([--enable-sim-bitsize=N], [Specify target bitsize (32 or 64)])], |
9c082ca8 MF |
371 | [sim_bitsize= |
372 | case "${enableval}" in | |
373 | 64,63 | 64,63,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63";; | |
374 | 32,31 | 32,31,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31";; | |
375 | 64,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";; | |
376 | 32,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";; | |
377 | 32) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then | |
378 | sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31" | |
379 | else | |
380 | sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0" | |
381 | fi ;; | |
382 | 64) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then | |
383 | sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63" | |
384 | else | |
385 | sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=0" | |
386 | fi ;; | |
387 | *) AC_MSG_ERROR("--enable-sim-bitsize was given $enableval. Expected 32 or 64") ;; | |
388 | esac | |
389 | # address bitsize | |
390 | tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9]]*,*//"` | |
391 | case x"${tmp}" in | |
392 | x ) ;; | |
393 | x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=32" ;; | |
394 | x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=64" ;; | |
395 | * ) AC_MSG_ERROR("--enable-sim-bitsize was given address size $enableval. Expected 32 or 64") ;; | |
396 | esac | |
397 | # cell bitsize | |
398 | tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9*]]*,*[[0-9]]*,*//"` | |
399 | case x"${tmp}" in | |
400 | x ) ;; | |
401 | x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=32" ;; | |
402 | x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=64" ;; | |
403 | * ) AC_MSG_ERROR("--enable-sim-bitsize was given cell size $enableval. Expected 32 or 64") ;; | |
404 | esac | |
405 | if test x"$silent" != x"yes" && test x"$sim_bitsize" != x""; then | |
406 | echo "Setting bitsize flags = $sim_bitsize" 6>&1 | |
407 | fi], | |
408 | [sim_bitsize="" | |
409 | if test x"$wire_word_bitsize" != x; then | |
410 | sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_BITSIZE=$wire_word_bitsize" | |
411 | fi | |
412 | if test x"$wire_word_msb" != x; then | |
413 | sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_MSB=$wire_word_msb" | |
414 | fi | |
415 | if test x"$wire_address_bitsize" != x; then | |
416 | sim_bitsize="$sim_bitsize -DWITH_TARGET_ADDRESS_BITSIZE=$wire_address_bitsize" | |
417 | fi | |
418 | if test x"$wire_cell_bitsize" != x; then | |
419 | sim_bitsize="$sim_bitsize -DWITH_TARGET_CELL_BITSIZE=$wire_cell_bitsize" | |
420 | fi])dnl | |
421 | ]) | |
422 | AC_SUBST(sim_bitsize) | |
423 | ||
424 | ||
425 | ||
426 | dnl --enable-sim-endian={yes,no,big,little} is for simulators | |
427 | dnl that support both big and little endian targets. | |
428 | dnl arg[1] is hardwired target endianness. | |
429 | dnl arg[2] is default target endianness. | |
430 | AC_DEFUN([SIM_AC_OPTION_ENDIAN], | |
431 | [ | |
432 | wire_endian="[$1]" | |
433 | default_endian="[$2]" | |
434 | AC_ARG_ENABLE(sim-endian, | |
8d0978fb MF |
435 | [AS_HELP_STRING([--enable-sim-endian=endian], |
436 | [Specify target byte endian orientation])], | |
9c082ca8 | 437 | [case "${enableval}" in |
1ac72f06 MF |
438 | b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_BIG";; |
439 | l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_LITTLE";; | |
9c082ca8 | 440 | yes) if test x"$wire_endian" != x; then |
1ac72f06 | 441 | sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}" |
9c082ca8 | 442 | else |
1ac72f06 MF |
443 | if test x"$default_endian" != x; then |
444 | sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}" | |
9c082ca8 MF |
445 | else |
446 | echo "No hard-wired endian for target $target" 1>&6 | |
1ac72f06 | 447 | sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN" |
9c082ca8 MF |
448 | fi |
449 | fi;; | |
450 | no) if test x"$default_endian" != x; then | |
1ac72f06 | 451 | sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}" |
9c082ca8 MF |
452 | else |
453 | if test x"$wire_endian" != x; then | |
1ac72f06 | 454 | sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}" |
9c082ca8 MF |
455 | else |
456 | echo "No default endian for target $target" 1>&6 | |
1ac72f06 | 457 | sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN" |
9c082ca8 MF |
458 | fi |
459 | fi;; | |
460 | *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";; | |
461 | esac | |
462 | if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then | |
463 | echo "Setting endian flags = $sim_endian" 6>&1 | |
464 | fi], | |
465 | [if test x"$default_endian" != x; then | |
1ac72f06 | 466 | sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}" |
9c082ca8 MF |
467 | else |
468 | if test x"$wire_endian" != x; then | |
1ac72f06 | 469 | sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}" |
9c082ca8 MF |
470 | else |
471 | sim_endian= | |
472 | fi | |
473 | fi])dnl | |
474 | ]) | |
475 | AC_SUBST(sim_endian) | |
476 | ||
477 | ||
9c082ca8 MF |
478 | dnl --enable-sim-float is for developers of the simulator |
479 | dnl It specifies the presence of hardware floating point | |
480 | dnl And optionally the bitsize of the floating point register. | |
481 | dnl arg[1] specifies the presence (or absence) of floating point hardware | |
482 | dnl arg[2] specifies the number of bits in a floating point register | |
483 | AC_DEFUN([SIM_AC_OPTION_FLOAT], | |
484 | [ | |
485 | default_sim_float="[$1]" | |
486 | default_sim_float_bitsize="[$2]" | |
487 | AC_ARG_ENABLE(sim-float, | |
8d0978fb MF |
488 | [AS_HELP_STRING([--enable-sim-float], |
489 | [Specify that the target processor has floating point hardware])], | |
9c082ca8 MF |
490 | [case "${enableval}" in |
491 | yes | hard) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";; | |
492 | no | soft) sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";; | |
493 | 32) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=32";; | |
494 | 64) sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=64";; | |
495 | *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-float"); sim_float="";; | |
496 | esac | |
497 | if test x"$silent" != x"yes" && test x"$sim_float" != x""; then | |
498 | echo "Setting float flags = $sim_float" 6>&1 | |
499 | fi],[ | |
500 | sim_float= | |
501 | if test x"${default_sim_float}" != x""; then | |
502 | sim_float="-DWITH_FLOATING_POINT=${default_sim_float}" | |
503 | fi | |
504 | if test x"${default_sim_float_bitsize}" != x""; then | |
505 | sim_float="$sim_float -DWITH_TARGET_FLOATING_POINT_BITSIZE=${default_sim_float_bitsize}" | |
506 | fi | |
507 | ])dnl | |
508 | ]) | |
509 | AC_SUBST(sim_float) | |
510 | ||
511 | ||
512 | dnl The argument is the default cache size if none is specified. | |
513 | AC_DEFUN([SIM_AC_OPTION_SCACHE], | |
514 | [ | |
515 | default_sim_scache="ifelse([$1],,0,[$1])" | |
516 | AC_ARG_ENABLE(sim-scache, | |
8d0978fb MF |
517 | [AS_HELP_STRING([--enable-sim-scache=size], |
518 | [Specify simulator execution cache size])], | |
9c082ca8 MF |
519 | [case "${enableval}" in |
520 | yes) sim_scache="-DWITH_SCACHE=${default_sim_scache}";; | |
521 | no) sim_scache="-DWITH_SCACHE=0" ;; | |
522 | [[0-9]]*) sim_scache="-DWITH_SCACHE=${enableval}";; | |
523 | *) AC_MSG_ERROR("Bad value $enableval passed to --enable-sim-scache"); | |
524 | sim_scache="";; | |
525 | esac | |
526 | if test x"$silent" != x"yes" && test x"$sim_scache" != x""; then | |
527 | echo "Setting scache size = $sim_scache" 6>&1 | |
528 | fi],[sim_scache="-DWITH_SCACHE=${default_sim_scache}"]) | |
529 | ]) | |
530 | AC_SUBST(sim_scache) | |
531 | ||
532 | ||
533 | dnl The argument is the default model if none is specified. | |
534 | AC_DEFUN([SIM_AC_OPTION_DEFAULT_MODEL], | |
535 | [ | |
536 | default_sim_default_model="ifelse([$1],,0,[$1])" | |
537 | AC_ARG_ENABLE(sim-default-model, | |
8d0978fb MF |
538 | [AS_HELP_STRING([--enable-sim-default-model=model], |
539 | [Specify default model to simulate])], | |
9c082ca8 MF |
540 | [case "${enableval}" in |
541 | yes|no) AC_MSG_ERROR("Missing argument to --enable-sim-default-model");; | |
542 | *) sim_default_model="-DWITH_DEFAULT_MODEL='\"${enableval}\"'";; | |
543 | esac | |
544 | if test x"$silent" != x"yes" && test x"$sim_default_model" != x""; then | |
545 | echo "Setting default model = $sim_default_model" 6>&1 | |
546 | fi],[sim_default_model="-DWITH_DEFAULT_MODEL='\"${default_sim_default_model}\"'"]) | |
547 | ]) | |
548 | AC_SUBST(sim_default_model) | |
549 | ||
550 | ||
551 | dnl --enable-sim-hardware is for users of the simulator | |
64dd13df | 552 | dnl arg[1] Enable sim-hw by default? ("yes" or "no") |
9c082ca8 MF |
553 | dnl arg[2] is a space separated list of devices that override the defaults |
554 | dnl arg[3] is a space separated list of extra target specific devices. | |
555 | AC_DEFUN([SIM_AC_OPTION_HARDWARE], | |
556 | [ | |
9c082ca8 MF |
557 | if test "[$2]"; then |
558 | hardware="[$2]" | |
559 | else | |
560 | hardware="cfi core pal glue" | |
561 | fi | |
562 | hardware="$hardware [$3]" | |
1517bd27 | 563 | |
9c082ca8 MF |
564 | sim_hw_cflags="-DWITH_HW=1" |
565 | sim_hw="$hardware" | |
566 | sim_hw_objs="\$(SIM_COMMON_HW_OBJS) `echo $sim_hw | sed -e 's/\([[^ ]][[^ ]]*\)/dv-\1.o/g'`" | |
1517bd27 | 567 | |
9c082ca8 | 568 | AC_ARG_ENABLE(sim-hardware, |
1517bd27 | 569 | [AS_HELP_STRING([--enable-sim-hardware=LIST], |
30452bbe MF |
570 | [Specify the hardware to be included in the build.])], |
571 | ,[enable_sim_hardware="[$1]"]) | |
1517bd27 | 572 | case ${enable_sim_hardware} in |
64dd13df MF |
573 | yes|no) ;; |
574 | ,*) hardware="${hardware} `echo ${enableval} | sed -e 's/,/ /'`";; | |
575 | *,) hardware="`echo ${enableval} | sed -e 's/,/ /'` ${hardware}";; | |
576 | *) hardware="`echo ${enableval} | sed -e 's/,/ /'`"'';; | |
9c082ca8 | 577 | esac |
1517bd27 | 578 | |
64dd13df | 579 | if test "$enable_sim_hardware" = no; then |
9c082ca8 MF |
580 | sim_hw_objs= |
581 | sim_hw_cflags="-DWITH_HW=0" | |
582 | sim_hw= | |
583 | else | |
584 | sim_hw_cflags="-DWITH_HW=1" | |
585 | # remove duplicates | |
586 | sim_hw="" | |
587 | sim_hw_objs="\$(SIM_COMMON_HW_OBJS)" | |
588 | for i in $hardware ; do | |
589 | case " $sim_hw " in | |
590 | *" $i "*) ;; | |
591 | *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";; | |
592 | esac | |
593 | done | |
3fd38161 | 594 | # mingw does not support sockser |
3fd38161 JS |
595 | case ${host} in |
596 | *mingw*) ;; | |
49cd1634 MF |
597 | *) # TODO: We don't add dv-sockser to sim_hw as it is not a "real" device |
598 | # that you instatiate. Instead, other code will call into it directly. | |
599 | # At some point, we should convert it over. | |
600 | sim_hw_objs="$sim_hw_objs dv-sockser.o" | |
3fd38161 JS |
601 | AC_DEFINE_UNQUOTED( |
602 | [HAVE_DV_SOCKSER], 1, [Define if dv-sockser is usable.]) | |
603 | ;; | |
604 | esac | |
1517bd27 MF |
605 | if test x"$silent" != x"yes"; then |
606 | echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs" | |
3fd38161 | 607 | fi |
1517bd27 MF |
608 | dnl Some devices require extra libraries. |
609 | case " $hardware " in | |
610 | *" cfi "*) AC_CHECK_LIB(m, log2);; | |
611 | esac | |
9c082ca8 | 612 | fi |
9c082ca8 MF |
613 | ]) |
614 | AC_SUBST(sim_hw_cflags) | |
615 | AC_SUBST(sim_hw_objs) | |
616 | AC_SUBST(sim_hw) | |
617 | ||
618 | ||
619 | dnl --enable-sim-inline is for users that wish to ramp up the simulator's | |
620 | dnl performance by inlining functions. | |
621 | dnl Guarantee that unconfigured simulators do not do any inlining | |
622 | sim_inline="-DDEFAULT_INLINE=0" | |
623 | AC_DEFUN([SIM_AC_OPTION_INLINE], | |
624 | [ | |
625 | default_sim_inline="ifelse([$1],,,-DDEFAULT_INLINE=[$1])" | |
626 | AC_ARG_ENABLE(sim-inline, | |
8d0978fb MF |
627 | [AS_HELP_STRING([--enable-sim-inline=inlines], |
628 | [Specify which functions should be inlined])], | |
9c082ca8 MF |
629 | [sim_inline="" |
630 | case "$enableval" in | |
631 | no) sim_inline="-DDEFAULT_INLINE=0";; | |
632 | 0) sim_inline="-DDEFAULT_INLINE=0";; | |
633 | yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_C_INLINE";; | |
634 | 1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";; | |
635 | *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do | |
636 | new_flag="" | |
637 | case "$x" in | |
638 | *_INLINE=*) new_flag="-D$x";; | |
639 | *=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;; | |
640 | *_INLINE) new_flag="-D$x=ALL_C_INLINE";; | |
641 | *) new_flag="-D$x""_INLINE=ALL_C_INLINE";; | |
642 | esac | |
643 | if test x"$sim_inline" = x""; then | |
644 | sim_inline="$new_flag" | |
645 | else | |
646 | sim_inline="$sim_inline $new_flag" | |
647 | fi | |
648 | done;; | |
649 | esac | |
650 | if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then | |
651 | echo "Setting inline flags = $sim_inline" 6>&1 | |
652 | fi],[ | |
653 | if test "x$cross_compiling" = "xno"; then | |
654 | if test x"$GCC" != "x" -a x"${default_sim_inline}" != "x" ; then | |
655 | sim_inline="${default_sim_inline}" | |
656 | if test x"$silent" != x"yes"; then | |
657 | echo "Setting inline flags = $sim_inline" 6>&1 | |
658 | fi | |
659 | else | |
660 | sim_inline="" | |
661 | fi | |
662 | else | |
663 | sim_inline="-DDEFAULT_INLINE=0" | |
664 | fi])dnl | |
665 | ]) | |
666 | AC_SUBST(sim_inline) | |
667 | ||
668 | ||
669 | AC_DEFUN([SIM_AC_OPTION_PACKAGES], | |
670 | [ | |
671 | AC_ARG_ENABLE(sim-packages, | |
8d0978fb MF |
672 | [AS_HELP_STRING([--enable-sim-packages=list], |
673 | [Specify the packages to be included in the build])], | |
9c082ca8 MF |
674 | [packages=disklabel |
675 | case "${enableval}" in | |
676 | yes) ;; | |
677 | no) AC_MSG_ERROR("List of packages must be specified for --enable-sim-packages"); packages="";; | |
678 | ,*) packages="${packages}${enableval}";; | |
679 | *,) packages="${enableval}${packages}";; | |
680 | *) packages="${enableval}"'';; | |
681 | esac | |
682 | sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'` | |
683 | sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'` | |
684 | if test x"$silent" != x"yes" && test x"$packages" != x""; then | |
685 | echo "Setting packages to $sim_pk_src, $sim_pk_obj" | |
686 | fi],[packages=disklabel | |
687 | sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'` | |
688 | sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'` | |
689 | if test x"$silent" != x"yes"; then | |
690 | echo "Setting packages to $sim_pk_src, $sim_pk_obj" | |
691 | fi])dnl | |
692 | ]) | |
693 | AC_SUBST(sim_packages) | |
694 | ||
695 | ||
696 | AC_DEFUN([SIM_AC_OPTION_REGPARM], | |
697 | [ | |
698 | AC_ARG_ENABLE(sim-regparm, | |
8d0978fb MF |
699 | [AS_HELP_STRING([--enable-sim-regparm=nr-parm], |
700 | [Pass parameters in registers instead of on the stack - x86/GCC specific])], | |
9c082ca8 MF |
701 | [case "${enableval}" in |
702 | 0*|1*|2*|3*|4*|5*|6*|7*|8*|9*) sim_regparm="-DWITH_REGPARM=${enableval}";; | |
703 | no) sim_regparm="" ;; | |
704 | yes) sim_regparm="-DWITH_REGPARM=3";; | |
705 | *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-regparm"); sim_regparm="";; | |
706 | esac | |
707 | if test x"$silent" != x"yes" && test x"$sim_regparm" != x""; then | |
708 | echo "Setting regparm flags = $sim_regparm" 6>&1 | |
709 | fi],[sim_regparm=""])dnl | |
710 | ]) | |
711 | AC_SUBST(sim_regparm) | |
712 | ||
713 | ||
714 | AC_DEFUN([SIM_AC_OPTION_RESERVED_BITS], | |
715 | [ | |
716 | default_sim_reserved_bits="ifelse([$1],,1,[$1])" | |
717 | AC_ARG_ENABLE(sim-reserved-bits, | |
8d0978fb MF |
718 | [AS_HELP_STRING([--enable-sim-reserved-bits], |
719 | [Specify whether to check reserved bits in instruction])], | |
9c082ca8 MF |
720 | [case "${enableval}" in |
721 | yes) sim_reserved_bits="-DWITH_RESERVED_BITS=1";; | |
722 | no) sim_reserved_bits="-DWITH_RESERVED_BITS=0";; | |
723 | *) AC_MSG_ERROR("--enable-sim-reserved-bits does not take a value"); sim_reserved_bits="";; | |
724 | esac | |
725 | if test x"$silent" != x"yes" && test x"$sim_reserved_bits" != x""; then | |
726 | echo "Setting reserved flags = $sim_reserved_bits" 6>&1 | |
727 | fi],[sim_reserved_bits="-DWITH_RESERVED_BITS=${default_sim_reserved_bits}"])dnl | |
728 | ]) | |
729 | AC_SUBST(sim_reserved_bits) | |
730 | ||
731 | ||
732 | AC_DEFUN([SIM_AC_OPTION_SMP], | |
733 | [ | |
734 | default_sim_smp="ifelse([$1],,5,[$1])" | |
735 | AC_ARG_ENABLE(sim-smp, | |
8d0978fb MF |
736 | [AS_HELP_STRING([--enable-sim-smp=n], |
737 | [Specify number of processors to configure for (default ${default_sim_smp})])], | |
9c082ca8 MF |
738 | [case "${enableval}" in |
739 | yes) sim_smp="-DWITH_SMP=5" ; sim_igen_smp="-N 5";; | |
740 | no) sim_smp="-DWITH_SMP=0" ; sim_igen_smp="-N 0";; | |
741 | *) sim_smp="-DWITH_SMP=$enableval" ; sim_igen_smp="-N $enableval";; | |
742 | esac | |
743 | if test x"$silent" != x"yes" && test x"$sim_smp" != x""; then | |
744 | echo "Setting smp flags = $sim_smp" 6>&1 | |
745 | fi],[sim_smp="-DWITH_SMP=${default_sim_smp}" ; sim_igen_smp="-N ${default_sim_smp}" | |
746 | if test x"$silent" != x"yes"; then | |
747 | echo "Setting smp flags = $sim_smp" 6>&1 | |
748 | fi])dnl | |
749 | ]) | |
750 | AC_SUBST(sim_smp) | |
751 | ||
752 | ||
753 | AC_DEFUN([SIM_AC_OPTION_STDCALL], | |
754 | [ | |
755 | AC_ARG_ENABLE(sim-stdcall, | |
8d0978fb MF |
756 | [AS_HELP_STRING([--enable-sim-stdcall=type], |
757 | [Use an alternative function call/return mechanism - x86/GCC specific])], | |
9c082ca8 MF |
758 | [case "${enableval}" in |
759 | no) sim_stdcall="" ;; | |
760 | std*) sim_stdcall="-DWITH_STDCALL=1";; | |
761 | yes) sim_stdcall="-DWITH_STDCALL=1";; | |
762 | *) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-stdcall"); sim_stdcall="";; | |
763 | esac | |
764 | if test x"$silent" != x"yes" && test x"$sim_stdcall" != x""; then | |
765 | echo "Setting function call flags = $sim_stdcall" 6>&1 | |
766 | fi],[sim_stdcall=""])dnl | |
767 | ]) | |
768 | AC_SUBST(sim_stdcall) | |
769 | ||
770 | ||
771 | AC_DEFUN([SIM_AC_OPTION_XOR_ENDIAN], | |
772 | [ | |
773 | default_sim_xor_endian="ifelse([$1],,8,[$1])" | |
774 | AC_ARG_ENABLE(sim-xor-endian, | |
8d0978fb MF |
775 | [AS_HELP_STRING([--enable-sim-xor-endian=n], |
776 | [Specify number bytes involved in XOR bi-endian mode (default ${default_sim_xor_endian})])], | |
9c082ca8 MF |
777 | [case "${enableval}" in |
778 | yes) sim_xor_endian="-DWITH_XOR_ENDIAN=8";; | |
779 | no) sim_xor_endian="-DWITH_XOR_ENDIAN=0";; | |
780 | *) sim_xor_endian="-DWITH_XOR_ENDIAN=$enableval";; | |
781 | esac | |
782 | if test x"$silent" != x"yes" && test x"$sim_xor_endian" != x""; then | |
783 | echo "Setting xor-endian flag = $sim_xor_endian" 6>&1 | |
784 | fi],[sim_xor_endian="-DWITH_XOR_ENDIAN=${default_sim_xor_endian}"])dnl | |
785 | ]) | |
786 | AC_SUBST(sim_xor_endian) | |
787 | ||
788 | ||
789 | dnl --enable-build-warnings is for developers of the simulator. | |
790 | dnl it enables extra GCC specific warnings. | |
791 | AC_DEFUN([SIM_AC_OPTION_WARNINGS], | |
792 | [ | |
ac0aacdf MF |
793 | AC_ARG_ENABLE(werror, |
794 | AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]), | |
795 | [case "${enableval}" in | |
796 | yes | y) ERROR_ON_WARNING="yes" ;; | |
797 | no | n) ERROR_ON_WARNING="no" ;; | |
798 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;; | |
799 | esac]) | |
800 | ||
801 | # Enable -Werror by default when using gcc | |
802 | if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then | |
803 | ERROR_ON_WARNING=yes | |
804 | fi | |
805 | ||
806 | WERROR_CFLAGS="" | |
807 | if test "${ERROR_ON_WARNING}" = yes ; then | |
808 | # NOTE: Disabled in the sim dir due to most sims generating warnings. | |
809 | # WERROR_CFLAGS="-Werror" | |
810 | true | |
9c082ca8 | 811 | fi |
ac0aacdf | 812 | |
ac0aacdf | 813 | build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \ |
1a8a700e | 814 | -Wpointer-sign \ |
ac0aacdf | 815 | -Wno-unused -Wunused-value -Wunused-function \ |
1a8a700e MF |
816 | -Wno-switch -Wno-char-subscripts -Wmissing-prototypes |
817 | -Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \ | |
818 | -Wold-style-declaration -Wold-style-definition" | |
ac0aacdf MF |
819 | |
820 | # Enable -Wno-format by default when using gcc on mingw since many | |
821 | # GCC versions complain about %I64. | |
822 | case "${host}" in | |
823 | *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;; | |
d3685d60 | 824 | *) build_warnings="$build_warnings -Wformat-nonliteral" ;; |
ac0aacdf MF |
825 | esac |
826 | ||
9c082ca8 | 827 | AC_ARG_ENABLE(build-warnings, |
ac0aacdf | 828 | AS_HELP_STRING([--enable-build-warnings], [enable build-time compiler warnings if gcc is used]), |
9c082ca8 MF |
829 | [case "${enableval}" in |
830 | yes) ;; | |
831 | no) build_warnings="-w";; | |
832 | ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"` | |
833 | build_warnings="${build_warnings} ${t}";; | |
834 | *,) t=`echo "${enableval}" | sed -e "s/,/ /g"` | |
835 | build_warnings="${t} ${build_warnings}";; | |
836 | *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;; | |
837 | esac | |
838 | if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then | |
839 | echo "Setting compiler warning flags = $build_warnings" 6>&1 | |
840 | fi])dnl | |
841 | AC_ARG_ENABLE(sim-build-warnings, | |
ac0aacdf | 842 | AS_HELP_STRING([--enable-sim-build-warnings], [enable SIM specific build-time compiler warnings if gcc is used]), |
9c082ca8 MF |
843 | [case "${enableval}" in |
844 | yes) ;; | |
845 | no) build_warnings="-w";; | |
846 | ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"` | |
847 | build_warnings="${build_warnings} ${t}";; | |
848 | *,) t=`echo "${enableval}" | sed -e "s/,/ /g"` | |
849 | build_warnings="${t} ${build_warnings}";; | |
850 | *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;; | |
851 | esac | |
852 | if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then | |
853 | echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1 | |
854 | fi])dnl | |
855 | WARN_CFLAGS="" | |
9c082ca8 MF |
856 | if test "x${build_warnings}" != x -a "x$GCC" = xyes |
857 | then | |
858 | AC_MSG_CHECKING(compiler warning flags) | |
859 | # Separate out the -Werror flag as some files just cannot be | |
860 | # compiled with it enabled. | |
861 | for w in ${build_warnings}; do | |
862 | case $w in | |
863 | -Werr*) WERROR_CFLAGS=-Werror ;; | |
864 | *) # Check that GCC accepts it | |
865 | saved_CFLAGS="$CFLAGS" | |
866 | CFLAGS="$CFLAGS $w" | |
867 | AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",) | |
868 | CFLAGS="$saved_CFLAGS" | |
869 | esac | |
870 | done | |
ac0aacdf | 871 | AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS}) |
9c082ca8 MF |
872 | fi |
873 | ]) | |
874 | AC_SUBST(WARN_CFLAGS) | |
875 | AC_SUBST(WERROR_CFLAGS) | |
876 | ||
877 | ||
878 | dnl Generate the Makefile in a target specific directory. | |
879 | dnl Substitutions aren't performed on the file in AC_SUBST_FILE, | |
880 | dnl so this is a cover macro to tuck the details away of how we cope. | |
881 | dnl We cope by having autoconf generate two files and then merge them into | |
882 | dnl one afterwards. The two pieces of the common fragment are inserted into | |
883 | dnl the target's fragment at the appropriate points. | |
884 | ||
885 | AC_DEFUN([SIM_AC_OUTPUT], | |
886 | [ | |
887 | AC_LINK_FILES($sim_link_files, $sim_link_links) | |
888 | dnl Make @cgen_breaks@ non-null only if the sim uses CGEN. | |
889 | cgen_breaks="" | |
890 | if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then | |
891 | cgen_breaks="break cgen_rtx_error"; | |
892 | fi | |
893 | AC_SUBST(cgen_breaks) | |
894 | AC_CONFIG_FILES(Makefile.sim:Makefile.in) | |
895 | AC_CONFIG_FILES(Make-common.sim:../common/Make-common.in) | |
896 | AC_CONFIG_FILES(.gdbinit:../common/gdbinit.in) | |
897 | AC_CONFIG_COMMANDS([Makefile], | |
898 | [echo "Merging Makefile.sim+Make-common.sim into Makefile ..." | |
899 | rm -f Makesim1.tmp Makesim2.tmp Makefile | |
900 | sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp | |
901 | sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp | |
902 | sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \ | |
903 | -e '/^## COMMON_POST_/ r Makesim2.tmp' \ | |
904 | <Makefile.sim >Makefile | |
905 | rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp | |
906 | ]) | |
907 | AC_CONFIG_COMMANDS([stamp-h], [echo > stamp-h]) | |
908 | AC_OUTPUT | |
909 | ]) | |
910 | ||
911 | sinclude(../../config/gettext-sister.m4) | |
912 | sinclude(../../config/acx.m4) | |
913 | ||
914 | dnl --enable-cgen-maint support | |
915 | AC_DEFUN([SIM_AC_OPTION_CGEN_MAINT], | |
916 | [ | |
917 | cgen_maint=no | |
918 | dnl Default is to use one in build tree. | |
919 | cgen=guile | |
920 | cgendir='$(srcdir)/../../cgen' | |
921 | dnl Having --enable-maintainer-mode take arguments is another way to go. | |
922 | dnl ??? One can argue --with is more appropriate if one wants to specify | |
923 | dnl a directory name, but what we're doing here is an enable/disable kind | |
924 | dnl of thing and specifying both --enable and --with is klunky. | |
925 | dnl If you reeely want this to be --with, go ahead and change it. | |
926 | AC_ARG_ENABLE(cgen-maint, | |
8d0978fb | 927 | [AS_HELP_STRING([--enable-cgen-maint[=DIR]], [build cgen generated files])], |
9c082ca8 MF |
928 | [case "${enableval}" in |
929 | yes) cgen_maint=yes ;; | |
930 | no) cgen_maint=no ;; | |
931 | *) | |
932 | # argument is cgen install directory (not implemented yet). | |
933 | # Having a `share' directory might be more appropriate for the .scm, | |
934 | # .cpu, etc. files. | |
935 | cgendir=${cgen_maint}/lib/cgen | |
936 | cgen=guile | |
937 | ;; | |
938 | esac])dnl | |
939 | dnl AM_CONDITIONAL(CGEN_MAINT, test x${cgen_maint} != xno) | |
940 | if test x${cgen_maint} != xno ; then | |
941 | CGEN_MAINT='' | |
942 | else | |
943 | CGEN_MAINT='#' | |
944 | fi | |
945 | AC_SUBST(CGEN_MAINT) | |
946 | AC_SUBST(cgendir) | |
947 | AC_SUBST(cgen) | |
948 | ]) |