1 # This file contains common code used by all simulators.
3 # common.m4 invokes AC macros used by all simulators and by the common
4 # directory. It is intended to be included before any target specific
5 # stuff. SIM_AC_OUTPUT is a cover function to AC_OUTPUT to generate
6 # the Makefile. 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.
12 # AC_INIT(Makefile.in)
13 # AC_CONFIG_HEADER(config.h:config.in)
15 # sinclude(../common/aclocal.m4)
16 # sinclude(../common/common.m4)
18 # ... target specific stuff ...
25 # Put a plausible default for CC_FOR_BUILD in Makefile.
26 if test "x$cross_compiling" = "xno"; then
31 AC_SUBST(CC_FOR_BUILD)
39 dnl We don't use gettext, but bfd does. So we do the appropriate checks
40 dnl to see if there are intl libraries we should link against.
44 # Check for common headers.
45 # FIXME: Seems to me this can cause problems for i386-windows hosts.
46 # At one point there were hardcoded AC_DEFINE's if ${host} = i386-*-windows*.
47 AC_CHECK_HEADERS(stdlib.h string.h strings.h unistd.h time.h)
48 AC_CHECK_HEADERS(sys/time.h sys/resource.h)
49 AC_CHECK_HEADERS(fcntl.h fpu_control.h)
50 AC_CHECK_HEADERS(dlfcn.h errno.h sys/stat.h)
51 AC_CHECK_FUNCS(getrusage time sigaction __setfpucw)
53 # Check for socket libraries
54 AC_CHECK_LIB(socket, bind)
55 AC_CHECK_LIB(nsl, gethostbyname)
57 . ${srcdir}/../../bfd/configure.host
59 dnl Standard (and optional) simulator options.
60 dnl Eventually all simulators will support these.
61 dnl Do not add any here that cannot be supported by all simulators.
62 dnl Do not add similar but different options to a particular simulator,
63 dnl all shall eventually behave the same way.
66 dnl We don't use automake, but we still want to support
67 dnl --enable-maintainer-mode.
68 USE_MAINTAINER_MODE=no
69 AC_ARG_ENABLE(maintainer-mode,
70 [ --enable-maintainer-mode Enable developer functionality.],
71 [case "${enableval}" in
72 yes) MAINT="" USE_MAINTAINER_MODE=yes ;;
74 *) AC_MSG_ERROR("--enable-maintainer-mode does not take a value"); MAINT="#" ;;
76 if test x"$silent" != x"yes" && test x"$MAINT" = x""; then
77 echo "Setting maintainer mode" 6>&1
82 dnl This is a generic option to enable special byte swapping
83 dnl insns on *any* cpu.
84 AC_ARG_ENABLE(sim-bswap,
85 [ --enable-sim-bswap Use Host specific BSWAP instruction.],
86 [case "${enableval}" in
87 yes) sim_bswap="-DWITH_BSWAP=1 -DUSE_BSWAP=1";;
88 no) sim_bswap="-DWITH_BSWAP=0";;
89 *) AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
91 if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
92 echo "Setting bswap flags = $sim_bswap" 6>&1
93 fi],[sim_bswap=""])dnl
97 AC_ARG_ENABLE(sim-cflags,
98 [ --enable-sim-cflags=opts Extra CFLAGS for use in building simulator],
99 [case "${enableval}" in
100 yes) sim_cflags="-O2 -fomit-frame-pointer";;
101 trace) AC_MSG_ERROR("Please use --enable-sim-debug instead."); sim_cflags="";;
103 *) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
105 if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then
106 echo "Setting sim cflags = $sim_cflags" 6>&1
107 fi],[sim_cflags=""])dnl
111 dnl --enable-sim-debug is for developers of the simulator
112 dnl the allowable values are work-in-progress
113 AC_ARG_ENABLE(sim-debug,
114 [ --enable-sim-debug=opts Enable debugging flags],
115 [case "${enableval}" in
116 yes) sim_debug="-DDEBUG=7 -DWITH_DEBUG=7";;
117 no) sim_debug="-DDEBUG=0 -DWITH_DEBUG=0";;
118 *) sim_debug="-DDEBUG='(${enableval})' -DWITH_DEBUG='(${enableval})'";;
120 if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then
121 echo "Setting sim debug = $sim_debug" 6>&1
122 fi],[sim_debug=""])dnl
126 dnl --enable-sim-stdio is for users of the simulator
127 dnl It determines if IO from the program is routed through STDIO (buffered)
128 AC_ARG_ENABLE(sim-stdio,
129 [ --enable-sim-stdio Specify whether to use stdio for console input/output.],
130 [case "${enableval}" in
131 yes) sim_stdio="-DWITH_STDIO=DO_USE_STDIO";;
132 no) sim_stdio="-DWITH_STDIO=DONT_USE_STDIO";;
133 *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-stdio"); sim_stdio="";;
135 if test x"$silent" != x"yes" && test x"$sim_stdio" != x""; then
136 echo "Setting stdio flags = $sim_stdio" 6>&1
137 fi],[sim_stdio=""])dnl
141 dnl --enable-sim-trace is for users of the simulator
142 dnl The argument is either a bitmask of things to enable [exactly what is
143 dnl up to the simulator], or is a comma separated list of names of tracing
144 dnl elements to enable. The latter is only supported on simulators that
146 AC_ARG_ENABLE(sim-trace,
147 [ --enable-sim-trace=opts Enable tracing flags],
148 [case "${enableval}" in
149 yes) sim_trace="-DTRACE=1 -DWITH_TRACE=-1";;
150 no) sim_trace="-DTRACE=0 -DWITH_TRACE=0";;
152 sim_trace="-DTRACE='(${enableval})' -DWITH_TRACE='(${enableval})'";;
155 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
156 if test x"$sim_trace" = x; then
157 sim_trace="-DWITH_TRACE='(TRACE_$x"
159 sim_trace="${sim_trace}|TRACE_$x"
162 sim_trace="$sim_trace)'" ;;
164 if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then
165 echo "Setting sim trace = $sim_trace" 6>&1
166 fi],[sim_trace=""])dnl
170 dnl --enable-sim-profile
171 dnl The argument is either a bitmask of things to enable [exactly what is
172 dnl up to the simulator], or is a comma separated list of names of profiling
173 dnl elements to enable. The latter is only supported on simulators that
174 dnl use WITH_PROFILE.
175 AC_ARG_ENABLE(sim-profile,
176 [ --enable-sim-profile=opts Enable profiling flags],
177 [case "${enableval}" in
178 yes) sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1";;
179 no) sim_profile="-DPROFILE=0 -DWITH_PROFILE=0";;
181 sim_profile="-DPROFILE='(${enableval})' -DWITH_PROFILE='(${enableval})'";;
184 for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
185 if test x"$sim_profile" = x; then
186 sim_profile="-DWITH_PROFILE='(PROFILE_$x"
188 sim_profile="${sim_profile}|PROFILE_$x"
191 sim_profile="$sim_profile)'" ;;
193 if test x"$silent" != x"yes" && test x"$sim_profile" != x""; then
194 echo "Setting sim profile = $sim_profile" 6>&1
195 fi],[sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1"])dnl
196 AC_SUBST(sim_profile)
199 dnl Types used by common code
202 dnl Detect exe extension
205 dnl These are available to append to as desired.
209 dnl Create tconfig.h either from simulator's tconfig.in or default one
211 sim_link_links=tconfig.h
212 if test -f ${srcdir}/tconfig.in
214 sim_link_files=tconfig.in
216 sim_link_files=../common/tconfig.in
219 # targ-vals.def points to the libc macro description file.
221 *-*-*) TARG_VALS_DEF=../common/nltvals.def ;;
223 sim_link_files="${sim_link_files} ${TARG_VALS_DEF}"
224 sim_link_links="${sim_link_links} targ-vals.def"