]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | # Makefile fragment for common parts of all simulators. |
213516ef | 2 | # Copyright 1997-2023 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 | ||
b3408412 | 37 | srcdir = @abs_srcdir@ |
36bb57e4 | 38 | VPATH = $(srcdir):$(srccom) |
c906108c SS |
39 | srccom = $(srcdir)/../common |
40 | srcroot = $(srcdir)/../.. | |
7b064844 | 41 | srcsim = $(srcdir)/.. |
c906108c | 42 | |
36bb57e4 MF |
43 | @SIM_COMMON_BUILD_FALSE@config.status = config.status |
44 | @SIM_COMMON_BUILD_TRUE@config.status = ../config.status | |
45 | ||
90db43bb MF |
46 | # Settings from top-level configure. |
47 | include ../arch-subdir.mk | |
48 | ||
7daf500d SM |
49 | include $(srcroot)/gdb/silent-rules.mk |
50 | ||
65f42b88 MF |
51 | ifeq ($(V),0) |
52 | ECHO_STAMP = @echo " GEN " | |
53 | else | |
54 | ECHO_STAMP = @: | |
55 | endif | |
56 | ||
5c9e84c2 | 57 | # Helper code from gnulib. |
483ab96a MF |
58 | GNULIB_PARENT_DIR = ../.. |
59 | include $(GNULIB_PARENT_DIR)/gnulib/Makefile.gnulib.inc | |
5c9e84c2 | 60 | |
c906108c SS |
61 | # This can be referenced by the gettext configuration code. |
62 | top_builddir = .. | |
63 | ||
c906108c SS |
64 | SHELL = @SHELL@ |
65 | ||
c906108c | 66 | SIM_BITSIZE = @sim_bitsize@ |
c906108c | 67 | SIM_FLOAT = @sim_float@ |
d4f3574e SS |
68 | SIM_WARN_CFLAGS = $(WARN_CFLAGS) |
69 | SIM_WERROR_CFLAGS = $(WERROR_CFLAGS) | |
c906108c | 70 | |
db2e4d67 | 71 | # Dependency tracking information. |
db2e4d67 MF |
72 | depcomp = $(SHELL) $(srcroot)/depcomp |
73 | ||
74 | # Note that these are overridden by GNU make-specific code below if | |
75 | # GNU make is used. The overrides implement dependency tracking. | |
46f900c0 | 76 | COMPILE.pre = $(CC) $(C_DIALECT) |
db2e4d67 | 77 | COMPILE.post = -c -o $@ |
7daf500d | 78 | COMPILE = $(ECHO_CC) $(COMPILE.pre) $(ALL_CFLAGS) $(COMPILE.post) |
db2e4d67 | 79 | POSTCOMPILE = @true |
c906108c SS |
80 | |
81 | # Each simulator's Makefile.in defines one or more of these variables | |
82 | # to override our settings as necessary. There is no need to define these | |
83 | # in the simulator's Makefile.in if one is using the default value. In fact | |
84 | # it's preferable not to. | |
85 | ||
86 | # List of object files, less common parts. | |
87 | SIM_OBJS = | |
88 | # List of extra dependencies. | |
89 | # Generally this consists of simulator specific files included by sim-main.h. | |
90 | SIM_EXTRA_DEPS = | |
91 | # List of flags to always pass to $(CC). | |
92 | SIM_EXTRA_CFLAGS = | |
93 | # List of extra libraries to link with. | |
94 | SIM_EXTRA_LIBS = | |
c906108c | 95 | # List of main object files for `run'. |
465fb143 | 96 | SIM_RUN_OBJS = nrun.o |
c906108c SS |
97 | # Dependency of `clean' to clean any extra files. |
98 | SIM_EXTRA_CLEAN = | |
99 | ||
100 | # Every time a new general purpose source file was added every target's | |
101 | # Makefile.in needed to be updated to include the file in SIM_OBJS. | |
102 | # This doesn't scale. | |
103 | # This variable specifies all the generic stuff common to the newer simulators. | |
104 | # Things like sim-reason.o can't go here as the cpu may provide its own | |
105 | # (though hopefully in time that won't be so). Things like sim-bits.o can go | |
106 | # here. Some files are used by all simulators (e.g. callback.o). | |
107 | # Those files are specified in LIB_OBJS below. | |
108 | ||
c906108c SS |
109 | ## End COMMON_PRE_CONFIG_FRAG |
110 | ||
111 | ## COMMON_POST_CONFIG_FRAG | |
112 | ||
113 | CONFIG_CFLAGS = \ | |
52d37d2c | 114 | -DHAVE_CONFIG_H \ |
c906108c | 115 | $(SIM_BITSIZE) \ |
c906108c SS |
116 | $(SIM_FLOAT) \ |
117 | $(SIM_HW_CFLAGS) \ | |
c906108c | 118 | $(SIM_INLINE) \ |
d4f3574e | 119 | $(SIM_WARN_CFLAGS) \ |
fc9c0bdc | 120 | $(SIM_WERROR_CFLAGS) |
ca7b34c5 MF |
121 | CSEARCH = -I. -I$(srcdir) -I$(srccom) \ |
122 | -I$(srcroot)/include \ | |
c906108c | 123 | -I../../bfd -I$(srcroot)/bfd \ |
ca7b34c5 | 124 | -I$(srcroot)/opcodes \ |
89cf99a9 | 125 | -I../.. |
5c9e84c2 | 126 | ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(INCGNU) $(SIM_EXTRA_CFLAGS) $(CFLAGS) |
c2783492 | 127 | BUILD_CFLAGS = $(CFLAGS_FOR_BUILD) $(CSEARCH) |
c906108c | 128 | |
10737236 | 129 | COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(SIM_EXTRA_CFLAGS) |
c906108c | 130 | |
3d042117 | 131 | SIM_HW_DEVICES = $(SIM_HW_DEVICES_) $($(arch)_SIM_EXTRA_HW_DEVICES) |
d47ea1b9 | 132 | SIM_NEW_COMMON_OBJS = $(SIM_NEW_COMMON_OBJS_) $(SIM_HW_OBJS) |
be0387ee | 133 | |
c906108c | 134 | LIBIBERTY_LIB = ../../libiberty/libiberty.a |
89cf99a9 MF |
135 | BFD_LIB = ../../bfd/libbfd.la |
136 | OPCODES_LIB = ../../opcodes/libopcodes.la | |
89cf99a9 MF |
137 | LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) |
138 | EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \ | |
49ea4303 | 139 | $(COMMON_LIBS) $(SIM_EXTRA_LIBS) $(LIBGNU) $(LIBGNU_EXTRA_LIBS) |
c906108c | 140 | |
dd8e16ea | 141 | COMMON_OBJS_NAMES = \ |
cd3ee89d | 142 | callback.o \ |
ad9cc209 | 143 | portability.o \ |
dd8e16ea | 144 | sim-load.o \ |
66882204 | 145 | syscall.o \ |
a7e40a99 | 146 | target-newlib-errno.o \ |
670817b9 | 147 | target-newlib-open.o \ |
88c8370b | 148 | target-newlib-signal.o \ |
1e42d017 | 149 | target-newlib-syscall.o \ |
dd8e16ea | 150 | version.o |
a1af8f40 | 151 | COMMON_OBJS = $(COMMON_OBJS_NAMES:%=../common/%) |
5bea0c32 | 152 | |
66882204 | 153 | LIB_OBJS = modules.o $(COMMON_OBJS) $(SIM_OBJS) |
64ae70dd | 154 | |
c6c7769d | 155 | COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(BUILD_CFLAGS) |
e7d9022b | 156 | LINK_FOR_BUILD = $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(LDFLAGS_FOR_BUILD) -o $@ |
c6c7769d | 157 | |
c906108c SS |
158 | RUNTESTFLAGS = |
159 | ||
c0c25232 | 160 | all: libsim.a $(SIM_RUN_OBJS) |
c906108c SS |
161 | |
162 | libsim.a: $(LIB_OBJS) | |
65f42b88 | 163 | $(SILENCE) rm -f libsim.a |
7daf500d SM |
164 | $(ECHO_AR) $(AR) $(AR_FLAGS) libsim.a $(LIB_OBJS) |
165 | $(ECHO_RANLIB) $(RANLIB) libsim.a | |
c906108c | 166 | |
db2e4d67 MF |
167 | # |
168 | # Dependency tracking. Most of this is conditional on GNU Make being | |
169 | # found by configure; if GNU Make is not found, we fall back to a | |
170 | # simpler scheme. | |
171 | # | |
172 | ||
efd82ac7 | 173 | ifeq ($(DEPMODE),depmode=gcc3) |
db2e4d67 MF |
174 | # Note that we put the dependencies into a .Tpo file, then move them |
175 | # into place if the compile succeeds. We need this because gcc does | |
176 | # not atomically write the dependency output file. | |
efd82ac7 TT |
177 | override COMPILE.post = -c -o $@ -MT $@ -MMD -MP \ |
178 | -MF $(DEPDIR)/$(basename $(@F)).Tpo | |
179 | override POSTCOMPILE = @mv $(DEPDIR)/$(basename $(@F)).Tpo \ | |
180 | $(DEPDIR)/$(basename $(@F)).Po | |
181 | else | |
182 | override COMPILE.pre = source='$<' object='$@' libtool=no \ | |
183 | DEPDIR=$(DEPDIR) $(DEPMODE) $(depcomp) $(CC) | |
db2e4d67 MF |
184 | # depcomp handles atomicity for us, so we don't need a postcompile |
185 | # step. | |
efd82ac7 TT |
186 | override POSTCOMPILE = |
187 | endif | |
db2e4d67 MF |
188 | |
189 | all_object_files = $(LIB_OBJS) $(SIM_RUN_OBJS) | |
190 | generated_files = \ | |
191 | $(SIM_EXTRA_DEPS) \ | |
1e42d017 | 192 | modules.c |
db2e4d67 MF |
193 | |
194 | # Ensure that generated files are created early. Use order-only | |
195 | # dependencies if available. They require GNU make 3.80 or newer, | |
196 | # and the .VARIABLES variable was introduced at the same time. | |
efd82ac7 TT |
197 | ifdef .VARIABLES |
198 | $(all_object_files): | $(generated_files) | |
199 | else | |
db2e4d67 | 200 | $(all_object_files) : $(generated_files) |
efd82ac7 | 201 | endif |
db2e4d67 MF |
202 | |
203 | # Dependencies. | |
efd82ac7 | 204 | -include $(patsubst %.o, $(DEPDIR)/%.Po, $(all_object_files)) |
c906108c | 205 | |
c906108c | 206 | test-hw-events: $(srccom)/hw-events.c libsim.a |
90db43bb MF |
207 | $(ECHO_CCLD) $(LIBTOOL) $(AM_V_lt) --tag=CC --mode=link \ |
208 | $(CC) $(ALL_CFLAGS) -DMAIN -o test-hw-events$(EXEEXT) \ | |
c906108c SS |
209 | $(srccom)/hw-events.c libsim.a $(EXTRA_LIBS) |
210 | ||
8e5f1516 | 211 | # See sim_pre_argv_init and sim_module_install in sim-module.c for more details. |
015f7b74 MF |
212 | modules.c: stamp-modules ; @true |
213 | stamp-modules: Makefile $(SIM_OBJS:.o=.c) | |
65f42b88 MF |
214 | $(ECHO_STAMP) modules.c |
215 | $(SILENCE) LANG=C ; export LANG ; \ | |
8e5f1516 MF |
216 | LC_ALL=C ; export LC_ALL ; \ |
217 | sed -n -e '/^sim_install_/{s/^\(sim_install_[a-z_0-9A-Z]*\).*/\1/;p}' $^ | sort >$@.l-tmp | |
218 | @set -e; (\ | |
219 | echo '/* Do not modify this file. */'; \ | |
220 | echo '/* It is created automatically by the Makefile. */'; \ | |
221 | echo '#include "libiberty.h"'; \ | |
222 | echo '#include "sim-module.h"'; \ | |
cee4c731 | 223 | sed -e 's:\(.*\):extern MODULE_INIT_FN \1;:' $@.l-tmp; \ |
8e5f1516 MF |
224 | echo 'MODULE_INSTALL_FN * const sim_modules_detected[] = {'; \ |
225 | sed -e 's:\(.*\): \1,:' $@.l-tmp; \ | |
226 | echo '};'; \ | |
227 | echo 'const int sim_modules_detected_len = ARRAY_SIZE (sim_modules_detected);'; \ | |
228 | ) >$@.tmp | |
4f2b181e | 229 | $(SILENCE) $(SHELL) $(srcroot)/move-if-change $@.tmp modules.c |
65f42b88 | 230 | $(SILENCE) rm -f $@.l-tmp $@.tmp |
b6143d31 | 231 | $(SILENCE) touch $@ |
8e5f1516 | 232 | |
c906108c SS |
233 | # Support targets. |
234 | ||
63bf33ff | 235 | install: |
c906108c | 236 | installdirs: |
59d8576e | 237 | uninstall: |
c906108c SS |
238 | |
239 | check: | |
c906108c | 240 | |
0d0878d7 MF |
241 | html: |
242 | clean-html: | |
243 | install-html: | |
244 | ||
c906108c SS |
245 | info: |
246 | clean-info: | |
247 | install-info: | |
248 | ||
0d0878d7 MF |
249 | pdf: |
250 | clean-pdf: | |
251 | install-pdf: | |
252 | ||
c906108c SS |
253 | .NOEXPORT: |
254 | MAKEOVERRIDES= | |
255 | ||
256 | tags etags: TAGS | |
257 | ||
258 | # Macros like EXTERN_SIM_CORE confuse tags. | |
259 | # And the sim-n-foo.h files create functions that can't be found either. | |
260 | TAGS: force | |
261 | cd $(srcdir) && \ | |
509deab2 | 262 | etags --regex '/^\([[:lower:]_]+\) (/\1/' --regex '/^\/[*] TAGS: .*/' \ |
c906108c SS |
263 | *.[ch] ../common/*.[ch] |
264 | ||
be866656 | 265 | mostlyclean clean: $(SIM_EXTRA_CLEAN) |
2213e33d MF |
266 | rm -f *.[oa] *~ core \ |
267 | run$(EXEEXT) libsim.a \ | |
b19d96d1 | 268 | modules.c stamp-modules |
c906108c | 269 | |
2a005e97 MF |
270 | distclean maintainer-clean realclean: clean |
271 | rm -f TAGS Makefile | |
c906108c SS |
272 | |
273 | .c.o: | |
db2e4d67 MF |
274 | $(COMPILE) $< |
275 | $(POSTCOMPILE) | |
c906108c SS |
276 | |
277 | # Dummy target to force execution of dependent targets. | |
278 | force: | |
279 | ||
36bb57e4 | 280 | Makefile: Makefile.in $(srccom)/Make-common.in $(config.status) |
9709fa5b MF |
281 | @SIM_COMMON_BUILD_FALSE@ $(ECHO_GEN) CONFIG_HEADERS= $(SHELL) ./config.status |
282 | @SIM_COMMON_BUILD_TRUE@ $(ECHO_GEN) pwd=`pwd` && subdir=`basename "$$pwd"` && cd .. && \ | |
cc717561 | 283 | @SIM_COMMON_BUILD_TRUE@ $(SHELL) ./config.status Make-common.sim $$subdir/Makefile.sim $$subdir/Makefile |
c906108c | 284 | |
36bb57e4 | 285 | @SIM_COMMON_BUILD_FALSE@config.status: configure |
9709fa5b | 286 | @SIM_COMMON_BUILD_FALSE@ $(ECHO_GEN) $(SHELL) ./config.status --recheck |
c906108c | 287 | |
c906108c | 288 | |
604259a0 FCE |
289 | # CGEN support |
290 | ||
2fe36d31 MF |
291 | GUILE = `if [ -f ../../guile/libguile/guile ]; then echo ../../guile/libguile/guile; else echo guile ; fi` |
292 | CGEN = "$(GUILE) -l $(CGENDIR)/guile.scm -s" | |
604259a0 | 293 | CGENFLAGS = -v |
e3e473da | 294 | CGEN_CPU_DIR = $(CGENDIR)/cpu |
604259a0 | 295 | |
6a8b8615 DE |
296 | # Most ports use the files here instead of cgen/cpu. |
297 | CPU_DIR = $(srcroot)/cpu | |
298 | ||
7ede505a | 299 | CGEN_READ_SCM = $(CGENDIR)/sim.scm |
e3e473da BE |
300 | CGEN_ARCH_SCM = $(CGENDIR)/sim-arch.scm |
301 | CGEN_CPU_SCM = $(CGENDIR)/sim-cpu.scm $(CGENDIR)/sim-model.scm | |
302 | CGEN_DECODE_SCM = $(CGENDIR)/sim-decode.scm | |
303 | CGEN_DESC_SCM = $(CGENDIR)/desc.scm $(CGENDIR)/desc-cpu.scm | |
604259a0 FCE |
304 | |
305 | # Various choices for which cpu specific files to generate. | |
2c2a86d7 DE |
306 | # These are passed to cgen.sh in the "extrafiles" argument. |
307 | CGEN_CPU_EXTR = /extr/ | |
308 | CGEN_CPU_READ = /read/ | |
309 | CGEN_CPU_WRITE = /write/ | |
310 | CGEN_CPU_SEM = /sem/ | |
311 | CGEN_CPU_SEMSW = /semsw/ | |
604259a0 FCE |
312 | |
313 | CGEN_FLAGS_TO_PASS = \ | |
9ab46d53 | 314 | CGEN='$(CGEN)' \ |
604259a0 FCE |
315 | CGENFLAGS="$(CGENFLAGS)" |
316 | ||
317 | # We store the generated files in the source directory until we decide to | |
318 | # ship a Scheme interpreter with gdb/binutils. Maybe we never will. | |
319 | ||
320 | cgen-arch: force | |
321 | $(SHELL) $(srccom)/cgen.sh arch $(srcdir) \ | |
322 | $(CGEN) $(CGENDIR) "$(CGENFLAGS)" \ | |
ea52ff81 DB |
323 | $(arch) "$(FLAGS)" ignored "$(isa)" $(mach) ignored \ |
324 | $(archfile) ignored | |
3c25f8c7 | 325 | |
604259a0 FCE |
326 | cgen-cpu: force |
327 | $(SHELL) $(srccom)/cgen.sh cpu $(srcdir) \ | |
328 | $(CGEN) $(CGENDIR) "$(CGENFLAGS)" \ | |
ea52ff81 DB |
329 | $(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \ |
330 | $(archfile) "$(EXTRAFILES)" | |
604259a0 | 331 | |
c79688eb BE |
332 | cgen-defs: force |
333 | $(SHELL) $(srccom)/cgen.sh defs $(srcdir) \ | |
334 | $(CGEN) $(CGENDIR) "$(CGENFLAGS)" \ | |
ea52ff81 DB |
335 | $(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \ |
336 | $(archfile) ignored | |
c79688eb | 337 | |
604259a0 FCE |
338 | cgen-decode: force |
339 | $(SHELL) $(srccom)/cgen.sh decode $(srcdir) \ | |
340 | $(CGEN) $(CGENDIR) "$(CGENFLAGS)" \ | |
ea52ff81 DB |
341 | $(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \ |
342 | $(archfile) "$(EXTRAFILES)" | |
604259a0 FCE |
343 | |
344 | cgen-cpu-decode: force | |
345 | $(SHELL) $(srccom)/cgen.sh cpu-decode $(srcdir) \ | |
346 | $(CGEN) $(CGENDIR) "$(CGENFLAGS)" \ | |
ea52ff81 DB |
347 | $(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \ |
348 | $(archfile) "$(EXTRAFILES)" | |
604259a0 FCE |
349 | |
350 | cgen-desc: force | |
351 | $(SHELL) $(srccom)/cgen.sh desc $(srcdir) \ | |
352 | $(CGEN) $(CGENDIR) "$(CGENFLAGS)" \ | |
ea52ff81 | 353 | $(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \ |
ad6e5d2e | 354 | $(archfile) ignored $(opcfile) |
604259a0 | 355 | |
c906108c | 356 | ## End COMMON_POST_CONFIG_FRAG |