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