Clarify meaning of sim_signalled's SIGRC argument. Document that this
[platform/upstream/binutils.git] / sim / common / Make-common.in
1 # Makefile fragment for common parts of all simulators.
2 # Copyright (C) 1997 Free Software Foundation, Inc.
3 # Contributed by Cygnus Support.
4
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.
9
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.
14
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.
18
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".
22 #
23 # The target Makefile should look like:
24 #
25 #># Copyright blah blah
26 #>
27 #>## COMMON_PRE_CONFIG_FRAG
28 #>
29 #># Any overrides necessary for the SIM_FOO config vars.
30 #>SIM_FOO = ...
31 #>
32 #>## COMMON_POST_CONFIG_FRAG
33 #>
34 #># Rules to build target specific .o's.
35
36 ## COMMON_PRE_CONFIG_FRAG
37
38 VPATH = @srcdir@
39 srcdir = @srcdir@
40 srccom = $(srcdir)/../common
41 srcroot = $(srcdir)/../..
42
43 prefix = @prefix@
44 exec_prefix = @exec_prefix@
45
46 host_alias = @host_alias@
47 target_alias = @target_alias@
48 program_transform_name = @program_transform_name@
49 bindir = @bindir@
50
51 libdir = @libdir@
52 tooldir = $(libdir)/$(target_alias)
53
54 datadir = @datadir@
55 mandir = @mandir@
56 man1dir = $(mandir)/man1
57 infodir = @infodir@
58 includedir = @includedir@
59
60 SHELL = /bin/sh
61
62 INSTALL = @INSTALL@
63 INSTALL_PROGRAM = @INSTALL_PROGRAM@
64 INSTALL_DATA = @INSTALL_DATA@
65
66 CC = @CC@
67 CC_FOR_BUILD = @CC_FOR_BUILD@
68 CFLAGS = @CFLAGS@
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@
74
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@
88 SIM_SMP = @sim_smp@
89 SIM_STDCALL = @sim_stdcall@
90 SIM_WARNINGS = @sim_warnings@
91 SIM_XOR_ENDIAN = @sim_xor_endian@
92
93 HDEFINES = @HDEFINES@
94 TDEFINES =
95
96 AR = @AR@
97 AR_FLAGS = rc
98 RANLIB = @RANLIB@
99 MAKEINFO = makeinfo
100
101 DEP = $(srcroot)/mkdep
102
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.
107
108 # List of object files, less common parts.
109 SIM_OBJS =
110 # List of extra dependencies.
111 # Generally this consists of simulator specific files included by sim-main.h.
112 SIM_EXTRA_DEPS =
113 # List of flags to always pass to $(CC).
114 SIM_EXTRA_CFLAGS =
115 # List of extra libraries to link with.
116 SIM_EXTRA_LIBS =
117 # List of extra program dependencies.
118 SIM_EXTRA_LIBDEPS =
119 # List of main object files for `run'.
120 SIM_RUN_OBJS = run.o
121 # Dependency of `all' to build any extra files.
122 SIM_EXTRA_ALL =
123 # Dependency of `install' to install any extra files.
124 SIM_EXTRA_INSTALL =
125 # Dependency of `clean' to clean any extra files.
126 SIM_EXTRA_CLEAN =
127
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.
136
137 SIM_NEW_COMMON_OBJS = \
138         sim-bits.o \
139         sim-break.o \
140         sim-config.o \
141         sim-core.o \
142         sim-endian.o \
143         sim-events.o \
144         sim-fpu.o \
145         sim-io.o \
146         sim-load.o \
147         sim-memopt.o \
148         sim-module.o \
149         sim-options.o \
150         sim-profile.o \
151         sim-signal.o \
152         sim-trace.o \
153         sim-utils.o \
154         sim-watch.o
155
156 ## End COMMON_PRE_CONFIG_FRAG
157
158 ## COMMON_POST_CONFIG_FRAG
159
160 CONFIG_CFLAGS = @DEFS@ \
161         $(SIM_CFLAGS) \
162         $(SIM_DEBUG) \
163         $(SIM_DEFAULT_MODEL) \
164         $(SIM_TRACE) \
165         $(SIM_PROFILE) \
166         $(SIM_BSWAP) \
167         $(SIM_ASSERT) \
168         $(SIM_ALIGNMENT) \
169         $(SIM_BITSIZE) \
170         $(SIM_ENDIAN) \
171         $(SIM_FLOAT) \
172         $(SIM_HARDWARE) \
173         $(SIM_HOSTENDIAN) \
174         $(SIM_INLINE) \
175         $(SIM_PACKAGES) \
176         $(SIM_REGPARM) \
177         $(SIM_RESERVED_BITS) \
178         $(SIM_SCACHE) \
179         $(SIM_SMP) \
180         $(SIM_STDCALL) \
181         $(SIM_WARNINGS) \
182         $(SIM_XOR_ENDIAN) \
183         $(SIM_EXTRA_CFLAGS) \
184         $(HDEFINES) $(TDEFINES)
185 CSEARCH = -I. -I$(srcdir) -I../common -I$(srccom) \
186   -I../../include -I$(srcroot)/include \
187   -I../../bfd -I$(srcroot)/bfd \
188   -I../../opcodes -I$(srcroot)/opcodes
189 ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(CFLAGS)
190 BUILD_CFLAGS = -g -O $(CSEARCH)
191
192 COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH)
193
194 LIBIBERTY_LIB = ../../libiberty/libiberty.a
195 BFD_LIB = ../../bfd/libbfd.a
196 OPCODES_LIB = ../../opcodes/libopcodes.a
197 CONFIG_LIBS = @LIBS@
198 LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
199         $(SIM_EXTRA_LIBDEPS)
200 EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
201         $(CONFIG_LIBS) $(SIM_EXTRA_LIBS)
202
203 LIB_OBJS = callback.o syscall.o targ-map.o $(SIM_OBJS)
204
205 all: $(SIM_EXTRA_ALL) libsim.a run
206
207 libsim.a: $(LIB_OBJS)
208         rm -f libsim.a
209         $(AR) $(AR_FLAGS) libsim.a $(LIB_OBJS)
210         $(RANLIB) libsim.a
211
212 run: $(SIM_RUN_OBJS) libsim.a $(LIBDEPS)
213         $(CC) $(ALL_CFLAGS) -o run \
214           $(SIM_RUN_OBJS) libsim.a $(EXTRA_LIBS)
215
216 run.o: $(srccom)/run.c config.h tconfig.h \
217           $(srcroot)/include/callback.h
218         $(CC) -c $(srccom)/run.c $(ALL_CFLAGS)
219
220 # FIXME: Ideally, callback.o and friends live in a library outside of
221 # both the gdb and simulator source trees (e.g. devo/remote.  Not
222 # devo/libremote because this directory would contain more than just
223 # a library).
224
225 callback.o: $(srccom)/callback.c config.h tconfig.h \
226           $(srcroot)/include/callback.h targ-vals.h
227         $(CC) -c $(srccom)/callback.c $(ALL_CFLAGS)
228
229 syscall.o: $(srccom)/syscall.c config.h tconfig.h \
230           $(srcroot)/include/callback.h targ-vals.h
231         $(CC) -c $(srccom)/syscall.c $(ALL_CFLAGS)
232
233 targ-map.o: targ-map.c targ-vals.h
234
235 gentmap: Makefile $(srccom)/gentmap.c targ-vals.def
236         $(CC_FOR_BUILD) $(srccom)/gentmap.c -o gentmap $(BUILD_CFLAGS) $(NL_TARGET)
237
238 targ-vals.h: gentmap
239         rm -f targ-vals.h
240         ./gentmap -h >targ-vals.h
241
242 targ-map.c: gentmap
243         rm -f targ-map.c
244         ./gentmap -c >targ-map.c
245
246
247 #
248 # Rules for building sim-* components.  Triggered by listing the corresponding
249 # .o file in the list of simulator targets.
250 #
251
252 sim_main_headers = \
253         sim-main.h \
254         $(srccom)/sim-config.h \
255         $(srccom)/sim-base.h \
256         $(srccom)/sim-basics.h \
257         $(srccom)/sim-signal.h \
258         $(srccom)/sim-memopt.h \
259         $(srccom)/sim-model.h \
260         $(srccom)/sim-module.h \
261         $(srccom)/sim-trace.h \
262         $(srccom)/sim-profile.h \
263         $(srccom)/sim-engine.h \
264         $(srccom)/sim-events.h \
265         $(srccom)/sim-watch.h \
266         $(srccom)/sim-assert.h \
267         tconfig.h \
268         $(SIM_EXTRA_DEPS)
269
270 sim-assert_h = $(srccom)/sim-assert.h
271 sim-endian_h = $(srccom)/sim-endian.h
272 sim-n-endian_h = $(srccom)/sim-n-endian.h
273 sim-bits_h = $(srccom)/sim-bits.h
274 sim-config_h = $(srccom)/sim-config.h
275 sim-n-bits_h = $(srccom)/sim-n-bits.h
276 sim-core_h = $(srccom)/sim-core.h
277 sim-n-core_h = $(srccom)/sim-n-core.h
278 sim-engine_h = $(srccom)/sim-engine.h
279 sim-events_h = $(srccom)/sim-events.h
280 sim-fpu_h = $(srccom)/sim-fpu.h
281 sim-io_h = $(srccom)/sim-io.h
282 sim-options_h = $(srccom)/sim-options.h
283 sim-break_h = $(srccom)/sim-break.h
284 sim-signal_h = $(srccom)/sim-signal.h
285
286 # FIXME: If this complicated way of building .o files from ../common is
287 # necessary, the reason should be documented here.
288
289 BUILT_SRC_FROM_COMMON= \
290         sim-inline.c
291
292 sim-abort.o: $(srccom)/sim-abort.c \
293           $(SIM_EXTRA_DEPS)
294         $(CC) -c $(srccom)/sim-abort.c $(ALL_CFLAGS)
295
296 sim-bits.o: $(srccom)/sim-bits.c $(sim-bits_h) $(sim-n-bits_h) \
297           $(SIM_EXTRA_DEPS)
298         $(CC) -c $(srccom)/sim-bits.c $(ALL_CFLAGS)
299
300 sim-config.o: $(srccom)/sim-config.c $(sim-config_h) \
301         $(SIM_EXTRA_DEPS)
302         $(CC) -c $(srccom)/sim-config.c $(ALL_CFLAGS)
303
304 sim-core.o: $(srccom)/sim-core.c $(sim-core_h) $(sim-n-core_h) \
305           $(SIM_EXTRA_DEPS)
306         $(CC) -c $(srccom)/sim-core.c $(ALL_CFLAGS)
307
308 sim-endian.o: $(srccom)/sim-endian.c $(sim-endian_h) $(sim-n-endian_h) \
309           $(SIM_EXTRA_DEPS)
310         $(CC) -c $(srccom)/sim-endian.c $(ALL_CFLAGS)
311
312 sim-engine.o: $(srccom)/sim-engine.c $(sim_main_headers) $(sim-engine_h)
313         $(CC) -c $(srccom)/sim-engine.c $(ALL_CFLAGS)
314
315 sim-events.o: $(srccom)/sim-events.c $(sim-events_h) \
316           $(SIM_EXTRA_DEPS)
317         $(CC) -c $(srccom)/sim-events.c $(ALL_CFLAGS)
318
319 sim-fpu.o: $(srccom)/sim-fpu.c $(sim-fpu_h) \
320           $(SIM_EXTRA_DEPS)
321         $(CC) -c $(srccom)/sim-fpu.c $(ALL_CFLAGS)
322
323 sim-hload.o: $(srccom)/sim-hload.c $(sim-assert_h) \
324           $(SIM_EXTRA_DEPS)
325         $(CC) -c $(srccom)/sim-hload.c $(ALL_CFLAGS)
326
327 sim-hrw.o: $(srccom)/sim-hrw.c $(sim-assert_h) \
328           $(SIM_EXTRA_DEPS)
329         $(CC) -c $(srccom)/sim-hrw.c $(ALL_CFLAGS)
330
331 sim-inline.c: $(srccom)/sim-inline.c
332         rm -f $@ tmp-$@
333         echo "# 1 \"$(srccom)/$@\"" > tmp-$@
334         cat $(srccom)/$@ >> tmp-$@
335         $(srcdir)/../../move-if-change tmp-$@ $@
336
337 sim-io.o: $(srccom)/sim-io.c $(sim_main_headers) $(sim-io_h)
338         $(CC) -c $(srccom)/sim-io.c $(ALL_CFLAGS)
339
340 sim-memopt.o: $(srccom)/sim-memopt.c $(sim_main_headers) \
341           $(sim-io_h)
342         $(CC) -c $(srccom)/sim-memopt.c $(ALL_CFLAGS)
343
344 sim-module.o: $(srccom)/sim-module.c $(sim_main_headers) \
345           $(sim-io_h)
346         $(CC) -c $(srccom)/sim-module.c $(ALL_CFLAGS)
347
348 sim-options.o: $(srccom)/sim-options.c $(sim_main_headers) \
349           $(sim-options_h) $(sim-io_h)
350         $(CC) -c $(srccom)/sim-options.c $(ALL_CFLAGS)
351
352 sim-reason.o: $(srccom)/sim-reason.c $(sim_main_headers)
353         $(CC) -c $(srccom)/sim-reason.c $(ALL_CFLAGS)
354
355 sim-resume.o: $(srccom)/sim-resume.c $(sim_main_headers)
356         $(CC) -c $(srccom)/sim-resume.c $(ALL_CFLAGS)
357
358 sim-run.o: $(srccom)/sim-run.c $(sim_main_headers)
359         $(CC) -c $(srccom)/sim-run.c $(ALL_CFLAGS)
360
361 sim-signal.o: $(srccom)/sim-signal.c $(sim_main_headers) $(sim-signal_h)
362         $(CC) -c $(srccom)/sim-signal.c $(ALL_CFLAGS)
363
364 sim-stop.o: $(srccom)/sim-stop.c $(sim_main_headers)
365         $(CC) -c $(srccom)/sim-stop.c $(ALL_CFLAGS)
366
367 sim-trace.o: $(srccom)/sim-trace.c $(sim_main_headers) \
368           $(sim-options_h) $(sim-io_h)
369         $(CC) -c $(srccom)/sim-trace.c $(ALL_CFLAGS)
370
371 sim-profile.o: $(srccom)/sim-profile.c $(sim_main_headers) \
372           $(sim-options_h) $(sim-io_h)
373         $(CC) -c $(srccom)/sim-profile.c $(ALL_CFLAGS)
374
375 sim-model.o: $(srccom)/sim-model.c $(sim_main_headers) \
376           $(sim-io_h)
377         $(CC) -c $(srccom)/sim-model.c $(ALL_CFLAGS)
378
379 sim-utils.o: $(srccom)/sim-utils.c $(sim_main_headers)
380         $(CC) -c $(srccom)/sim-utils.c $(ALL_CFLAGS)
381
382 sim-watch.o: $(srccom)/sim-watch.c $(sim_main_headers)
383         $(CC) -c $(srccom)/sim-watch.c $(ALL_CFLAGS)
384
385 sim-load.o: $(srccom)/sim-load.c $(srcroot)/include/callback.h
386         $(CC) -c $(srccom)/sim-load.c $(ALL_CFLAGS)
387
388 sim-break.o: $(srccom)/sim-break.c $(sim_main_headers) \
389           $(sim_break_h)
390         $(CC) -c $(srccom)/sim-break.c $(ALL_CFLAGS)
391
392 nrun.o: $(srccom)/nrun.c config.h tconfig.h \
393           $(srcroot)/include/callback.h $(sim_main_headers)
394         $(CC) -c $(srccom)/nrun.c $(ALL_CFLAGS)
395
396 # CGEN support.
397
398 cgen-run.o: $(srccom)/cgen-run.c $(sim_main_headers) \
399           $(srccom)/cgen-mem.h $(srccom)/cgen-ops.h \
400           $(srccom)/cgen-scache.h
401         $(CC) -c $(srccom)/cgen-run.c $(ALL_CFLAGS)
402
403 cgen-scache.o: $(srccom)/cgen-scache.c $(sim_main_headers) \
404           $(srccom)/cgen-scache.h
405         $(CC) -c $(srccom)/cgen-scache.c $(ALL_CFLAGS)
406
407 cgen-trace.o: $(srccom)/cgen-trace.c $(sim_main_headers) \
408           $(srccom)/cgen-trace.h
409         $(CC) -c $(srccom)/cgen-trace.c $(ALL_CFLAGS)
410
411 cgen-utils.o: $(srccom)/cgen-utils.c $(sim_main_headers) \
412           $(srccom)/cgen-mem.h $(srccom)/cgen-ops.h
413         $(CC) -c $(srccom)/cgen-utils.c $(ALL_CFLAGS)
414
415 # Support targets.
416
417 install: install-common $(SIM_EXTRA_INSTALL)
418
419 install-common: installdirs
420         n=`echo run | sed '$(program_transform_name)'`; \
421         $(INSTALL_PROGRAM) run $(bindir)/$$n
422
423 installdirs:
424         $(SHELL) $(srcdir)/../../mkinstalldirs $(bindir)
425
426 check:
427
428 info:
429 clean-info:
430 install-info:
431
432 .NOEXPORT:
433 MAKEOVERRIDES=
434
435 tags etags: TAGS
436
437 TAGS: force
438         etags --regex '/^\/[*] TAGS: .*/' *.c *.h
439
440 clean: $(SIM_EXTRA_CLEAN)
441         rm -f *.[oa] *~ core
442         rm -f run libsim.a
443         rm -f gentmap targ-map.c targ-vals.h
444         if [ ! -f Make-common.in ] ; then \
445                 rm -f $(BUILT_SRC_FROM_COMMON) ; \
446         fi
447
448 distclean mostlyclean maintainer-clean realclean: clean
449         rm -f TAGS
450         rm -f Makefile config.cache config.log config.status .gdbinit
451         rm -f tconfig.h config.h stamp-h
452         rm -f targ-vals.def
453
454 .c.o:
455         $(CC) -c $(ALL_CFLAGS) $<
456
457 # Dummy target to force execution of dependent targets.
458 force:
459
460 Makefile: Makefile.in $(srccom)/Make-common.in config.status
461         CONFIG_HEADERS= $(SHELL) ./config.status
462
463 config.status: configure
464         $(SHELL) ./config.status --recheck
465
466 config.h: stamp-h ; @true
467 stamp-h: config.in config.status
468         CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
469
470 .gdbinit: # config.status $(srccom)/gdbinit.in
471         CONFIG_FILES=$@:../common/gdbinit.in CONFIG_HEADERS= $(SHELL) ./config.status
472
473 ## End COMMON_POST_CONFIG_FRAG