]>
Commit | Line | Data |
---|---|---|
5bea0c32 | 1 | ## See sim/Makefile.am. |
de8a2781 | 2 | ## |
1d506c26 | 3 | ## Copyright (C) 1997-2024 Free Software Foundation, Inc. |
de8a2781 MF |
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 3 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, see <http://www.gnu.org/licenses/>. | |
5bea0c32 | 17 | |
de8a2781 | 18 | ## Parts of the common/ sim code that have been unified. |
5bea0c32 | 19 | |
a1af8f40 MF |
20 | AM_CPPFLAGS += \ |
21 | -I$(srcdir)/%D% \ | |
bc438b3e MF |
22 | -DSIM_TOPDIR_BUILD |
23 | AM_CPPFLAGS_%C% = -DSIM_COMMON_BUILD | |
fde7c6bf | 24 | AM_CPPFLAGS_FOR_BUILD += -I$(srcdir)/%D% |
5bea0c32 | 25 | |
de8a2781 MF |
26 | ## NB: libcommon.a isn't used directly by ports. We need a target for common |
27 | ## objects to be a part of, and ports use the individual objects directly. | |
eac2fbdc | 28 | ## We can delete this once ppc/Makefile.in is merged into ppc/local.mk. |
127d167a | 29 | noinst_LIBRARIES += %D%/libcommon.a |
5bea0c32 | 30 | %C%_libcommon_a_SOURCES = \ |
cd3ee89d | 31 | %D%/callback.c \ |
ad9cc209 | 32 | %D%/portability.c \ |
dd8e16ea | 33 | %D%/sim-load.c \ |
7fd14d6f | 34 | %D%/sim-signal.c \ |
66882204 | 35 | %D%/syscall.c \ |
a7e40a99 | 36 | %D%/target-newlib-errno.c \ |
670817b9 | 37 | %D%/target-newlib-open.c \ |
88c8370b | 38 | %D%/target-newlib-signal.c \ |
64ae70dd | 39 | %D%/target-newlib-syscall.c \ |
5bea0c32 MF |
40 | %D%/version.c |
41 | ||
015f7b74 MF |
42 | %D%/version.c: %D%/version.c-stamp ; @true |
43 | %D%/version.c-stamp: $(srcroot)/gdb/version.in $(srcroot)/bfd/version.h $(srcdir)/%D%/create-version.sh | |
fbe8d1cf | 44 | $(AM_V_GEN)$(SHELL) $(srcdir)/%D%/create-version.sh $(srcroot)/gdb $@.tmp |
015f7b74 | 45 | $(AM_V_at)$(SHELL) $(srcroot)/move-if-change $@.tmp $(@:-stamp=) |
fbe8d1cf | 46 | $(AM_V_at)touch $@ |
015f7b74 MF |
47 | |
48 | CLEANFILES += \ | |
49 | %D%/version.c %D%/version.c-stamp | |
c0c25232 | 50 | |
b014c9b0 MF |
51 | ## NB: This is a bit of a hack. If we can generalize the common/ files, we can |
52 | ## turn this from an arch-specific %/test-hw-events into a common/test-hw-events | |
53 | ## program. | |
54 | .PRECIOUS: %/test-hw-events.o | |
55 | %/test-hw-events.o: common/hw-events.c | |
56 | $(AM_V_CC)$(COMPILE) -DMAIN -c -o $@ $< | |
57 | %/test-hw-events: %/test-hw-events.o %/libsim.a | |
58 | $(AM_V_CCLD)$(LINK) -o $@ $^ $(SIM_COMMON_LIBS) $(LIBS) | |
59 | ||
c0c25232 MF |
60 | ## |
61 | ## For subdirs. | |
62 | ## | |
63 | ||
d47ea1b9 MF |
64 | SIM_COMMON_HW_OBJS = \ |
65 | hw-alloc.o \ | |
66 | hw-base.o \ | |
67 | hw-device.o \ | |
68 | hw-events.o \ | |
69 | hw-handles.o \ | |
70 | hw-instances.o \ | |
71 | hw-ports.o \ | |
72 | hw-properties.o \ | |
73 | hw-tree.o \ | |
74 | sim-hw.o | |
75 | ||
76 | SIM_NEW_COMMON_OBJS = \ | |
77 | sim-arange.o \ | |
78 | sim-bits.o \ | |
79 | sim-close.o \ | |
80 | sim-command.o \ | |
81 | sim-config.o \ | |
82 | sim-core.o \ | |
83 | sim-cpu.o \ | |
84 | sim-endian.o \ | |
85 | sim-engine.o \ | |
86 | sim-events.o \ | |
87 | sim-fpu.o \ | |
88 | sim-hload.o \ | |
89 | sim-hrw.o \ | |
90 | sim-io.o \ | |
91 | sim-info.o \ | |
92 | sim-memopt.o \ | |
93 | sim-model.o \ | |
94 | sim-module.o \ | |
95 | sim-options.o \ | |
96 | sim-profile.o \ | |
97 | sim-reason.o \ | |
98 | sim-reg.o \ | |
d47ea1b9 MF |
99 | sim-stop.o \ |
100 | sim-syscall.o \ | |
101 | sim-trace.o \ | |
102 | sim-utils.o \ | |
103 | sim-watch.o | |
104 | ||
d47ea1b9 MF |
105 | SIM_HW_DEVICES = cfi core pal glue |
106 | ||
107 | if SIM_ENABLE_HW | |
108 | SIM_NEW_COMMON_OBJS += \ | |
109 | $(SIM_COMMON_HW_OBJS) \ | |
110 | $(SIM_HW_SOCKSER) | |
d47ea1b9 MF |
111 | endif |
112 | ||
f4ac2306 MF |
113 | # FIXME This is one very simple-minded way of generating the file hw-config.h. |
114 | %/hw-config.h: %/stamp-hw ; @true | |
115 | %/stamp-hw: Makefile | |
116 | $(AM_V_GEN)set -e; \ | |
117 | ( \ | |
118 | sim_hw="$(SIM_HW_DEVICES) $($(@D)_SIM_EXTRA_HW_DEVICES)" ; \ | |
119 | echo "/* generated by Makefile */" ; \ | |
120 | printf "extern const struct hw_descriptor dv_%s_descriptor[];\n" $$sim_hw ; \ | |
121 | echo "const struct hw_descriptor * const hw_descriptors[] = {" ; \ | |
122 | printf " dv_%s_descriptor,\n" $$sim_hw ; \ | |
123 | echo " NULL," ; \ | |
124 | echo "};" \ | |
125 | ) > $@.tmp; \ | |
126 | $(SHELL) $(srcroot)/move-if-change $@.tmp $(@D)/hw-config.h; \ | |
127 | touch $@ | |
128 | .PRECIOUS: %/stamp-hw | |
129 | ||
49444fea | 130 | MOSTLYCLEANFILES += $(SIM_ENABLED_ARCHES:%=%/hw-config.h) $(SIM_ENABLED_ARCHES:%=%/stamp-hw) |
f4ac2306 | 131 | |
437eeee9 MF |
132 | ## See sim_pre_argv_init and sim_module_install in sim-module.c for more details. |
133 | ## TODO: Switch this to xxx_SOURCES once projects build objects in local.mk. | |
134 | am_arch_d = $(subst -,_,$(@D)) | |
135 | GEN_MODULES_C_SRCS = \ | |
136 | $(wildcard \ | |
54e26255 MF |
137 | $(patsubst %,$(srcdir)/%,$($(am_arch_d)_libsim_a_SOURCES)) \ |
138 | $(patsubst %.o,$(srcdir)/%.c,$($(am_arch_d)_libsim_a_OBJECTS) $($(am_arch_d)_libsim_a_LIBADD)) \ | |
139 | $(filter-out %.o,$(patsubst $(@D)/%.o,$(srcdir)/common/%.c,$($(am_arch_d)_libsim_a_LIBADD)))) | |
140 | %/modules.c: %/stamp-modules ; @true | |
141 | %/stamp-modules: Makefile | |
142 | $(AM_V_GEN)set -e; \ | |
143 | LANG=C ; export LANG; \ | |
144 | LC_ALL=C ; export LC_ALL; \ | |
145 | sed -n -e '/^sim_install_/{s/^\(sim_install_[a-z_0-9A-Z]*\).*/\1/;p}' $(GEN_MODULES_C_SRCS) | sort >$@.l-tmp; \ | |
146 | ( \ | |
147 | echo '/* Do not modify this file. */'; \ | |
148 | echo '/* It is created automatically by the Makefile. */'; \ | |
149 | echo '#include "libiberty.h"'; \ | |
150 | echo '#include "sim-module.h"'; \ | |
151 | sed -e 's:\(.*\):extern MODULE_INIT_FN \1;:' $@.l-tmp; \ | |
152 | echo 'MODULE_INSTALL_FN * const sim_modules_detected[] = {'; \ | |
153 | sed -e 's:\(.*\): \1,:' $@.l-tmp; \ | |
154 | echo '};'; \ | |
155 | echo 'const int sim_modules_detected_len = ARRAY_SIZE (sim_modules_detected);'; \ | |
156 | ) >$@.tmp; \ | |
157 | $(SHELL) $(srcroot)/move-if-change $@.tmp $(@D)/modules.c; \ | |
158 | rm -f $@.l-tmp; \ | |
159 | touch $@ | |
160 | .PRECIOUS: %/stamp-modules | |
437eeee9 MF |
161 | |
162 | ## NB: The ppc port doesn't currently utilize the modules API, so skip it. | |
1b907fc0 | 163 | MOSTLYCLEANFILES += $(SIM_ENABLED_ARCHES:%=%/modules.c) $(SIM_ENABLED_ARCHES:%=%/stamp-modules) |
437eeee9 | 164 | |
c0c25232 MF |
165 | LIBIBERTY_LIB = ../libiberty/libiberty.a |
166 | BFD_LIB = ../bfd/libbfd.la | |
167 | OPCODES_LIB = ../opcodes/libopcodes.la | |
168 | ||
169 | SIM_COMMON_LIBS = \ | |
c0c25232 MF |
170 | $(BFD_LIB) \ |
171 | $(OPCODES_LIB) \ | |
172 | $(LIBIBERTY_LIB) \ | |
173 | $(LIBGNU) \ | |
174 | $(LIBGNU_EXTRA_LIBS) | |
93b937c9 MF |
175 | |
176 | ## | |
177 | ## CGEN support. | |
178 | ## | |
179 | ||
180 | ## If the local tree has a bundled copy of guile, use that. | |
fd669f71 | 181 | GUILE = guile |
93b937c9 MF |
182 | CGEN = "$(GUILE) -l $(cgendir)/guile.scm -s" |
183 | CGENFLAGS = -v | |
184 | CGEN_CPU_DIR = $(cgendir)/cpu | |
185 | ## Most ports use the files here instead of cgen/cpu. | |
186 | CPU_DIR = $(srcroot)/cpu | |
187 | CGEN_ARCHFILE = $(CPU_DIR)/$(@D).cpu | |
188 | ||
189 | CGEN_READ_SCM = $(cgendir)/sim.scm | |
190 | CGEN_ARCH_SCM = $(cgendir)/sim-arch.scm | |
191 | CGEN_CPU_SCM = $(cgendir)/sim-cpu.scm $(cgendir)/sim-model.scm | |
192 | CGEN_DECODE_SCM = $(cgendir)/sim-decode.scm | |
193 | CGEN_DESC_SCM = $(cgendir)/desc.scm $(cgendir)/desc-cpu.scm | |
194 | ||
195 | ## Various choices for which cpu specific files to generate. | |
196 | ## These are passed to cgen.sh in the "extrafiles" argument. | |
197 | CGEN_CPU_EXTR = /extr/ | |
198 | CGEN_CPU_READ = /read/ | |
199 | CGEN_CPU_WRITE = /write/ | |
200 | CGEN_CPU_SEM = /sem/ | |
201 | CGEN_CPU_SEMSW = /semsw/ | |
202 | ||
203 | CGEN_WRAPPER = $(srccom)/cgen.sh | |
204 | ||
205 | CGEN_GEN_ARCH = \ | |
206 | $(SHELL) $(CGEN_WRAPPER) arch $(srcdir)/$(@D) \ | |
207 | $(CGEN) $(cgendir) "$(CGENFLAGS)" \ | |
208 | $(@D) "$$FLAGS" ignored "$$isa" $$mach ignored \ | |
209 | $(CGEN_ARCHFILE) ignored | |
210 | CGEN_GEN_CPU = \ | |
211 | $(SHELL) $(CGEN_WRAPPER) cpu $(srcdir)/$(@D) \ | |
212 | $(CGEN) $(cgendir) "$(CGENFLAGS)" \ | |
213 | $(@D) "$$FLAGS" $$cpu "$$isa" $$mach "$$SUFFIX" \ | |
214 | $(CGEN_ARCHFILE) "$$EXTRAFILES" | |
215 | CGEN_GEN_DEFS = \ | |
216 | $(SHELL) $(CGEN_WRAPPER) defs $(srcdir)/$(@D) \ | |
217 | $(CGEN) $(cgendir) "$(CGENFLAGS)" \ | |
218 | $(@D) "$$FLAGS" $$cpu "$$isa" $$mach "$$SUFFIX" \ | |
219 | $(CGEN_ARCHFILE) ignored | |
220 | CGEN_GEN_DECODE = \ | |
221 | $(SHELL) $(CGEN_WRAPPER) decode $(srcdir)/$(@D) \ | |
222 | $(CGEN) $(cgendir) "$(CGENFLAGS)" \ | |
223 | $(@D) "$$FLAGS" $$cpu "$$isa" $$mach "$$SUFFIX" \ | |
224 | $(CGEN_ARCHFILE) "$$EXTRAFILES" | |
225 | CGEN_GEN_CPU_DECODE = \ | |
226 | $(SHELL) $(CGEN_WRAPPER) cpu-decode $(srcdir)/$(@D) \ | |
227 | $(CGEN) $(cgendir) "$(CGENFLAGS)" \ | |
228 | $(@D) "$$FLAGS" $$cpu "$$isa" $$mach "$$SUFFIX" \ | |
229 | $(CGEN_ARCHFILE) "$$EXTRAFILES" | |
230 | CGEN_GEN_CPU_DESC = \ | |
231 | $(SHELL) $(CGEN_WRAPPER) desc $(srcdir)/$(@D) \ | |
232 | $(CGEN) $(cgendir) "$(CGENFLAGS)" \ | |
233 | $(@D) "$$FLAGS" $$cpu "$$isa" $$mach "$$SUFFIX" \ | |
234 | $(CGEN_ARCHFILE) ignored $$opcfile | |
09d4e6bb MF |
235 | |
236 | CGEN_GEN_MLOOP = \ | |
c0e97c85 MF |
237 | $(SHELL) $(srccom)/lineno.sh \ |
238 | $(srccom)/genmloop.sh \ | |
239 | $@.lineno.sh \ | |
240 | -shell $(SHELL) -awk $(AWK) -lineno $(srccom)/lineno.sh \ | |
09d4e6bb | 241 | -infile $< -outfile-prefix $(@D)/ |