xref: /netbsd-src/external/gpl3/gdb.old/dist/sim/bpf/Makefile.in (revision 528ce0b18ee40383f14928382d06afd754b01561)
1# Makefile template for configure for the eBPF simulator
2# Copyright (C) 2020 Free Software Foundation, Inc.
3#
4# This file is part of GDB, the GNU debugger.
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## COMMON_PRE_CONFIG_FRAG
20
21CGEN_STD_OBJS = cgen-run.o cgen-scache.o cgen-trace.o cgen-utils.o
22BPF_GEN_OBJS = arch.o cpu.o \
23               decode-le.o decode-be.o \
24               sem-le.o sem-be.o \
25               mloop-le.o mloop-be.o
26BPF_HAND_OBJS = bpf.o sim-if.o traps.o bpf-helpers.o
27
28SIM_OBJS = \
29	$(SIM_NEW_COMMON_OBJS) \
30	$(CGEN_STD_OBJS) \
31	$(BPF_GEN_OBJS) \
32	$(BPF_HAND_OBJS)
33
34SIM_EXTRA_DEPS = \
35	$(CGEN_INCLUDE_DEPS) \
36	arch.h \
37	bpf-sim.h \
38	$(srcdir)/../../opcodes/bpf-desc.h \
39	$(srcdir)/../../opcodes/bpf-opc.h
40
41SIM_EXTRA_CLEAN = bpf-clean
42
43## COMMON_POST_CONFIG_FRAG
44
45# cgen support, enable with --enable-cgen-maint
46CGEN_MAINT = ; @true
47# The following line is commented in or out depending upon --enable-cgen-maint.
48@CGEN_MAINT@CGEN_MAINT =
49
50# BPF headers
51
52BPF_INCLUDE_DEPS = \
53	$(CGEN_MAIN_CPU_DEPS) \
54	$(SIM_EXTRA_DEPS) \
55	cpu.h cpuall.h \
56        decode-le.h decode-be.h \
57        defs-le.h defs-be.h \
58        eng-le.h eng-be.h \
59        config.h
60
61# Dependencies for binaries from CGEN generated source
62
63arch.o: arch.c $(SIM_MAIN_DEPS)
64cpu.o: cpu.c $(BPF_INCLUDE_DEPS)
65decode-le.o: decode-le.c $(BPF_INCLUDE_DEPS)
66decode-be.o: decode-be.c $(BPF_INCLUDE_DEPS)
67
68sim-if.o: sim-if.c $(SIM_MAIN_DEPS) $(srcdir)/../common/sim-core.h eng.h
69	$(COMPILE) $<
70	$(POSTCOMPILE)
71
72traps.o: traps.c $(SIM_MAIN_DEPS) eng.h
73	$(COMPILE) $<
74	$(POSTCOMPILE)
75
76mloop-le.o: mloop-le.c $(BPF_INCLUDE_DEPS)
77	$(CC) -c mloop-le.c $(ALL_CFLAGS) -DWANT_ISA_EBPFLE
78mloop-be.o: mloop-be.c $(BPF_INCLUDE_DEPS)
79	$(CC) -c mloop-be.c $(ALL_CFLAGS) -DWANT_ISA_EBPFBE
80
81decode-le.o: decode-le.c $(BPF_INCLUDE_DEPS)
82	$(CC) -c $(srcdir)/decode-le.c $(ALL_CFLAGS) -DWANT_ISA_EBPFLE
83decode-be.o: decode-be.c $(BPF_INCLUDE_DEPS)
84	$(CC) -c $(srcdir)/decode-be.c $(ALL_CFLAGS) -DWANT_ISA_EBPFBE
85
86sem-le.o: sem-le.c $(BPF_INCLUDE_DEPS)
87	$(CC) -c $(srcdir)/sem-le.c $(ALL_CFLAGS) -DWANT_ISA_EBPFLE
88sem-be.o: sem-be.c $(BPF_INCLUDE_DEPS)
89	$(CC) -c $(srcdir)/sem-be.c $(ALL_CFLAGS) -DWANT_ISA_EBPFBE
90
91arch = bpf
92
93CGEN_COMMON_DEPS = \
94	$(CGEN_READ_SCM) \
95	$(srcdir)/../../cpu/bpf.cpu \
96	$(srcdir)/../../cpu/bpf.opc \
97	Makefile
98
99stamp-arch: $(CGEN_COMMON_DEPS) $(CGEN_ARCH_SCM)
100	$(MAKE) cgen-arch $(CGEN_FLAGS_TO_PASS) \
101		mach=bpf cpu=bpfbf \
102		archfile=$(srcdir)/../../cpu/bpf.cpu \
103		FLAGS="with-scache"
104	touch $@
105$(srcdir)/arch.h $(srcdir)/arch.c $(srcdir)/cpuall.h: $(CGEN_MAINT) stamp-arch
106	@true
107
108stamp-cpu: $(CGEN_COMMON_DEPS) $(CGEN_CPU_SCM)
109	$(MAKE) cgen-cpu  $(CGEN_FLAGS_TO_PASS) \
110		isa=ebpfle,ebpfbe cpu=bpfbf mach=bpf \
111		archfile=$(srcdir)/../../cpu/bpf.cpu \
112		FLAGS="with-multiple-isa with-scache"
113	rm -f $(srcdir)/model.c
114	touch $@
115$(srcdir)/cpu.h $(srcdir)/cpu.c $(srcdir)/model.c: $(CGEN_MAINT) stamp-cpu
116	@true
117
118# We need to generate a group of files per ISA.
119# For eBPF little-endian:
120#    defs-le.h
121#    sem-le.c, decode-le.c, decode-le.h
122#    $(objdir)/mloop-le.c $(objdir)/eng-le.h
123# For eBPF big-endian:
124#    defs-be.h
125#    sem-be.c, decode-be.c, decode-be.h
126#    $(objdir)/mloop-be.c $(objdir)/eng-le.h
127#
128# The rules below take care of that.
129
130stamp-defs-le: $(CGEN_COMMON_DEPS) $(CGEN_CPU_SCM)
131	$(MAKE) cgen-defs $(CGEN_FLAGS_TO_PASS) \
132		isa=ebpfle cpu=bpfbf mach=bpf \
133		archfile=$(srcdir)/../../cpu/bpf.cpu \
134		FLAGS="with-scache" \
135                SUFFIX="-le"
136	touch $@
137$(srcdir)/defs-le.h: $(CGEN_MAINT) stamp-defs-le
138	@true
139
140
141stamp-defs-be: $(CGEN_COMMON_DEPS) $(CGEN_CPU_SCM)
142	$(MAKE) cgen-defs $(CGEN_FLAGS_TO_PASS) \
143		isa=ebpfbe cpu=bpfbf mach=bpf \
144		archfile=$(srcdir)/../../cpu/bpf.cpu \
145		FLAGS="with-scache" \
146                SUFFIX="-be"
147	touch $@
148$(srcdir)/defs-be.h: $(CGEN_MAINT) stamp-defs-be
149	@true
150
151stamp-decode-le: $(CGEN_COMMON_DEPS) $(CGEN_CPU_SCM) $(GEN_DECODE_SCM)
152	$(MAKE) cgen-decode $(CGEN_FLAGS_TO_PASS) \
153		isa=ebpfle cpu=bpfbf mach=bpf \
154		archfile=$(srcdir)/../../cpu/bpf.cpu \
155		FLAGS="with-scache" \
156                SUFFIX="-le" \
157		EXTRAFILES="$(CGEN_CPU_SEM)"
158	touch $@
159$(srcdir)/sem-le.c $(srcdir)/decode-le.c $(srcdir)/decode-le.h: \
160              $(CGEN_MAINT) stamp-decode-le
161	@true
162
163
164stamp-decode-be: $(CGEN_COMMON_DEPS) $(CGEN_CPU_SCM) $(GEN_DECODE_SCM)
165	$(MAKE) cgen-decode $(CGEN_FLAGS_TO_PASS) \
166		isa=ebpfbe cpu=bpfbf mach=bpf \
167		archfile=$(srcdir)/../../cpu/bpf.cpu \
168		FLAGS="with-scache" \
169                SUFFIX="-be" \
170		EXTRAFILES="$(CGEN_CPU_SEM)"
171	touch $@
172$(srcdir)/sem-be.c $(srcdir)/decode-be.c $(srcdir)/decode-be.h: \
173              $(CGEN_MAINT) stamp-decode-be
174	@true
175
176# Note the following files are generated in objdir, not srcdir.
177
178stamp-mloop: stamp-mloop-le stamp-mloop-be
179
180stamp-mloop-le: $(srcdir)/../common/genmloop.sh mloop.in Makefile
181	$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
182		-mono -scache -prefix bpfbf_ebpfle -cpu bpfbf \
183                -infile $(srcdir)/mloop.in -outfile-suffix -le
184	$(SHELL) $(srcroot)/move-if-change eng-le.hin eng-le.h
185	$(SHELL) $(srcroot)/move-if-change mloop-le.cin mloop-le.c
186	touch $@
187mloop-le.c eng-le.h: stamp-mloop-le
188	@true
189
190stamp-mloop-be: $(srcdir)/../common/genmloop.sh mloop.in Makefile
191	$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
192		-mono -scache -prefix bpfbf_ebpfbe -cpu bpfbf \
193                -infile $(srcdir)/mloop.in -outfile-suffix -be
194	$(SHELL) $(srcroot)/move-if-change eng-be.hin eng-be.h
195	$(SHELL) $(srcroot)/move-if-change mloop-be.cin mloop-be.c
196	touch $@
197mloop-be.c eng-be.h: stamp-mloop-be
198	@true
199
200.PHONY = bpf-clean
201
202bpf-clean:
203	rm -f stamp-arch stamp-cpu stamp-decode stamp-defs stamp-mloop
204