meson: target
[qemu.git] / Makefile.target
1 # -*- Mode: makefile -*-
2
3 BUILD_DIR?=$(CURDIR)/..
4
5 include ../config-host.mak
6 include config-target.mak
7 include $(SRC_PATH)/rules.mak
8
9 FULL_TARGET_NAME=$(TARGET_NAME)-$(if $(CONFIG_SOFTMMU),softmmu,linux-user)
10
11 ifdef CONFIG_SOFTMMU
12 include ../$(FULL_TARGET_NAME)-config-devices.mak
13 endif
14
15 $(call set-vpath, $(SRC_PATH):$(BUILD_DIR))
16 ifdef CONFIG_LINUX
17 QEMU_CFLAGS += -isystem ../linux-headers
18 endif
19 QEMU_CFLAGS += -iquote .. -iquote $(SRC_PATH)/target/$(TARGET_BASE_ARCH) -DNEED_CPU_H
20
21 QEMU_CFLAGS+=-iquote $(SRC_PATH)/include
22
23 QEMU_CFLAGS += -DCONFIG_TARGET=\"../$(FULL_TARGET_NAME)-config-target.h\"
24 QEMU_CFLAGS += -DCONFIG_DEVICES=\"../$(FULL_TARGET_NAME)-config-devices.h\"
25
26 ifdef CONFIG_USER_ONLY
27 # user emulator name
28 QEMU_PROG=qemu-$(TARGET_NAME)
29 QEMU_PROG_BUILD = $(QEMU_PROG)
30 else
31 # system emulator name
32 QEMU_PROG=qemu-system-$(TARGET_NAME)$(EXESUF)
33 ifneq (,$(findstring -mwindows,$(SDL_LIBS)))
34 # Terminate program name with a 'w' because the linker builds a windows executable.
35 QEMU_PROGW=qemu-system-$(TARGET_NAME)w$(EXESUF)
36 $(QEMU_PROG): $(QEMU_PROGW)
37         $(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG),"GEN","$(TARGET_DIR)$(QEMU_PROG)")
38 QEMU_PROG_BUILD = $(QEMU_PROGW)
39 else
40 QEMU_PROG_BUILD = $(QEMU_PROG)
41 endif
42 endif
43
44 LIBQEMU = ../libqemu-$(FULL_TARGET_NAME).fa
45 PROGS=$(QEMU_PROG) $(QEMU_PROGW)
46 STPFILES=
47
48 ifdef CONFIG_TRACE_SYSTEMTAP
49 stap: $(QEMU_PROG).stp-installed $(QEMU_PROG).stp $(QEMU_PROG)-simpletrace.stp $(QEMU_PROG)-log.stp
50
51 ifdef CONFIG_USER_ONLY
52 TARGET_TYPE=user
53 else
54 TARGET_TYPE=system
55 endif
56
57 tracetool-y = $(SRC_PATH)/scripts/tracetool.py
58 tracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py")
59
60 $(QEMU_PROG).stp-installed: $(BUILD_DIR)/trace/trace-events-all $(tracetool-y)
61         $(call quiet-command,$(TRACETOOL) \
62                 --group=all \
63                 --format=stap \
64                 --backends=$(TRACE_BACKENDS) \
65                 --binary=$(bindir)/$(QEMU_PROG) \
66                 --target-name=$(TARGET_NAME) \
67                 --target-type=$(TARGET_TYPE) \
68                 $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG).stp-installed")
69
70 $(QEMU_PROG).stp: $(BUILD_DIR)/trace/trace-events-all $(tracetool-y)
71         $(call quiet-command,$(TRACETOOL) \
72                 --group=all \
73                 --format=stap \
74                 --backends=$(TRACE_BACKENDS) \
75                 --binary=$(realpath .)/$(QEMU_PROG) \
76                 --target-name=$(TARGET_NAME) \
77                 --target-type=$(TARGET_TYPE) \
78                 $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG).stp")
79
80 $(QEMU_PROG)-simpletrace.stp: $(BUILD_DIR)/trace/trace-events-all $(tracetool-y)
81         $(call quiet-command,$(TRACETOOL) \
82                 --group=all \
83                 --format=simpletrace-stap \
84                 --backends=$(TRACE_BACKENDS) \
85                 --probe-prefix=qemu.$(TARGET_TYPE).$(TARGET_NAME) \
86                 $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG)-simpletrace.stp")
87
88 $(QEMU_PROG)-log.stp: $(BUILD_DIR)/trace/trace-events-all $(tracetool-y)
89         $(call quiet-command,$(TRACETOOL) \
90                 --group=all \
91                 --format=log-stap \
92                 --backends=$(TRACE_BACKENDS) \
93                 --probe-prefix=qemu.$(TARGET_TYPE).$(TARGET_NAME) \
94                 $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG)-log.stp")
95
96 else
97 stap:
98 endif
99 .PHONY: stap
100
101 all: $(PROGS) stap
102
103 # Dummy command so that make thinks it has done something
104         @true
105
106 obj-y += $(LIBQEMU)
107
108 obj-y += trace/
109
110 #########################################################
111 # cpu emulator library
112 obj-y += exec.o exec-vary.o
113 obj-y += accel/
114 obj-$(CONFIG_TCG) += tcg/tcg.o tcg/tcg-op.o tcg/tcg-op-vec.o tcg/tcg-op-gvec.o
115 obj-$(CONFIG_TCG) += tcg/tcg-common.o tcg/optimize.o
116 obj-$(CONFIG_TCG_INTERPRETER) += tcg/tci.o
117 obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
118 obj-$(CONFIG_TCG) += fpu/softfloat.o
119 obj-y += disas.o
120 obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
121 LIBS := $(libs_cpu) $(LIBS)
122
123 obj-$(CONFIG_PLUGIN) += plugins/
124
125 #########################################################
126 # Linux user emulator target
127
128 ifdef CONFIG_LINUX_USER
129
130 QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) \
131              -I$(SRC_PATH)/linux-user/host/$(ARCH) \
132              -I$(SRC_PATH)/linux-user \
133              -Ilinux-user/$(TARGET_ABI_DIR)
134
135 obj-y += linux-user/
136 obj-y += gdbstub.o thunk.o
137
138 endif #CONFIG_LINUX_USER
139
140 #########################################################
141 # BSD user emulator target
142
143 ifdef CONFIG_BSD_USER
144
145 QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ABI_DIR) \
146                          -I$(SRC_PATH)/bsd-user/$(HOST_VARIANT_DIR)
147
148 obj-y += bsd-user/
149 obj-y += gdbstub.o
150
151 endif #CONFIG_BSD_USER
152
153 #########################################################
154 # System emulator target
155 ifdef CONFIG_SOFTMMU
156 obj-y += softmmu/
157 obj-y += gdbstub.o
158 LIBS := $(libs_softmmu) $(LIBS)
159
160 # Temporary until emulators are linked by Meson
161 LIBS := $(LIBS) @../block.syms @../qemu.syms
162 ifneq ($(CONFIG_MODULES),y)
163 LIBS := $(LIBS) $(ALSA_LIBS) $(OSS_LIBS) $(PULSE_LIBS) $(SDL_LIBS)
164 LIBS := $(LIBS) $(GTK_LIBS) $(VTE_LIBS) $(X11_LIBS) $(CURSES_LIBS) $(ICONV_LIBS) $(GIO_LIBS)
165 endif
166 LIBS := $(LIBS) $(BRLAPI_LIBS) $(SDL_LIBS) $(SPICE_LIBS) $(OPENGL_LIBS) $(SECCOMP_LIBS)
167 LIBS := $(LIBS) $(COREAUDIO_LIBS) $(DSOUND_LIBS)
168 LIBS := $(LIBS) $(VDE_LIBS) $(SLIRP_LIBS)
169 LIBS := $(LIBS) $(LIBUSB_LIBS) $(SMARTCARD_LIBS) $(USB_REDIR_LIBS)
170 LIBS := $(LIBS) $(VIRGL_LIBS) $(CURSES_LIBS)
171
172 generated-files-y += hmp-commands.h hmp-commands-info.h
173
174 endif # CONFIG_SOFTMMU
175
176 dummy := $(call unnest-vars,,obj-y)
177 all-obj-y := $(obj-y)
178
179 include $(SRC_PATH)/Makefile.objs
180 dummy := $(call fix-paths,../,, \
181               authz-obj-y \
182               block-obj-y \
183               chardev-obj-y \
184               crypto-obj-y \
185               io-obj-y \
186               qom-obj-y)
187 dummy := $(call unnest-vars,..,common-obj-y)
188
189 all-obj-y += $(common-obj-y)
190 all-obj-y += $(qom-obj-y)
191 all-obj-$(CONFIG_SOFTMMU) += $(authz-obj-y)
192 all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y) $(chardev-obj-y)
193 all-obj-$(CONFIG_SOFTMMU) += $(crypto-obj-y)
194 all-obj-$(CONFIG_SOFTMMU) += $(io-obj-y)
195
196 ifdef CONFIG_SOFTMMU
197 $(QEMU_PROG_BUILD): ../$(FULL_TARGET_NAME)-config-devices.mak
198 endif
199
200 COMMON_LDADDS = ../libqemuutil.a
201
202 # build either PROG or PROGW
203 $(QEMU_PROG_BUILD): $(all-obj-y) $(COMMON_LDADDS) $(softmmu-main-y)
204         $(call LINK, $(filter-out %.mak, $^))
205 ifdef CONFIG_DARWIN
206         $(call quiet-command,Rez -append $(SRC_PATH)/pc-bios/qemu.rsrc -o $@,"REZ","$(TARGET_DIR)$@")
207         $(call quiet-command,SetFile -a C $@,"SETFILE","$(TARGET_DIR)$@")
208 endif
209
210 gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
211         $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES),"GEN","$(TARGET_DIR)$@")
212
213 clean: clean-target
214         rm -f *.a *~ $(PROGS)
215         rm -f $(shell find . -name '*.[od]')
216         rm -f hmp-commands.h gdbstub-xml.c
217         rm -f trace/generated-helpers.c trace/generated-helpers.c-timestamp
218 ifdef CONFIG_TRACE_SYSTEMTAP
219         rm -f *.stp
220 endif
221
222 ifdef CONFIG_FUZZ
223 include $(SRC_PATH)/tests/qtest/fuzz/Makefile.include
224 include $(SRC_PATH)/tests/qtest/Makefile.include
225
226 fuzz: fuzz-vars
227 fuzz-vars: QEMU_CFLAGS := $(FUZZ_CFLAGS) $(QEMU_CFLAGS)
228 fuzz-vars: QEMU_LDFLAGS := $(FUZZ_LDFLAGS) $(QEMU_LDFLAGS)
229 fuzz-vars: $(QEMU_PROG_FUZZ)
230 dummy := $(call unnest-vars,, fuzz-obj-y)
231
232
233 $(QEMU_PROG_FUZZ): config-devices.mak $(all-obj-y) $(COMMON_LDADDS) $(fuzz-obj-y)
234         $(call LINK, $(filter-out %.mak, $^))
235
236 endif
237
238 install: all
239 ifneq ($(PROGS),)
240         $(call install-prog,$(PROGS),$(DESTDIR)$(bindir))
241 endif
242 ifdef CONFIG_TRACE_SYSTEMTAP
243         $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset"
244         $(INSTALL_DATA) $(QEMU_PROG).stp-installed "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG).stp"
245         $(INSTALL_DATA) $(QEMU_PROG)-simpletrace.stp "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG)-simpletrace.stp"
246         $(INSTALL_DATA) $(QEMU_PROG)-log.stp "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG)-log.stp"
247 endif
248
249 Makefile: $(generated-files-y)