blob: 3e7aafd72d3796adec0f688de0a9f6659fda5fef [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
Paolo Bonzinifec90ff2012-05-29 11:49:50 +020010$(call set-vpath, $(SRC_PATH))
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
Richard Henderson951c6302014-09-19 11:39:20 -070088obj-y += tcg/tcg.o tcg/tcg-op.o tcg/optimize.o
Paolo Bonzini9cdc8df2012-05-29 10:55:47 +020089obj-$(CONFIG_TCG_INTERPRETER) += tci.o
Stefan Weil50348332013-01-01 18:43:56 +010090obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
Paolo Bonzini9cdc8df2012-05-29 10:55:47 +020091obj-y += fpu/softfloat.o
Paolo Bonzini5e8861a2012-05-29 10:23:15 +020092obj-y += target-$(TARGET_BASE_ARCH)/
Paolo Bonzini76cad712012-10-24 11:12:21 +020093obj-y += disas.o
Ákos Kovácsb77abd92013-09-13 18:25:54 +010094obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
Ákos Kovácscf01ba92013-09-13 18:25:53 +010095obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
Paolo Bonzini5e8861a2012-05-29 10:23:15 +020096
Tom Mustae58f8d12014-04-21 15:54:52 -050097obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decContext.o
98obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decNumber.o
99obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal32.o
100obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal64.o
101obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal128.o
102
bellard40293e52008-01-31 11:32:10 +0000103#########################################################
104# Linux user emulator target
105
106ifdef CONFIG_LINUX_USER
107
Mike Frysingerc3109ba2011-02-07 01:05:54 -0500108QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) -I$(SRC_PATH)/linux-user
Blue Swirl5ba65312009-08-15 07:52:19 +0000109
Paolo Bonzini7fc51522012-05-29 09:33:59 +0200110obj-y += linux-user/
Paolo Bonzini8a090702012-12-20 15:40:20 +0100111obj-y += gdbstub.o thunk.o user-exec.o
bellard40293e52008-01-31 11:32:10 +0000112
bellard40293e52008-01-31 11:32:10 +0000113endif #CONFIG_LINUX_USER
114
115#########################################################
blueswir184778502008-10-26 20:33:16 +0000116# BSD user emulator target
117
118ifdef CONFIG_BSD_USER
119
Stacey Sonadfc3e92014-06-08 09:57:22 -0700120QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ABI_DIR) \
121 -I$(SRC_PATH)/bsd-user/$(HOST_VARIANT_DIR)
blueswir184778502008-10-26 20:33:16 +0000122
Paolo Bonzini7fc51522012-05-29 09:33:59 +0200123obj-y += bsd-user/
Paolo Bonzini8a090702012-12-20 15:40:20 +0100124obj-y += gdbstub.o user-exec.o
blueswir184778502008-10-26 20:33:16 +0000125
blueswir184778502008-10-26 20:33:16 +0000126endif #CONFIG_BSD_USER
127
128#########################################################
bellard40293e52008-01-31 11:32:10 +0000129# System emulator target
Juan Quintela76dfdd22009-08-03 14:46:41 +0200130ifdef CONFIG_SOFTMMU
Wanlong Gao96d0e262014-05-14 17:43:05 +0800131obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
Gongleibc741122014-10-07 16:00:05 +0800132obj-y += qtest.o bootdevice.o
Paolo Bonzinic353f262012-05-29 11:49:34 +0200133obj-y += hw/
Paolo Bonzinifbe37ef2012-05-29 11:48:59 +0200134obj-$(CONFIG_KVM) += kvm-all.o
Juan Quintelac3049a52015-05-08 12:49:01 +0200135obj-y += memory.o cputlb.o
Andreas Färberc22d8e02013-05-28 14:53:32 +0200136obj-y += memory_mapping.o
Andreas Färber2a786362013-05-17 11:54:40 +0200137obj-y += dump.o
Juan Quintelac3049a52015-05-08 12:49:01 +0200138obj-y += migration/ram.o migration/savevm.o
Wei Liu7398dfc2015-03-09 14:54:33 +0000139LIBS := $(libs_softmmu) $(LIBS)
bellard4fb240a2007-11-07 19:24:02 +0000140
Anthony PERARD3285cf42010-08-19 12:27:56 +0100141# xen support
Wei Liu04b0de02014-05-07 16:16:43 +0000142obj-$(CONFIG_XEN) += xen-common.o
143obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o
144obj-$(call lnot,$(CONFIG_XEN)) += xen-common-stub.o
145obj-$(call lnot,$(CONFIG_XEN_I386)) += xen-hvm-stub.o
Anthony PERARD3285cf42010-08-19 12:27:56 +0100146
bellarda541f292004-04-12 20:39:29 +0000147# Hardware support
Paolo Bonzinib9a7b742013-06-04 14:45:26 +0200148ifeq ($(TARGET_NAME), sparc64)
Paolo Bonzini5e8861a2012-05-29 10:23:15 +0200149obj-y += hw/sparc64/
bellard34751872005-07-02 14:31:34 +0000150else
Paolo Bonzini5e8861a2012-05-29 10:23:15 +0200151obj-y += hw/$(TARGET_BASE_ARCH)/
bellard34751872005-07-02 14:31:34 +0000152endif
Juan Quintela96374432009-07-16 18:33:58 +0200153
Paolo Bonzini41158522012-05-29 12:41:34 +0200154GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h
Andreas Färber0e8c9212010-01-06 20:24:05 +0100155
Juan Quintela76dfdd22009-08-03 14:46:41 +0200156endif # CONFIG_SOFTMMU
bellard00a67ba2006-10-28 12:19:07 +0000157
Paolo Bonzinicbdd1992012-11-28 09:40:23 +0100158# Workaround for http://gcc.gnu.org/PR55489, see configure.
159%/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS)
160
Fam Zhengba1183d2014-02-10 14:48:52 +0800161dummy := $(call unnest-vars,,obj-y)
Paolo Bonzinid608cc52014-04-29 17:49:25 +0200162all-obj-y := $(obj-y)
Fam Zhengba1183d2014-02-10 14:48:52 +0800163
Lluís Vilanova341ea692014-05-30 14:11:56 +0200164target-obj-y :=
Fam Zhengba1183d2014-02-10 14:48:52 +0800165block-obj-y :=
166common-obj-y :=
Paolo Bonzini99100dc2012-05-22 13:41:27 +0200167include $(SRC_PATH)/Makefile.objs
Lluís Vilanova341ea692014-05-30 14:11:56 +0200168dummy := $(call unnest-vars,,target-obj-y)
169target-obj-y-save := $(target-obj-y)
Fam Zhengcc475692014-02-10 14:48:59 +0800170dummy := $(call unnest-vars,.., \
171 block-obj-y \
172 block-obj-m \
173 common-obj-y \
174 common-obj-m)
Lluís Vilanova341ea692014-05-30 14:11:56 +0200175target-obj-y := $(target-obj-y-save)
Paolo Bonzinid608cc52014-04-29 17:49:25 +0200176all-obj-y += $(common-obj-y)
Lluís Vilanova341ea692014-05-30 14:11:56 +0200177all-obj-y += $(target-obj-y)
Fam Zhengba1183d2014-02-10 14:48:52 +0800178all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
Paolo Bonzini7fc51522012-05-29 09:33:59 +0200179
Michael S. Tsirkina9ad5e12015-02-19 08:48:52 +0100180$(QEMU_PROG_BUILD): config-devices.mak
181
Michael Tokarev5c40c732014-04-28 11:03:03 +0400182# build either PROG or PROGW
183$(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
Michael S. Tsirkina9ad5e12015-02-19 08:48:52 +0100184 $(call LINK, $(filter-out %.mak, $^))
Programmingkid4e340172015-05-19 09:11:17 +0100185ifdef CONFIG_DARWIN
186 $(call quiet-command,Rez -append $(SRC_PATH)/pc-bios/qemu.rsrc -o $@," REZ $(TARGET_DIR)$@")
187 $(call quiet-command,SetFile -a C $@," SETFILE $(TARGET_DIR)$@")
188endif
Juan Quintela16394482009-07-16 18:34:04 +0200189
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000190gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
191 $(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 +0000192
Luiz Capitulinoacd0a092010-09-30 16:00:22 -0300193hmp-commands.h: $(SRC_PATH)/hmp-commands.hx
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000194 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
Blue Swirl23130862009-06-06 08:22:04 +0000195
Anthony Liguorie3193602011-09-02 12:34:47 -0500196qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000197 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
blueswir15824d652009-03-28 06:44:27 +0000198
bellard626df762003-08-10 21:39:31 +0000199clean:
Peter Maydellb54fa7d2012-06-20 18:02:33 +0100200 rm -f *.a *~ $(PROGS)
201 rm -f $(shell find . -name '*.[od]')
Anthony Liguorie3193602011-09-02 12:34:47 -0500202 rm -f hmp-commands.h qmp-commands-old.h gdbstub-xml.c
Lluís6d8a7642011-08-31 20:30:43 +0200203ifdef CONFIG_TRACE_SYSTEMTAP
Daniel P. Berrangec276b172010-11-12 13:20:25 +0000204 rm -f *.stp
205endif
bellard1e43adf2003-09-30 20:54:24 +0000206
ths5fafdf22007-09-16 21:08:06 +0000207install: all
bellard9b14bb02004-03-26 22:43:34 +0000208ifneq ($(PROGS),)
Michael Tokarev0d659422014-06-22 10:55:23 +0400209 $(call install-prog,$(PROGS),$(DESTDIR)$(bindir))
bellard9b14bb02004-03-26 22:43:34 +0000210endif
Lluís6d8a7642011-08-31 20:30:43 +0200211ifdef CONFIG_TRACE_SYSTEMTAP
Eduardo Habkost6aae2a22012-04-18 16:55:41 -0300212 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset"
Alon Levyc14518e2013-06-14 15:19:07 +0100213 $(INSTALL_DATA) $(QEMU_PROG).stp-installed "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG).stp"
Stefan Hajnoczie0b2fd02014-06-22 21:46:07 +0800214 $(INSTALL_DATA) $(QEMU_PROG)-simpletrace.stp "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG)-simpletrace.stp"
Daniel P. Berrangec276b172010-11-12 13:20:25 +0000215endif
bellard626df762003-08-10 21:39:31 +0000216
Paolo Bonzini41158522012-05-29 12:41:34 +0200217GENERATED_HEADERS += config-target.h
218Makefile: $(GENERATED_HEADERS)