1 # Makefile fragment for common parts of all simulators.
2 # Copyright (C) 1997 Free Software Foundation, Inc.
3 # Contributed by Cygnus Support.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 # This Makefile fragment consists of two separate parts.
20 # They are merged into the final Makefile at points denoted by
21 # "## COMMON_PRE_CONFIG_FRAG" and "## COMMON_POST_CONFIG_FRAG".
23 # The target Makefile should look like:
25 #># Copyright blah blah
27 #>## COMMON_PRE_CONFIG_FRAG
29 #># Any overrides necessary for the SIM_FOO config vars.
32 #>## COMMON_POST_CONFIG_FRAG
34 #># Rules to build target specific .o's.
36 ## COMMON_PRE_CONFIG_FRAG
40 srcroot = $(srcdir)/../..
43 exec_prefix = @exec_prefix@
45 host_alias = @host_alias@
46 target_alias = @target_alias@
47 program_transform_name = @program_transform_name@
51 tooldir = $(libdir)/$(target_alias)
55 man1dir = $(mandir)/man1
57 includedir = @includedir@
62 INSTALL_PROGRAM = @INSTALL_PROGRAM@
63 INSTALL_DATA = @INSTALL_DATA@
66 CC_FOR_BUILD = @CC_FOR_BUILD@
68 SIM_BSWAP = @sim_bswap@
69 SIM_CFLAGS = @sim_cflags@
70 SIM_DEBUG = @sim_debug@
71 SIM_TRACE = @sim_trace@
82 # Each simulator's Makefile.in defines one or more of these variables
83 # to override our settings as necessary. There is no need to define these
84 # in the simulator's Makefile.in if one is using the default value. In fact
85 # it's preferable not to.
87 # List of object files, less common parts.
89 # List of extra dependencies.
90 # Generally this consists of simulator specific files included by sim-main.h.
92 # List of flags to always pass to $(CC).
94 # List of extra libraries to link with.
96 # List of extra program dependencies.
98 # List of main object files for `run'.
100 # Dependency of `all' to build any extra files.
102 # Dependency of `install' to install any extra files.
104 # Dependency of `clean' to clean any extra files.
107 ## End COMMON_PRE_CONFIG_FRAG
109 ## COMMON_POST_CONFIG_FRAG
111 CONFIG_CFLAGS = @DEFS@ $(SIM_CFLAGS) $(SIM_DEBUG) $(SIM_TRACE) $(SIM_BSWAP) \
112 $(SIM_EXTRA_CFLAGS) $(HDEFINES) $(TDEFINES)
113 CSEARCH = -I. -I$(srcdir) -I../common -I$(srcdir)/../common \
114 -I../../include -I$(srcroot)/include \
115 -I../../bfd -I$(srcroot)/bfd \
116 -I../../opcodes -I$(srcroot)/opcodes
117 ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(CFLAGS)
118 BUILD_CFLAGS = -g -O $(CSEARCH)
120 LIBIBERTY_LIB = ../../libiberty/libiberty.a
121 BFD_LIB = ../../bfd/libbfd.a
122 OPCODES_LIB = ../../opcodes/libopcodes.a
124 LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
126 EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
127 $(CONFIG_LIBS) $(SIM_EXTRA_LIBS)
129 LIB_OBJS = callback.o targ-map.o $(SIM_OBJS)
131 all: libsim.a run $(SIM_EXTRA_ALL)
133 libsim.a: $(LIB_OBJS)
135 $(AR) $(ARFLAGS) libsim.a $(LIB_OBJS)
138 run: $(SIM_RUN_OBJS) libsim.a $(LIBDEPS)
139 $(CC) $(ALL_CFLAGS) -o run \
140 $(SIM_RUN_OBJS) libsim.a $(EXTRA_LIBS)
142 run.o: $(srcdir)/../common/run.c config.h tconfig.h \
143 $(srcroot)/include/callback.h
144 $(CC) -c $(srcdir)/../common/run.c $(ALL_CFLAGS)
146 # FIXME: Ideally, callback.o and friends live in a library outside of
147 # both the gdb and simulator source trees (e.g. devo/remote. Not
148 # devo/libremote because this directory would contain more than just
151 callback.o: $(srcdir)/../common/callback.c config.h tconfig.h \
152 $(srcroot)/include/callback.h targ-vals.h
153 $(CC) -c $(srcdir)/../common/callback.c $(ALL_CFLAGS)
155 targ-map.o: targ-map.c targ-vals.h
157 gentmap: Makefile $(srcdir)/../common/gentmap.c targ-vals.def
158 $(CC_FOR_BUILD) $(srcdir)/../common/gentmap.c -o gentmap $(BUILD_CFLAGS)
162 ./gentmap -h >targ-vals.h
166 ./gentmap -c >targ-map.c
170 # Rules for building sim-* components. Triggered by listing the corresponding
171 # .o file in the list of simulator targets.
176 $(srcdir)/../common/sim-config.h \
177 $(srcdir)/../common/sim-base.h \
178 $(srcdir)/../common/sim-basics.h \
179 $(srcdir)/../common/sim-trace.h \
182 sim-assert_h = $(srcdir)/../common/sim-assert.h
183 sim-endian_h = $(srcdir)/../common/sim-endian.h
184 sim-n-endian_h = $(srcdir)/../common/sim-n-endian.h
185 sim-bits_h = $(srcdir)/../common/sim-bits.h
186 sim-config_h = $(srcdir)/../common/sim-config.h
187 sim-n-bits_h = $(srcdir)/../common/sim-n-bits.h
188 sim-core_h = $(srcdir)/../common/sim-core.h
189 sim-n-core_h = $(srcdir)/../common/sim-n-core.h
190 sim-events_h = $(srcdir)/../common/sim-events.h
191 sim-io_h = $(srcdir)/../common/sim-io.h
192 sim-n-io_h = $(srcdir)/../common/sim-n-io.h
194 # FIXME: If this complicated way of building .o files from ../common is
195 # necessary, the reason should be documented here!
197 BUILT_SRC_FROM_COMMON= \
206 sim-bits.o: sim-bits.c $(sim-bits_h) $(sim-n-bits_h) $(sim-assert_h) \
208 sim-bits.c: $(srcdir)/../common/sim-bits.c
210 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
211 cat $(srcdir)/../common/$@ >> tmp-$@
212 $(srcdir)/../../move-if-change tmp-$@ $@
214 sim-config.o: sim-config.c $(sim-config_h) $(sim-nconfig_h) $(sim-assert_h) \
216 sim-config.c: $(srcdir)/../common/sim-config.c
218 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
219 cat $(srcdir)/../common/$@ >> tmp-$@
220 $(srcdir)/../../move-if-change tmp-$@ $@
222 sim-core.o: sim-core.c $(sim-core_h) $(sim-n-core_h) \
224 sim-core.c: $(srcdir)/../common/sim-core.c
226 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
227 cat $(srcdir)/../common/$@ >> tmp-$@
228 $(srcdir)/../../move-if-change tmp-$@ $@
230 sim-endian.o: sim-endian.c $(sim-endian_h) $(sim-n-endian_h) $(sim-assert_h) \
232 sim-endian.c: $(srcdir)/../common/sim-endian.c
234 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
235 cat $(srcdir)/../common/$@ >> tmp-$@
236 $(srcdir)/../../move-if-change tmp-$@ $@
238 sim-events.o: sim-events.c $(sim-events_h) $(sim-assert_h) \
240 sim-events.c: $(srcdir)/../common/sim-events.c
242 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
243 cat $(srcdir)/../common/$@ >> tmp-$@
244 $(srcdir)/../../move-if-change tmp-$@ $@
246 sim-inline.c: $(srcdir)/../common/sim-inline.c
248 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
249 cat $(srcdir)/../common/$@ >> tmp-$@
250 $(srcdir)/../../move-if-change tmp-$@ $@
252 sim-io.o: sim-io.c $(sim_main_headers) $(sim-io_h) $(sim-assert_h) \
254 sim-io.c: $(srcdir)/../common/sim-io.c
256 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
257 cat $(srcdir)/../common/$@ >> tmp-$@
258 $(srcdir)/../../move-if-change tmp-$@ $@
260 sim-options.o: $(srcdir)/../common/sim-options.c $(sim_main_headers) \
261 $(srcdir)/../common/sim-options.h
262 $(CC) -c $(srcdir)/../common/sim-options.c $(ALL_CFLAGS)
264 sim-trace.o: $(srcdir)/../common/sim-trace.c $(sim_main_headers) \
265 $(srcdir)/../common/sim-io.h
266 $(CC) -c $(srcdir)/../common/sim-trace.c $(ALL_CFLAGS)
268 sim-utils.o: $(srcdir)/../common/sim-utils.c $(sim_main_headers) \
270 $(CC) -c $(srcdir)/../common/sim-utils.c $(ALL_CFLAGS)
272 sim-load.o: $(srcdir)/../common/sim-load.c
273 $(CC) -c $(srcdir)/../common/sim-load.c $(ALL_CFLAGS)
275 nrun.o: $(srcdir)/../common/nrun.c config.h tconfig.h \
276 $(srcroot)/include/callback.h $(sim_main_headers)
277 $(CC) -c $(srcdir)/../common/nrun.c $(ALL_CFLAGS)
279 install: install-common $(SIM_EXTRA_INSTALL)
281 install-common: installdirs
282 n=`echo run | sed '$(program_transform_name)'`; \
283 $(INSTALL_PROGRAM) run $(bindir)/$$n
286 $(SHELL) $(srcdir)/../../mkinstalldirs $(bindir)
302 clean: $(SIM_EXTRA_CLEAN)
305 rm -f gentmap targ-map.c targ-vals.h
306 rm -f $(BUILT_SRC_FROM_COMMON)
308 distclean mostlyclean maintainer-clean realclean: clean
310 rm -f Makefile config.cache config.log config.status
311 rm -f tconfig.h config.h stamp-h
314 $(CC) -c $(ALL_CFLAGS) $<
316 # Dummy target to force execution of dependent targets.
319 Makefile: Makefile.in $(srcdir)/../common/Make-common.in config.status
320 CONFIG_HEADERS= $(SHELL) ./config.status
322 config.status: configure
323 $(SHELL) ./config.status --recheck
325 config.h: stamp-h ; @true
326 stamp-h: config.in config.status
327 CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
329 ## End COMMON_POST_CONFIG_FRAG