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 srccom = $(srcdir)/../common
41 srcroot = $(srcdir)/../..
44 exec_prefix = @exec_prefix@
46 host_alias = @host_alias@
47 target_alias = @target_alias@
48 program_transform_name = @program_transform_name@
52 tooldir = $(libdir)/$(target_alias)
56 man1dir = $(mandir)/man1
58 includedir = @includedir@
63 INSTALL_PROGRAM = @INSTALL_PROGRAM@
64 INSTALL_DATA = @INSTALL_DATA@
67 CC_FOR_BUILD = @CC_FOR_BUILD@
69 SIM_BSWAP = @sim_bswap@
70 SIM_CFLAGS = @sim_cflags@
71 SIM_DEBUG = @sim_debug@
72 SIM_TRACE = @sim_trace@
73 SIM_PROFILE = @sim_profile@
75 SIM_ASSERT = @sim_assert@
76 SIM_ALIGNMENT = @sim_alignment@
77 SIM_BITSIZE = @sim_bitsize@
78 SIM_DEFAULT_MODEL = @sim_default_model@
79 SIM_ENDIAN = @sim_endian@
80 SIM_FLOAT = @sim_float@
81 SIM_HARDWARE = @sim_hardware@
82 SIM_HOSTENDIAN = @sim_hostendian@
83 SIM_INLINE = @sim_inline@
84 SIM_PACKAGES = @sim_packages@
85 SIM_REGPARM = @sim_regparm@
86 SIM_RESERVED_BITS = @sim_reserved_bits@
87 SIM_SCACHE = @sim_scache@
89 SIM_STDCALL = @sim_stdcall@
90 SIM_WARNINGS = @sim_warnings@
91 SIM_XOR_ENDIAN = @sim_xor_endian@
101 DEP = $(srcroot)/mkdep
103 # Each simulator's Makefile.in defines one or more of these variables
104 # to override our settings as necessary. There is no need to define these
105 # in the simulator's Makefile.in if one is using the default value. In fact
106 # it's preferable not to.
108 # List of object files, less common parts.
110 # List of extra dependencies.
111 # Generally this consists of simulator specific files included by sim-main.h.
113 # List of flags to always pass to $(CC).
115 # List of extra libraries to link with.
117 # List of extra program dependencies.
119 # List of main object files for `run'.
121 # Dependency of `all' to build any extra files.
123 # Dependency of `install' to install any extra files.
125 # Dependency of `clean' to clean any extra files.
128 # Every time a new general purpose source file was added every target's
129 # Makefile.in needed to be updated to include the file in SIM_OBJS.
130 # This doesn't scale.
131 # This variable specifies all the generic stuff common to the newer simulators.
132 # Things like sim-reason.o can't go here as the cpu may provide its own
133 # (though hopefully in time that won't be so). Things like sim-bits.o can go
134 # here. Some files are used by all simulators (e.g. callback.o).
135 # Those files are specified in LIB_OBJS below.
137 SIM_NEW_COMMON_OBJS = \
155 ## End COMMON_PRE_CONFIG_FRAG
157 ## COMMON_POST_CONFIG_FRAG
159 CONFIG_CFLAGS = @DEFS@ \
162 $(SIM_DEFAULT_MODEL) \
176 $(SIM_RESERVED_BITS) \
182 $(SIM_EXTRA_CFLAGS) \
183 $(HDEFINES) $(TDEFINES)
184 CSEARCH = -I. -I$(srcdir) -I../common -I$(srccom) \
185 -I../../include -I$(srcroot)/include \
186 -I../../bfd -I$(srcroot)/bfd \
187 -I../../opcodes -I$(srcroot)/opcodes
188 ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(CFLAGS)
189 BUILD_CFLAGS = -g -O $(CSEARCH)
191 COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH)
193 LIBIBERTY_LIB = ../../libiberty/libiberty.a
194 BFD_LIB = ../../bfd/libbfd.a
195 OPCODES_LIB = ../../opcodes/libopcodes.a
197 LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
199 EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
200 $(CONFIG_LIBS) $(SIM_EXTRA_LIBS)
202 LIB_OBJS = callback.o syscall.o targ-map.o $(SIM_OBJS)
204 all: $(SIM_EXTRA_ALL) libsim.a run
206 libsim.a: $(LIB_OBJS)
208 $(AR) $(AR_FLAGS) libsim.a $(LIB_OBJS)
211 run: $(SIM_RUN_OBJS) libsim.a $(LIBDEPS)
212 $(CC) $(ALL_CFLAGS) -o run \
213 $(SIM_RUN_OBJS) libsim.a $(EXTRA_LIBS)
215 run.o: $(srccom)/run.c config.h tconfig.h \
216 $(srcroot)/include/callback.h
217 $(CC) -c $(srccom)/run.c $(ALL_CFLAGS)
219 # FIXME: Ideally, callback.o and friends live in a library outside of
220 # both the gdb and simulator source trees (e.g. devo/remote. Not
221 # devo/libremote because this directory would contain more than just
224 callback.o: $(srccom)/callback.c config.h tconfig.h \
225 $(srcroot)/include/callback.h targ-vals.h
226 $(CC) -c $(srccom)/callback.c $(ALL_CFLAGS)
228 syscall.o: $(srccom)/syscall.c config.h tconfig.h \
229 $(srcroot)/include/callback.h targ-vals.h
230 $(CC) -c $(srccom)/syscall.c $(ALL_CFLAGS)
232 targ-map.o: targ-map.c targ-vals.h
234 gentmap: Makefile $(srccom)/gentmap.c targ-vals.def
235 $(CC_FOR_BUILD) $(srccom)/gentmap.c -o gentmap $(BUILD_CFLAGS) $(NL_TARGET)
239 ./gentmap -h >targ-vals.h
243 ./gentmap -c >targ-map.c
247 # Rules for building sim-* components. Triggered by listing the corresponding
248 # .o file in the list of simulator targets.
253 $(srccom)/sim-config.h \
254 $(srccom)/sim-base.h \
255 $(srccom)/sim-basics.h \
256 $(srccom)/sim-memopt.h \
257 $(srccom)/sim-model.h \
258 $(srccom)/sim-module.h \
259 $(srccom)/sim-trace.h \
260 $(srccom)/sim-profile.h \
261 $(srccom)/sim-engine.h \
262 $(srccom)/sim-events.h \
263 $(srccom)/sim-watch.h \
264 $(srccom)/sim-assert.h \
268 sim-assert_h = $(srccom)/sim-assert.h
269 sim-endian_h = $(srccom)/sim-endian.h
270 sim-n-endian_h = $(srccom)/sim-n-endian.h
271 sim-bits_h = $(srccom)/sim-bits.h
272 sim-config_h = $(srccom)/sim-config.h
273 sim-n-bits_h = $(srccom)/sim-n-bits.h
274 sim-core_h = $(srccom)/sim-core.h
275 sim-n-core_h = $(srccom)/sim-n-core.h
276 sim-engine_h = $(srccom)/sim-engine.h
277 sim-events_h = $(srccom)/sim-events.h
278 sim-fpu_h = $(srccom)/sim-fpu.h
279 sim-io_h = $(srccom)/sim-io.h
280 sim-options_h = $(srccom)/sim-options.h
281 sim-break_h = $(srccom)/sim-break.h
283 # FIXME: If this complicated way of building .o files from ../common is
284 # necessary, the reason should be documented here.
286 BUILT_SRC_FROM_COMMON= \
289 sim-abort.o: $(srccom)/sim-abort.c \
291 $(CC) -c $(srccom)/sim-abort.c $(ALL_CFLAGS)
293 sim-bits.o: $(srccom)/sim-bits.c $(sim-bits_h) $(sim-n-bits_h) \
295 $(CC) -c $(srccom)/sim-bits.c $(ALL_CFLAGS)
297 sim-config.o: $(srccom)/sim-config.c $(sim-config_h) \
299 $(CC) -c $(srccom)/sim-config.c $(ALL_CFLAGS)
301 sim-core.o: $(srccom)/sim-core.c $(sim-core_h) $(sim-n-core_h) \
303 $(CC) -c $(srccom)/sim-core.c $(ALL_CFLAGS)
305 sim-endian.o: $(srccom)/sim-endian.c $(sim-endian_h) $(sim-n-endian_h) \
307 $(CC) -c $(srccom)/sim-endian.c $(ALL_CFLAGS)
309 sim-engine.o: $(srccom)/sim-engine.c $(sim_main_headers) $(sim-engine_h)
310 $(CC) -c $(srccom)/sim-engine.c $(ALL_CFLAGS)
312 sim-events.o: $(srccom)/sim-events.c $(sim-events_h) \
314 $(CC) -c $(srccom)/sim-events.c $(ALL_CFLAGS)
316 sim-fpu.o: $(srccom)/sim-fpu.c $(sim-fpu_h) \
318 $(CC) -c $(srccom)/sim-fpu.c $(ALL_CFLAGS)
320 sim-hload.o: $(srccom)/sim-hload.c $(sim-assert_h) \
322 $(CC) -c $(srccom)/sim-hload.c $(ALL_CFLAGS)
324 sim-hrw.o: $(srccom)/sim-hrw.c $(sim-assert_h) \
326 $(CC) -c $(srccom)/sim-hrw.c $(ALL_CFLAGS)
328 sim-inline.c: $(srccom)/sim-inline.c
330 echo "# 1 \"$(srccom)/$@\"" > tmp-$@
331 cat $(srccom)/$@ >> tmp-$@
332 $(srcdir)/../../move-if-change tmp-$@ $@
334 sim-io.o: $(srccom)/sim-io.c $(sim_main_headers) $(sim-io_h)
335 $(CC) -c $(srccom)/sim-io.c $(ALL_CFLAGS)
337 sim-memopt.o: $(srccom)/sim-memopt.c $(sim_main_headers) \
339 $(CC) -c $(srccom)/sim-memopt.c $(ALL_CFLAGS)
341 sim-module.o: $(srccom)/sim-module.c $(sim_main_headers) \
343 $(CC) -c $(srccom)/sim-module.c $(ALL_CFLAGS)
345 sim-options.o: $(srccom)/sim-options.c $(sim_main_headers) \
346 $(sim-options_h) $(sim-io_h)
347 $(CC) -c $(srccom)/sim-options.c $(ALL_CFLAGS)
349 sim-reason.o: $(srccom)/sim-reason.c $(sim_main_headers)
350 $(CC) -c $(srccom)/sim-reason.c $(ALL_CFLAGS)
352 sim-resume.o: $(srccom)/sim-resume.c $(sim_main_headers)
353 $(CC) -c $(srccom)/sim-resume.c $(ALL_CFLAGS)
355 sim-run.o: $(srccom)/sim-run.c $(sim_main_headers)
356 $(CC) -c $(srccom)/sim-run.c $(ALL_CFLAGS)
358 sim-stop.o: $(srccom)/sim-stop.c $(sim_main_headers)
359 $(CC) -c $(srccom)/sim-stop.c $(ALL_CFLAGS)
361 sim-trace.o: $(srccom)/sim-trace.c $(sim_main_headers) \
362 $(sim-options_h) $(sim-io_h)
363 $(CC) -c $(srccom)/sim-trace.c $(ALL_CFLAGS)
365 sim-profile.o: $(srccom)/sim-profile.c $(sim_main_headers) \
366 $(sim-options_h) $(sim-io_h)
367 $(CC) -c $(srccom)/sim-profile.c $(ALL_CFLAGS)
369 sim-model.o: $(srccom)/sim-model.c $(sim_main_headers) \
371 $(CC) -c $(srccom)/sim-model.c $(ALL_CFLAGS)
373 sim-utils.o: $(srccom)/sim-utils.c $(sim_main_headers)
374 $(CC) -c $(srccom)/sim-utils.c $(ALL_CFLAGS)
376 sim-watch.o: $(srccom)/sim-watch.c $(sim_main_headers)
377 $(CC) -c $(srccom)/sim-watch.c $(ALL_CFLAGS)
379 sim-load.o: $(srccom)/sim-load.c $(srcroot)/include/callback.h
380 $(CC) -c $(srccom)/sim-load.c $(ALL_CFLAGS)
382 sim-break.o: $(srccom)/sim-break.c $(sim_main_headers) \
384 $(CC) -c $(srccom)/sim-break.c $(ALL_CFLAGS)
386 nrun.o: $(srccom)/nrun.c config.h tconfig.h \
387 $(srcroot)/include/callback.h $(sim_main_headers)
388 $(CC) -c $(srccom)/nrun.c $(ALL_CFLAGS)
392 cgen-run.o: $(srccom)/cgen-run.c $(sim_main_headers) \
393 $(srccom)/cgen-mem.h $(srccom)/cgen-ops.h \
394 $(srccom)/cgen-scache.h
395 $(CC) -c $(srccom)/cgen-run.c $(ALL_CFLAGS)
397 cgen-scache.o: $(srccom)/cgen-scache.c $(sim_main_headers) \
398 $(srccom)/cgen-scache.h
399 $(CC) -c $(srccom)/cgen-scache.c $(ALL_CFLAGS)
401 cgen-trace.o: $(srccom)/cgen-trace.c $(sim_main_headers) \
402 $(srccom)/cgen-trace.h
403 $(CC) -c $(srccom)/cgen-trace.c $(ALL_CFLAGS)
405 cgen-utils.o: $(srccom)/cgen-utils.c $(sim_main_headers) \
406 $(srccom)/cgen-mem.h $(srccom)/cgen-ops.h
407 $(CC) -c $(srccom)/cgen-utils.c $(ALL_CFLAGS)
411 install: install-common $(SIM_EXTRA_INSTALL)
413 install-common: installdirs
414 n=`echo run | sed '$(program_transform_name)'`; \
415 $(INSTALL_PROGRAM) run $(bindir)/$$n
418 $(SHELL) $(srcdir)/../../mkinstalldirs $(bindir)
432 etags --regex '/^\/[*] TAGS: .*/' *.c *.h
434 clean: $(SIM_EXTRA_CLEAN)
437 rm -f gentmap targ-map.c targ-vals.h
438 if [ ! -f Make-common.in ] ; then \
439 rm -f $(BUILT_SRC_FROM_COMMON) ; \
442 distclean mostlyclean maintainer-clean realclean: clean
444 rm -f Makefile config.cache config.log config.status .gdbinit
445 rm -f tconfig.h config.h stamp-h
449 $(CC) -c $(ALL_CFLAGS) $<
451 # Dummy target to force execution of dependent targets.
454 Makefile: Makefile.in $(srccom)/Make-common.in config.status
455 CONFIG_HEADERS= $(SHELL) ./config.status
457 config.status: configure
458 $(SHELL) ./config.status --recheck
460 config.h: stamp-h ; @true
461 stamp-h: config.in config.status
462 CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
464 .gdbinit: # config.status $(srccom)/gdbinit.in
465 CONFIG_FILES=$@:../common/gdbinit.in CONFIG_HEADERS= $(SHELL) ./config.status
467 ## End COMMON_POST_CONFIG_FRAG