1## See sim/Makefile.am
2##
3## Copyright (C) 1990-2024 Free Software Foundation, Inc.
4## Written by Cygnus Support.
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          %D%/interp.o \
25          $(patsubst %,%D%/%,$(SIM_NEW_COMMON_OBJS)) \
26          $(patsubst %,%D%/dv-%.o,$(SIM_HW_DEVICES)) \
27          %D%/table.o
28$(%C%_libsim_a_OBJECTS) $(%C%_libsim_a_LIBADD): %D%/hw-config.h
29
30noinst_LIBRARIES += %D%/libsim.a
31
32## Override wildcards that trigger common/modules.c to be (incorrectly) used.
33%D%/modules.o: %D%/modules.c
34
35%D%/%.o: common/%.c ; $(SIM_COMPILE)
36-@am__include@ %D%/$(DEPDIR)/*.Po
37
38%C%_run_SOURCES =
39%C%_run_LDADD = \
40          %D%/nrun.o \
41          %D%/libsim.a \
42          $(SIM_COMMON_LIBS)
43
44noinst_PROGRAMS += %D%/run
45
46## List all generated headers to help Automake dependency tracking.
47## NB: These .c files are only included by other .c files.  They are not
48## compiled individually.  Hence they're really "header" files.
49BUILT_SOURCES += \
50          %D%/code.c \
51          %D%/ppi.c
52%C%_BUILD_OUTPUTS = \
53          %D%/gencode$(EXEEXT) \
54          %D%/code.c \
55          %D%/ppi.c \
56          %D%/table.c
57
58## Generating modules.c requires all sources to scan.
59%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
60
61%C%_gencode_SOURCES = %D%/gencode.c
62
63# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
64%D%/gencode$(EXEEXT): $(%C%_gencode_OBJECTS) $(%C%_gencode_DEPENDENCIES) %D%/$(am__dirstamp)
65          $(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_gencode_OBJECTS) $(%C%_gencode_LDADD)
66
67# gencode is a build-time only tool.  Override the default rules for it.
68%D%/gencode.o: %D%/gencode.c
69          $(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
70
71%D%/code.c: %D%/gencode$(EXEEXT)
72          $(AM_V_GEN)$< -x >$@
73
74%D%/ppi.c: %D%/gencode$(EXEEXT)
75          $(AM_V_GEN)$< -p >$@
76
77%D%/table.c: %D%/gencode$(EXEEXT)
78          $(AM_V_GEN)$< -s >$@
79
80EXTRA_PROGRAMS += %D%/gencode
81MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
82