1# This file contains common code used by all simulators.
2#
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.
7#
8# The simulator's configure.in should look like:
9#
10# dnl Process this file with autoconf to produce a configure script.
11# AC_PREREQ(2.5)dnl
12# AC_INIT(Makefile.in)
13# AC_CONFIG_HEADER(config.h:config.in)
14#
15# sinclude(../common/aclocal.m4)
16# sinclude(../common/common.m4)
17#
18# ... target specific stuff ...
19
20AC_CANONICAL_SYSTEM
21AC_ARG_PROGRAM
22AC_PROG_CC
23AC_PROG_INSTALL
24
25# Put a plausible default for CC_FOR_BUILD in Makefile.
26if test "x$cross_compiling" = "xno"; then
27  CC_FOR_BUILD='$(CC)'
28else
29  CC_FOR_BUILD=gcc
30fi
31AC_SUBST(CC_FOR_BUILD)
32
33AC_SUBST(CFLAGS)
34AC_SUBST(HDEFINES)
35AR=${AR-ar}
36AC_SUBST(AR)
37AC_PROG_RANLIB
38
39dnl We don't use gettext, but bfd does.  So we do the appropriate checks
40dnl to see if there are intl libraries we should link against.
41ALL_LINGUAS=
42ZW_GNU_GETTEXT_SISTER_DIR(../../intl)
43
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*.
47AC_CHECK_HEADERS(stdlib.h string.h strings.h unistd.h time.h)
48AC_CHECK_HEADERS(sys/time.h sys/resource.h)
49AC_CHECK_HEADERS(fcntl.h fpu_control.h)
50AC_CHECK_HEADERS(dlfcn.h errno.h sys/stat.h)
51AC_CHECK_FUNCS(getrusage time sigaction __setfpucw)
52
53# Check for socket libraries
54AC_CHECK_LIB(socket, bind)
55AC_CHECK_LIB(nsl, gethostbyname)
56
57# BFD conditionally uses zlib, so we must link it in if libbfd does, by
58# using the same condition.
59AM_ZLIB
60
61. ${srcdir}/../../bfd/configure.host
62
63dnl Standard (and optional) simulator options.
64dnl Eventually all simulators will support these.
65dnl Do not add any here that cannot be supported by all simulators.
66dnl Do not add similar but different options to a particular simulator,
67dnl all shall eventually behave the same way.
68
69
70dnl We don't use automake, but we still want to support
71dnl --enable-maintainer-mode.
72USE_MAINTAINER_MODE=no
73AC_ARG_ENABLE(maintainer-mode,
74[  --enable-maintainer-mode		Enable developer functionality.],
75[case "${enableval}" in
76  yes)	MAINT="" USE_MAINTAINER_MODE=yes ;;
77  no)	MAINT="#" ;;
78  *)	AC_MSG_ERROR("--enable-maintainer-mode does not take a value"); MAINT="#" ;;
79esac
80if test x"$silent" != x"yes" && test x"$MAINT" = x""; then
81  echo "Setting maintainer mode" 6>&1
82fi],[MAINT="#"])dnl
83AC_SUBST(MAINT)
84
85
86dnl This is a generic option to enable special byte swapping
87dnl insns on *any* cpu.
88AC_ARG_ENABLE(sim-bswap,
89[  --enable-sim-bswap			Use Host specific BSWAP instruction.],
90[case "${enableval}" in
91  yes)	sim_bswap="-DWITH_BSWAP=1 -DUSE_BSWAP=1";;
92  no)	sim_bswap="-DWITH_BSWAP=0";;
93  *)	AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
94esac
95if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
96  echo "Setting bswap flags = $sim_bswap" 6>&1
97fi],[sim_bswap=""])dnl
98AC_SUBST(sim_bswap)
99
100
101AC_ARG_ENABLE(sim-cflags,
102[  --enable-sim-cflags=opts		Extra CFLAGS for use in building simulator],
103[case "${enableval}" in
104  yes)	 sim_cflags="-O2 -fomit-frame-pointer";;
105  trace) AC_MSG_ERROR("Please use --enable-sim-debug instead."); sim_cflags="";;
106  no)	 sim_cflags="";;
107  *)	 sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
108esac
109if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then
110  echo "Setting sim cflags = $sim_cflags" 6>&1
111fi],[sim_cflags=""])dnl
112AC_SUBST(sim_cflags)
113
114
115dnl --enable-sim-debug is for developers of the simulator
116dnl the allowable values are work-in-progress
117AC_ARG_ENABLE(sim-debug,
118[  --enable-sim-debug=opts		Enable debugging flags],
119[case "${enableval}" in
120  yes) sim_debug="-DDEBUG=7 -DWITH_DEBUG=7";;
121  no)  sim_debug="-DDEBUG=0 -DWITH_DEBUG=0";;
122  *)   sim_debug="-DDEBUG='(${enableval})' -DWITH_DEBUG='(${enableval})'";;
123esac
124if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then
125  echo "Setting sim debug = $sim_debug" 6>&1
126fi],[sim_debug=""])dnl
127AC_SUBST(sim_debug)
128
129
130dnl --enable-sim-stdio is for users of the simulator
131dnl It determines if IO from the program is routed through STDIO (buffered)
132AC_ARG_ENABLE(sim-stdio,
133[  --enable-sim-stdio			Specify whether to use stdio for console input/output.],
134[case "${enableval}" in
135  yes)	sim_stdio="-DWITH_STDIO=DO_USE_STDIO";;
136  no)	sim_stdio="-DWITH_STDIO=DONT_USE_STDIO";;
137  *)	AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-stdio"); sim_stdio="";;
138esac
139if test x"$silent" != x"yes" && test x"$sim_stdio" != x""; then
140  echo "Setting stdio flags = $sim_stdio" 6>&1
141fi],[sim_stdio=""])dnl
142AC_SUBST(sim_stdio)
143
144
145dnl --enable-sim-trace is for users of the simulator
146dnl The argument is either a bitmask of things to enable [exactly what is
147dnl up to the simulator], or is a comma separated list of names of tracing
148dnl elements to enable.  The latter is only supported on simulators that
149dnl use WITH_TRACE.
150AC_ARG_ENABLE(sim-trace,
151[  --enable-sim-trace=opts		Enable tracing flags],
152[case "${enableval}" in
153  yes)	sim_trace="-DTRACE=1 -DWITH_TRACE=-1";;
154  no)	sim_trace="-DTRACE=0 -DWITH_TRACE=0";;
155  [[-0-9]]*)
156	sim_trace="-DTRACE='(${enableval})' -DWITH_TRACE='(${enableval})'";;
157  [[a-z]]*)
158	sim_trace=""
159	for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
160	  if test x"$sim_trace" = x; then
161	    sim_trace="-DWITH_TRACE='(TRACE_$x"
162	  else
163	    sim_trace="${sim_trace}|TRACE_$x"
164	  fi
165	done
166	sim_trace="$sim_trace)'" ;;
167esac
168if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then
169  echo "Setting sim trace = $sim_trace" 6>&1
170fi],[sim_trace=""])dnl
171AC_SUBST(sim_trace)
172
173
174dnl --enable-sim-profile
175dnl The argument is either a bitmask of things to enable [exactly what is
176dnl up to the simulator], or is a comma separated list of names of profiling
177dnl elements to enable.  The latter is only supported on simulators that
178dnl use WITH_PROFILE.
179AC_ARG_ENABLE(sim-profile,
180[  --enable-sim-profile=opts		Enable profiling flags],
181[case "${enableval}" in
182  yes)	sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1";;
183  no)	sim_profile="-DPROFILE=0 -DWITH_PROFILE=0";;
184  [[-0-9]]*)
185	sim_profile="-DPROFILE='(${enableval})' -DWITH_PROFILE='(${enableval})'";;
186  [[a-z]]*)
187	sim_profile=""
188	for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
189	  if test x"$sim_profile" = x; then
190	    sim_profile="-DWITH_PROFILE='(PROFILE_$x"
191	  else
192	    sim_profile="${sim_profile}|PROFILE_$x"
193	  fi
194	done
195	sim_profile="$sim_profile)'" ;;
196esac
197if test x"$silent" != x"yes" && test x"$sim_profile" != x""; then
198  echo "Setting sim profile = $sim_profile" 6>&1
199fi],[sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1"])dnl
200AC_SUBST(sim_profile)
201
202ACX_PKGVERSION([GDB])
203ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
204AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
205AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
206
207dnl Types used by common code
208AC_TYPE_SIGNAL
209
210dnl Detect exe extension
211AC_EXEEXT
212
213dnl These are available to append to as desired.
214sim_link_files=
215sim_link_links=
216
217dnl Create tconfig.h either from simulator's tconfig.in or default one
218dnl in common.
219sim_link_links=tconfig.h
220if test -f ${srcdir}/tconfig.in
221then
222  sim_link_files=tconfig.in
223else
224  sim_link_files=../common/tconfig.in
225fi
226
227# targ-vals.def points to the libc macro description file.
228case "${target}" in
229*-*-*) TARG_VALS_DEF=../common/nltvals.def ;;
230esac
231sim_link_files="${sim_link_files} ${TARG_VALS_DEF}"
232sim_link_links="${sim_link_links} targ-vals.def"
233