* Make-common.in (srccom): New variable.
[deliverable/binutils-gdb.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 ## End COMMON_PRE_CONFIG_FRAG
129
130 ## COMMON_POST_CONFIG_FRAG
131
132 CONFIG_CFLAGS = @DEFS@ \
133 $(SIM_CFLAGS) \
134 $(SIM_DEBUG) \
135 $(SIM_DEFAULT_MODEL) \
136 $(SIM_TRACE) \
137 $(SIM_PROFILE) \
138 $(SIM_BSWAP) \
139 $(SIM_ASSERT) \
140 $(SIM_ALIGNMENT) \
141 $(SIM_BITSIZE) \
142 $(SIM_ENDIAN) \
143 $(SIM_FLOAT) \
144 $(SIM_HARDWARE) \
145 $(SIM_HOSTENDIAN) \
146 $(SIM_INLINE) \
147 $(SIM_PACKAGES) \
148 $(SIM_REGPARM) \
149 $(SIM_RESERVED_BITS) \
150 $(SIM_SCACHE) \
151 $(SIM_SMP) \
152 $(SIM_STDCALL) \
153 $(SIM_WARNINGS) \
154 $(SIM_XOR_ENDIAN) \
155 $(SIM_EXTRA_CFLAGS) \
156 $(HDEFINES) $(TDEFINES)
157 CSEARCH = -I. -I$(srcdir) -I../common -I$(srccom) \
158 -I../../include -I$(srcroot)/include \
159 -I../../bfd -I$(srcroot)/bfd \
160 -I../../opcodes -I$(srcroot)/opcodes
161 ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(CFLAGS)
162 BUILD_CFLAGS = -g -O $(CSEARCH)
163
164 COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH)
165
166 LIBIBERTY_LIB = ../../libiberty/libiberty.a
167 BFD_LIB = ../../bfd/libbfd.a
168 OPCODES_LIB = ../../opcodes/libopcodes.a
169 CONFIG_LIBS = @LIBS@
170 LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
171 $(SIM_EXTRA_LIBDEPS)
172 EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
173 $(CONFIG_LIBS) $(SIM_EXTRA_LIBS)
174
175 LIB_OBJS = callback.o syscall.o targ-map.o $(SIM_OBJS)
176
177 all: $(SIM_EXTRA_ALL) libsim.a run
178
179 libsim.a: $(LIB_OBJS)
180 rm -f libsim.a
181 $(AR) $(AR_FLAGS) libsim.a $(LIB_OBJS)
182 $(RANLIB) libsim.a
183
184 run: $(SIM_RUN_OBJS) libsim.a $(LIBDEPS)
185 $(CC) $(ALL_CFLAGS) -o run \
186 $(SIM_RUN_OBJS) libsim.a $(EXTRA_LIBS)
187
188 run.o: $(srccom)/run.c config.h tconfig.h \
189 $(srcroot)/include/callback.h
190 $(CC) -c $(srccom)/run.c $(ALL_CFLAGS)
191
192 # FIXME: Ideally, callback.o and friends live in a library outside of
193 # both the gdb and simulator source trees (e.g. devo/remote. Not
194 # devo/libremote because this directory would contain more than just
195 # a library).
196
197 callback.o: $(srccom)/callback.c config.h tconfig.h \
198 $(srcroot)/include/callback.h targ-vals.h
199 $(CC) -c $(srccom)/callback.c $(ALL_CFLAGS)
200
201 syscall.o: $(srccom)/syscall.c config.h tconfig.h \
202 $(srcroot)/include/callback.h targ-vals.h
203 $(CC) -c $(srccom)/syscall.c $(ALL_CFLAGS)
204
205 targ-map.o: targ-map.c targ-vals.h
206
207 gentmap: Makefile $(srccom)/gentmap.c targ-vals.def
208 $(CC_FOR_BUILD) $(srccom)/gentmap.c -o gentmap $(BUILD_CFLAGS) $(NL_TARGET)
209
210 targ-vals.h: gentmap
211 rm -f targ-vals.h
212 ./gentmap -h >targ-vals.h
213
214 targ-map.c: gentmap
215 rm -f targ-map.c
216 ./gentmap -c >targ-map.c
217
218
219 #
220 # Rules for building sim-* components. Triggered by listing the corresponding
221 # .o file in the list of simulator targets.
222 #
223
224 sim_main_headers = \
225 sim-main.h \
226 $(srccom)/sim-config.h \
227 $(srccom)/sim-base.h \
228 $(srccom)/sim-basics.h \
229 $(srccom)/sim-memopt.h \
230 $(srccom)/sim-model.h \
231 $(srccom)/sim-module.h \
232 $(srccom)/sim-trace.h \
233 $(srccom)/sim-profile.h \
234 $(srccom)/sim-engine.h \
235 $(srccom)/sim-events.h \
236 $(srccom)/sim-watch.h \
237 $(srccom)/sim-assert.h \
238 tconfig.h \
239 $(SIM_EXTRA_DEPS)
240
241 sim-assert_h = $(srccom)/sim-assert.h
242 sim-endian_h = $(srccom)/sim-endian.h
243 sim-n-endian_h = $(srccom)/sim-n-endian.h
244 sim-bits_h = $(srccom)/sim-bits.h
245 sim-config_h = $(srccom)/sim-config.h
246 sim-n-bits_h = $(srccom)/sim-n-bits.h
247 sim-core_h = $(srccom)/sim-core.h
248 sim-n-core_h = $(srccom)/sim-n-core.h
249 sim-engine_h = $(srccom)/sim-engine.h
250 sim-events_h = $(srccom)/sim-events.h
251 sim-fpu_h = $(srccom)/sim-fpu.h
252 sim-io_h = $(srccom)/sim-io.h
253 sim-options_h = $(srccom)/sim-options.h
254 sim-break_h = $(srccom)/sim-break.h
255
256 # FIXME: If this complicated way of building .o files from ../common is
257 # necessary, the reason should be documented here.
258
259 BUILT_SRC_FROM_COMMON= \
260 sim-inline.c
261
262 sim-abort.o: $(srccom)/sim-abort.c \
263 $(SIM_EXTRA_DEPS)
264 $(CC) -c $(srccom)/sim-abort.c $(ALL_CFLAGS)
265
266 sim-bits.o: $(srccom)/sim-bits.c $(sim-bits_h) $(sim-n-bits_h) \
267 $(SIM_EXTRA_DEPS)
268 $(CC) -c $(srccom)/sim-bits.c $(ALL_CFLAGS)
269
270 sim-config.o: $(srccom)/sim-config.c $(sim-config_h) \
271 $(SIM_EXTRA_DEPS)
272 $(CC) -c $(srccom)/sim-config.c $(ALL_CFLAGS)
273
274 sim-core.o: $(srccom)/sim-core.c $(sim-core_h) $(sim-n-core_h) \
275 $(SIM_EXTRA_DEPS)
276 $(CC) -c $(srccom)/sim-core.c $(ALL_CFLAGS)
277
278 sim-endian.o: $(srccom)/sim-endian.c $(sim-endian_h) $(sim-n-endian_h) \
279 $(SIM_EXTRA_DEPS)
280 $(CC) -c $(srccom)/sim-endian.c $(ALL_CFLAGS)
281
282 sim-engine.o: $(srccom)/sim-engine.c $(sim_main_headers) $(sim-engine_h)
283 $(CC) -c $(srccom)/sim-engine.c $(ALL_CFLAGS)
284
285 sim-events.o: $(srccom)/sim-events.c $(sim-events_h) \
286 $(SIM_EXTRA_DEPS)
287 $(CC) -c $(srccom)/sim-events.c $(ALL_CFLAGS)
288
289 sim-fpu.o: $(srccom)/sim-fpu.c $(sim-fpu_h) \
290 $(SIM_EXTRA_DEPS)
291 $(CC) -c $(srccom)/sim-fpu.c $(ALL_CFLAGS)
292
293 sim-hload.o: $(srccom)/sim-hload.c $(sim-assert_h) \
294 $(SIM_EXTRA_DEPS)
295 $(CC) -c $(srccom)/sim-hload.c $(ALL_CFLAGS)
296
297 sim-hrw.o: $(srccom)/sim-hrw.c $(sim-assert_h) \
298 $(SIM_EXTRA_DEPS)
299 $(CC) -c $(srccom)/sim-hrw.c $(ALL_CFLAGS)
300
301 sim-inline.c: $(srccom)/sim-inline.c
302 rm -f $@ tmp-$@
303 echo "# 1 \"$(srccom)/$@\"" > tmp-$@
304 cat $(srccom)/$@ >> tmp-$@
305 $(srcdir)/../../move-if-change tmp-$@ $@
306
307 sim-io.o: $(srccom)/sim-io.c $(sim_main_headers) $(sim-io_h)
308 $(CC) -c $(srccom)/sim-io.c $(ALL_CFLAGS)
309
310 sim-memopt.o: $(srccom)/sim-memopt.c $(sim_main_headers) \
311 $(sim-io_h)
312 $(CC) -c $(srccom)/sim-memopt.c $(ALL_CFLAGS)
313
314 sim-module.o: $(srccom)/sim-module.c $(sim_main_headers) \
315 $(sim-io_h)
316 $(CC) -c $(srccom)/sim-module.c $(ALL_CFLAGS)
317
318 sim-options.o: $(srccom)/sim-options.c $(sim_main_headers) \
319 $(sim-options_h) $(sim-io_h)
320 $(CC) -c $(srccom)/sim-options.c $(ALL_CFLAGS)
321
322 sim-reason.o: $(srccom)/sim-reason.c $(sim_main_headers)
323 $(CC) -c $(srccom)/sim-reason.c $(ALL_CFLAGS)
324
325 sim-resume.o: $(srccom)/sim-resume.c $(sim_main_headers)
326 $(CC) -c $(srccom)/sim-resume.c $(ALL_CFLAGS)
327
328 sim-run.o: $(srccom)/sim-run.c $(sim_main_headers)
329 $(CC) -c $(srccom)/sim-run.c $(ALL_CFLAGS)
330
331 sim-stop.o: $(srccom)/sim-stop.c $(sim_main_headers)
332 $(CC) -c $(srccom)/sim-stop.c $(ALL_CFLAGS)
333
334 sim-trace.o: $(srccom)/sim-trace.c $(sim_main_headers) \
335 $(sim-options_h) $(sim-io_h)
336 $(CC) -c $(srccom)/sim-trace.c $(ALL_CFLAGS)
337
338 sim-profile.o: $(srccom)/sim-profile.c $(sim_main_headers) \
339 $(sim-options_h) $(sim-io_h)
340 $(CC) -c $(srccom)/sim-profile.c $(ALL_CFLAGS)
341
342 sim-model.o: $(srccom)/sim-model.c $(sim_main_headers) \
343 $(sim-io_h)
344 $(CC) -c $(srccom)/sim-model.c $(ALL_CFLAGS)
345
346 sim-utils.o: $(srccom)/sim-utils.c $(sim_main_headers)
347 $(CC) -c $(srccom)/sim-utils.c $(ALL_CFLAGS)
348
349 sim-watch.o: $(srccom)/sim-watch.c $(sim_main_headers)
350 $(CC) -c $(srccom)/sim-watch.c $(ALL_CFLAGS)
351
352 sim-load.o: $(srccom)/sim-load.c $(srcroot)/include/callback.h
353 $(CC) -c $(srccom)/sim-load.c $(ALL_CFLAGS)
354
355 sim-break.o: $(srccom)/sim-break.c $(sim_main_headers) \
356 $(sim_break_h)
357 $(CC) -c $(srccom)/sim-break.c $(ALL_CFLAGS)
358
359 nrun.o: $(srccom)/nrun.c config.h tconfig.h \
360 $(srcroot)/include/callback.h $(sim_main_headers)
361 $(CC) -c $(srccom)/nrun.c $(ALL_CFLAGS)
362
363 # CGEN support.
364
365 cgen-run.o: $(srccom)/cgen-run.c $(sim_main_headers) \
366 $(srccom)/cgen-mem.h $(srccom)/cgen-ops.h \
367 $(srccom)/cgen-scache.h
368 $(CC) -c $(srccom)/cgen-run.c $(ALL_CFLAGS)
369
370 cgen-scache.o: $(srccom)/cgen-scache.c $(sim_main_headers) \
371 $(srccom)/cgen-scache.h
372 $(CC) -c $(srccom)/cgen-scache.c $(ALL_CFLAGS)
373
374 cgen-trace.o: $(srccom)/cgen-trace.c $(sim_main_headers) \
375 $(srccom)/cgen-trace.h
376 $(CC) -c $(srccom)/cgen-trace.c $(ALL_CFLAGS)
377
378 cgen-utils.o: $(srccom)/cgen-utils.c $(sim_main_headers) \
379 $(srccom)/cgen-mem.h $(srccom)/cgen-ops.h
380 $(CC) -c $(srccom)/cgen-utils.c $(ALL_CFLAGS)
381
382 # Support targets.
383
384 install: install-common $(SIM_EXTRA_INSTALL)
385
386 install-common: installdirs
387 n=`echo run | sed '$(program_transform_name)'`; \
388 $(INSTALL_PROGRAM) run $(bindir)/$$n
389
390 installdirs:
391 $(SHELL) $(srcdir)/../../mkinstalldirs $(bindir)
392
393 check:
394
395 info:
396 clean-info:
397 install-info:
398
399 .NOEXPORT:
400 MAKEOVERRIDES=
401
402 tags etags: TAGS
403
404 TAGS: force
405 etags --regex '/^\/[*] TAGS: .*/' *.c *.h
406
407 clean: $(SIM_EXTRA_CLEAN)
408 rm -f *.[oa] *~ core
409 rm -f run libsim.a
410 rm -f gentmap targ-map.c targ-vals.h
411 if [ ! -f Make-common.in ] ; then \
412 rm -f $(BUILT_SRC_FROM_COMMON) ; \
413 fi
414
415 distclean mostlyclean maintainer-clean realclean: clean
416 rm -f TAGS
417 rm -f Makefile config.cache config.log config.status .gdbinit
418 rm -f tconfig.h config.h stamp-h
419 rm -f targ-vals.def
420
421 .c.o:
422 $(CC) -c $(ALL_CFLAGS) $<
423
424 # Dummy target to force execution of dependent targets.
425 force:
426
427 Makefile: Makefile.in $(srccom)/Make-common.in config.status
428 CONFIG_HEADERS= $(SHELL) ./config.status
429
430 config.status: configure
431 $(SHELL) ./config.status --recheck
432
433 config.h: stamp-h ; @true
434 stamp-h: config.in config.status
435 CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
436
437 .gdbinit: # config.status $(srccom)/gdbinit.in
438 CONFIG_FILES=$@:../common/gdbinit.in CONFIG_HEADERS= $(SHELL) ./config.status
439
440 ## End COMMON_POST_CONFIG_FRAG
This page took 0.039158 seconds and 4 git commands to generate.