1## See sim/Makefile.am
2##
3## Copyright (C) 2017-2024 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
18AM_CPPFLAGS_%C% = -DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31
19
20nodist_%C%_libsim_a_SOURCES = \
21	%D%/modules.c
22%C%_libsim_a_SOURCES = \
23	$(common_libcommon_a_SOURCES)
24%C%_libsim_a_LIBADD = \
25	$(patsubst %,%D%/%,$(SIM_NEW_COMMON_OBJS)) \
26	$(patsubst %,%D%/dv-%.o,$(SIM_HW_DEVICES)) \
27	\
28	%D%/cgen-accfp.o \
29	%D%/cgen-fpu.o \
30	%D%/cgen-run.o \
31	%D%/cgen-scache.o \
32	%D%/cgen-trace.o \
33	%D%/cgen-utils.o \
34	\
35	%D%/arch.o \
36	%D%/cpu.o \
37	%D%/decode.o \
38	%D%/mloop.o \
39	%D%/model.o \
40	%D%/sem.o \
41	\
42	%D%/or1k.o \
43	%D%/sim-if.o \
44	%D%/traps.o
45$(%C%_libsim_a_OBJECTS) $(%C%_libsim_a_LIBADD): %D%/hw-config.h
46
47noinst_LIBRARIES += %D%/libsim.a
48
49## Override wildcards that trigger common/modules.c to be (incorrectly) used.
50%D%/modules.o: %D%/modules.c
51
52%D%/%.o: common/%.c ; $(SIM_COMPILE)
53-@am__include@ %D%/$(DEPDIR)/*.Po
54
55%C%_run_SOURCES =
56%C%_run_LDADD = \
57	%D%/nrun.o \
58	%D%/libsim.a \
59	$(SIM_COMMON_LIBS)
60
61noinst_PROGRAMS += %D%/run
62
63%C%docdir = $(docdir)/%C%
64%C%doc_DATA = %D%/README
65
66## List all generated headers to help Automake dependency tracking.
67BUILT_SOURCES += %D%/eng.h
68%C%_BUILD_OUTPUTS = \
69	%D%/mloop.c \
70	%D%/stamp-mloop
71
72## Generating modules.c requires all sources to scan.
73%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
74
75## FIXME: Use of `mono' is wip.
76%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
77%D%/stamp-mloop: %D%/mloop.in $(srccom)/genmloop.sh
78	$(AM_V_GEN)$(CGEN_GEN_MLOOP) \
79		-mono -fast -pbb -switch sem-switch.c \
80		-cpu or1k32bf
81	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng.hin %D%/eng.h
82	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop.cin %D%/mloop.c
83	$(AM_V_at)touch $@
84
85CLEANFILES += %D%/eng.h
86MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
87
88## Target that triggers all cgen targets that works when --disable-cgen-maint.
89%D%/cgen: %D%/cgen-arch %D%/cgen-cpu-decode
90
91%D%/cgen-arch:
92	$(AM_V_GEN)mach=or32,or32nd FLAGS="with-scache"; $(CGEN_GEN_ARCH)
93$(srcdir)/%D%/arch.h $(srcdir)/%D%/arch.c $(srcdir)/%D%/cpuall.h: @CGEN_MAINT@ %D%/cgen-arch
94
95%D%/cgen-cpu-decode:
96	$(AM_V_GEN)cpu=or1k32bf mach=or32,or32nd FLAGS="with-scache" EXTRAFILES="$(CGEN_CPU_SEM) $(CGEN_CPU_SEMSW)"; $(CGEN_GEN_CPU_DECODE)
97$(srcdir)/%D%/cpu.h $(srcdir)/%D%/cpu.c $(srcdir)/%D%/model.c $(srcdir)/%D%/sem.c $(srcdir)/%D%/sem-switch.c $(srcdir)/%D%/decode.c $(srcdir)/%D%/decode.h: @CGEN_MAINT@ %D%/cgen-cpu-decode
98