lto: Don't add indirect symbols for versioned aliases in IR
[binutils-gdb.git] / sim / common / local.mk
1 ## See sim/Makefile.am.
2 ##
3 ## Copyright (C) 1997-2023 Free Software Foundation, Inc.
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/>.
17
18 ## Parts of the common/ sim code that have been unified.
19
20 AM_CPPFLAGS += \
21 -I$(srcdir)/%D% \
22 -DSIM_TOPDIR_BUILD
23 AM_CPPFLAGS_%C% = -DSIM_COMMON_BUILD
24 AM_CPPFLAGS_FOR_BUILD += -I$(srcdir)/%D%
25
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.
28 ## We can delete this once ppc/Makefile.in is merged into ppc/local.mk.
29 noinst_LIBRARIES += %D%/libcommon.a
30 %C%_libcommon_a_SOURCES = \
31 %D%/callback.c \
32 %D%/portability.c \
33 %D%/sim-load.c \
34 %D%/sim-signal.c \
35 %D%/syscall.c \
36 %D%/target-newlib-errno.c \
37 %D%/target-newlib-open.c \
38 %D%/target-newlib-signal.c \
39 %D%/target-newlib-syscall.c \
40 %D%/version.c
41
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
44 $(AM_V_GEN)$(SHELL) $(srcdir)/%D%/create-version.sh $(srcroot)/gdb $@.tmp
45 $(AM_V_at)$(SHELL) $(srcroot)/move-if-change $@.tmp $(@:-stamp=)
46 $(AM_V_at)touch $@
47
48 CLEANFILES += \
49 %D%/version.c %D%/version.c-stamp
50
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
60 ##
61 ## For subdirs.
62 ##
63
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 \
99 sim-stop.o \
100 sim-syscall.o \
101 sim-trace.o \
102 sim-utils.o \
103 sim-watch.o
104
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)
111 endif
112
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
130 MOSTLYCLEANFILES += $(SIM_ENABLED_ARCHES:%=%/hw-config.h) $(SIM_ENABLED_ARCHES:%=%/stamp-hw)
131
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 \
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
161
162 ## NB: The ppc port doesn't currently utilize the modules API, so skip it.
163 MOSTLYCLEANFILES += $(SIM_ENABLED_ARCHES:%=%/modules.c) $(SIM_ENABLED_ARCHES:%=%/stamp-modules)
164
165 LIBIBERTY_LIB = ../libiberty/libiberty.a
166 BFD_LIB = ../bfd/libbfd.la
167 OPCODES_LIB = ../opcodes/libopcodes.la
168
169 SIM_COMMON_LIBS = \
170 $(BFD_LIB) \
171 $(OPCODES_LIB) \
172 $(LIBIBERTY_LIB) \
173 $(LIBGNU) \
174 $(LIBGNU_EXTRA_LIBS)
175
176 ##
177 ## CGEN support.
178 ##
179
180 ## If the local tree has a bundled copy of guile, use that.
181 GUILE = $(or $(wildcard ../guile/libguile/guile),guile)
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