]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - sim/common/Make-common.in
Remove need to update <targ>/Makefile.in when adding optional options
[thirdparty/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 srcroot = $(srcdir)/../..
41
42 prefix = @prefix@
43 exec_prefix = @exec_prefix@
44
45 host_alias = @host_alias@
46 target_alias = @target_alias@
47 program_transform_name = @program_transform_name@
48 bindir = @bindir@
49
50 libdir = @libdir@
51 tooldir = $(libdir)/$(target_alias)
52
53 datadir = @datadir@
54 mandir = @mandir@
55 man1dir = $(mandir)/man1
56 infodir = @infodir@
57 includedir = @includedir@
58
59 SHELL = /bin/sh
60
61 INSTALL = @INSTALL@
62 INSTALL_PROGRAM = @INSTALL_PROGRAM@
63 INSTALL_DATA = @INSTALL_DATA@
64
65 CC = @CC@
66 CC_FOR_BUILD = @CC_FOR_BUILD@
67 CFLAGS = @CFLAGS@
68 SIM_BSWAP = @sim_bswap@
69 SIM_CFLAGS = @sim_cflags@
70 SIM_DEBUG = @sim_debug@
71 SIM_TRACE = @sim_trace@
72 SIM_PROFILE = @sim_profile@
73
74 SIM_ASSERT = @sim_assert@
75 SIM_ALIGNMENT = @sim_alignment@
76 SIM_ENDIAN = @sim_endian@
77 SIM_FLOAT = @sim_float@
78 SIM_HARDWARE = @sim_hardware@
79 SIM_HOSTENDIAN = @sim_hostendian@
80 SIM_INLINE = @sim_inline@
81 SIM_PACKAGES = @sim_packages@
82 SIM_REGPARM = @sim_regparm@
83 SIM_RESERVED_BITS = @sim_reserved_bits@
84 SIM_SMP = @sim_smp@
85 SIM_STDCALL = @sim_stdcall@
86 SIM_WARNINGS = @sim_warnings@
87 SIM_XOR_ENDIAN = @sim_xor_endian@
88
89
90 HDEFINES = @HDEFINES@
91 TDEFINES =
92
93 AR = @AR@
94 AR_FLAGS = rc
95 RANLIB = @RANLIB@
96 MAKEINFO = makeinfo
97
98 # Each simulator's Makefile.in defines one or more of these variables
99 # to override our settings as necessary. There is no need to define these
100 # in the simulator's Makefile.in if one is using the default value. In fact
101 # it's preferable not to.
102
103 # List of object files, less common parts.
104 SIM_OBJS =
105 # List of extra dependencies.
106 # Generally this consists of simulator specific files included by sim-main.h.
107 SIM_EXTRA_DEPS =
108 # List of flags to always pass to $(CC).
109 SIM_EXTRA_CFLAGS =
110 # List of extra libraries to link with.
111 SIM_EXTRA_LIBS =
112 # List of extra program dependencies.
113 SIM_EXTRA_LIBDEPS =
114 # List of main object files for `run'.
115 SIM_RUN_OBJS = run.o
116 # Dependency of `all' to build any extra files.
117 SIM_EXTRA_ALL =
118 # Dependency of `install' to install any extra files.
119 SIM_EXTRA_INSTALL =
120 # Dependency of `clean' to clean any extra files.
121 SIM_EXTRA_CLEAN =
122
123 ## End COMMON_PRE_CONFIG_FRAG
124
125 ## COMMON_POST_CONFIG_FRAG
126
127 CONFIG_CFLAGS = @DEFS@ \
128 $(SIM_CFLAGS) \
129 $(SIM_DEBUG) \
130 $(SIM_TRACE) \
131 $(SIM_PROFILE) \
132 $(SIM_BSWAP) \
133 $(SIM_ASSERT) \
134 $(SIM_ALIGNMENT) \
135 $(SIM_ENDIAN) \
136 $(SIM_FLOAT) \
137 $(SIM_HARDWARE) \
138 $(SIM_HOSTENDIAN) \
139 $(SIM_INLINE) \
140 $(SIM_PACKAGES) \
141 $(SIM_REGPARM) \
142 $(SIM_RESERVED_BITS) \
143 $(SIM_SMP) \
144 $(SIM_STDCALL) \
145 $(SIM_WARNINGS) \
146 $(SIM_XOR_ENDIAN) \
147 $(SIM_EXTRA_CFLAGS) \
148 $(HDEFINES) $(TDEFINES)
149 CSEARCH = -I. -I$(srcdir) -I../common -I$(srcdir)/../common \
150 -I../../include -I$(srcroot)/include \
151 -I../../bfd -I$(srcroot)/bfd \
152 -I../../opcodes -I$(srcroot)/opcodes
153 ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(CFLAGS)
154 BUILD_CFLAGS = -g -O $(CSEARCH)
155
156 LIBIBERTY_LIB = ../../libiberty/libiberty.a
157 BFD_LIB = ../../bfd/libbfd.a
158 OPCODES_LIB = ../../opcodes/libopcodes.a
159 CONFIG_LIBS = @LIBS@
160 LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
161 $(SIM_EXTRA_LIBDEPS)
162 EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
163 $(CONFIG_LIBS) $(SIM_EXTRA_LIBS)
164
165 LIB_OBJS = callback.o targ-map.o $(SIM_OBJS)
166
167 all: libsim.a run $(SIM_EXTRA_ALL)
168
169 libsim.a: $(LIB_OBJS)
170 rm -f libsim.a
171 $(AR) $(AR_FLAGS) libsim.a $(LIB_OBJS)
172 $(RANLIB) libsim.a
173
174 run: $(SIM_RUN_OBJS) libsim.a $(LIBDEPS)
175 $(CC) $(ALL_CFLAGS) -o run \
176 $(SIM_RUN_OBJS) libsim.a $(EXTRA_LIBS)
177
178 run.o: $(srcdir)/../common/run.c config.h tconfig.h \
179 $(srcroot)/include/callback.h
180 $(CC) -c $(srcdir)/../common/run.c $(ALL_CFLAGS)
181
182 # FIXME: Ideally, callback.o and friends live in a library outside of
183 # both the gdb and simulator source trees (e.g. devo/remote. Not
184 # devo/libremote because this directory would contain more than just
185 # a library).
186
187 callback.o: $(srcdir)/../common/callback.c config.h tconfig.h \
188 $(srcroot)/include/callback.h targ-vals.h
189 $(CC) -c $(srcdir)/../common/callback.c $(ALL_CFLAGS)
190
191 targ-map.o: targ-map.c targ-vals.h
192
193 gentmap: Makefile $(srcdir)/../common/gentmap.c targ-vals.def
194 $(CC_FOR_BUILD) $(srcdir)/../common/gentmap.c -o gentmap $(BUILD_CFLAGS)
195
196 targ-vals.h: gentmap
197 rm -f targ-vals.h
198 ./gentmap -h >targ-vals.h
199
200 targ-map.c: gentmap
201 rm -f targ-map.c
202 ./gentmap -c >targ-map.c
203
204
205 #
206 # Rules for building sim-* components. Triggered by listing the corresponding
207 # .o file in the list of simulator targets.
208 #
209
210 sim_main_headers = \
211 sim-main.h \
212 $(srcdir)/../common/sim-config.h \
213 $(srcdir)/../common/sim-base.h \
214 $(srcdir)/../common/sim-basics.h \
215 $(srcdir)/../common/sim-memopt.h \
216 $(srcdir)/../common/sim-model.h \
217 $(srcdir)/../common/sim-module.h \
218 $(srcdir)/../common/sim-trace.h \
219 $(srcdir)/../common/sim-profile.h \
220 $(srcdir)/../common/sim-engine.h \
221 $(srcdir)/../common/sim-events.h \
222 $(srcdir)/../common/sim-watch.h \
223 $(srcdir)/../common/sim-assert.h \
224 tconfig.h
225
226 sim-assert_h = $(srcdir)/../common/sim-assert.h
227 sim-endian_h = $(srcdir)/../common/sim-endian.h
228 sim-n-endian_h = $(srcdir)/../common/sim-n-endian.h
229 sim-bits_h = $(srcdir)/../common/sim-bits.h
230 sim-config_h = $(srcdir)/../common/sim-config.h
231 sim-n-bits_h = $(srcdir)/../common/sim-n-bits.h
232 sim-core_h = $(srcdir)/../common/sim-core.h
233 sim-n-core_h = $(srcdir)/../common/sim-n-core.h
234 sim-engine_h = $(srcdir)/../common/sim-engine.h
235 sim-events_h = $(srcdir)/../common/sim-events.h
236 sim-fpu_h = $(srcdir)/../common/sim-fpu.h
237 sim-io_h = $(srcdir)/../common/sim-io.h
238 sim-options_h = $(srcdir)/../common/sim-options.h
239
240 # FIXME: If this complicated way of building .o files from ../common is
241 # necessary, the reason should be documented here.
242
243 BUILT_SRC_FROM_COMMON= \
244 sim-endian.c \
245 sim-inline.c \
246 sim-bits.c \
247 sim-events.c \
248 sim-core.c \
249 sim-config.c \
250 sim-io.c
251
252 sim-abort.o: $(srcdir)/../common/sim-abort.c \
253 $(SIM_EXTRA_DEPS)
254 $(CC) -c $(srcdir)/../common/sim-abort.c $(ALL_CFLAGS)
255
256 sim-bits.o: $(srcdir)/../common/sim-bits.c $(sim-bits_h) $(sim-n-bits_h) \
257 $(SIM_EXTRA_DEPS)
258 $(CC) -c $(srcdir)/../common/sim-bits.c $(ALL_CFLAGS)
259
260 sim-config.o: $(srcdir)/../common/sim-config.c $(sim-config_h) $(sim-nconfig_h) \
261 $(SIM_EXTRA_DEPS)
262 $(CC) -c $(srcdir)/../common/sim-config.c $(ALL_CFLAGS)
263
264 sim-core.o: $(srcdir)/../common/sim-core.c $(sim-core_h) $(sim-n-core_h) \
265 $(SIM_EXTRA_DEPS)
266 $(CC) -c $(srcdir)/../common/sim-core.c $(ALL_CFLAGS)
267
268 sim-endian.o: $(srcdir)/../common/sim-endian.c $(sim-endian_h) $(sim-n-endian_h) \
269 $(SIM_EXTRA_DEPS)
270 $(CC) -c $(srcdir)/../common/sim-endian.c $(ALL_CFLAGS)
271
272 sim-engine.o: $(srcdir)/../common/sim-engine.c $(sim_main_headers) $(sim-engine_h) \
273 $(SIM_EXTRA_DEPS)
274 $(CC) -c $(srcdir)/../common/sim-engine.c $(ALL_CFLAGS)
275
276 sim-events.o: $(srcdir)/../common/sim-events.c $(sim-events_h) \
277 $(SIM_EXTRA_DEPS)
278 $(CC) -c $(srcdir)/../common/sim-events.c $(ALL_CFLAGS)
279
280 sim-fpu.o: $(srcdir)/../common/sim-fpu.c $(sim-fpu_h) \
281 $(SIM_EXTRA_DEPS)
282 $(CC) -c $(srcdir)/../common/sim-fpu.c $(ALL_CFLAGS)
283
284 sim-hload.o: $(srcdir)/../common/sim-hload.c $(sim-assert_h) \
285 $(SIM_EXTRA_DEPS)
286 $(CC) -c $(srcdir)/../common/sim-hload.c $(ALL_CFLAGS)
287
288 sim-hrw.o: $(srcdir)/../common/sim-hrw.c $(sim-assert_h) \
289 $(SIM_EXTRA_DEPS)
290 $(CC) -c $(srcdir)/../common/sim-hrw.c $(ALL_CFLAGS)
291
292 sim-inline.c: $(srcdir)/../common/sim-inline.c
293 rm -f $@ tmp-$@
294 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
295 cat $(srcdir)/../common/$@ >> tmp-$@
296 $(srcdir)/../../move-if-change tmp-$@ $@
297
298 sim-io.o: $(srcdir)/../common/sim-io.c $(sim_main_headers) $(sim-io_h) \
299 $(SIM_EXTRA_DEPS)
300 $(CC) -c $(srcdir)/../common/sim-io.c $(ALL_CFLAGS)
301
302 sim-memopt.o: $(srcdir)/../common/sim-memopt.c $(sim_main_headers) \
303 $(sim-io_h) $(SIM_EXTRA_DEPS)
304 $(CC) -c $(srcdir)/../common/sim-memopt.c $(ALL_CFLAGS)
305
306 sim-module.o: $(srcdir)/../common/sim-module.c $(sim_main_headers) \
307 $(sim-io_h) $(SIM_EXTRA_DEPS)
308 $(CC) -c $(srcdir)/../common/sim-module.c $(ALL_CFLAGS)
309
310 sim-options.o: $(srcdir)/../common/sim-options.c $(sim_main_headers) \
311 $(sim-options_h) $(sim-io_h) $(SIM_EXTRA_DEPS)
312 $(CC) -c $(srcdir)/../common/sim-options.c $(ALL_CFLAGS)
313
314 sim-reason.o: $(srcdir)/../common/sim-reason.c $(sim_main_headers) \
315 $(SIM_EXTRA_DEPS)
316 $(CC) -c $(srcdir)/../common/sim-reason.c $(ALL_CFLAGS)
317
318 sim-resume.o: $(srcdir)/../common/sim-resume.c $(sim_main_headers) \
319 $(SIM_EXTRA_DEPS)
320 $(CC) -c $(srcdir)/../common/sim-resume.c $(ALL_CFLAGS)
321
322 sim-run.o: $(srcdir)/../common/sim-run.c $(sim_main_headers) \
323 $(SIM_EXTRA_DEPS)
324 $(CC) -c $(srcdir)/../common/sim-run.c $(ALL_CFLAGS)
325
326 sim-stop.o: $(srcdir)/../common/sim-stop.c $(sim_main_headers) \
327 $(SIM_EXTRA_DEPS)
328 $(CC) -c $(srcdir)/../common/sim-stop.c $(ALL_CFLAGS)
329
330 sim-trace.o: $(srcdir)/../common/sim-trace.c $(sim_main_headers) \
331 $(sim-options_h) $(sim-io_h) $(SIM_EXTRA_DEPS)
332 $(CC) -c $(srcdir)/../common/sim-trace.c $(ALL_CFLAGS)
333
334 sim-profile.o: $(srcdir)/../common/sim-profile.c $(sim_main_headers) \
335 $(sim-options_h) $(sim-io_h) $(SIM_EXTRA_DEPS)
336 $(CC) -c $(srcdir)/../common/sim-profile.c $(ALL_CFLAGS)
337
338 sim-model.o: $(srcdir)/../common/sim-model.c $(sim_main_headers) \
339 $(sim-io_h) $(SIM_EXTRA_DEPS)
340 $(CC) -c $(srcdir)/../common/sim-model.c $(ALL_CFLAGS)
341
342 sim-utils.o: $(srcdir)/../common/sim-utils.c $(sim_main_headers) \
343 $(SIM_EXTRA_DEPS)
344 $(CC) -c $(srcdir)/../common/sim-utils.c $(ALL_CFLAGS)
345
346 sim-watch.o: $(srcdir)/../common/sim-watch.c $(sim_main_headers) \
347 $(SIM_EXTRA_DEPS)
348 $(CC) -c $(srcdir)/../common/sim-watch.c $(ALL_CFLAGS)
349
350 sim-load.o: $(srcdir)/../common/sim-load.c
351 $(CC) -c $(srcdir)/../common/sim-load.c $(ALL_CFLAGS)
352
353 nrun.o: $(srcdir)/../common/nrun.c config.h tconfig.h \
354 $(srcroot)/include/callback.h $(sim_main_headers)
355 $(CC) -c $(srcdir)/../common/nrun.c $(ALL_CFLAGS)
356
357 # CGEN support.
358
359 cgen-run.o: $(srcdir)/../common/cgen-run.c $(sim_main_headers) \
360 $(SIM_EXTRA_DEPS)
361 $(CC) -c $(srcdir)/../common/cgen-run.c $(ALL_CFLAGS)
362
363 cgen-scache.o: $(srcdir)/../common/cgen-scache.c $(sim_main_headers) \
364 $(SIM_EXTRA_DEPS) $(srcdir)/../common/cgen-scache.h
365 $(CC) -c $(srcdir)/../common/cgen-scache.c $(ALL_CFLAGS)
366
367 cgen-trace.o: $(srcdir)/../common/cgen-trace.c $(sim_main_headers) \
368 $(SIM_EXTRA_DEPS) $(srcdir)/../common/cgen-trace.h
369 $(CC) -c $(srcdir)/../common/cgen-trace.c $(ALL_CFLAGS)
370
371 cgen-utils.o: $(srcdir)/../common/cgen-utils.c $(sim_main_headers) \
372 $(SIM_EXTRA_DEPS) mem-ops.h sem-ops.h
373 $(CC) -c $(srcdir)/../common/cgen-utils.c $(ALL_CFLAGS)
374
375 # Support targets.
376
377 install: install-common $(SIM_EXTRA_INSTALL)
378
379 install-common: installdirs
380 n=`echo run | sed '$(program_transform_name)'`; \
381 $(INSTALL_PROGRAM) run $(bindir)/$$n
382
383 installdirs:
384 $(SHELL) $(srcdir)/../../mkinstalldirs $(bindir)
385
386 check:
387
388 info:
389 clean-info:
390 install-info:
391
392 .NOEXPORT:
393 MAKEOVERRIDES=
394
395 tags etags: TAGS
396
397 TAGS: force
398 etags --regex '/^\/[*] TAGS: .*/' *.c *.h
399
400 clean: $(SIM_EXTRA_CLEAN)
401 rm -f *.[oa] *~ core
402 rm -f run libsim.a
403 rm -f gentmap targ-map.c targ-vals.h
404 rm -f $(BUILT_SRC_FROM_COMMON)
405
406 distclean mostlyclean maintainer-clean realclean: clean
407 rm -f TAGS
408 rm -f Makefile config.cache config.log config.status .gdbinit
409 rm -f tconfig.h config.h stamp-h
410 rm -f targ-vals.def
411
412 .c.o:
413 $(CC) -c $(ALL_CFLAGS) $<
414
415 # Dummy target to force execution of dependent targets.
416 force:
417
418 Makefile: Makefile.in $(srcdir)/../common/Make-common.in config.status
419 CONFIG_HEADERS= $(SHELL) ./config.status
420
421 config.status: configure
422 $(SHELL) ./config.status --recheck
423
424 config.h: stamp-h ; @true
425 stamp-h: config.in config.status
426 CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
427
428 .gdbinit: config.status $(srcdir)/../common/gdbinit.in
429 CONFIG_FILES=$@:../common/gdbinit.in CONFIG_HEADERS= $(SHELL) ./config.status
430
431 ## End COMMON_POST_CONFIG_FRAG