blob: 34ddb7e76262d1a1efc0e783ebe0a138a24ab31b [file] [log] [blame]
Anthony Liguori562593a2009-08-04 08:24:23 -05001# -*- Mode: makefile -*-
2
Peter Crosthwaite6b4ad3b2015-05-25 22:38:06 -07003BUILD_DIR?=$(CURDIR)/..
4
Juan Quinteladeed3cc2009-10-07 02:40:57 +02005include ../config-host.mak
Juan Quintela25be210f2009-10-07 02:41:00 +02006include config-target.mak
Paolo Bonzinif3aa8442013-04-16 10:50:38 +02007include config-devices.mak
aliguori17759182009-01-21 18:12:52 +00008include $(SRC_PATH)/rules.mak
bellard626df762003-08-10 21:39:31 +00009
Michael Marineau12a1ddc2015-08-09 00:02:55 -070010$(call set-vpath, $(SRC_PATH):$(BUILD_DIR))
Jan Kiszkaaf2be202011-06-23 10:05:12 +020011ifdef CONFIG_LINUX
12QEMU_CFLAGS += -I../linux-headers
13endif
Paolo Bonzinifec90ff2012-05-29 11:49:50 +020014QEMU_CFLAGS += -I.. -I$(SRC_PATH)/target-$(TARGET_BASE_ARCH) -DNEED_CPU_H
bellard1e43adf2003-09-30 20:54:24 +000015
Anthony Liguori2f28d2f2011-12-03 17:10:08 -060016QEMU_CFLAGS+=-I$(SRC_PATH)/include
17
bellard16e9b7d2003-10-27 21:09:52 +000018ifdef CONFIG_USER_ONLY
bellard40293e52008-01-31 11:32:10 +000019# user emulator name
Paolo Bonzinic1799a82013-06-14 15:19:07 +010020QEMU_PROG=qemu-$(TARGET_NAME)
Michael Tokarev5c40c732014-04-28 11:03:03 +040021QEMU_PROG_BUILD = $(QEMU_PROG)
bellard16e9b7d2003-10-27 21:09:52 +000022else
bellard40293e52008-01-31 11:32:10 +000023# system emulator name
Michael Tokarev5c40c732014-04-28 11:03:03 +040024QEMU_PROG=qemu-system-$(TARGET_NAME)$(EXESUF)
Paolo Bonzinic12915e2013-04-24 22:57:59 +020025ifneq (,$(findstring -mwindows,$(libs_softmmu)))
Stefan Weil0fa54912011-12-22 11:18:53 +010026# Terminate program name with a 'w' because the linker builds a windows executable.
Paolo Bonzinic1799a82013-06-14 15:19:07 +010027QEMU_PROGW=qemu-system-$(TARGET_NAME)w$(EXESUF)
Michael Tokarev5c40c732014-04-28 11:03:03 +040028$(QEMU_PROG): $(QEMU_PROGW)
29 $(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG)," GEN $(TARGET_DIR)$(QEMU_PROG)")
30QEMU_PROG_BUILD = $(QEMU_PROGW)
31else
32QEMU_PROG_BUILD = $(QEMU_PROG)
33endif
bellardde5eaa62003-11-16 23:18:17 +000034endif
bellard728c9fd2004-01-05 00:08:14 +000035
Michael Tokarev5c40c732014-04-28 11:03:03 +040036PROGS=$(QEMU_PROG) $(QEMU_PROGW)
Peter Maydellb8841702010-11-16 20:07:07 +000037STPFILES=
bellard626df762003-08-10 21:39:31 +000038
Juan Quintela91880d92009-10-07 02:41:01 +020039config-target.h: config-target.h-timestamp
40config-target.h-timestamp: config-target.mak
41
Lluís6d8a7642011-08-31 20:30:43 +020042ifdef CONFIG_TRACE_SYSTEMTAP
Stefan Hajnoczie0b2fd02014-06-22 21:46:07 +080043stap: $(QEMU_PROG).stp-installed $(QEMU_PROG).stp $(QEMU_PROG)-simpletrace.stp
Daniel P. Berrangec276b172010-11-12 13:20:25 +000044
45ifdef CONFIG_USER_ONLY
46TARGET_TYPE=user
47else
48TARGET_TYPE=system
49endif
50
Alon Levyc14518e2013-06-14 15:19:07 +010051$(QEMU_PROG).stp-installed: $(SRC_PATH)/trace-events
Lluís Vilanovac0424932012-04-18 20:15:45 +020052 $(call quiet-command,$(TRACETOOL) \
Lluís Vilanova650ab982012-04-03 20:47:39 +020053 --format=stap \
Lluís Vilanova5b808272014-05-27 15:02:14 +020054 --backends=$(TRACE_BACKENDS) \
Lluís Vilanova650ab982012-04-03 20:47:39 +020055 --binary=$(bindir)/$(QEMU_PROG) \
Paolo Bonzinib9a7b742013-06-04 14:45:26 +020056 --target-name=$(TARGET_NAME) \
Lluís Vilanova650ab982012-04-03 20:47:39 +020057 --target-type=$(TARGET_TYPE) \
Alon Levyc14518e2013-06-14 15:19:07 +010058 < $< > $@," GEN $(TARGET_DIR)$(QEMU_PROG).stp-installed")
59
60$(QEMU_PROG).stp: $(SRC_PATH)/trace-events
61 $(call quiet-command,$(TRACETOOL) \
62 --format=stap \
Lluís Vilanova5b808272014-05-27 15:02:14 +020063 --backends=$(TRACE_BACKENDS) \
Alon Levyc14518e2013-06-14 15:19:07 +010064 --binary=$(realpath .)/$(QEMU_PROG) \
Paolo Bonzinib9a7b742013-06-04 14:45:26 +020065 --target-name=$(TARGET_NAME) \
Alon Levyc14518e2013-06-14 15:19:07 +010066 --target-type=$(TARGET_TYPE) \
Paolo Bonziniaaf821f2012-12-21 10:45:20 +010067 < $< > $@," GEN $(TARGET_DIR)$(QEMU_PROG).stp")
Alon Levyc14518e2013-06-14 15:19:07 +010068
Stefan Hajnoczie0b2fd02014-06-22 21:46:07 +080069$(QEMU_PROG)-simpletrace.stp: $(SRC_PATH)/trace-events
70 $(call quiet-command,$(TRACETOOL) \
71 --format=simpletrace-stap \
72 --backends=$(TRACE_BACKENDS) \
73 --probe-prefix=qemu.$(TARGET_TYPE).$(TARGET_NAME) \
74 < $< > $@," GEN $(TARGET_DIR)$(QEMU_PROG)-simpletrace.stp")
75
Daniel P. Berrangec276b172010-11-12 13:20:25 +000076else
77stap:
78endif
79
80all: $(PROGS) stap
Juan Quintela91880d92009-10-07 02:41:01 +020081
Paul Brookc2fb2632009-05-25 18:54:53 +010082# Dummy command so that make thinks it has done something
83 @true
bellard626df762003-08-10 21:39:31 +000084
bellard40293e52008-01-31 11:32:10 +000085#########################################################
bellard626df762003-08-10 21:39:31 +000086# cpu emulator library
Paolo Bonzinifbe37ef2012-05-29 11:48:59 +020087obj-y = exec.o translate-all.o cpu-exec.o
Peter Crosthwaite9b68a772015-09-10 22:39:33 -070088obj-y += translate-common.o
Peter Crosthwaite5abf9492015-09-10 22:39:31 -070089obj-y += cpu-exec-common.o
Richard Henderson951c6302014-09-19 11:39:20 -070090obj-y += tcg/tcg.o tcg/tcg-op.o tcg/optimize.o
Paolo Bonzini9cdc8df2012-05-29 10:55:47 +020091obj-$(CONFIG_TCG_INTERPRETER) += tci.o
Peter Crosthwaite7d8f7872015-09-10 22:39:34 -070092obj-y += tcg/tcg-common.o
Stefan Weil50348332013-01-01 18:43:56 +010093obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
Paolo Bonzini9cdc8df2012-05-29 10:55:47 +020094obj-y += fpu/softfloat.o
Paolo Bonzini5e8861a2012-05-29 10:23:15 +020095obj-y += target-$(TARGET_BASE_ARCH)/
Paolo Bonzini76cad712012-10-24 11:12:21 +020096obj-y += disas.o
Ákos Kovácsb77abd92013-09-13 18:25:54 +010097obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
Ákos Kovácscf01ba92013-09-13 18:25:53 +010098obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
Paolo Bonzini5e8861a2012-05-29 10:23:15 +020099
Tom Mustae58f8d12014-04-21 15:54:52 -0500100obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decContext.o
101obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decNumber.o
102obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal32.o
103obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal64.o
104obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal128.o
105
bellard40293e52008-01-31 11:32:10 +0000106#########################################################
107# Linux user emulator target
108
109ifdef CONFIG_LINUX_USER
110
Mike Frysingerc3109ba2011-02-07 01:05:54 -0500111QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) -I$(SRC_PATH)/linux-user
Blue Swirl5ba65312009-08-15 07:52:19 +0000112
Paolo Bonzini7fc51522012-05-29 09:33:59 +0200113obj-y += linux-user/
Paolo Bonzini8a090702012-12-20 15:40:20 +0100114obj-y += gdbstub.o thunk.o user-exec.o
bellard40293e52008-01-31 11:32:10 +0000115
bellard40293e52008-01-31 11:32:10 +0000116endif #CONFIG_LINUX_USER
117
118#########################################################
blueswir184778502008-10-26 20:33:16 +0000119# BSD user emulator target
120
121ifdef CONFIG_BSD_USER
122
Stacey Sonadfc3e92014-06-08 09:57:22 -0700123QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ABI_DIR) \
124 -I$(SRC_PATH)/bsd-user/$(HOST_VARIANT_DIR)
blueswir184778502008-10-26 20:33:16 +0000125
Paolo Bonzini7fc51522012-05-29 09:33:59 +0200126obj-y += bsd-user/
Paolo Bonzini8a090702012-12-20 15:40:20 +0100127obj-y += gdbstub.o user-exec.o
blueswir184778502008-10-26 20:33:16 +0000128
blueswir184778502008-10-26 20:33:16 +0000129endif #CONFIG_BSD_USER
130
131#########################################################
bellard40293e52008-01-31 11:32:10 +0000132# System emulator target
Juan Quintela76dfdd22009-08-03 14:46:41 +0200133ifdef CONFIG_SOFTMMU
Wanlong Gao96d0e262014-05-14 17:43:05 +0800134obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
Gongleibc741122014-10-07 16:00:05 +0800135obj-y += qtest.o bootdevice.o
Paolo Bonzinic353f262012-05-29 11:49:34 +0200136obj-y += hw/
Paolo Bonzinifbe37ef2012-05-29 11:48:59 +0200137obj-$(CONFIG_KVM) += kvm-all.o
Juan Quintelac3049a52015-05-08 12:49:01 +0200138obj-y += memory.o cputlb.o
Andreas Färberc22d8e02013-05-28 14:53:32 +0200139obj-y += memory_mapping.o
Andreas Färber2a786362013-05-17 11:54:40 +0200140obj-y += dump.o
Juan Quintelac3049a52015-05-08 12:49:01 +0200141obj-y += migration/ram.o migration/savevm.o
Wei Liu7398dfc2015-03-09 14:54:33 +0000142LIBS := $(libs_softmmu) $(LIBS)
bellard4fb240a2007-11-07 19:24:02 +0000143
Anthony PERARD3285cf42010-08-19 12:27:56 +0100144# xen support
Wei Liu04b0de02014-05-07 16:16:43 +0000145obj-$(CONFIG_XEN) += xen-common.o
146obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o
147obj-$(call lnot,$(CONFIG_XEN)) += xen-common-stub.o
148obj-$(call lnot,$(CONFIG_XEN_I386)) += xen-hvm-stub.o
Anthony PERARD3285cf42010-08-19 12:27:56 +0100149
bellarda541f292004-04-12 20:39:29 +0000150# Hardware support
Paolo Bonzinib9a7b742013-06-04 14:45:26 +0200151ifeq ($(TARGET_NAME), sparc64)
Paolo Bonzini5e8861a2012-05-29 10:23:15 +0200152obj-y += hw/sparc64/
bellard34751872005-07-02 14:31:34 +0000153else
Paolo Bonzini5e8861a2012-05-29 10:23:15 +0200154obj-y += hw/$(TARGET_BASE_ARCH)/
bellard34751872005-07-02 14:31:34 +0000155endif
Juan Quintela96374432009-07-16 18:33:58 +0200156
Pavel Butsykinda76ee72015-09-10 18:38:58 +0300157GENERATED_HEADERS += hmp-commands.h hmp-commands-info.h qmp-commands-old.h
Andreas Färber0e8c9212010-01-06 20:24:05 +0100158
Juan Quintela76dfdd22009-08-03 14:46:41 +0200159endif # CONFIG_SOFTMMU
bellard00a67ba2006-10-28 12:19:07 +0000160
Paolo Bonzinicbdd1992012-11-28 09:40:23 +0100161# Workaround for http://gcc.gnu.org/PR55489, see configure.
162%/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS)
163
Fam Zhengba1183d2014-02-10 14:48:52 +0800164dummy := $(call unnest-vars,,obj-y)
Paolo Bonzinid608cc52014-04-29 17:49:25 +0200165all-obj-y := $(obj-y)
Fam Zhengba1183d2014-02-10 14:48:52 +0800166
Lluís Vilanova341ea692014-05-30 14:11:56 +0200167target-obj-y :=
Fam Zhengba1183d2014-02-10 14:48:52 +0800168block-obj-y :=
169common-obj-y :=
Paolo Bonzini99100dc2012-05-22 13:41:27 +0200170include $(SRC_PATH)/Makefile.objs
Lluís Vilanova341ea692014-05-30 14:11:56 +0200171dummy := $(call unnest-vars,,target-obj-y)
172target-obj-y-save := $(target-obj-y)
Fam Zhengcc475692014-02-10 14:48:59 +0800173dummy := $(call unnest-vars,.., \
174 block-obj-y \
175 block-obj-m \
Daniel P. Berrangefb377262015-09-02 10:57:27 +0100176 crypto-obj-y \
177 crypto-aes-obj-y \
Daniel P. Berrange0c7012e2015-09-02 11:18:16 +0100178 qom-obj-y \
Daniel P. Berrange666a3af2015-02-27 16:19:33 +0000179 io-obj-y \
Fam Zhengcc475692014-02-10 14:48:59 +0800180 common-obj-y \
181 common-obj-m)
Lluís Vilanova341ea692014-05-30 14:11:56 +0200182target-obj-y := $(target-obj-y-save)
Paolo Bonzinid608cc52014-04-29 17:49:25 +0200183all-obj-y += $(common-obj-y)
Lluís Vilanova341ea692014-05-30 14:11:56 +0200184all-obj-y += $(target-obj-y)
Daniel P. Berrange0c7012e2015-09-02 11:18:16 +0100185all-obj-y += $(qom-obj-y)
Fam Zhengba1183d2014-02-10 14:48:52 +0800186all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
Daniel P. Berrangefb377262015-09-02 10:57:27 +0100187all-obj-$(CONFIG_USER_ONLY) += $(crypto-aes-obj-y)
188all-obj-$(CONFIG_SOFTMMU) += $(crypto-obj-y)
Daniel P. Berrange666a3af2015-02-27 16:19:33 +0000189all-obj-$(CONFIG_SOFTMMU) += $(io-obj-y)
Paolo Bonzini7fc51522012-05-29 09:33:59 +0200190
Michael S. Tsirkina9ad5e12015-02-19 08:48:52 +0100191$(QEMU_PROG_BUILD): config-devices.mak
192
Michael Tokarev5c40c732014-04-28 11:03:03 +0400193# build either PROG or PROGW
194$(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
Michael S. Tsirkina9ad5e12015-02-19 08:48:52 +0100195 $(call LINK, $(filter-out %.mak, $^))
Programmingkid4e340172015-05-19 09:11:17 +0100196ifdef CONFIG_DARWIN
197 $(call quiet-command,Rez -append $(SRC_PATH)/pc-bios/qemu.rsrc -o $@," REZ $(TARGET_DIR)$@")
198 $(call quiet-command,SetFile -a C $@," SETFILE $(TARGET_DIR)$@")
199endif
Juan Quintela16394482009-07-16 18:34:04 +0200200
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000201gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
202 $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES)," GEN $(TARGET_DIR)$@")
pbrook56aebc82008-10-11 17:55:29 +0000203
Luiz Capitulinoacd0a092010-09-30 16:00:22 -0300204hmp-commands.h: $(SRC_PATH)/hmp-commands.hx
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000205 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
Blue Swirl23130862009-06-06 08:22:04 +0000206
Pavel Butsykinda76ee72015-09-10 18:38:58 +0300207hmp-commands-info.h: $(SRC_PATH)/hmp-commands-info.hx
208 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
209
Anthony Liguorie3193602011-09-02 12:34:47 -0500210qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000211 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
blueswir15824d652009-03-28 06:44:27 +0000212
bellard626df762003-08-10 21:39:31 +0000213clean:
Peter Maydellb54fa7d2012-06-20 18:02:33 +0100214 rm -f *.a *~ $(PROGS)
215 rm -f $(shell find . -name '*.[od]')
Anthony Liguorie3193602011-09-02 12:34:47 -0500216 rm -f hmp-commands.h qmp-commands-old.h gdbstub-xml.c
Lluís6d8a7642011-08-31 20:30:43 +0200217ifdef CONFIG_TRACE_SYSTEMTAP
Daniel P. Berrangec276b172010-11-12 13:20:25 +0000218 rm -f *.stp
219endif
bellard1e43adf2003-09-30 20:54:24 +0000220
ths5fafdf22007-09-16 21:08:06 +0000221install: all
bellard9b14bb02004-03-26 22:43:34 +0000222ifneq ($(PROGS),)
Michael Tokarev0d659422014-06-22 10:55:23 +0400223 $(call install-prog,$(PROGS),$(DESTDIR)$(bindir))
bellard9b14bb02004-03-26 22:43:34 +0000224endif
Lluís6d8a7642011-08-31 20:30:43 +0200225ifdef CONFIG_TRACE_SYSTEMTAP
Eduardo Habkost6aae2a22012-04-18 16:55:41 -0300226 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset"
Alon Levyc14518e2013-06-14 15:19:07 +0100227 $(INSTALL_DATA) $(QEMU_PROG).stp-installed "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG).stp"
Stefan Hajnoczie0b2fd02014-06-22 21:46:07 +0800228 $(INSTALL_DATA) $(QEMU_PROG)-simpletrace.stp "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG)-simpletrace.stp"
Daniel P. Berrangec276b172010-11-12 13:20:25 +0000229endif
bellard626df762003-08-10 21:39:31 +0000230
Paolo Bonzini41158522012-05-29 12:41:34 +0200231GENERATED_HEADERS += config-target.h
232Makefile: $(GENERATED_HEADERS)