Miscellaneous fixes for config/slite.exp.
[deliverable/binutils-gdb.git] / sim / common / aclocal.m4
CommitLineData
80b7b3a5
SG
1# This file contains common code used by all simulators.
2# SIM_AC_COMMON invokes AC macros used by all simulators and by the
3# common directory.
4# SIM_AC_OUTPUT is a cover function to AC_OUTPUT to use generate the
5# Makefile in a target specific directory.
6
7AC_DEFUN(SIM_AC_COMMON,
8[
9# autoconf.info says this should be called right after AC_INIT.
10AC_CONFIG_HEADER(config.h:config.in)
11
12AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..)
13AC_CANONICAL_SYSTEM
14AC_ARG_PROGRAM
15AC_PROG_CC
16AC_PROG_INSTALL
17AC_C_BIGENDIAN
18
19# Put a plausible default for CC_FOR_BUILD in Makefile.
20AC_C_CROSS
21if test "x$cross_compiling" = "xno"; then
22 CC_FOR_BUILD='$(CC)'
23else
24 CC_FOR_BUILD=gcc
25fi
26AC_SUBST(CC_FOR_BUILD)
27
28AC_SUBST(CFLAGS)
29AC_SUBST(HDEFINES)
30AR=${AR-ar}
31AC_SUBST(AR)
32AC_PROG_RANLIB
33
34. ${srcdir}/../../bfd/configure.host
35
36dnl Standard simulator options.
37dnl Eventually all simulators will support these.
38dnl Do not add any here that cannot be supported by all simulators.
39dnl Do not add similar but different options to a particular simulator,
40dnl all shall eventually behave the same way.
41
42AC_ARG_ENABLE(sim-cflags,
43[ --enable-sim-cflags=opts Extra CFLAGS for use in building simulator],
44[case "${enableval}" in
45 yes) sim_cflags="-O2";;
46 trace) AC_MSG_ERROR("Please use --enable-sim-debug instead."); sim_cflags="";;
47 no) sim_cflags="";;
48 *) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
49esac
50if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then
51 echo "Setting sim cflags = $sim_cflags" 6>&1
52fi],[sim_cflags=""])dnl
53AC_SUBST(sim_cflags)
54
55dnl --enable-sim-debug is for developers of the simulator
56dnl the allowable values are work-in-progress
57AC_ARG_ENABLE(sim-debug,
58[ --enable-sim-debug=opts Enable debugging flags],
59[case "${enableval}" in
60 yes) sim_debug="-DDEBUG=7";;
61 no) sim_debug="-DDEBUG=0";;
62 *) sim_debug="-DDEBUG='(${enableval})'";;
63esac
64if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then
65 echo "Setting sim debug = $sim_debug" 6>&1
66fi],[sim_debug=""])dnl
67AC_SUBST(sim_debug)
68
69dnl --enable-sim-trace is for users of the simulator
70dnl the allowable values are work-in-progress
71AC_ARG_ENABLE(sim-trace,
72[ --enable-sim-trace=opts Enable tracing flags],
73[case "${enableval}" in
74 yes) sim_trace="-DTRACE=1";;
75 no) sim_trace="-DTRACE=0";;
76 *) sim_trace="-DTRACE='(${enableval})'";;
77esac
78if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then
79 echo "Setting sim trace = $sim_trace" 6>&1
80fi],[sim_trace=""])dnl
81AC_SUBST(sim_trace)
82
83dnl This is a generic option to enable special byte swapping
84dnl insns on *any* cpu.
85AC_ARG_ENABLE(sim-bswap,
86[ --enable-sim-bswap Use Host specific BSWAP instruction.],
87[case "${enableval}" in
88 yes) sim_bswap="-DUSE_BSWAP";;
89 no) sim_bswap="";;
90 *) AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
91esac
92if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
93 echo "Setting bswap flags = $sim_bswap" 6>&1
94fi],[sim_bswap=""])dnl
95AC_SUBST(sim_bswap)
96
97dnl These are available to append to as desired.
98sim_link_files=
99sim_link_links=
100
101dnl Create tconfig.h either from simulator's tconfig.in or default one
102dnl in common.
103sim_link_links=tconfig.h
104if test -f ${srcdir}/tconfig.in
105then
106 sim_link_files=tconfig.in
107else
108 sim_link_files=../common/tconfig.in
109fi
110
111case "${target}" in
112*-*-*)
113 sim_link_files="${sim_link_files} ../common/nltvals.def"
114 sim_link_links="${sim_link_links} targ-vals.def"
115 ;;
116esac
117
118dnl Stuff that gets inserted into the Makefile
119
120COMMON_MAKEFILE_FRAG=makefile-temp-$$
121cat > $COMMON_MAKEFILE_FRAG <<EOF
122VPATH = ${srcdir}
123srcdir = ${srcdir}
124srcroot = \$(srcdir)/../..
125
126prefix = ${prefix}
127exec_prefix = ${exec_prefix}
128
129host_alias = ${host_alias}
130target_alias = ${target_alias}
131program_transform_name = ${program_transform_name}
132bindir = ${bindir}
133
134libdir = ${libdir}
135tooldir = \$(libdir)/\$(target_alias)
136
137datadir = ${datadir}
138mandir = ${mandir}
139man1dir = \$(mandir)/man1
140infodir = ${infodir}
141includedir = ${includedir}
142
143SHELL = /bin/sh
144
145INSTALL = \$(srcroot)/install.sh -c
146INSTALL_PROGRAM = ${INSTALL_PROGRAM}
147INSTALL_DATA = ${INSTALL_DATA}
76e2c9ae 148INSTALL_XFORM = \$(INSTALL) -t='\$(program_transform_name)'
80b7b3a5
SG
149INSTALL_XFORM1= \$(INSTALL_XFORM) -b=.1
150
151CC = ${CC}
152CC_FOR_BUILD = ${CC_FOR_BUILD}
153CFLAGS = ${CFLAGS}
154SIM_CFLAGS = ${sim_cflags}
155SIM_DEBUG = ${sim_debug}
156SIM_TRACE = ${sim_trace}
157SIM_BSWAP = ${sim_bswap}
158
159HDEFINES = ${HDEFINES}
160TDEFINES =
161
162AR = ${AR}
163AR_FLAGS = rc
164RANLIB = ${RANLIB}
165MAKEINFO = makeinfo
166
167# Each simulator's Makefile.in defines one or more of these variables
168# as necessary. The SIM_AC_OUTPUT macro then inserts those values
169# at '## Config'.
170
171# List of object files, less common parts.
172#SIM_OBJS =
76e2c9ae 173# List of flags to always pass to \$(CC).
80b7b3a5
SG
174#SIM_EXTRA_CFLAGS =
175# List of extra libraries to link with.
176#SIM_EXTRA_LIBS =
177# List of extra program dependencies.
178#SIM_EXTRA_LIBDEPS =
179# Dependency of 'all' to build any extra files.
180#SIM_EXTRA_ALL =
181# Dependency of 'install' to install any extra files.
182#SIM_EXTRA_INSTALL =
183# Dependency of 'clean' to clean any extra files.
184#SIM_EXTRA_CLEAN =
185
186CONFIG_CFLAGS = ${DEFS} \$(SIM_CFLAGS) \$(SIM_DEBUG) \$(SIM_TRACE) \$(SIM_BSWAP) \
187 \$(SIM_EXTRA_CFLAGS) \$(HDEFINES) \$(TDEFINES)
188CSEARCH = -I. -I\$(srcdir) -I../common -I\$(srcdir)/../common \
189 -I../../include -I\$(srcroot)/include \
190 -I../../bfd -I\$(srcroot)/bfd -I\$(srcroot)/gdb \
191 -I../../opcodes -I\$(srcroot)/opcodes
192ALL_CFLAGS = \$(CONFIG_CFLAGS) \$(CSEARCH) \$(CFLAGS)
193BUILD_CFLAGS = -g -O \$(CSEARCH)
194
195.NOEXPORT:
196MAKEOVERRIDES=
197
198LIBIBERTY_LIB = ../../libiberty/libiberty.a
199BFD_LIB = ../../bfd/libbfd.a
200OPCODES_LIB = ../../opcodes/libopcodes.a
201CONFIG_LIBS = ${LIBS}
202LIBDEPS = \$(BFD_LIB) \$(OPCODES_LIB) \$(LIBIBERTY_LIB) \
203 \$(SIM_EXTRA_LIBDEPS)
204EXTRA_LIBS = \$(BFD_LIB) \$(OPCODES_LIB) \$(LIBIBERTY_LIB) \
205 \$(CONFIG_LIBS) \$(SIM_EXTRA_LIBS)
206
207LIB_OBJS = callback.o targ-map.o \$(SIM_OBJS)
208
209all: run libsim.a \$(SIM_EXTRA_ALL)
210
211libsim.a: \$(LIB_OBJS)
212 rm -f libsim.a
213 \$(AR) \$(ARFLAGS) libsim.a \$(LIB_OBJS)
214 \$(RANLIB) libsim.a
215
216run: run.o libsim.a \$(LIBDEPS)
217 \$(CC) \$(ALL_CFLAGS) -o run \
218 run.o libsim.a \$(EXTRA_LIBS)
219
220run.o: \$(srcdir)/../common/run.c config.h tconfig.h \
221 \$(srcroot)/include/callback.h
222 \$(CC) -c \$(srcdir)/../common/run.c \$(ALL_CFLAGS)
223
224callback.o: \$(srcdir)/../common/callback.c config.h tconfig.h \
225 \$(srcroot)/include/callback.h targ-vals.h
226 \$(CC) -c \$(srcdir)/../common/callback.c \$(ALL_CFLAGS)
227
228gentmap: \$(srcdir)/../common/gentmap.c targ-vals.def
229 \$(CC_FOR_BUILD) \$(srcdir)/../common/gentmap.c -o gentmap \$(BUILD_CFLAGS) -I\$(srcdir)/../common
230
231targ-vals.h: gentmap
232 rm -f targ-vals.h
233 ./gentmap -h >targ-vals.h
234
235targ-map.c: gentmap
236 rm -f targ-map.c
237 ./gentmap -c >targ-map.c
238
239install: install-common \$(SIM_EXTRA_INSTALL)
240
241install-common:
242 \$(INSTALL_XFORM) run \$(bindir)/run
243
244check:
245
246info:
247clean-info:
248install-info:
249
250tags etags: TAGS
251
252TAGS: force
253 etags *.c *.h
254
255clean: \$(SIM_EXTRA_CLEAN)
256 rm -f *.[[oa]] *~ core gentmap targ-map.c targ-vals.h
257 rm -f run libsim.a
258
259distclean mostlyclean maintainer-clean realclean: clean
260 rm -f TAGS
261 rm -f Makefile config.cache config.log config.status
42653e99 262 rm -f tconfig.h config.h stamp-h targ-vals.def
80b7b3a5
SG
263
264.c.o:
265 \$(CC) -c \$(ALL_CFLAGS) \$<
266
267# Dummy target to force execution of dependent targets.
268force:
269
e1dfb8c5 270Makefile: Makefile.in config.status
80b7b3a5
SG
271 CONFIG_HEADERS= \$(SHELL) ./config.status
272
273config.status: configure
274 \$(SHELL) ./config.status --recheck
275
276config.h: stamp-h ; @true
277stamp-h: config.in config.status
278 CONFIG_FILES= CONFIG_HEADERS=config.h:config.in \$(SHELL) ./config.status
279
280# We can't add dependencies to configure because it causes too much trouble
281# to end users if configure's timestamp is out of sync.
282.PHONY: run-autoconf
283run-autoconf:
284 cd \$(srcdir) && autoconf -l ../common
285EOF
286
287dnl end of COMMON_MAKEFILE_FRAG
288
289AC_SUBST_FILE(COMMON_MAKEFILE_FRAG)
290
291]) dnl End of SIM_AC_COMMON
292
293dnl Generate the Makefile in a target specific directory.
294dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
295dnl so this is a cover macro to tuck the details away of how we cope.
296dnl It also inserts default definitions of the SIM_FOO variables.
297
298AC_DEFUN(SIM_AC_OUTPUT,
299[
300AC_LINK_FILES($sim_link_files, $sim_link_links)
301 AC_OUTPUT(Makefile,[
302 case "x$CONFIG_HEADERS" in xconfig.h:config.in) echo > stamp-h ;; esac
303 ])
304
305rm $COMMON_MAKEFILE_FRAG
306
307])dnl End of SIM_AC_OUTPUT
This page took 0.034125 seconds and 4 git commands to generate.