1## See sim/Makefile.am
2##
3## Copyright (C) 1999-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
19## We must use 32-bit addresses to support memory bank switching.
20## The WORD_BITSIZE is normally 16 but must be switched (temporarily)
21## to 32 to avoid a bug in the sim-common which uses 'unsigned_word'
22## instead of 'address_word' in some places (the result is a truncation
23## of the 32-bit address to 16-bit; and this breaks the simulator).
24AM_CPPFLAGS_%C% = \
25          -DWITH_TARGET_WORD_BITSIZE=32 \
26          -DWITH_TARGET_CELL_BITSIZE=32 \
27          -DWITH_TARGET_ADDRESS_BITSIZE=32 \
28          -DWITH_TARGET_WORD_MSB=31
29
30nodist_%C%_libsim_a_SOURCES = \
31          %D%/modules.c
32%C%_libsim_a_SOURCES = \
33          $(common_libcommon_a_SOURCES)
34%C%_libsim_a_LIBADD = \
35          %D%/interp.o \
36          %D%/m68hc11int.o \
37          %D%/m68hc12int.o \
38          %D%/emulos.o \
39          %D%/interrupts.o \
40          %D%/m68hc11_sim.o \
41          $(patsubst %,%D%/%,$(SIM_NEW_COMMON_OBJS)) \
42          $(patsubst %,%D%/dv-%.o,$(SIM_HW_DEVICES)) \
43          $(patsubst %,%D%/dv-%.o,$(%C%_SIM_EXTRA_HW_DEVICES)) \
44          %D%/sim-resume.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%_SIM_EXTRA_HW_DEVICES = m68hc11 m68hc11sio m68hc11eepr m68hc11tim m68hc11spi nvram
64
65%C%_BUILD_OUTPUTS = \
66          %D%/gencode$(EXEEXT) \
67          %D%/m68hc11int.c \
68          %D%/m68hc12int.c
69
70## Generating modules.c requires all sources to scan.
71%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
72
73%C%_gencode_SOURCES = %D%/gencode.c
74
75# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
76%D%/gencode$(EXEEXT): $(%C%_gencode_OBJECTS) $(%C%_gencode_DEPENDENCIES) %D%/$(am__dirstamp)
77          $(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_gencode_OBJECTS) $(%C%_gencode_LDADD)
78
79# gencode is a build-time only tool.  Override the default rules for it.
80%D%/gencode.o: %D%/gencode.c
81          $(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
82
83%D%/m68hc11int.c: %D%/gencode$(EXEEXT)
84          $(AM_V_GEN)$< -m6811 >$@
85
86%D%/m68hc12int.c: %D%/gencode$(EXEEXT)
87          $(AM_V_GEN)$< -m6812 >$@
88
89EXTRA_PROGRAMS += %D%/gencode
90MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
91