1## See sim/Makefile.am
2##
3## Copyright (C) 2005-2024 Free Software Foundation, Inc.
4## Contributed by Red Hat, Inc.
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
19AM_CPPFLAGS_%C% = -DTIMER_A
20
21nodist_%C%_libsim_a_SOURCES = \
22	%D%/modules.c
23%C%_libsim_a_SOURCES = \
24	$(common_libcommon_a_SOURCES)
25%C%_libsim_a_LIBADD = \
26	%D%/gdb-if.o \
27	%D%/int.o \
28	%D%/load.o \
29	%D%/m32c.o \
30	%D%/mem.o \
31	%D%/misc.o \
32	%D%/r8c.o \
33	%D%/reg.o \
34	%D%/srcdest.o \
35	%D%/syscalls.o \
36	%D%/trace.o
37$(%C%_libsim_a_OBJECTS) $(%C%_libsim_a_LIBADD): %D%/hw-config.h
38
39noinst_LIBRARIES += %D%/libsim.a
40
41## Override wildcards that trigger common/modules.c to be (incorrectly) used.
42%D%/modules.o: %D%/modules.c
43
44%D%/%.o: common/%.c ; $(SIM_COMPILE)
45-@am__include@ %D%/$(DEPDIR)/*.Po
46
47%C%_run_SOURCES =
48%C%_run_LDADD = \
49	%D%/main.o \
50	%D%/libsim.a \
51	$(SIM_COMMON_LIBS)
52
53noinst_PROGRAMS += %D%/run
54
55%C%_BUILD_OUTPUTS = \
56	%D%/opc2c$(EXEEXT) \
57	%D%/m32c.c \
58	%D%/r8c.c
59
60## Generating modules.c requires all sources to scan.
61%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
62
63%C%_opc2c_SOURCES = %D%/opc2c.c
64
65# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
66%D%/opc2c$(EXEEXT): $(%C%_opc2c_OBJECTS) $(%C%_opc2c_DEPENDENCIES) %D%/$(am__dirstamp)
67	$(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_opc2c_OBJECTS) $(%C%_opc2c_LDADD)
68
69# opc2c is a build-time only tool.  Override the default rules for it.
70%D%/opc2c.o: %D%/opc2c.c
71	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
72
73# opc2c leaks memory, and therefore makes AddressSanitizer unhappy.  Disable
74# leak detection while running it.
75%C%_OPC2C_RUN = ASAN_OPTIONS=detect_leaks=0 %D%/opc2c$(EXEEXT)
76
77%D%/m32c.c: %D%/m32c.opc %D%/opc2c$(EXEEXT)
78	$(AM_V_GEN)$(%C%_OPC2C_RUN) -l $@.log $< > $@.tmp
79	$(AM_V_at)mv $@.tmp $@
80
81%D%/r8c.c: %D%/r8c.opc %D%/opc2c$(EXEEXT)
82	$(AM_V_GEN)$(%C%_OPC2C_RUN) -l $@.log $< > $@.tmp
83	$(AM_V_at)mv $@.tmp $@
84
85EXTRA_PROGRAMS += %D%/opc2c
86MOSTLYCLEANFILES += \
87	$(%C%_BUILD_OUTPUTS) \
88	%D%/m32c.c.log \
89	%D%/r8c.c.log
90