build: move obj-TARGET-y variables to nested Makefile.objs
[qemu/kevin.git] / Makefile.target
blobc416ba56fc67c78dbdcd989d557346ff72611507
1 # -*- Mode: makefile -*-
3 CONFIG_NO_PCI = $(if $(subst n,,$(CONFIG_PCI)),n,y)
4 CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y)
5 CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y)
7 include ../config-host.mak
8 include config-devices.mak
9 include config-target.mak
10 include $(SRC_PATH)/rules.mak
11 ifneq ($(HWDIR),)
12 include $(HWDIR)/config.mak
13 endif
15 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
16 $(call set-vpath, $(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw)
17 ifdef CONFIG_LINUX
18 QEMU_CFLAGS += -I../linux-headers
19 endif
20 QEMU_CFLAGS += -I.. -I$(TARGET_PATH) -DNEED_CPU_H
22 include $(SRC_PATH)/Makefile.objs
24 QEMU_CFLAGS+=-I$(SRC_PATH)/include
26 ifdef CONFIG_USER_ONLY
27 # user emulator name
28 QEMU_PROG=qemu-$(TARGET_ARCH2)
29 else
30 # system emulator name
31 ifneq (,$(findstring -mwindows,$(LIBS)))
32 # Terminate program name with a 'w' because the linker builds a windows executable.
33 QEMU_PROGW=qemu-system-$(TARGET_ARCH2)w$(EXESUF)
34 endif # windows executable
35 QEMU_PROG=qemu-system-$(TARGET_ARCH2)$(EXESUF)
36 endif
38 PROGS=$(QEMU_PROG)
39 ifdef QEMU_PROGW
40 PROGS+=$(QEMU_PROGW)
41 endif
42 STPFILES=
44 ifndef CONFIG_HAIKU
45 LIBS+=-lm
46 endif
48 config-target.h: config-target.h-timestamp
49 config-target.h-timestamp: config-target.mak
51 ifdef CONFIG_TRACE_SYSTEMTAP
52 stap: $(QEMU_PROG).stp
54 ifdef CONFIG_USER_ONLY
55 TARGET_TYPE=user
56 else
57 TARGET_TYPE=system
58 endif
60 $(QEMU_PROG).stp: $(SRC_PATH)/trace-events
61         $(call quiet-command,$(TRACETOOL) \
62                 --format=stap \
63                 --backend=$(TRACE_BACKEND) \
64                 --binary=$(bindir)/$(QEMU_PROG) \
65                 --target-arch=$(TARGET_ARCH) \
66                 --target-type=$(TARGET_TYPE) \
67                 < $< > $@,"  GEN   $(QEMU_PROG).stp")
68 else
69 stap:
70 endif
72 all: $(PROGS) stap
74 # Dummy command so that make thinks it has done something
75         @true
77 #########################################################
78 # cpu emulator library
79 libobj-y = exec.o translate-all.o cpu-exec.o translate.o
80 libobj-y += tcg/tcg.o tcg/optimize.o
81 libobj-$(CONFIG_TCG_INTERPRETER) += tci.o
82 libobj-y += fpu/softfloat.o
83 ifneq ($(TARGET_BASE_ARCH), sparc)
84 ifneq ($(TARGET_BASE_ARCH), alpha)
85 libobj-y += op_helper.o
86 endif
87 endif
88 libobj-y += helper.o
89 ifneq ($(TARGET_BASE_ARCH), ppc)
90 libobj-y += cpu.o
91 endif
92 libobj-$(TARGET_SPARC64) += vis_helper.o
93 libobj-$(CONFIG_NEED_MMU) += mmu.o
94 libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o
95 ifeq ($(TARGET_BASE_ARCH), sparc)
96 libobj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o
97 endif
98 libobj-$(TARGET_SPARC) += int32_helper.o
99 libobj-$(TARGET_SPARC64) += int64_helper.o
100 libobj-$(TARGET_ALPHA) += int_helper.o fpu_helper.o sys_helper.o mem_helper.o
102 libobj-y += disas.o
103 libobj-$(CONFIG_TCI_DIS) += tci-dis.o
105 obj-y += target-$(TARGET_BASE_ARCH)/
107 tci-dis.o: QEMU_CFLAGS += -I$(SRC_PATH)/tcg -I$(SRC_PATH)/tcg/tci
109 # HELPER_CFLAGS is used for all the legacy code compiled with static register
110 # variables
111 ifneq ($(TARGET_BASE_ARCH), sparc)
112 op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
113 endif
114 user-exec.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
116 # Note: this is a workaround. The real fix is to avoid compiling
117 # cpu_signal_handler() in user-exec.c.
118 %/signal.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
120 #########################################################
121 # Linux user emulator target
123 ifdef CONFIG_LINUX_USER
125 QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) -I$(SRC_PATH)/linux-user
127 obj-y += linux-user/
128 obj-y += gdbstub.o thunk.o user-exec.o $(oslib-obj-y)
130 obj-y += $(addprefix ../, $(universal-obj-y))
131 obj-y += $(addprefix ../libuser/, $(user-obj-y))
132 obj-y += $(addprefix ../libdis-user/, $(libdis-y))
133 obj-y += $(libobj-y)
135 endif #CONFIG_LINUX_USER
137 #########################################################
138 # BSD user emulator target
140 ifdef CONFIG_BSD_USER
142 QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH)
144 obj-y += bsd-user/
145 obj-y += gdbstub.o user-exec.o
147 obj-y += $(addprefix ../, $(universal-obj-y))
148 obj-y += $(addprefix ../libuser/, $(user-obj-y))
149 obj-y += $(addprefix ../libdis-user/, $(libdis-y))
150 obj-y += $(libobj-y)
152 endif #CONFIG_BSD_USER
154 #########################################################
155 # System emulator target
156 ifdef CONFIG_SOFTMMU
158 obj-y += arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o
159 # virtio has to be here due to weird dependency between PCI and virtio-net.
160 # need to fix this properly
161 obj-$(CONFIG_NO_PCI) += pci-stub.o
162 obj-$(CONFIG_VIRTIO) += virtio.o virtio-blk.o virtio-balloon.o virtio-net.o virtio-serial-bus.o
163 obj-$(CONFIG_VIRTIO) += virtio-scsi.o
164 obj-y += vhost_net.o
165 obj-$(CONFIG_VHOST_NET) += vhost.o
166 obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/virtio-9p-device.o
167 obj-$(CONFIG_KVM) += kvm.o kvm-all.o
168 obj-$(CONFIG_NO_KVM) += kvm-stub.o
169 obj-$(CONFIG_VGA) += vga.o
170 obj-y += memory.o savevm.o cputlb.o
171 obj-y += memory_mapping.o
172 obj-$(CONFIG_HAVE_GET_MEMORY_MAPPING) += arch_memory_mapping.o
173 obj-$(CONFIG_HAVE_CORE_DUMP) += arch_dump.o
174 LIBS+=-lz
176 QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
177 QEMU_CFLAGS += $(VNC_SASL_CFLAGS)
178 QEMU_CFLAGS += $(VNC_JPEG_CFLAGS)
179 QEMU_CFLAGS += $(VNC_PNG_CFLAGS)
181 # xen support
182 obj-$(CONFIG_XEN) += xen-all.o xen_machine_pv.o xen_domainbuild.o xen-mapcache.o
183 obj-$(CONFIG_NO_XEN) += xen-stub.o
185 # Inter-VM PCI shared memory
186 CONFIG_IVSHMEM =
187 ifeq ($(CONFIG_KVM), y)
188   ifeq ($(CONFIG_PCI), y)
189     CONFIG_IVSHMEM = y
190   endif
191 endif
192 obj-$(CONFIG_IVSHMEM) += ivshmem.o
194 # Generic hotplugging
195 obj-y += device-hotplug.o
197 # Hardware support
198 ifeq ($(TARGET_ARCH), sparc64)
199 obj-y += hw/sparc64/
200 else
201 obj-y += hw/$(TARGET_BASE_ARCH)/
202 endif
204 # Device tree
205 ifeq ($(CONFIG_FDT), y)
206 obj-$(TARGET_ARM) += device_tree.o
207 obj-$(TARGET_MICROBLAZE) += device_tree.o
208 obj-$(TARGET_PPC) += device_tree.o
209 endif
211 main.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
213 GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h
215 obj-y += $(addprefix ../, $(universal-obj-y))
216 obj-y += $(addprefix ../, $(common-obj-y))
217 obj-y += $(addprefix ../libdis/, $(libdis-y))
218 obj-y += $(libobj-y)
219 obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y))
220 obj-y += $(addprefix ../, $(trace-obj-y))
222 endif # CONFIG_SOFTMMU
224 obj-y += dump.o
226 ifndef CONFIG_LINUX_USER
227 ifndef CONFIG_BSD_USER
228 # libcacard needs qemu-thread support, and besides is only needed by devices
229 # so not requires with linux-user / bsd-user targets
230 obj-$(CONFIG_SMARTCARD_NSS) += $(addprefix ../libcacard/, $(libcacard-y))
231 endif # CONFIG_BSD_USER
232 endif # CONFIG_LINUX_USER
234 obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
236 nested-vars = obj-y
237 dummy := $(call unnest-vars)
239 ifdef QEMU_PROGW
240 # The linker builds a windows executable. Make also a console executable.
241 $(QEMU_PROGW): $(obj-y)
242         $(call LINK,$^)
243 $(QEMU_PROG): $(QEMU_PROGW)
244         $(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG),"  GEN   $(TARGET_DIR)$(QEMU_PROG)")
245 else
246 $(QEMU_PROG): $(obj-y)
247         $(call LINK,$^)
248 endif
250 gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
251         $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES),"  GEN   $(TARGET_DIR)$@")
253 hmp-commands.h: $(SRC_PATH)/hmp-commands.hx
254         $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
256 qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx
257         $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
259 clean:
260         rm -f *.o *.a *~ $(PROGS) nwfpe/*.o fpu/*.o
261         rm -f *.d */*.d tcg/*.o ide/*.o 9pfs/*.o kvm/*.o
262         rm -f hmp-commands.h qmp-commands-old.h gdbstub-xml.c
263 ifdef CONFIG_TRACE_SYSTEMTAP
264         rm -f *.stp
265 endif
267 install: all
268 ifneq ($(PROGS),)
269         $(INSTALL) -m 755 $(PROGS) "$(DESTDIR)$(bindir)"
270 ifneq ($(STRIP),)
271         $(STRIP) $(patsubst %,"$(DESTDIR)$(bindir)/%",$(PROGS))
272 endif
273 endif
274 ifdef CONFIG_TRACE_SYSTEMTAP
275         $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset"
276         $(INSTALL_DATA) $(QEMU_PROG).stp "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset"
277 endif
279 GENERATED_HEADERS += config-target.h
280 Makefile: $(GENERATED_HEADERS)
282 # Include automatically generated dependency files
283 -include $(wildcard *.d */*.d)