build: move per-target hw/ objects to nested Makefile.objs
[qemu-kvm.git] / Makefile.target
blob5635043f4ac19687bc1c2f5480c07a1c61c96228
1 # -*- Mode: makefile -*-
3 include ../config-host.mak
4 include config-devices.mak
5 include config-target.mak
6 include $(SRC_PATH)/rules.mak
7 ifneq ($(HWDIR),)
8 include $(HWDIR)/config.mak
9 endif
11 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
12 $(call set-vpath, $(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw)
13 ifdef CONFIG_LINUX
14 QEMU_CFLAGS += -I../linux-headers
15 endif
16 QEMU_CFLAGS += -I.. -I$(TARGET_PATH) -DNEED_CPU_H
18 QEMU_CFLAGS+=-I$(SRC_PATH)/include
20 ifdef CONFIG_USER_ONLY
21 # user emulator name
22 QEMU_PROG=qemu-$(TARGET_ARCH2)
23 else
24 # system emulator name
25 ifneq (,$(findstring -mwindows,$(LIBS)))
26 # Terminate program name with a 'w' because the linker builds a windows executable.
27 QEMU_PROGW=qemu-system-$(TARGET_ARCH2)w$(EXESUF)
28 endif # windows executable
29 QEMU_PROG=qemu-system-$(TARGET_ARCH2)$(EXESUF)
30 endif
32 PROGS=$(QEMU_PROG)
33 ifdef QEMU_PROGW
34 PROGS+=$(QEMU_PROGW)
35 endif
36 STPFILES=
38 ifndef CONFIG_HAIKU
39 LIBS+=-lm
40 endif
42 config-target.h: config-target.h-timestamp
43 config-target.h-timestamp: config-target.mak
45 ifdef CONFIG_TRACE_SYSTEMTAP
46 stap: $(QEMU_PROG).stp
48 ifdef CONFIG_USER_ONLY
49 TARGET_TYPE=user
50 else
51 TARGET_TYPE=system
52 endif
54 $(QEMU_PROG).stp: $(SRC_PATH)/trace-events
55         $(call quiet-command,$(TRACETOOL) \
56                 --format=stap \
57                 --backend=$(TRACE_BACKEND) \
58                 --binary=$(bindir)/$(QEMU_PROG) \
59                 --target-arch=$(TARGET_ARCH) \
60                 --target-type=$(TARGET_TYPE) \
61                 < $< > $@,"  GEN   $(QEMU_PROG).stp")
62 else
63 stap:
64 endif
66 all: $(PROGS) stap
68 # Dummy command so that make thinks it has done something
69         @true
71 #########################################################
72 # cpu emulator library
73 obj-y = exec.o translate-all.o cpu-exec.o
74 obj-y += tcg/tcg.o tcg/optimize.o
75 obj-$(CONFIG_TCG_INTERPRETER) += tci.o
76 obj-y += fpu/softfloat.o
77 obj-y += disas.o
78 obj-$(CONFIG_TCI_DIS) += tci-dis.o
79 obj-y += target-$(TARGET_BASE_ARCH)/
80 obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
82 tci-dis.o: QEMU_CFLAGS += -I$(SRC_PATH)/tcg -I$(SRC_PATH)/tcg/tci
84 # HELPER_CFLAGS is used for all the legacy code compiled with static register
85 # variables
86 user-exec.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
88 # Note: this is a workaround. The real fix is to avoid compiling
89 # cpu_signal_handler() in user-exec.c.
90 %/signal.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
92 #########################################################
93 # Linux user emulator target
95 ifdef CONFIG_LINUX_USER
97 QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) -I$(SRC_PATH)/linux-user
99 obj-y += linux-user/
100 obj-y += gdbstub.o thunk.o user-exec.o $(oslib-obj-y)
102 endif #CONFIG_LINUX_USER
104 #########################################################
105 # BSD user emulator target
107 ifdef CONFIG_BSD_USER
109 QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH)
111 obj-y += bsd-user/
112 obj-y += gdbstub.o user-exec.o
114 endif #CONFIG_BSD_USER
116 #########################################################
117 # System emulator target
118 ifdef CONFIG_SOFTMMU
119 CONFIG_NO_PCI = $(if $(subst n,,$(CONFIG_PCI)),n,y)
120 CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y)
121 CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y)
122 CONFIG_NO_GET_MEMORY_MAPPING = $(if $(subst n,,$(CONFIG_HAVE_GET_MEMORY_MAPPING)),n,y)
123 CONFIG_NO_CORE_DUMP = $(if $(subst n,,$(CONFIG_HAVE_CORE_DUMP)),n,y)
125 obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o
126 obj-y += hw/
127 obj-$(CONFIG_KVM) += kvm-all.o
128 obj-$(CONFIG_NO_KVM) += kvm-stub.o
129 obj-y += memory.o savevm.o cputlb.o
130 obj-$(CONFIG_HAVE_GET_MEMORY_MAPPING) += memory_mapping.o
131 obj-$(CONFIG_HAVE_CORE_DUMP) += dump.o
132 obj-$(CONFIG_NO_GET_MEMORY_MAPPING) += memory_mapping-stub.o
133 obj-$(CONFIG_NO_CORE_DUMP) += dump-stub.o
134 LIBS+=-lz
136 QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
137 QEMU_CFLAGS += $(VNC_SASL_CFLAGS)
138 QEMU_CFLAGS += $(VNC_JPEG_CFLAGS)
139 QEMU_CFLAGS += $(VNC_PNG_CFLAGS)
141 # xen support
142 obj-$(CONFIG_XEN) += xen-all.o xen-mapcache.o
143 obj-$(CONFIG_NO_XEN) += xen-stub.o
145 # Hardware support
146 ifeq ($(TARGET_ARCH), sparc64)
147 obj-y += hw/sparc64/
148 else
149 obj-y += hw/$(TARGET_BASE_ARCH)/
150 endif
152 # Device tree
153 ifeq ($(CONFIG_FDT), y)
154 obj-$(TARGET_ARM) += device_tree.o
155 obj-$(TARGET_MICROBLAZE) += device_tree.o
156 obj-$(TARGET_PPC) += device_tree.o
157 endif
159 main.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
161 GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h
163 endif # CONFIG_SOFTMMU
165 nested-vars += obj-y
167 # This resolves all nested paths, so it must come last
168 include $(SRC_PATH)/Makefile.objs
170 all-obj-y = $(obj-y)
171 all-obj-y += $(addprefix ../, $(universal-obj-y))
173 ifdef CONFIG_SOFTMMU
175 all-obj-y += $(addprefix ../, $(common-obj-y))
176 all-obj-y += $(addprefix ../libdis/, $(libdis-y))
177 all-obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y))
178 all-obj-y += $(addprefix ../, $(trace-obj-y))
180 # libcacard needs qemu-thread support, and besides is only needed by devices
181 # so not requires with linux-user / bsd-user targets
182 all-obj-$(CONFIG_SMARTCARD_NSS) += $(addprefix ../libcacard/, $(libcacard-y))
184 else
185 all-obj-y += $(addprefix ../libuser/, $(user-obj-y))
186 all-obj-y += $(addprefix ../libdis-user/, $(libdis-y))
187 endif #CONFIG_LINUX_USER
189 ifdef QEMU_PROGW
190 # The linker builds a windows executable. Make also a console executable.
191 $(QEMU_PROGW): $(all-obj-y)
192         $(call LINK,$^)
193 $(QEMU_PROG): $(QEMU_PROGW)
194         $(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG),"  GEN   $(TARGET_DIR)$(QEMU_PROG)")
195 else
196 $(QEMU_PROG): $(all-obj-y)
197         $(call LINK,$^)
198 endif
200 gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
201         $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES),"  GEN   $(TARGET_DIR)$@")
203 hmp-commands.h: $(SRC_PATH)/hmp-commands.hx
204         $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
206 qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx
207         $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
209 clean:
210         rm -f *.o *.a *~ $(PROGS) nwfpe/*.o fpu/*.o
211         rm -f *.d */*.d tcg/*.o ide/*.o 9pfs/*.o kvm/*.o
212         rm -f hmp-commands.h qmp-commands-old.h gdbstub-xml.c
213 ifdef CONFIG_TRACE_SYSTEMTAP
214         rm -f *.stp
215 endif
217 install: all
218 ifneq ($(PROGS),)
219         $(INSTALL) -m 755 $(PROGS) "$(DESTDIR)$(bindir)"
220 ifneq ($(STRIP),)
221         $(STRIP) $(patsubst %,"$(DESTDIR)$(bindir)/%",$(PROGS))
222 endif
223 endif
224 ifdef CONFIG_TRACE_SYSTEMTAP
225         $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset"
226         $(INSTALL_DATA) $(QEMU_PROG).stp "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset"
227 endif
229 GENERATED_HEADERS += config-target.h
230 Makefile: $(GENERATED_HEADERS)
232 # Include automatically generated dependency files
233 -include $(wildcard *.d */*.d)