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_ENVIRONMENT = @sim_environment@
81 SIM_FLOAT = @sim_float@
82 SIM_HARDWARE = @sim_hardware@
83 SIM_HW_OBJS = @sim_hw_obj@
85 SIM_HOSTENDIAN = @sim_hostendian@
86 SIM_INLINE = @sim_inline@
87 SIM_PACKAGES = @sim_packages@
88 SIM_REGPARM = @sim_regparm@
89 SIM_RESERVED_BITS = @sim_reserved_bits@
90 SIM_SCACHE = @sim_scache@
92 SIM_STDCALL = @sim_stdcall@
93 SIM_WARNINGS = @sim_warnings@
94 SIM_XOR_ENDIAN = @sim_xor_endian@
104 DEP = $(srcroot)/mkdep
106 # Each simulator's Makefile.in defines one or more of these variables
107 # to override our settings as necessary. There is no need to define these
108 # in the simulator's Makefile.in if one is using the default value. In fact
109 # it's preferable not to.
111 # List of object files, less common parts.
113 # List of extra dependencies.
114 # Generally this consists of simulator specific files included by sim-main.h.
116 # List of flags to always pass to $(CC).
118 # List of extra libraries to link with.
120 # List of extra program dependencies.
122 # List of main object files for `run'.
124 # Dependency of `all' to build any extra files.
126 # Dependency of `install' to install any extra files.
128 # Dependency of `clean' to clean any extra files.
131 # Every time a new general purpose source file was added every target's
132 # Makefile.in needed to be updated to include the file in SIM_OBJS.
133 # This doesn't scale.
134 # This variable specifies all the generic stuff common to the newer simulators.
135 # Things like sim-reason.o can't go here as the cpu may provide its own
136 # (though hopefully in time that won't be so). Things like sim-bits.o can go
137 # here. Some files are used by all simulators (e.g. callback.o).
138 # Those files are specified in LIB_OBJS below.
140 SIM_NEW_COMMON_OBJS = \
163 ## End COMMON_PRE_CONFIG_FRAG
165 ## COMMON_POST_CONFIG_FRAG
171 $(SIM_DEFAULT_MODEL) \
186 $(SIM_RESERVED_BITS) \
193 $(SIM_EXTRA_CFLAGS) \
194 $(HDEFINES) $(TDEFINES)
195 CSEARCH = -I. -I$(srcdir) -I../common -I$(srccom) \
196 -I../../include -I$(srcroot)/include \
197 -I../../bfd -I$(srcroot)/bfd \
198 -I../../opcodes -I$(srcroot)/opcodes
199 ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(CFLAGS)
200 BUILD_CFLAGS = -g -O $(CSEARCH)
202 COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH)
204 LIBIBERTY_LIB = ../../libiberty/libiberty.a
205 BFD_LIB = ../../bfd/libbfd.a
206 OPCODES_LIB = ../../opcodes/libopcodes.a
208 LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
210 EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
211 $(CONFIG_LIBS) $(SIM_EXTRA_LIBS)
213 LIB_OBJS = callback.o syscall.o targ-map.o $(SIM_OBJS)
215 all: $(SIM_EXTRA_ALL) libsim.a run .gdbinit
217 libsim.a: $(LIB_OBJS)
219 $(AR) $(AR_FLAGS) libsim.a $(LIB_OBJS)
222 run: $(SIM_RUN_OBJS) libsim.a $(LIBDEPS)
223 $(CC) $(ALL_CFLAGS) -o run \
224 $(SIM_RUN_OBJS) libsim.a $(EXTRA_LIBS)
226 run.o: $(srccom)/run.c config.h tconfig.h \
227 $(srcroot)/include/remote-sim.h $(srcroot)/include/callback.h
228 $(CC) -c $(srccom)/run.c $(ALL_CFLAGS)
230 # FIXME: Ideally, callback.o and friends live in a library outside of
231 # both the gdb and simulator source trees (e.g. devo/remote. Not
232 # devo/libremote because this directory would contain more than just
235 callback.o: $(srccom)/callback.c config.h tconfig.h \
236 $(srcroot)/include/callback.h targ-vals.h
237 $(CC) -c $(srccom)/callback.c $(ALL_CFLAGS)
239 syscall.o: $(srccom)/syscall.c config.h tconfig.h \
240 $(srcroot)/include/callback.h targ-vals.h
241 $(CC) -c $(srccom)/syscall.c $(ALL_CFLAGS)
243 targ-map.o: targ-map.c targ-vals.h
245 gentmap: Makefile $(srccom)/gentmap.c targ-vals.def
246 $(CC_FOR_BUILD) $(srccom)/gentmap.c -o gentmap $(BUILD_CFLAGS) $(NL_TARGET)
248 targ-vals.h targ-map.c: stamp-tvals
250 rm -f tmp-tvals.h tmp-tmap.c
251 ./gentmap -h >tmp-tvals.h
252 $(SHELL) $(srcroot)/move-if-change tmp-tvals.h targ-vals.h
253 ./gentmap -c >tmp-tmap.c
254 $(SHELL) $(srcroot)/move-if-change tmp-tmap.c targ-map.c
258 # Rules for building sim-* components. Triggered by listing the corresponding
259 # .o file in the list of simulator targets.
264 $(srccom)/sim-inline.h \
265 $(srccom)/sim-config.h \
266 $(srccom)/sim-base.h \
267 $(srccom)/sim-basics.h \
268 $(srccom)/sim-signal.h \
269 $(srccom)/sim-memopt.h \
270 $(srccom)/sim-model.h \
271 $(srccom)/sim-module.h \
272 $(srccom)/sim-trace.h \
273 $(srccom)/sim-profile.h \
274 $(srccom)/sim-engine.h \
275 $(srccom)/sim-events.h \
276 $(srccom)/sim-watch.h \
277 $(srccom)/sim-assert.h \
281 sim-assert_h = $(srccom)/sim-assert.h
282 sim-endian_h = $(srccom)/sim-endian.h
283 sim-n-endian_h = $(srccom)/sim-n-endian.h
284 sim-bits_h = $(srccom)/sim-bits.h
285 sim-config_h = $(srccom)/sim-config.h
286 sim-n-bits_h = $(srccom)/sim-n-bits.h
287 sim-core_h = $(srccom)/sim-core.h
288 sim-n-core_h = $(srccom)/sim-n-core.h
289 sim-engine_h = $(srccom)/sim-engine.h
290 sim-events_h = $(srccom)/sim-events.h
291 sim-fpu_h = $(srccom)/sim-fpu.h
292 sim-io_h = $(srccom)/sim-io.h
293 sim-options_h = $(srccom)/sim-options.h
294 sim-break_h = $(srccom)/sim-break.h
295 sim-signal_h = $(srccom)/sim-signal.h
297 # start-sanitize-am30
298 hw-base_h = $(srccom)/hw-base.h
299 hw-device_h = $(srccom)/hw-device.h
300 hw-handles_h = #$(srccom)/hw-handles.h
301 hw-instances_h = #$(srccom)/hw-instances.h
302 hw-ports_h = $(srccom)/hw-ports.h
303 hw-properties_h = $(srccom)/hw-properties.h
304 hw-tree_h = $(srccom)/hw-tree.h
315 # FIXME: If this complicated way of building .o files from ../common is
316 # necessary, the reason should be documented here.
318 BUILT_SRC_FROM_COMMON= \
321 sim-abort.o: $(srccom)/sim-abort.c \
323 $(CC) -c $(srccom)/sim-abort.c $(ALL_CFLAGS)
325 sim-bits.o: $(srccom)/sim-bits.c $(sim-bits_h) $(sim-n-bits_h) \
327 $(CC) -c $(srccom)/sim-bits.c $(ALL_CFLAGS)
329 sim-config.o: $(srccom)/sim-config.c $(sim-config_h) \
331 $(CC) -c $(srccom)/sim-config.c $(ALL_CFLAGS)
333 sim-core.o: $(srccom)/sim-core.c $(sim_main_headers) \
334 $(sim-core_h) $(sim-n-core_h) \
336 $(CC) -c $(srccom)/sim-core.c $(ALL_CFLAGS)
338 sim-endian.o: $(srccom)/sim-endian.c $(sim-endian_h) $(sim-n-endian_h) \
340 $(CC) -c $(srccom)/sim-endian.c $(ALL_CFLAGS)
342 sim-engine.o: $(srccom)/sim-engine.c $(sim_main_headers) $(sim-engine_h)
343 $(CC) -c $(srccom)/sim-engine.c $(ALL_CFLAGS)
345 sim-events.o: $(srccom)/sim-events.c $(sim-events_h) \
347 $(CC) -c $(srccom)/sim-events.c $(ALL_CFLAGS)
349 sim-fpu.o: $(srccom)/sim-fpu.c $(sim-fpu_h) \
351 $(CC) -c $(srccom)/sim-fpu.c $(ALL_CFLAGS)
353 sim-hload.o: $(srccom)/sim-hload.c $(sim-assert_h) \
354 $(srcroot)/include/remote-sim.h \
356 $(CC) -c $(srccom)/sim-hload.c $(ALL_CFLAGS)
358 sim-hrw.o: $(srccom)/sim-hrw.c $(sim-assert_h) $(sim_core_h) \
359 $(srcroot)/include/remote-sim.h \
361 $(CC) -c $(srccom)/sim-hrw.c $(ALL_CFLAGS)
364 sim-hw.o: $(srccom)/sim-hw.c $(sim_main_headers) $(SIM_EXTRA_DEPS)
365 $(CC) -c $(srccom)/sim-hw.c $(ALL_CFLAGS)
368 sim-info.o: $(srccom)/sim-info.c $(sim-assert_h) \
369 $(srcroot)/include/remote-sim.h \
371 $(CC) -c $(srccom)/sim-info.c $(ALL_CFLAGS)
373 sim-inline.c: $(srccom)/sim-inline.c
375 echo "# 1 \"$(srccom)/$@\"" > tmp-$@
376 cat $(srccom)/$@ >> tmp-$@
377 $(SHELL) $(srcdir)/../../move-if-change tmp-$@ $@
379 sim-io.o: $(srccom)/sim-io.c $(sim_main_headers) $(sim-io_h) \
380 $(srcroot)/include/remote-sim.h
381 $(CC) -c $(srccom)/sim-io.c $(ALL_CFLAGS)
383 sim-memopt.o: $(srccom)/sim-memopt.c $(sim_main_headers) \
385 $(CC) -c $(srccom)/sim-memopt.c $(ALL_CFLAGS)
387 sim-module.o: $(srccom)/sim-module.c $(sim_main_headers) \
389 $(CC) -c $(srccom)/sim-module.c $(ALL_CFLAGS)
391 sim-options.o: $(srccom)/sim-options.c $(sim_main_headers) \
392 $(sim-options_h) $(sim-io_h)
393 $(CC) -c $(srccom)/sim-options.c $(ALL_CFLAGS)
395 sim-reason.o: $(srccom)/sim-reason.c $(sim_main_headers) \
396 $(srcroot)/include/remote-sim.h
397 $(CC) -c $(srccom)/sim-reason.c $(ALL_CFLAGS)
399 sim-resume.o: $(srccom)/sim-resume.c $(sim_main_headers) \
400 $(srcroot)/include/remote-sim.h
401 $(CC) -c $(srccom)/sim-resume.c $(ALL_CFLAGS)
403 sim-run.o: $(srccom)/sim-run.c $(sim_main_headers)
404 $(CC) -c $(srccom)/sim-run.c $(ALL_CFLAGS)
406 sim-signal.o: $(srccom)/sim-signal.c $(sim_main_headers) $(sim-signal_h)
407 $(CC) -c $(srccom)/sim-signal.c $(ALL_CFLAGS)
409 sim-stop.o: $(srccom)/sim-stop.c $(sim_main_headers)
410 $(CC) -c $(srccom)/sim-stop.c $(ALL_CFLAGS)
412 sim-trace.o: $(srccom)/sim-trace.c $(sim_main_headers) \
413 $(sim-options_h) $(sim-io_h)
414 $(CC) -c $(srccom)/sim-trace.c $(ALL_CFLAGS)
416 sim-profile.o: $(srccom)/sim-profile.c $(sim_main_headers) \
417 $(sim-options_h) $(sim-io_h)
418 $(CC) -c $(srccom)/sim-profile.c $(ALL_CFLAGS)
420 sim-model.o: $(srccom)/sim-model.c $(sim_main_headers) \
422 $(CC) -c $(srccom)/sim-model.c $(ALL_CFLAGS)
424 sim-utils.o: $(srccom)/sim-utils.c $(sim_main_headers)
425 $(CC) -c $(srccom)/sim-utils.c $(ALL_CFLAGS)
427 sim-watch.o: $(srccom)/sim-watch.c $(sim_main_headers)
428 $(CC) -c $(srccom)/sim-watch.c $(ALL_CFLAGS)
430 sim-load.o: $(srccom)/sim-load.c $(srcroot)/include/callback.h
431 $(CC) -c $(srccom)/sim-load.c $(ALL_CFLAGS)
433 sim-break.o: $(srccom)/sim-break.c $(sim_main_headers) \
435 $(CC) -c $(srccom)/sim-break.c $(ALL_CFLAGS)
438 # start-sanitize-am30
439 # FIXME This is one very simple-minded way of generating the file hw-config.h
440 hw-config.h: Makefile.in $(srccom)/Make-common.in config.status Makefile
442 echo "/* generated by Makefile */" > tmp-hw.h
443 for hw in $(SIM_HW) ; do \
444 echo "extern const struct hw_device_descriptor dv_$${hw}_descriptor[];" ; \
446 echo "const struct hw_device_descriptor *hw_descriptors[] = {" >> tmp-hw.h
447 for hw in $(SIM_HW) ; do \
448 echo " dv_$${hw}_descriptor," ; \
450 echo " NULL," >> tmp-hw.h
451 echo "};" >> tmp-hw.h
452 mv tmp-hw.h hw-config.h
454 hw-base.o: $(srccom)/hw-base.c $(sim_main_headers) \
455 $(hw_base_headers) hw-config.h
456 $(CC) -c $(srccom)/hw-base.c $(ALL_CFLAGS)
458 hw-device.o: $(srccom)/hw-device.c $(sim_main_headers) \
460 $(CC) -c $(srccom)/hw-device.c $(ALL_CFLAGS)
462 hw-instances.o: $(srccom)/hw-instances.c $(sim_main_headers) \
464 $(CC) -c $(srccom)/hw-instances.c $(ALL_CFLAGS)
466 hw-handles.o: $(srccom)/hw-handles.c $(sim_main_headers) \
468 $(CC) -c $(srccom)/hw-handles.c $(ALL_CFLAGS)
470 hw-ports.o: $(srccom)/hw-ports.c $(sim_main_headers) \
472 $(CC) -c $(srccom)/hw-ports.c $(ALL_CFLAGS)
474 hw-properties.o: $(srccom)/hw-properties.c $(sim_main_headers) \
476 $(CC) -c $(srccom)/hw-properties.c $(ALL_CFLAGS)
478 hw-tree.o: $(srccom)/hw-tree.c $(sim_main_headers) \
479 $(hw-tree_h) $(hw_base_headers)
480 $(CC) -c $(srccom)/hw-tree.c $(ALL_CFLAGS)
483 dv-core.o: $(srccom)/dv-core.c $(sim_main_headers) \
484 $(sim-main_h) $(hw_base_headers)
485 $(CC) -c $(srccom)/dv-core.c $(ALL_CFLAGS)
487 dv-glue.o: $(srccom)/dv-glue.c $(sim_main_headers) \
488 $(sim-main_h) $(hw_base_headers)
489 $(CC) -c $(srccom)/dv-glue.c $(ALL_CFLAGS)
491 dv-pal.o: $(srccom)/dv-pal.c $(sim_main_headers) \
492 $(sim-main_h) $(hw_base_headers)
493 $(CC) -c $(srccom)/dv-pal.c $(ALL_CFLAGS)
497 nrun.o: $(srccom)/nrun.c config.h tconfig.h \
498 $(srcroot)/include/remote-sim.h $(srcroot)/include/callback.h \
500 $(CC) -c $(srccom)/nrun.c $(ALL_CFLAGS)
504 dv-sockser.o: $(srccom)/dv-sockser.h $(sim_main_headers)
505 $(CC) -c $(srccom)/dv-sockser.c $(ALL_CFLAGS)
509 cgen-run.o: $(srccom)/cgen-run.c $(sim_main_headers) \
510 $(srccom)/cgen-mem.h $(srccom)/cgen-ops.h
511 $(CC) -c $(srccom)/cgen-run.c $(ALL_CFLAGS)
513 cgen-scache.o: $(srccom)/cgen-scache.c $(sim_main_headers)
514 $(CC) -c $(srccom)/cgen-scache.c $(ALL_CFLAGS)
516 cgen-trace.o: $(srccom)/cgen-trace.c $(sim_main_headers) \
517 $(srccom)/cgen-trace.h
518 $(CC) -c $(srccom)/cgen-trace.c $(ALL_CFLAGS)
520 cgen-utils.o: $(srccom)/cgen-utils.c $(sim_main_headers) \
521 $(srccom)/cgen-mem.h $(srccom)/cgen-ops.h
522 $(CC) -c $(srccom)/cgen-utils.c $(ALL_CFLAGS)
526 install: install-common $(SIM_EXTRA_INSTALL)
528 install-common: installdirs
529 n=`echo run | sed '$(program_transform_name)'`; \
530 $(INSTALL_PROGRAM) run $(bindir)/$$n
533 $(SHELL) $(srcdir)/../../mkinstalldirs $(bindir)
536 cd ../testsuite && $(MAKE) check
547 # Macros like EXTERN_SIM_CORE confuse tags.
548 # And the sim-n-foo.h files create functions that can't be found either.
551 etags --regex '/^\([a-z_]+\) (/\1/' --regex '/^\/[*] TAGS: .*/' \
552 *.[ch] ../common/*.[ch]
554 clean: $(SIM_EXTRA_CLEAN)
557 rm -f gentmap targ-map.c targ-vals.h stamp-tvals
558 if [ ! -f Make-common.in ] ; then \
559 rm -f $(BUILT_SRC_FROM_COMMON) ; \
562 distclean mostlyclean maintainer-clean realclean: clean
564 rm -f Makefile config.cache config.log config.status .gdbinit
565 rm -f tconfig.h config.h stamp-h
569 $(CC) -c $(ALL_CFLAGS) $<
571 # Dummy target to force execution of dependent targets.
574 Makefile: Makefile.in $(srccom)/Make-common.in config.status
575 CONFIG_HEADERS= $(SHELL) ./config.status
577 config.status: configure
578 $(SHELL) ./config.status --recheck
580 config.h: stamp-h ; @true
581 stamp-h: config.in config.status
582 CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
584 .gdbinit: # config.status $(srccom)/gdbinit.in
585 CONFIG_FILES=$@:../common/gdbinit.in CONFIG_HEADERS= $(SHELL) ./config.status
587 # start-sanitize-cygnus
593 srccgen = $(srcroot)/cgen
596 CGEN_MAIN_SCM = $(srccgen)/object.scm $(srccgen)/utils.scm \
597 $(srccgen)/attr.scm $(srccgen)/enum.scm $(srccgen)/types.scm \
598 $(srccgen)/utils-cgen.scm $(srccgen)/cpu.scm \
599 $(srccgen)/mode.scm $(srccgen)/mach.scm \
600 $(srccgen)/model.scm $(srccgen)/hardware.scm \
601 $(srccgen)/ifield.scm $(srccgen)/iformat.scm \
602 $(srccgen)/operand.scm $(srccgen)/insn.scm \
603 $(srccgen)/cdl-c.scm $(srccgen)/sim.scm
604 CGEN_CPU_SCM = $(srccgen)/sim-cpu.scm $(srccgen)/sim-model.scm
605 CGEN_DECODE_SCM = $(srccgen)/sim-decode.scm
607 # Various choices for which cpu specific files to generate.
608 CGEN_CPU_EXTR = -E tmp-ext.c1
609 CGEN_CPU_READ = -R tmp-read.c1
610 CGEN_CPU_SEM = -S tmp-sem.c1
611 CGEN_CPU_SEMSW = -W tmp-semsw.c1
613 # We store the generated files in the source directory until we decide to
614 # ship a Scheme interpreter with gdb/binutils. Maybe we never will.
617 $(SHELL) $(srccom)/cgen.sh arch $(srcdir) \
618 $(SCHEME) $(SCHEMEFLAGS) \
619 $(srccgen) $(CGEN_VERBOSE) \
620 $(arch) "$(FLAGS)" ignored ignored ignored ignored
623 $(SHELL) $(srccom)/cgen.sh cpu $(srcdir) \
624 $(SCHEME) $(SCHEMEFLAGS) \
625 $(srccgen) $(CGEN_VERBOSE) \
626 $(arch) "$(FLAGS)" $(cpu) $(mach) "$(SUFFIX)" "$(EXTRAFILES)"
629 $(SHELL) $(srccom)/cgen.sh decode $(srcdir) \
630 $(SCHEME) $(SCHEMEFLAGS) \
631 $(srccgen) $(CGEN_VERBOSE) \
632 $(arch) "$(FLAGS)" $(cpu) $(mach) "$(SUFFIX)" ignored
634 # end-sanitize-cygnus
636 ## End COMMON_POST_CONFIG_FRAG