Commit | Line | Data |
---|---|---|
c906108c | 1 | # Makefile fragment for common parts of all simulators. |
3666a048 | 2 | # Copyright 1997-2021 Free Software Foundation, Inc. |
c906108c SS |
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 | |
4744ac1b | 7 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 8 | # (at your option) any later version. |
4744ac1b | 9 | # |
c906108c SS |
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. | |
4744ac1b | 14 | # |
c906108c | 15 | # You should have received a copy of the GNU General Public License |
4744ac1b | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c SS |
17 | |
18 | # This Makefile fragment consists of two separate parts. | |
19 | # They are merged into the final Makefile at points denoted by | |
20 | # "## COMMON_PRE_CONFIG_FRAG" and "## COMMON_POST_CONFIG_FRAG". | |
21 | # | |
22 | # The target Makefile should look like: | |
23 | # | |
24 | #># Copyright blah blah | |
25 | #> | |
26 | #>## COMMON_PRE_CONFIG_FRAG | |
27 | #> | |
28 | #># Any overrides necessary for the SIM_FOO config vars. | |
29 | #>SIM_FOO = ... | |
30 | #> | |
31 | #>## COMMON_POST_CONFIG_FRAG | |
32 | #> | |
33 | #># Rules to build target specific .o's. | |
34 | ||
35 | ## COMMON_PRE_CONFIG_FRAG | |
36 | ||
db2e4d67 | 37 | VPATH = @srcdir@:$(srccom) |
c906108c SS |
38 | srcdir = @srcdir@ |
39 | srccom = $(srcdir)/../common | |
40 | srcroot = $(srcdir)/../.. | |
7b064844 | 41 | srcsim = $(srcdir)/.. |
c906108c | 42 | |
7daf500d SM |
43 | include $(srcroot)/gdb/silent-rules.mk |
44 | ||
5c9e84c2 | 45 | # Helper code from gnulib. |
483ab96a MF |
46 | GNULIB_PARENT_DIR = ../.. |
47 | include $(GNULIB_PARENT_DIR)/gnulib/Makefile.gnulib.inc | |
5c9e84c2 | 48 | |
3f8414df MF |
49 | # Settings from top-level configure. |
50 | include ../arch-subdir.mk | |
51 | ||
c906108c SS |
52 | prefix = @prefix@ |
53 | exec_prefix = @exec_prefix@ | |
54 | ||
c906108c SS |
55 | bindir = @bindir@ |
56 | ||
57 | libdir = @libdir@ | |
58 | tooldir = $(libdir)/$(target_alias) | |
59 | ||
60 | datadir = @datadir@ | |
1428dced | 61 | datarootdir = @datarootdir@ |
c906108c SS |
62 | mandir = @mandir@ |
63 | man1dir = $(mandir)/man1 | |
64 | infodir = @infodir@ | |
65 | includedir = @includedir@ | |
66 | ||
67 | # This can be referenced by the gettext configuration code. | |
68 | top_builddir = .. | |
69 | ||
c906108c SS |
70 | SHELL = @SHELL@ |
71 | ||
c906108c SS |
72 | SIM_BITSIZE = @sim_bitsize@ |
73 | SIM_DEFAULT_MODEL = @sim_default_model@ | |
c906108c SS |
74 | SIM_FLOAT = @sim_float@ |
75 | SIM_HW_CFLAGS = @sim_hw_cflags@ | |
76 | SIM_HW_OBJS = @sim_hw_objs@ | |
77 | SIM_HW = @sim_hw@ | |
c906108c | 78 | SIM_INLINE = @sim_inline@ |
c906108c SS |
79 | SIM_RESERVED_BITS = @sim_reserved_bits@ |
80 | SIM_SCACHE = @sim_scache@ | |
d4f3574e SS |
81 | SIM_WARN_CFLAGS = $(WARN_CFLAGS) |
82 | SIM_WERROR_CFLAGS = $(WERROR_CFLAGS) | |
c906108c | 83 | |
db2e4d67 | 84 | # Dependency tracking information. |
db2e4d67 MF |
85 | depcomp = $(SHELL) $(srcroot)/depcomp |
86 | ||
87 | # Note that these are overridden by GNU make-specific code below if | |
88 | # GNU make is used. The overrides implement dependency tracking. | |
46f900c0 | 89 | COMPILE.pre = $(CC) $(C_DIALECT) |
db2e4d67 | 90 | COMPILE.post = -c -o $@ |
7daf500d | 91 | COMPILE = $(ECHO_CC) $(COMPILE.pre) $(ALL_CFLAGS) $(COMPILE.post) |
db2e4d67 | 92 | POSTCOMPILE = @true |
c906108c | 93 | |
2b8d134b SM |
94 | # igen leaks memory, and therefore makes AddressSanitizer unhappy. Disable |
95 | # leak detection while running it. | |
a55b92be MF |
96 | IGEN = ../igen/igen$(EXEEXT) |
97 | IGEN_RUN = ASAN_OPTIONS=detect_leaks=0 $(IGEN) | |
2b8d134b | 98 | |
c906108c SS |
99 | # Each simulator's Makefile.in defines one or more of these variables |
100 | # to override our settings as necessary. There is no need to define these | |
101 | # in the simulator's Makefile.in if one is using the default value. In fact | |
102 | # it's preferable not to. | |
103 | ||
104 | # List of object files, less common parts. | |
105 | SIM_OBJS = | |
106 | # List of extra dependencies. | |
107 | # Generally this consists of simulator specific files included by sim-main.h. | |
108 | SIM_EXTRA_DEPS = | |
109 | # List of flags to always pass to $(CC). | |
110 | SIM_EXTRA_CFLAGS = | |
111 | # List of extra libraries to link with. | |
112 | SIM_EXTRA_LIBS = | |
c906108c | 113 | # List of main object files for `run'. |
465fb143 | 114 | SIM_RUN_OBJS = nrun.o |
c906108c SS |
115 | # Dependency of `install' to install any extra files. |
116 | SIM_EXTRA_INSTALL = | |
117 | # Dependency of `clean' to clean any extra files. | |
118 | SIM_EXTRA_CLEAN = | |
d690312f CD |
119 | # Likewise `distclean' |
120 | SIM_EXTRA_DISTCLEAN = | |
c906108c SS |
121 | |
122 | # Every time a new general purpose source file was added every target's | |
123 | # Makefile.in needed to be updated to include the file in SIM_OBJS. | |
124 | # This doesn't scale. | |
125 | # This variable specifies all the generic stuff common to the newer simulators. | |
126 | # Things like sim-reason.o can't go here as the cpu may provide its own | |
127 | # (though hopefully in time that won't be so). Things like sim-bits.o can go | |
128 | # here. Some files are used by all simulators (e.g. callback.o). | |
129 | # Those files are specified in LIB_OBJS below. | |
130 | ||
131 | SIM_COMMON_HW_OBJS = \ | |
132 | hw-alloc.o \ | |
133 | hw-base.o \ | |
134 | hw-device.o \ | |
135 | hw-events.o \ | |
136 | hw-handles.o \ | |
137 | hw-instances.o \ | |
138 | hw-ports.o \ | |
139 | hw-properties.o \ | |
140 | hw-tree.o \ | |
141 | sim-hw.o \ | |
142 | ||
143 | SIM_NEW_COMMON_OBJS = \ | |
144 | sim-arange.o \ | |
145 | sim-bits.o \ | |
6e4f085c | 146 | sim-close.o \ |
2419798b | 147 | sim-command.o \ |
c906108c SS |
148 | sim-config.o \ |
149 | sim-core.o \ | |
78e9aa70 | 150 | sim-cpu.o \ |
c906108c | 151 | sim-endian.o \ |
122bbfb5 | 152 | sim-engine.o \ |
c906108c SS |
153 | sim-events.o \ |
154 | sim-fpu.o \ | |
5e744ef8 | 155 | sim-hload.o \ |
122bbfb5 | 156 | sim-hrw.o \ |
c906108c SS |
157 | sim-io.o \ |
158 | sim-info.o \ | |
c906108c | 159 | sim-memopt.o \ |
0d585950 | 160 | sim-model.o \ |
c906108c SS |
161 | sim-module.o \ |
162 | sim-options.o \ | |
163 | sim-profile.o \ | |
797eee42 MF |
164 | sim-reason.o \ |
165 | sim-reg.o \ | |
c906108c | 166 | sim-signal.o \ |
797eee42 | 167 | sim-stop.o \ |
61a0c964 | 168 | sim-syscall.o \ |
c906108c SS |
169 | sim-trace.o \ |
170 | sim-utils.o \ | |
171 | sim-watch.o \ | |
172 | \ | |
173 | $(SIM_HW_OBJS) \ | |
174 | ||
80532737 DE |
175 | # cgen-sim.h and the headers it includes |
176 | CGEN_SIM_DEPS = \ | |
177 | $(srccom)/cgen-sim.h \ | |
c906108c | 178 | $(srccom)/cgen-defs.h \ |
c906108c | 179 | $(srccom)/cgen-scache.h \ |
80532737 DE |
180 | $(srccom)/cgen-fpu.h \ |
181 | $(srccom)/cgen-par.h \ | |
182 | $(srccom)/cgen-cpu.h \ | |
c906108c | 183 | $(srccom)/cgen-trace.h \ |
80532737 DE |
184 | cpuall.h |
185 | ||
186 | # Add this to SIM_EXTRA_DEPS. | |
187 | CGEN_INCLUDE_DEPS = \ | |
188 | $(CGEN_SIM_DEPS) \ | |
189 | $(srccom)/cgen-engine.h \ | |
c906108c SS |
190 | $(srccom)/cgen-types.h \ |
191 | $(srcdir)/../../include/opcode/cgen.h | |
192 | ||
193 | ## End COMMON_PRE_CONFIG_FRAG | |
194 | ||
195 | ## COMMON_POST_CONFIG_FRAG | |
196 | ||
197 | CONFIG_CFLAGS = \ | |
52d37d2c | 198 | -DHAVE_CONFIG_H \ |
c906108c | 199 | $(SIM_DEFAULT_MODEL) \ |
c906108c | 200 | $(SIM_BITSIZE) \ |
c906108c SS |
201 | $(SIM_FLOAT) \ |
202 | $(SIM_HW_CFLAGS) \ | |
c906108c | 203 | $(SIM_INLINE) \ |
c906108c SS |
204 | $(SIM_RESERVED_BITS) \ |
205 | $(SIM_SCACHE) \ | |
d4f3574e SS |
206 | $(SIM_WARN_CFLAGS) \ |
207 | $(SIM_WERROR_CFLAGS) \ | |
10737236 | 208 | $(SIM_HARDWARE) |
c906108c SS |
209 | CSEARCH = -I. -I$(srcdir) -I../common -I$(srccom) \ |
210 | -I../../include -I$(srcroot)/include \ | |
211 | -I../../bfd -I$(srcroot)/bfd \ | |
212 | -I../../opcodes -I$(srcroot)/opcodes \ | |
5c9e84c2 | 213 | -I../.. \ |
79730a3b | 214 | @INCINTL@ |
5c9e84c2 | 215 | ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(INCGNU) $(SIM_EXTRA_CFLAGS) $(CFLAGS) |
c2783492 | 216 | BUILD_CFLAGS = $(CFLAGS_FOR_BUILD) $(CSEARCH) |
c906108c | 217 | |
10737236 | 218 | COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(SIM_EXTRA_CFLAGS) |
c906108c | 219 | |
b5689863 | 220 | ZLIB = $(zlibdir) -lz |
c906108c | 221 | LIBIBERTY_LIB = ../../libiberty/libiberty.a |
79730a3b | 222 | BFD_LIB = ../../bfd/libbfd.a |
c906108c | 223 | OPCODES_LIB = ../../opcodes/libopcodes.a |
20e95c23 DJ |
224 | LIBINTL = @LIBINTL@ |
225 | LIBINTL_DEP = @LIBINTL_DEP@ | |
07490bf8 | 226 | CONFIG_LIBS = $(COMMON_LIBS) @LIBS@ $(ZLIB) |
ed30adf7 | 227 | LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL_DEP) $(LIBIBERTY_LIB) |
20e95c23 | 228 | EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL) $(LIBIBERTY_LIB) \ |
b25370aa | 229 | $(CONFIG_LIBS) $(SIM_EXTRA_LIBS) $(LIBDL) $(LIBGNU) $(LIBGNU_EXTRA_LIBS) |
c906108c | 230 | |
dd8e16ea | 231 | COMMON_OBJS_NAMES = \ |
ad9cc209 | 232 | portability.o \ |
dd8e16ea MF |
233 | sim-load.o \ |
234 | version.o | |
235 | COMMON_OBJS = $(COMMON_OBJS_NAMES:%=../common/common_libcommon_a-%) | |
5bea0c32 MF |
236 | |
237 | LIB_OBJS = callback.o modules.o syscall.o targ-map.o $(COMMON_OBJS) $(SIM_OBJS) | |
c906108c | 238 | |
c6c7769d | 239 | COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(BUILD_CFLAGS) |
e7d9022b | 240 | LINK_FOR_BUILD = $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(LDFLAGS_FOR_BUILD) -o $@ |
c6c7769d | 241 | |
c906108c SS |
242 | RUNTESTFLAGS = |
243 | ||
df68e12b MF |
244 | callback_h = $(srcroot)/include/sim/callback.h |
245 | remote_sim_h = $(srcroot)/include/sim/sim.h | |
3c25f8c7 | 246 | |
f8069d55 | 247 | all: libsim.a run$(EXEEXT) .gdbinit |
c906108c SS |
248 | |
249 | libsim.a: $(LIB_OBJS) | |
250 | rm -f libsim.a | |
7daf500d SM |
251 | $(ECHO_AR) $(AR) $(AR_FLAGS) libsim.a $(LIB_OBJS) |
252 | $(ECHO_RANLIB) $(RANLIB) libsim.a | |
c906108c | 253 | |
4ec242d7 | 254 | run$(EXEEXT): $(SIM_RUN_OBJS) libsim.a $(LIBDEPS) |
7daf500d | 255 | $(ECHO_CCLD) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o run$(EXEEXT) \ |
c906108c SS |
256 | $(SIM_RUN_OBJS) libsim.a $(EXTRA_LIBS) |
257 | ||
c906108c SS |
258 | # FIXME: Ideally, callback.o and friends live in a library outside of |
259 | # both the gdb and simulator source trees (e.g. devo/remote. Not | |
260 | # devo/libremote because this directory would contain more than just | |
261 | # a library). | |
262 | ||
c6c7769d | 263 | gentmap.o: Makefile $(srccom)/gentmap.c $(srccom)/nltvals.def |
7daf500d | 264 | $(ECHO_CC) $(COMPILE_FOR_BUILD) -o $@ -c $(srccom)/gentmap.c $(NL_TARGET) |
c6c7769d MF |
265 | |
266 | gentmap: gentmap.o | |
7daf500d | 267 | $(ECHO_CC) $(LINK_FOR_BUILD) $< |
c906108c SS |
268 | |
269 | targ-vals.h targ-map.c: stamp-tvals | |
270 | stamp-tvals: gentmap | |
271 | rm -f tmp-tvals.h tmp-tmap.c | |
272 | ./gentmap -h >tmp-tvals.h | |
273 | $(SHELL) $(srcroot)/move-if-change tmp-tvals.h targ-vals.h | |
274 | ./gentmap -c >tmp-tmap.c | |
275 | $(SHELL) $(srcroot)/move-if-change tmp-tmap.c targ-map.c | |
276 | touch stamp-tvals | |
277 | ||
278 | # | |
279 | # Rules for building sim-* components. Triggered by listing the corresponding | |
280 | # .o file in the list of simulator targets. | |
281 | # | |
282 | ||
283 | sim_main_headers = \ | |
284 | sim-main.h \ | |
08cd3760 RE |
285 | $(sim-assert_h) \ |
286 | $(sim-base_h) \ | |
287 | $(sim-cpu_h) \ | |
288 | $(sim-engine_h) \ | |
289 | $(sim-events_h) \ | |
290 | $(sim-memopt_h) \ | |
291 | $(sim-model_h) \ | |
292 | $(sim-module_h) \ | |
293 | $(sim-profile_h) \ | |
294 | $(sim-trace_h) \ | |
295 | $(sim-watch_h) \ | |
296 | $(sim-basics_h) \ | |
c906108c SS |
297 | $(SIM_EXTRA_DEPS) |
298 | ||
299 | # Exported version of sim_main_headers. | |
300 | SIM_MAIN_DEPS = \ | |
301 | $(sim_main_headers) | |
302 | ||
08cd3760 | 303 | sim-alu_h = $(srccom)/sim-alu.h |
ef986697 | 304 | sim-arange_h = $(srccom)/sim-arange.h |
c906108c | 305 | sim-assert_h = $(srccom)/sim-assert.h |
08cd3760 RE |
306 | sim-base_h = $(srccom)/sim-base.h \ |
307 | $(sim-module_h) \ | |
308 | $(sim-trace_h) \ | |
309 | $(sim-core_h) \ | |
310 | $(sim-events_h) \ | |
311 | $(sim-profile_h) \ | |
312 | $(sim-model_h) \ | |
313 | $(sim-io_h) \ | |
314 | $(sim-engine_h) \ | |
315 | $(sim-watch_h) \ | |
316 | $(sim-memopt_h) \ | |
317 | $(sim-cpu_h) | |
318 | sim-basics_h = $(srccom)/sim-basics.h \ | |
08cd3760 | 319 | $(sim-config_h) \ |
70ae6611 | 320 | $(callback_h) \ |
08cd3760 RE |
321 | $(sim-inline_h) \ |
322 | $(sim-types_h) \ | |
323 | $(sim-bits_h) \ | |
324 | $(sim-endian_h) \ | |
325 | $(sim-signal_h) \ | |
326 | $(sim-arange_h) \ | |
327 | $(sim-utils_h) | |
328 | sim-bits_h = $(srccom)/sim-bits.h \ | |
329 | $(srccom)/sim-bits.c | |
c906108c | 330 | sim-config_h = $(srccom)/sim-config.h |
c906108c | 331 | sim-core_h = $(srccom)/sim-core.h |
08cd3760 RE |
332 | sim-cpu_h = $(srccom)/sim-cpu.h |
333 | sim-endian_h = $(srccom)/sim-endian.h \ | |
334 | $(srccom)/sim-endian.c | |
c906108c SS |
335 | sim-engine_h = $(srccom)/sim-engine.h |
336 | sim-events_h = $(srccom)/sim-events.h | |
337 | sim-fpu_h = $(srccom)/sim-fpu.h | |
08cd3760 RE |
338 | sim-hw_h = $(srccom)/sim-hw.h |
339 | sim-inline_h = $(srccom)/sim-inline.h | |
c906108c | 340 | sim-io_h = $(srccom)/sim-io.h |
08cd3760 RE |
341 | sim-memopt_h = $(srccom)/sim-memopt.h |
342 | sim-model_h = $(srccom)/sim-model.h | |
343 | sim-module_h = $(srccom)/sim-module.h | |
344 | sim-n-bits_h = $(srccom)/sim-n-bits.h | |
345 | sim-n-core_h = $(srccom)/sim-n-core.h | |
346 | sim-n-endian_h = $(srccom)/sim-n-endian.h | |
c906108c | 347 | sim-options_h = $(srccom)/sim-options.h |
08cd3760 | 348 | sim-profile_h = $(srccom)/sim-profile.h |
c906108c | 349 | sim-signal_h = $(srccom)/sim-signal.h |
08cd3760 RE |
350 | sim-trace_h = $(srccom)/sim-trace.h |
351 | sim-types_h = $(srccom)/sim-types.h | |
352 | sim-utils_h = $(srccom)/sim-utils.h | |
353 | sim-watch_h = $(srccom)/sim-watch.h | |
c906108c SS |
354 | |
355 | hw-alloc_h = $(srccom)/hw-alloc.h | |
356 | hw-base_h = $(srccom)/hw-base.h | |
357 | hw-device_h = $(srccom)/hw-device.h | |
358 | hw-events_h = $(srccom)/hw-events.h | |
359 | hw-handles_h = $(srccom)/hw-handles.h | |
360 | hw-instances_h = $(srccom)/hw-instances.h | |
361 | hw-ports_h = $(srccom)/hw-ports.h | |
362 | hw-properties_h = $(srccom)/hw-properties.h | |
363 | hw-tree_h = $(srccom)/hw-tree.h | |
364 | ||
365 | hw_main_headers = \ | |
366 | $(srccom)/hw-main.h \ | |
367 | $(hw-alloc_h) \ | |
368 | $(hw-base_h) \ | |
369 | $(hw-device_h) \ | |
370 | $(hw-events_h) \ | |
371 | $(hw-instances_h) \ | |
372 | $(hw-handles_h) \ | |
373 | $(hw-ports_h) \ | |
374 | $(hw-properties_h) \ | |
375 | ||
db2e4d67 MF |
376 | # |
377 | # Dependency tracking. Most of this is conditional on GNU Make being | |
378 | # found by configure; if GNU Make is not found, we fall back to a | |
379 | # simpler scheme. | |
380 | # | |
381 | ||
efd82ac7 | 382 | ifeq ($(DEPMODE),depmode=gcc3) |
db2e4d67 MF |
383 | # Note that we put the dependencies into a .Tpo file, then move them |
384 | # into place if the compile succeeds. We need this because gcc does | |
385 | # not atomically write the dependency output file. | |
efd82ac7 TT |
386 | override COMPILE.post = -c -o $@ -MT $@ -MMD -MP \ |
387 | -MF $(DEPDIR)/$(basename $(@F)).Tpo | |
388 | override POSTCOMPILE = @mv $(DEPDIR)/$(basename $(@F)).Tpo \ | |
389 | $(DEPDIR)/$(basename $(@F)).Po | |
390 | else | |
391 | override COMPILE.pre = source='$<' object='$@' libtool=no \ | |
392 | DEPDIR=$(DEPDIR) $(DEPMODE) $(depcomp) $(CC) | |
db2e4d67 MF |
393 | # depcomp handles atomicity for us, so we don't need a postcompile |
394 | # step. | |
efd82ac7 TT |
395 | override POSTCOMPILE = |
396 | endif | |
db2e4d67 MF |
397 | |
398 | all_object_files = $(LIB_OBJS) $(SIM_RUN_OBJS) | |
399 | generated_files = \ | |
400 | $(SIM_EXTRA_DEPS) \ | |
401 | hw-config.h \ | |
8e5f1516 | 402 | modules.c \ |
db2e4d67 | 403 | targ-map.c \ |
5bea0c32 | 404 | targ-vals.h |
db2e4d67 MF |
405 | |
406 | # Ensure that generated files are created early. Use order-only | |
407 | # dependencies if available. They require GNU make 3.80 or newer, | |
408 | # and the .VARIABLES variable was introduced at the same time. | |
efd82ac7 TT |
409 | ifdef .VARIABLES |
410 | $(all_object_files): | $(generated_files) | |
411 | else | |
db2e4d67 | 412 | $(all_object_files) : $(generated_files) |
efd82ac7 | 413 | endif |
db2e4d67 MF |
414 | |
415 | # Dependencies. | |
efd82ac7 | 416 | -include $(patsubst %.o, $(DEPDIR)/%.Po, $(all_object_files)) |
c906108c | 417 | |
c906108c | 418 | # FIXME This is one very simple-minded way of generating the file hw-config.h |
b396d3a1 TT |
419 | hw-config.h: stamp-hw ; @true |
420 | stamp-hw: Makefile.in $(srccom)/Make-common.in config.status Makefile | |
c906108c SS |
421 | rm -f tmp-hw.h |
422 | echo "/* generated by Makefile */" > tmp-hw.h | |
96987c2b JB |
423 | sim_hw="$(SIM_HW)"; \ |
424 | for hw in $$sim_hw ; do \ | |
c906108c SS |
425 | echo "extern const struct hw_descriptor dv_$${hw}_descriptor[];" ; \ |
426 | done >> tmp-hw.h | |
427 | echo "const struct hw_descriptor *hw_descriptors[] = {" >> tmp-hw.h | |
96987c2b JB |
428 | sim_hw="$(SIM_HW)"; \ |
429 | for hw in $$sim_hw ; do \ | |
c906108c SS |
430 | echo " dv_$${hw}_descriptor," ; \ |
431 | done >> tmp-hw.h | |
432 | echo " NULL," >> tmp-hw.h | |
433 | echo "};" >> tmp-hw.h | |
b396d3a1 TT |
434 | $(SHELL) $(srcroot)/move-if-change tmp-hw.h hw-config.h |
435 | @echo stamp > stamp-hw | |
c906108c | 436 | |
c906108c SS |
437 | test-hw-events: $(srccom)/hw-events.c libsim.a |
438 | $(CC) $(ALL_CFLAGS) -DMAIN -o test-hw-events$(EXEEXT) \ | |
439 | $(srccom)/hw-events.c libsim.a $(EXTRA_LIBS) | |
440 | ||
8e5f1516 | 441 | # See sim_pre_argv_init and sim_module_install in sim-module.c for more details. |
015f7b74 MF |
442 | modules.c: stamp-modules ; @true |
443 | stamp-modules: Makefile $(SIM_OBJS:.o=.c) | |
8e5f1516 MF |
444 | @echo Generating $@ |
445 | @LANG=C ; export LANG ; \ | |
446 | LC_ALL=C ; export LC_ALL ; \ | |
447 | sed -n -e '/^sim_install_/{s/^\(sim_install_[a-z_0-9A-Z]*\).*/\1/;p}' $^ | sort >$@.l-tmp | |
448 | @set -e; (\ | |
449 | echo '/* Do not modify this file. */'; \ | |
450 | echo '/* It is created automatically by the Makefile. */'; \ | |
451 | echo '#include "libiberty.h"'; \ | |
452 | echo '#include "sim-module.h"'; \ | |
453 | sed -e 's:\(.*\):extern __attribute__((__weak__)) MODULE_INIT_FN \1;:' $@.l-tmp; \ | |
454 | echo 'MODULE_INSTALL_FN * const sim_modules_detected[] = {'; \ | |
455 | sed -e 's:\(.*\): \1,:' $@.l-tmp; \ | |
456 | echo '};'; \ | |
457 | echo 'const int sim_modules_detected_len = ARRAY_SIZE (sim_modules_detected);'; \ | |
458 | ) >$@.tmp | |
015f7b74 | 459 | $(SHELL) $(srcroot)/move-if-change $@.tmp modules.c |
8e5f1516 | 460 | @rm -f $@.l-tmp $@.tmp |
b50a658a | 461 | touch $@ |
8e5f1516 | 462 | |
c906108c SS |
463 | # CGEN support. |
464 | ||
465 | # For use in Makefile.in for cpu-specific files. | |
466 | CGEN_MAIN_CPU_DEPS = \ | |
467 | $(SIM_MAIN_DEPS) \ | |
c906108c | 468 | $(srccom)/cgen-ops.h \ |
80532737 | 469 | $(srccom)/cgen-mem.h |
c906108c | 470 | |
c906108c SS |
471 | # Support targets. |
472 | ||
473 | install: install-common $(SIM_EXTRA_INSTALL) | |
474 | ||
475 | install-common: installdirs | |
a0e674c1 | 476 | a=`basename "$$(pwd)"`; \ |
c906108c | 477 | n=`echo run | sed '$(program_transform_name)'`; \ |
a0e674c1 | 478 | [ "$(SIM_PRIMARY_TARGET)" = "$$a" ] || n="$$n-$$a"; \ |
149cfe5b | 479 | $(INSTALL_PROGRAM) run$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT) |
a0e674c1 MF |
480 | n="$(target_alias)-sim"; \ |
481 | a=`basename "$$(pwd)"`; \ | |
482 | [ "$(SIM_PRIMARY_TARGET)" = "$$a" ] || n="$$n-$$a"; \ | |
483 | n="lib$$n.a"; \ | |
149cfe5b DJ |
484 | $(INSTALL_DATA) libsim.a $(DESTDIR)$(libdir)/$$n ; \ |
485 | ( cd $(DESTDIR)$(libdir) ; $(RANLIB) $$n ) | |
c906108c SS |
486 | |
487 | installdirs: | |
149cfe5b DJ |
488 | $(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(bindir) |
489 | $(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(libdir) | |
c906108c SS |
490 | |
491 | check: | |
c906108c | 492 | |
0d0878d7 MF |
493 | html: |
494 | clean-html: | |
495 | install-html: | |
496 | ||
c906108c SS |
497 | info: |
498 | clean-info: | |
499 | install-info: | |
500 | ||
0d0878d7 MF |
501 | pdf: |
502 | clean-pdf: | |
503 | install-pdf: | |
504 | ||
c906108c SS |
505 | .NOEXPORT: |
506 | MAKEOVERRIDES= | |
507 | ||
508 | tags etags: TAGS | |
509 | ||
510 | # Macros like EXTERN_SIM_CORE confuse tags. | |
511 | # And the sim-n-foo.h files create functions that can't be found either. | |
512 | TAGS: force | |
513 | cd $(srcdir) && \ | |
509deab2 | 514 | etags --regex '/^\([[:lower:]_]+\) (/\1/' --regex '/^\/[*] TAGS: .*/' \ |
c906108c SS |
515 | *.[ch] ../common/*.[ch] |
516 | ||
be866656 | 517 | mostlyclean clean: $(SIM_EXTRA_CLEAN) |
c906108c | 518 | rm -f *.[oa] *~ core |
4ec242d7 | 519 | rm -f run$(EXEEXT) libsim.a |
b396d3a1 | 520 | rm -f hw-config.h stamp-hw |
015f7b74 | 521 | rm -f modules.c stamp-modules |
c906108c SS |
522 | rm -f gentmap targ-map.c targ-vals.h stamp-tvals |
523 | if [ ! -f Make-common.in ] ; then \ | |
524 | rm -f $(BUILT_SRC_FROM_COMMON) ; \ | |
525 | fi | |
526 | rm -f tmp-mloop.hin tmp-mloop.h tmp-mloop.cin tmp-mloop.c | |
527 | ||
be866656 | 528 | distclean maintainer-clean realclean: clean $(SIM_EXTRA_DISTCLEAN) |
c906108c SS |
529 | rm -f TAGS |
530 | rm -f Makefile config.cache config.log config.status .gdbinit | |
c906108c SS |
531 | |
532 | .c.o: | |
db2e4d67 MF |
533 | $(COMPILE) $< |
534 | $(POSTCOMPILE) | |
c906108c SS |
535 | |
536 | # Dummy target to force execution of dependent targets. | |
537 | force: | |
538 | ||
539 | Makefile: Makefile.in $(srccom)/Make-common.in config.status | |
540 | CONFIG_HEADERS= $(SHELL) ./config.status | |
541 | ||
542 | config.status: configure | |
543 | $(SHELL) ./config.status --recheck | |
544 | ||
c906108c SS |
545 | .gdbinit: # config.status $(srccom)/gdbinit.in |
546 | CONFIG_FILES=$@:../common/gdbinit.in CONFIG_HEADERS= $(SHELL) ./config.status | |
547 | ||
548 | ||
604259a0 FCE |
549 | # CGEN support |
550 | ||
551 | CGENDIR = @cgendir@ | |
9ab46d53 | 552 | CGEN = "`if [ -f ../../guile/libguile/guile ]; then echo ../../guile/libguile/guile; else echo guile ; fi` -l $(CGENDIR)/guile.scm -s" |
604259a0 | 553 | CGENFLAGS = -v |
e3e473da | 554 | CGEN_CPU_DIR = $(CGENDIR)/cpu |
604259a0 | 555 | |
6a8b8615 DE |
556 | # Most ports use the files here instead of cgen/cpu. |
557 | CPU_DIR = $(srcroot)/cpu | |
558 | ||
7ede505a | 559 | CGEN_READ_SCM = $(CGENDIR)/sim.scm |
e3e473da BE |
560 | CGEN_ARCH_SCM = $(CGENDIR)/sim-arch.scm |
561 | CGEN_CPU_SCM = $(CGENDIR)/sim-cpu.scm $(CGENDIR)/sim-model.scm | |
562 | CGEN_DECODE_SCM = $(CGENDIR)/sim-decode.scm | |
563 | CGEN_DESC_SCM = $(CGENDIR)/desc.scm $(CGENDIR)/desc-cpu.scm | |
604259a0 FCE |
564 | |
565 | # Various choices for which cpu specific files to generate. | |
2c2a86d7 DE |
566 | # These are passed to cgen.sh in the "extrafiles" argument. |
567 | CGEN_CPU_EXTR = /extr/ | |
568 | CGEN_CPU_READ = /read/ | |
569 | CGEN_CPU_WRITE = /write/ | |
570 | CGEN_CPU_SEM = /sem/ | |
571 | CGEN_CPU_SEMSW = /semsw/ | |
604259a0 FCE |
572 | |
573 | CGEN_FLAGS_TO_PASS = \ | |
9ab46d53 | 574 | CGEN='$(CGEN)' \ |
604259a0 FCE |
575 | CGENFLAGS="$(CGENFLAGS)" |
576 | ||
577 | # We store the generated files in the source directory until we decide to | |
578 | # ship a Scheme interpreter with gdb/binutils. Maybe we never will. | |
579 | ||
580 | cgen-arch: force | |
581 | $(SHELL) $(srccom)/cgen.sh arch $(srcdir) \ | |
582 | $(CGEN) $(CGENDIR) "$(CGENFLAGS)" \ | |
ea52ff81 DB |
583 | $(arch) "$(FLAGS)" ignored "$(isa)" $(mach) ignored \ |
584 | $(archfile) ignored | |
3c25f8c7 | 585 | |
604259a0 FCE |
586 | cgen-cpu: force |
587 | $(SHELL) $(srccom)/cgen.sh cpu $(srcdir) \ | |
588 | $(CGEN) $(CGENDIR) "$(CGENFLAGS)" \ | |
ea52ff81 DB |
589 | $(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \ |
590 | $(archfile) "$(EXTRAFILES)" | |
604259a0 | 591 | |
c79688eb BE |
592 | cgen-defs: force |
593 | $(SHELL) $(srccom)/cgen.sh defs $(srcdir) \ | |
594 | $(CGEN) $(CGENDIR) "$(CGENFLAGS)" \ | |
ea52ff81 DB |
595 | $(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \ |
596 | $(archfile) ignored | |
c79688eb | 597 | |
604259a0 FCE |
598 | cgen-decode: force |
599 | $(SHELL) $(srccom)/cgen.sh decode $(srcdir) \ | |
600 | $(CGEN) $(CGENDIR) "$(CGENFLAGS)" \ | |
ea52ff81 DB |
601 | $(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \ |
602 | $(archfile) "$(EXTRAFILES)" | |
604259a0 FCE |
603 | |
604 | cgen-cpu-decode: force | |
605 | $(SHELL) $(srccom)/cgen.sh cpu-decode $(srcdir) \ | |
606 | $(CGEN) $(CGENDIR) "$(CGENFLAGS)" \ | |
ea52ff81 DB |
607 | $(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \ |
608 | $(archfile) "$(EXTRAFILES)" | |
604259a0 FCE |
609 | |
610 | cgen-desc: force | |
611 | $(SHELL) $(srccom)/cgen.sh desc $(srcdir) \ | |
612 | $(CGEN) $(CGENDIR) "$(CGENFLAGS)" \ | |
ea52ff81 | 613 | $(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \ |
ad6e5d2e | 614 | $(archfile) ignored $(opcfile) |
604259a0 | 615 | |
c906108c | 616 | ## End COMMON_POST_CONFIG_FRAG |