trap signals for "-serial mon:stdio"
[qemu.git] / Makefile.target
1 # -*- Mode: makefile -*-
2
3 include ../config-host.mak
4 include config-target.mak
5 include config-devices.mak
6 include $(SRC_PATH)/rules.mak
7
8 $(call set-vpath, $(SRC_PATH))
9 ifdef CONFIG_LINUX
10 QEMU_CFLAGS += -I../linux-headers
11 endif
12 QEMU_CFLAGS += -I.. -I$(SRC_PATH)/target-$(TARGET_BASE_ARCH) -DNEED_CPU_H
13
14 QEMU_CFLAGS+=-I$(SRC_PATH)/include
15
16 ifdef CONFIG_USER_ONLY
17 # user emulator name
18 QEMU_PROG=qemu-$(TARGET_NAME)
19 else
20 # system emulator name
21 ifneq (,$(findstring -mwindows,$(libs_softmmu)))
22 # Terminate program name with a 'w' because the linker builds a windows executable.
23 QEMU_PROGW=qemu-system-$(TARGET_NAME)w$(EXESUF)
24 endif # windows executable
25 QEMU_PROG=qemu-system-$(TARGET_NAME)$(EXESUF)
26 endif
27
28 PROGS=$(QEMU_PROG)
29 ifdef QEMU_PROGW
30 PROGS+=$(QEMU_PROGW)
31 endif
32 STPFILES=
33
34 config-target.h: config-target.h-timestamp
35 config-target.h-timestamp: config-target.mak
36
37 ifdef CONFIG_TRACE_SYSTEMTAP
38 stap: $(QEMU_PROG).stp-installed $(QEMU_PROG).stp
39
40 ifdef CONFIG_USER_ONLY
41 TARGET_TYPE=user
42 else
43 TARGET_TYPE=system
44 endif
45
46 $(QEMU_PROG).stp-installed: $(SRC_PATH)/trace-events
47         $(call quiet-command,$(TRACETOOL) \
48                 --format=stap \
49                 --backend=$(TRACE_BACKEND) \
50                 --binary=$(bindir)/$(QEMU_PROG) \
51                 --target-name=$(TARGET_NAME) \
52                 --target-type=$(TARGET_TYPE) \
53                 < $< > $@,"  GEN   $(TARGET_DIR)$(QEMU_PROG).stp-installed")
54
55 $(QEMU_PROG).stp: $(SRC_PATH)/trace-events
56         $(call quiet-command,$(TRACETOOL) \
57                 --format=stap \
58                 --backend=$(TRACE_BACKEND) \
59                 --binary=$(realpath .)/$(QEMU_PROG) \
60                 --target-name=$(TARGET_NAME) \
61                 --target-type=$(TARGET_TYPE) \
62                 < $< > $@,"  GEN   $(TARGET_DIR)$(QEMU_PROG).stp")
63
64 else
65 stap:
66 endif
67
68 all: $(PROGS) stap
69
70 # Dummy command so that make thinks it has done something
71         @true
72
73 CONFIG_NO_PCI = $(if $(subst n,,$(CONFIG_PCI)),n,y)
74 CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y)
75 CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y)
76
77 #########################################################
78 # cpu emulator library
79 obj-y = exec.o translate-all.o cpu-exec.o
80 obj-y += tcg/tcg.o tcg/optimize.o
81 obj-$(CONFIG_TCG_INTERPRETER) += tci.o
82 obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
83 obj-y += fpu/softfloat.o
84 obj-y += target-$(TARGET_BASE_ARCH)/
85 obj-y += disas.o
86 obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
87 obj-$(CONFIG_NO_KVM) += kvm-stub.o
88
89 #########################################################
90 # Linux user emulator target
91
92 ifdef CONFIG_LINUX_USER
93
94 QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) -I$(SRC_PATH)/linux-user
95
96 obj-y += linux-user/
97 obj-y += gdbstub.o thunk.o user-exec.o
98
99 endif #CONFIG_LINUX_USER
100
101 #########################################################
102 # BSD user emulator target
103
104 ifdef CONFIG_BSD_USER
105
106 QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ABI_DIR)
107
108 obj-y += bsd-user/
109 obj-y += gdbstub.o user-exec.o
110
111 endif #CONFIG_BSD_USER
112
113 #########################################################
114 # System emulator target
115 ifdef CONFIG_SOFTMMU
116 obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o
117 obj-y += qtest.o
118 obj-y += hw/
119 obj-$(CONFIG_FDT) += device_tree.o
120 obj-$(CONFIG_KVM) += kvm-all.o
121 obj-y += memory.o savevm.o cputlb.o
122 obj-y += memory_mapping.o
123 obj-y += dump.o
124 LIBS+=$(libs_softmmu)
125
126 # xen support
127 obj-$(CONFIG_XEN) += xen-all.o xen-mapcache.o
128 obj-$(CONFIG_NO_XEN) += xen-stub.o
129
130 # Hardware support
131 ifeq ($(TARGET_NAME), sparc64)
132 obj-y += hw/sparc64/
133 else
134 obj-y += hw/$(TARGET_BASE_ARCH)/
135 endif
136
137 main.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
138
139 GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h
140
141 endif # CONFIG_SOFTMMU
142
143 # Workaround for http://gcc.gnu.org/PR55489, see configure.
144 %/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS)
145
146 nested-vars += obj-y
147
148 # This resolves all nested paths, so it must come last
149 include $(SRC_PATH)/Makefile.objs
150
151 all-obj-y = $(obj-y)
152 all-obj-y += $(addprefix ../, $(common-obj-y))
153
154 ifndef CONFIG_HAIKU
155 LIBS+=-lm
156 endif
157
158 ifdef QEMU_PROGW
159 # The linker builds a windows executable. Make also a console executable.
160 $(QEMU_PROGW): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
161         $(call LINK,$^)
162 $(QEMU_PROG): $(QEMU_PROGW)
163         $(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG),"  GEN   $(TARGET_DIR)$(QEMU_PROG)")
164 else
165 $(QEMU_PROG): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
166         $(call LINK,$^)
167 endif
168
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
172 hmp-commands.h: $(SRC_PATH)/hmp-commands.hx
173         $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
174
175 qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx
176         $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
177
178 clean:
179         rm -f *.a *~ $(PROGS)
180         rm -f $(shell find . -name '*.[od]')
181         rm -f hmp-commands.h qmp-commands-old.h gdbstub-xml.c
182 ifdef CONFIG_TRACE_SYSTEMTAP
183         rm -f *.stp
184 endif
185
186 install: all
187 ifneq ($(PROGS),)
188         $(INSTALL) -m 755 $(PROGS) "$(DESTDIR)$(bindir)"
189 ifneq ($(STRIP),)
190         $(STRIP) $(patsubst %,"$(DESTDIR)$(bindir)/%",$(PROGS))
191 endif
192 endif
193 ifdef CONFIG_TRACE_SYSTEMTAP
194         $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset"
195         $(INSTALL_DATA) $(QEMU_PROG).stp-installed "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG).stp"
196 endif
197
198 GENERATED_HEADERS += config-target.h
199 Makefile: $(GENERATED_HEADERS)