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