1 ## See sim/Makefile.am.
3 ## Copyright (C) 1997-2023 Free Software Foundation, Inc.
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.
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.
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/>.
18 ## Parts of the common/ sim code that have been unified.
23 AM_CPPFLAGS_
%C
% = -DSIM_COMMON_BUILD
24 AM_CPPFLAGS_FOR_BUILD
+= -I
$(srcdir)/%D
%
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
= \
36 %D
%/target-newlib-errno.c \
37 %D
%/target-newlib-open.c \
38 %D
%/target-newlib-signal.c \
39 %D
%/target-newlib-syscall.c \
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
=)
49 %D
%/version.c
%D
%/version.c-stamp
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
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
)
64 SIM_COMMON_HW_OBJS
= \
76 SIM_NEW_COMMON_OBJS
= \
105 SIM_HW_DEVICES
= cfi core pal glue
108 SIM_NEW_COMMON_OBJS
+= \
109 $(SIM_COMMON_HW_OBJS
) \
113 # FIXME This is one very simple-minded way of generating the file hw-config.h.
114 %/hw-config.h
: %/stamp-hw
; @true
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 ; \
126 $(SHELL
) $(srcroot
)/move-if-change
$@.tmp
$(@D
)/hw-config.h
; \
128 .PRECIOUS
: %/stamp-hw
130 MOSTLYCLEANFILES
+= $(SIM_ENABLED_ARCHES
:%=%/hw-config.h
) $(SIM_ENABLED_ARCHES
:%=%/stamp-hw
)
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
= \
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
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
; \
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
; \
155 echo
'const int sim_modules_detected_len = ARRAY_SIZE (sim_modules_detected);'; \
157 $(SHELL
) $(srcroot
)/move-if-change
$@.tmp
$(@D
)/modules.c
; \
160 .PRECIOUS
: %/stamp-modules
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
)
165 LIBIBERTY_LIB
= ..
/libiberty
/libiberty.a
166 BFD_LIB
= ..
/bfd
/libbfd.la
167 OPCODES_LIB
= ..
/opcodes
/libopcodes.la
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"
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
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
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
/
201 CGEN_CPU_SEMSW
= /semsw
/
203 CGEN_WRAPPER
= $(srccom
)/cgen.sh
206 $(SHELL
) $(CGEN_WRAPPER
) arch
$(srcdir)/$(@D
) \
207 $(CGEN
) $(cgendir
) "$(CGENFLAGS)" \
208 $(@D
) "$$FLAGS" ignored
"$$isa" $$mach ignored \
209 $(CGEN_ARCHFILE
) ignored
211 $(SHELL
) $(CGEN_WRAPPER
) cpu
$(srcdir)/$(@D
) \
212 $(CGEN
) $(cgendir
) "$(CGENFLAGS)" \
213 $(@D
) "$$FLAGS" $$cpu "$$isa" $$mach "$$SUFFIX" \
214 $(CGEN_ARCHFILE
) "$$EXTRAFILES"
216 $(SHELL
) $(CGEN_WRAPPER
) defs
$(srcdir)/$(@D
) \
217 $(CGEN
) $(cgendir
) "$(CGENFLAGS)" \
218 $(@D
) "$$FLAGS" $$cpu "$$isa" $$mach "$$SUFFIX" \
219 $(CGEN_ARCHFILE
) ignored
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