Makefile.target 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. # -*- Mode: makefile -*-
  2. BUILD_DIR?=$(CURDIR)/..
  3. include ../config-host.mak
  4. include config-target.mak
  5. include config-devices.mak
  6. include $(SRC_PATH)/rules.mak
  7. $(call set-vpath, $(SRC_PATH):$(BUILD_DIR))
  8. ifdef CONFIG_LINUX
  9. QEMU_CFLAGS += -I../linux-headers
  10. endif
  11. QEMU_CFLAGS += -I.. -I$(SRC_PATH)/target/$(TARGET_BASE_ARCH) -DNEED_CPU_H
  12. QEMU_CFLAGS+=-I$(SRC_PATH)/include
  13. ifdef CONFIG_USER_ONLY
  14. # user emulator name
  15. QEMU_PROG=qemu-$(TARGET_NAME)
  16. QEMU_PROG_BUILD = $(QEMU_PROG)
  17. else
  18. # system emulator name
  19. QEMU_PROG=qemu-system-$(TARGET_NAME)$(EXESUF)
  20. ifneq (,$(findstring -mwindows,$(libs_softmmu)))
  21. # Terminate program name with a 'w' because the linker builds a windows executable.
  22. QEMU_PROGW=qemu-system-$(TARGET_NAME)w$(EXESUF)
  23. $(QEMU_PROG): $(QEMU_PROGW)
  24. $(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG),"GEN","$(TARGET_DIR)$(QEMU_PROG)")
  25. QEMU_PROG_BUILD = $(QEMU_PROGW)
  26. else
  27. QEMU_PROG_BUILD = $(QEMU_PROG)
  28. endif
  29. endif
  30. PROGS=$(QEMU_PROG) $(QEMU_PROGW)
  31. STPFILES=
  32. config-target.h: config-target.h-timestamp
  33. config-target.h-timestamp: config-target.mak
  34. ifdef CONFIG_TRACE_SYSTEMTAP
  35. stap: $(QEMU_PROG).stp-installed $(QEMU_PROG).stp $(QEMU_PROG)-simpletrace.stp
  36. ifdef CONFIG_USER_ONLY
  37. TARGET_TYPE=user
  38. else
  39. TARGET_TYPE=system
  40. endif
  41. $(QEMU_PROG).stp-installed: $(BUILD_DIR)/trace-events-all
  42. $(call quiet-command,$(TRACETOOL) \
  43. --group=all \
  44. --format=stap \
  45. --backends=$(TRACE_BACKENDS) \
  46. --binary=$(bindir)/$(QEMU_PROG) \
  47. --target-name=$(TARGET_NAME) \
  48. --target-type=$(TARGET_TYPE) \
  49. $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG).stp-installed")
  50. $(QEMU_PROG).stp: $(BUILD_DIR)/trace-events-all
  51. $(call quiet-command,$(TRACETOOL) \
  52. --group=all \
  53. --format=stap \
  54. --backends=$(TRACE_BACKENDS) \
  55. --binary=$(realpath .)/$(QEMU_PROG) \
  56. --target-name=$(TARGET_NAME) \
  57. --target-type=$(TARGET_TYPE) \
  58. $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG).stp")
  59. $(QEMU_PROG)-simpletrace.stp: $(BUILD_DIR)/trace-events-all
  60. $(call quiet-command,$(TRACETOOL) \
  61. --group=all \
  62. --format=simpletrace-stap \
  63. --backends=$(TRACE_BACKENDS) \
  64. --probe-prefix=qemu.$(TARGET_TYPE).$(TARGET_NAME) \
  65. $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG)-simpletrace.stp")
  66. else
  67. stap:
  68. endif
  69. .PHONY: stap
  70. all: $(PROGS) stap
  71. # Dummy command so that make thinks it has done something
  72. @true
  73. #########################################################
  74. # cpu emulator library
  75. obj-y = exec.o translate-all.o cpu-exec.o
  76. obj-y += translate-common.o
  77. obj-y += cpu-exec-common.o
  78. obj-y += tcg/tcg.o tcg/tcg-op.o tcg/optimize.o
  79. obj-$(CONFIG_TCG_INTERPRETER) += tci.o
  80. obj-y += tcg/tcg-common.o
  81. obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
  82. obj-y += fpu/softfloat.o
  83. obj-y += target/$(TARGET_BASE_ARCH)/
  84. obj-y += disas.o
  85. obj-y += tcg-runtime.o
  86. obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
  87. obj-$(call lnot,$(CONFIG_HAX)) += hax-stub.o
  88. obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
  89. obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decContext.o
  90. obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decNumber.o
  91. obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal32.o
  92. obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal64.o
  93. obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal128.o
  94. #########################################################
  95. # Linux user emulator target
  96. ifdef CONFIG_LINUX_USER
  97. QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) \
  98. -I$(SRC_PATH)/linux-user/host/$(ARCH) \
  99. -I$(SRC_PATH)/linux-user
  100. obj-y += linux-user/
  101. obj-y += gdbstub.o thunk.o user-exec.o user-exec-stub.o
  102. endif #CONFIG_LINUX_USER
  103. #########################################################
  104. # BSD user emulator target
  105. ifdef CONFIG_BSD_USER
  106. QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ABI_DIR) \
  107. -I$(SRC_PATH)/bsd-user/$(HOST_VARIANT_DIR)
  108. obj-y += bsd-user/
  109. obj-y += gdbstub.o user-exec.o user-exec-stub.o
  110. endif #CONFIG_BSD_USER
  111. #########################################################
  112. # System emulator target
  113. ifdef CONFIG_SOFTMMU
  114. obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
  115. obj-y += qtest.o bootdevice.o
  116. obj-y += hw/
  117. obj-$(CONFIG_KVM) += kvm-all.o
  118. obj-y += memory.o cputlb.o
  119. obj-y += memory_mapping.o
  120. obj-y += dump.o
  121. obj-y += migration/ram.o
  122. LIBS := $(libs_softmmu) $(LIBS)
  123. # Hardware support
  124. ifeq ($(TARGET_NAME), sparc64)
  125. obj-y += hw/sparc64/
  126. else
  127. obj-y += hw/$(TARGET_BASE_ARCH)/
  128. endif
  129. GENERATED_FILES += hmp-commands.h hmp-commands-info.h
  130. endif # CONFIG_SOFTMMU
  131. # Workaround for http://gcc.gnu.org/PR55489, see configure.
  132. %/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS)
  133. dummy := $(call unnest-vars,,obj-y)
  134. all-obj-y := $(obj-y)
  135. target-obj-y :=
  136. block-obj-y :=
  137. common-obj-y :=
  138. chardev-obj-y :=
  139. include $(SRC_PATH)/Makefile.objs
  140. dummy := $(call unnest-vars,,target-obj-y)
  141. target-obj-y-save := $(target-obj-y)
  142. dummy := $(call unnest-vars,.., \
  143. block-obj-y \
  144. block-obj-m \
  145. chardev-obj-y \
  146. crypto-obj-y \
  147. crypto-aes-obj-y \
  148. qom-obj-y \
  149. io-obj-y \
  150. common-obj-y \
  151. common-obj-m)
  152. target-obj-y := $(target-obj-y-save)
  153. all-obj-y += $(common-obj-y)
  154. all-obj-y += $(target-obj-y)
  155. all-obj-y += $(qom-obj-y)
  156. all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y) $(chardev-obj-y)
  157. all-obj-$(CONFIG_USER_ONLY) += $(crypto-aes-obj-y)
  158. all-obj-$(CONFIG_SOFTMMU) += $(crypto-obj-y)
  159. all-obj-$(CONFIG_SOFTMMU) += $(io-obj-y)
  160. $(QEMU_PROG_BUILD): config-devices.mak
  161. COMMON_LDADDS = ../libqemuutil.a ../libqemustub.a
  162. # build either PROG or PROGW
  163. $(QEMU_PROG_BUILD): $(all-obj-y) $(COMMON_LDADDS)
  164. $(call LINK, $(filter-out %.mak, $^))
  165. ifdef CONFIG_DARWIN
  166. $(call quiet-command,Rez -append $(SRC_PATH)/pc-bios/qemu.rsrc -o $@,"REZ","$(TARGET_DIR)$@")
  167. $(call quiet-command,SetFile -a C $@,"SETFILE","$(TARGET_DIR)$@")
  168. endif
  169. gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
  170. $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES),"GEN","$(TARGET_DIR)$@")
  171. hmp-commands.h: $(SRC_PATH)/hmp-commands.hx $(SRC_PATH)/scripts/hxtool
  172. $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$(TARGET_DIR)$@")
  173. hmp-commands-info.h: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxtool
  174. $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$(TARGET_DIR)$@")
  175. clean: clean-target
  176. rm -f *.a *~ $(PROGS)
  177. rm -f $(shell find . -name '*.[od]')
  178. rm -f hmp-commands.h gdbstub-xml.c
  179. ifdef CONFIG_TRACE_SYSTEMTAP
  180. rm -f *.stp
  181. endif
  182. install: all
  183. ifneq ($(PROGS),)
  184. $(call install-prog,$(PROGS),$(DESTDIR)$(bindir))
  185. endif
  186. ifdef CONFIG_TRACE_SYSTEMTAP
  187. $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset"
  188. $(INSTALL_DATA) $(QEMU_PROG).stp-installed "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG).stp"
  189. $(INSTALL_DATA) $(QEMU_PROG)-simpletrace.stp "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG)-simpletrace.stp"
  190. endif
  191. GENERATED_FILES += config-target.h
  192. Makefile: $(GENERATED_FILES)