1## See sim/Makefile.am
2##
3## Copyright (C) 2004-2024 Free Software Foundation, Inc.
4## Contributed by Axis Communications.
5##
6## This program is free software; you can redistribute it and/or modify
7## it under the terms of the GNU General Public License as published by
8## the Free Software Foundation; either version 3 of the License, or
9## (at your option) any later version.
10##
11## This program is distributed in the hope that it will be useful,
12## but WITHOUT ANY WARRANTY; without even the implied warranty of
13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14## GNU General Public License for more details.
15##
16## You should have received a copy of the GNU General Public License
17## along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19## Some CGEN kludges are causing build-time warnings.  See cris.cpu for details.
20AM_CFLAGS_%C%_mloopv10f.o = $(SIM_CFLAG_WNO_UNUSED_BUT_SET_VARIABLE)
21AM_CFLAGS_%C%_mloopv32f.o = $(SIM_CFLAG_WNO_UNUSED_BUT_SET_VARIABLE)
22## Some CGEN assignments use variable names that are nested & repeated.
23AM_CFLAGS_%C%_mloopv10f.o += $(SIM_CFLAG_WNO_SHADOW_LOCAL)
24
25nodist_%C%_libsim_a_SOURCES = \
26	%D%/modules.c
27%C%_libsim_a_SOURCES = \
28	$(common_libcommon_a_SOURCES)
29%C%_libsim_a_LIBADD = \
30	$(patsubst %,%D%/%,$(SIM_NEW_COMMON_OBJS)) \
31	$(patsubst %,%D%/dv-%.o,$(SIM_HW_DEVICES)) \
32	$(patsubst %,%D%/dv-%.o,$(%C%_SIM_EXTRA_HW_DEVICES)) \
33	\
34	%D%/cgen-run.o \
35	%D%/cgen-scache.o \
36	%D%/cgen-trace.o \
37	%D%/cgen-utils.o \
38	\
39	%D%/arch.o \
40	%D%/crisv10f.o \
41	%D%/cpuv10.o \
42	%D%/decodev10.o \
43	%D%/modelv10.o \
44	%D%/mloopv10f.o \
45	%D%/crisv32f.o \
46	%D%/cpuv32.o \
47	%D%/decodev32.o \
48	%D%/modelv32.o \
49	%D%/mloopv32f.o \
50	\
51	%D%/sim-if.o \
52	%D%/traps.o
53$(%C%_libsim_a_OBJECTS) $(%C%_libsim_a_LIBADD): %D%/hw-config.h
54
55noinst_LIBRARIES += %D%/libsim.a
56
57## Override wildcards that trigger common/modules.c to be (incorrectly) used.
58%D%/modules.o: %D%/modules.c
59
60%D%/%.o: common/%.c ; $(SIM_COMPILE)
61-@am__include@ %D%/$(DEPDIR)/*.Po
62
63%C%_run_SOURCES =
64%C%_run_LDADD = \
65	%D%/nrun.o \
66	%D%/libsim.a \
67	$(SIM_COMMON_LIBS)
68
69noinst_PROGRAMS += %D%/run
70
71%C%_SIM_EXTRA_HW_DEVICES = rv cris cris_900000xx
72
73## rvdummy is just used for testing -- it runs on the same host as `run`.
74## It does nothing if --enable-sim-hardware isn't active.
75%C%_rvdummy_SOURCES = %D%/rvdummy.c
76%C%_rvdummy_LDADD = $(LIBIBERTY_LIB)
77
78check_PROGRAMS += %D%/rvdummy
79
80## List all generated headers to help Automake dependency tracking.
81BUILT_SOURCES += \
82	%D%/engv10.h \
83	%D%/engv32.h
84%C%_BUILD_OUTPUTS = \
85	%D%/mloopv10f.c \
86	%D%/stamp-mloop-v10f \
87	%D%/mloopv32f.c \
88	%D%/stamp-mloop-v32f
89
90## Generating modules.c requires all sources to scan.
91%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
92
93## FIXME: What is mono and what does "Use of `mono' is wip" mean (other
94## than the apparent; some "mono" feature is work in progress)?
95%D%/mloopv10f.c %D%/engv10.h: %D%/stamp-mloop-v10f ; @true
96%D%/stamp-mloop-v10f: %D%/mloop.in $(srccom)/genmloop.sh
97	$(AM_V_GEN)$(CGEN_GEN_MLOOP) \
98		-mono -no-fast -pbb -switch semcrisv10f-switch.c \
99		-cpu crisv10f -outfile-suffix -v10f
100	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng-v10f.hin %D%/engv10.h
101	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop-v10f.cin %D%/mloopv10f.c
102	$(AM_V_at)touch $@
103
104## FIXME: What is mono and what does "Use of `mono' is wip" mean (other
105## than the apparent; some "mono" feature is work in progress)?
106%D%/mloopv32f.c %D%/engv32.h: %D%/stamp-mloop-v32f ; @true
107%D%/stamp-mloop-v32f: %D%/mloop.in $(srccom)/genmloop.sh
108	$(AM_V_GEN)$(CGEN_GEN_MLOOP) \
109		-mono -no-fast -pbb -switch semcrisv32f-switch.c \
110		-cpu crisv32f -outfile-suffix -v32f
111	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng-v32f.hin %D%/engv32.h
112	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop-v32f.cin %D%/mloopv32f.c
113	$(AM_V_at)touch $@
114
115CLEANFILES += %D%/engv10.h %D%/engv32.h
116MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
117
118## Target that triggers all cgen targets that works when --disable-cgen-maint.
119%D%/cgen: %D%/cgen-arch %D%/cgen-cpu-decode-v10f %D%/cgen-cpu-decode-v32f
120
121%D%/cgen-arch:
122	$(AM_V_GEN)mach=crisv10,crisv32 FLAGS="with-scache with-profile=fn"; $(CGEN_GEN_ARCH)
123$(srcdir)/%D%/arch.h $(srcdir)/%D%/arch.c $(srcdir)/%D%/cpuall.h: @CGEN_MAINT@ %D%/cgen-arch
124
125%D%/cgen-cpu-decode-v10f:
126	$(AM_V_GEN)cpu=crisv10f mach=crisv10 SUFFIX=v10 FLAGS="with-scache with-profile=fn" EXTRAFILES="$(CGEN_CPU_SEMSW)"; $(CGEN_GEN_CPU_DECODE)
127	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change $(srcdir)/%D%/semv10-switch.c $(srcdir)/%D%/semcrisv10f-switch.c
128$(srcdir)/%D%/cpuv10.h $(srcdir)/%D%/cpuv10.c $(srcdir)/%D%/semcrisv10f-switch.c $(srcdir)/%D%/modelv10.c $(srcdir)/%D%/decodev10.c $(srcdir)/%D%/decodev10.h: @CGEN_MAINT@ %D%/cgen-cpu-decode-v10f
129
130%D%/cgen-cpu-decode-v32f:
131	$(AM_V_GEN)cpu=crisv32f mach=crisv32 SUFFIX=v32 FLAGS="with-scache with-profile=fn" EXTRAFILES="$(CGEN_CPU_SEMSW)"; $(CGEN_GEN_CPU_DECODE)
132	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change $(srcdir)/%D%/semv32-switch.c $(srcdir)/%D%/semcrisv32f-switch.c
133$(srcdir)/%D%/cpuv32.h $(srcdir)/%D%/cpuv32.c $(srcdir)/%D%/semcrisv32f-switch.c $(srcdir)/%D%/modelv32.c $(srcdir)/%D%/decodev32.c $(srcdir)/%D%/decodev32.h: @CGEN_MAINT@ %D%/cgen-cpu-decode-v32f
134