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