1 # This file contains common code used by all simulators.
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.
8 # The simulator's configure.in should look like:
10 # dnl Process this file with `autoconf -l ../common' to produce a configure script.
12 # AC_INIT(Makefile.in)
15 # ... target specific stuff ...
19 AC_DEFUN(SIM_AC_COMMON,
21 # autoconf.info says this should be called right after AC_INIT.
22 AC_CONFIG_HEADER(config.h:config.in)
24 AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..)
31 # Put a plausible default for CC_FOR_BUILD in Makefile.
33 if test "x$cross_compiling" = "xno"; then
38 AC_SUBST(CC_FOR_BUILD)
46 . ${srcdir}/../../bfd/configure.host
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.
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="";;
60 *) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
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
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})'";;
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
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})'";;
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
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";;
102 *) AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
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
109 dnl These are available to append to as desired.
113 dnl Create tconfig.h either from simulator's tconfig.in or default one
115 sim_link_links=tconfig.h
116 if test -f ${srcdir}/tconfig.in
118 sim_link_files=tconfig.in
120 sim_link_files=../common/tconfig.in
125 sim_link_files="${sim_link_files} ../common/nltvals.def"
126 sim_link_links="${sim_link_links} targ-vals.def"
130 ]) dnl End of SIM_AC_COMMON
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.
137 AC_DEFUN(SIM_AC_OUTPUT,
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.
144 COMMON_MAKEFILE_FRAG=makefile-temp-$$
145 cat > $COMMON_MAKEFILE_FRAG <<EOF
148 srcroot = \$(srcdir)/../..
151 exec_prefix = ${exec_prefix}
153 host_alias = ${host_alias}
154 target_alias = ${target_alias}
155 program_transform_name = ${program_transform_name}
159 tooldir = \$(libdir)/\$(target_alias)
163 man1dir = \$(mandir)/man1
165 includedir = ${includedir}
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
176 CC_FOR_BUILD = ${CC_FOR_BUILD}
178 SIM_CFLAGS = ${sim_cflags}
179 SIM_DEBUG = ${sim_debug}
180 SIM_TRACE = ${sim_trace}
181 SIM_BSWAP = ${sim_bswap}
183 HDEFINES = ${HDEFINES}
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
195 # List of object files, less common parts.
197 # List of flags to always pass to \$(CC).
199 # List of extra libraries to link with.
201 # List of extra program dependencies.
203 # Dependency of 'all' to build any extra files.
205 # Dependency of 'install' to install any extra files.
207 # Dependency of 'clean' to clean any extra files.
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)
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)
231 LIB_OBJS = callback.o targ-map.o \$(SIM_OBJS)
233 all: run libsim.a \$(SIM_EXTRA_ALL)
235 libsim.a: \$(LIB_OBJS)
237 \$(AR) \$(ARFLAGS) libsim.a \$(LIB_OBJS)
240 run: run.o libsim.a \$(LIBDEPS)
241 \$(CC) \$(ALL_CFLAGS) -o run \
242 run.o libsim.a \$(EXTRA_LIBS)
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)
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)
252 gentmap: \$(srcdir)/../common/gentmap.c targ-vals.def
253 \$(CC_FOR_BUILD) \$(srcdir)/../common/gentmap.c -o gentmap \$(BUILD_CFLAGS) -I\$(srcdir)/../common
257 ./gentmap -h >targ-vals.h
261 ./gentmap -c >targ-map.c
263 install: install-common \$(SIM_EXTRA_INSTALL)
266 \$(INSTALL_XFORM) run \$(bindir)/run
279 clean: \$(SIM_EXTRA_CLEAN)
280 rm -f *.[[oa]] *~ core gentmap targ-map.c targ-vals.h
283 distclean mostlyclean maintainer-clean realclean: clean
285 rm -f Makefile config.cache config.log config.status
286 rm -f tconfig.h config.h stamp-h targ-vals.def
289 \$(CC) -c \$(ALL_CFLAGS) \$<
291 # Dummy target to force execution of dependent targets.
294 Makefile: Makefile.in config.status
295 CONFIG_HEADERS= \$(SHELL) ./config.status
297 config.status: configure
298 \$(SHELL) ./config.status --recheck
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
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.
308 cd \$(srcdir) && autoconf -l ../common
311 dnl end of COMMON_MAKEFILE_FRAG
313 AC_SUBST_FILE(COMMON_MAKEFILE_FRAG)
315 AC_LINK_FILES($sim_link_files, $sim_link_links)
317 case "x$CONFIG_HEADERS" in xconfig.h:config.in) echo > stamp-h ;; esac
320 rm $COMMON_MAKEFILE_FRAG
322 ])dnl End of SIM_AC_OUTPUT