1 # This file contains common code used by all simulators.
2 # SIM_AC_COMMON invokes AC macros used by all simulators and by the
4 # SIM_AC_OUTPUT is a cover function to AC_OUTPUT to use generate the
5 # Makefile in a target specific directory.
7 AC_DEFUN(SIM_AC_COMMON,
9 # autoconf.info says this should be called right after AC_INIT.
10 AC_CONFIG_HEADER(config.h:config.in)
12 AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..)
19 # Put a plausible default for CC_FOR_BUILD in Makefile.
21 if test "x$cross_compiling" = "xno"; then
26 AC_SUBST(CC_FOR_BUILD)
34 . ${srcdir}/../../bfd/configure.host
36 dnl Standard simulator options.
37 dnl Eventually all simulators will support these.
38 dnl Do not add any here that cannot be supported by all simulators.
39 dnl Do not add similar but different options to a particular simulator,
40 dnl all shall eventually behave the same way.
42 AC_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="";;
48 *) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
50 if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then
51 echo "Setting sim cflags = $sim_cflags" 6>&1
52 fi],[sim_cflags=""])dnl
55 dnl --enable-sim-debug is for developers of the simulator
56 dnl the allowable values are work-in-progress
57 AC_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})'";;
64 if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then
65 echo "Setting sim debug = $sim_debug" 6>&1
66 fi],[sim_debug=""])dnl
69 dnl --enable-sim-trace is for users of the simulator
70 dnl the allowable values are work-in-progress
71 AC_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})'";;
78 if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then
79 echo "Setting sim trace = $sim_trace" 6>&1
80 fi],[sim_trace=""])dnl
83 dnl This is a generic option to enable special byte swapping
84 dnl insns on *any* cpu.
85 AC_ARG_ENABLE(sim-bswap,
86 [ --enable-sim-bswap Use Host specific BSWAP instruction.],
87 [case "${enableval}" in
88 yes) sim_bswap="-DUSE_BSWAP";;
90 *) AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
92 if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
93 echo "Setting bswap flags = $sim_bswap" 6>&1
94 fi],[sim_bswap=""])dnl
97 dnl These are available to append to as desired.
101 dnl Create tconfig.h either from simulator's tconfig.in or default one
103 sim_link_links=tconfig.h
104 if test -f ${srcdir}/tconfig.in
106 sim_link_files=tconfig.in
108 sim_link_files=../common/tconfig.in
113 sim_link_files="${sim_link_files} ../common/nltvals.def"
114 sim_link_links="${sim_link_links} targ-vals.def"
118 dnl Stuff that gets inserted into the Makefile
120 COMMON_MAKEFILE_FRAG=makefile-temp-$$
121 cat > $COMMON_MAKEFILE_FRAG <<EOF
124 srcroot = \$(srcdir)/../..
127 exec_prefix = ${exec_prefix}
129 host_alias = ${host_alias}
130 target_alias = ${target_alias}
131 program_transform_name = ${program_transform_name}
135 tooldir = \$(libdir)/\$(target_alias)
139 man1dir = \$(mandir)/man1
141 includedir = ${includedir}
145 INSTALL = \$(srcroot)/install.sh -c
146 INSTALL_PROGRAM = ${INSTALL_PROGRAM}
147 INSTALL_DATA = ${INSTALL_DATA}
148 INSTALL_XFORM = \$(INSTALL) -t='$(program_transform_name)'
149 INSTALL_XFORM1= \$(INSTALL_XFORM) -b=.1
152 CC_FOR_BUILD = ${CC_FOR_BUILD}
154 SIM_CFLAGS = ${sim_cflags}
155 SIM_DEBUG = ${sim_debug}
156 SIM_TRACE = ${sim_trace}
157 SIM_BSWAP = ${sim_bswap}
159 HDEFINES = ${HDEFINES}
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
171 # List of object files, less common parts.
173 # List of flags to always pass to $(CC).
175 # List of extra libraries to link with.
177 # List of extra program dependencies.
179 # Dependency of 'all' to build any extra files.
181 # Dependency of 'install' to install any extra files.
183 # Dependency of 'clean' to clean any extra files.
186 CONFIG_CFLAGS = ${DEFS} \$(SIM_CFLAGS) \$(SIM_DEBUG) \$(SIM_TRACE) \$(SIM_BSWAP) \
187 \$(SIM_EXTRA_CFLAGS) \$(HDEFINES) \$(TDEFINES)
188 CSEARCH = -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
192 ALL_CFLAGS = \$(CONFIG_CFLAGS) \$(CSEARCH) \$(CFLAGS)
193 BUILD_CFLAGS = -g -O \$(CSEARCH)
198 LIBIBERTY_LIB = ../../libiberty/libiberty.a
199 BFD_LIB = ../../bfd/libbfd.a
200 OPCODES_LIB = ../../opcodes/libopcodes.a
201 CONFIG_LIBS = ${LIBS}
202 LIBDEPS = \$(BFD_LIB) \$(OPCODES_LIB) \$(LIBIBERTY_LIB) \
203 \$(SIM_EXTRA_LIBDEPS)
204 EXTRA_LIBS = \$(BFD_LIB) \$(OPCODES_LIB) \$(LIBIBERTY_LIB) \
205 \$(CONFIG_LIBS) \$(SIM_EXTRA_LIBS)
207 LIB_OBJS = callback.o targ-map.o \$(SIM_OBJS)
209 all: run libsim.a \$(SIM_EXTRA_ALL)
211 libsim.a: \$(LIB_OBJS)
213 \$(AR) \$(ARFLAGS) libsim.a \$(LIB_OBJS)
216 run: run.o libsim.a \$(LIBDEPS)
217 \$(CC) \$(ALL_CFLAGS) -o run \
218 run.o libsim.a \$(EXTRA_LIBS)
220 run.o: \$(srcdir)/../common/run.c config.h tconfig.h \
221 \$(srcroot)/include/callback.h
222 \$(CC) -c \$(srcdir)/../common/run.c \$(ALL_CFLAGS)
224 callback.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)
228 gentmap: \$(srcdir)/../common/gentmap.c targ-vals.def
229 \$(CC_FOR_BUILD) \$(srcdir)/../common/gentmap.c -o gentmap \$(BUILD_CFLAGS) -I\$(srcdir)/../common
233 ./gentmap -h >targ-vals.h
237 ./gentmap -c >targ-map.c
239 install: install-common \$(SIM_EXTRA_INSTALL)
242 \$(INSTALL_XFORM) run \$(bindir)/run
255 clean: \$(SIM_EXTRA_CLEAN)
256 rm -f *.[[oa]] *~ core gentmap targ-map.c targ-vals.h
259 distclean mostlyclean maintainer-clean realclean: clean
261 rm -f Makefile config.cache config.log config.status
262 rm -f tconfig.h config.h stamp-h
265 \$(CC) -c \$(ALL_CFLAGS) \$<
267 # Dummy target to force execution of dependent targets.
270 Makefile: Makefile.in \$(srcdir)/../common/Make-common.in config.status
271 CONFIG_HEADERS= \$(SHELL) ./config.status
273 config.status: configure
274 \$(SHELL) ./config.status --recheck
276 config.h: stamp-h ; @true
277 stamp-h: config.in config.status
278 CONFIG_FILES= CONFIG_HEADERS=config.h:config.in \$(SHELL) ./config.status
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.
284 cd \$(srcdir) && autoconf -l ../common
287 dnl end of COMMON_MAKEFILE_FRAG
289 AC_SUBST_FILE(COMMON_MAKEFILE_FRAG)
291 ]) dnl End of SIM_AC_COMMON
293 dnl Generate the Makefile in a target specific directory.
294 dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
295 dnl so this is a cover macro to tuck the details away of how we cope.
296 dnl It also inserts default definitions of the SIM_FOO variables.
298 AC_DEFUN(SIM_AC_OUTPUT,
300 AC_LINK_FILES($sim_link_files, $sim_link_links)
302 case "x$CONFIG_HEADERS" in xconfig.h:config.in) echo > stamp-h ;; esac
305 rm $COMMON_MAKEFILE_FRAG
307 ])dnl End of SIM_AC_OUTPUT