blob: 9a4985213bc91acf46e384c2c2cc2dccf3eadaad [file] [log] [blame]
Anthony Liguori562593a2009-08-04 08:24:23 -05001# -*- Mode: makefile -*-
2
Juan Quinteladeed3cc2009-10-07 02:40:57 +02003include ../config-host.mak
Juan Quintela25be210f2009-10-07 02:41:00 +02004include config-target.mak
Paolo Bonzinif3aa8442013-04-16 10:50:38 +02005include config-devices.mak
aliguori17759182009-01-21 18:12:52 +00006include $(SRC_PATH)/rules.mak
bellard626df762003-08-10 21:39:31 +00007
Paolo Bonzinifec90ff2012-05-29 11:49:50 +02008$(call set-vpath, $(SRC_PATH))
Jan Kiszkaaf2be202011-06-23 10:05:12 +02009ifdef CONFIG_LINUX
10QEMU_CFLAGS += -I../linux-headers
11endif
Paolo Bonzinifec90ff2012-05-29 11:49:50 +020012QEMU_CFLAGS += -I.. -I$(SRC_PATH)/target-$(TARGET_BASE_ARCH) -DNEED_CPU_H
bellard1e43adf2003-09-30 20:54:24 +000013
Anthony Liguori2f28d2f2011-12-03 17:10:08 -060014QEMU_CFLAGS+=-I$(SRC_PATH)/include
15
bellard16e9b7d2003-10-27 21:09:52 +000016ifdef CONFIG_USER_ONLY
bellard40293e52008-01-31 11:32:10 +000017# user emulator name
Paolo Bonzinic1799a82013-06-14 15:19:07 +010018QEMU_PROG=qemu-$(TARGET_NAME)
bellard16e9b7d2003-10-27 21:09:52 +000019else
bellard40293e52008-01-31 11:32:10 +000020# system emulator name
Paolo Bonzinic12915e2013-04-24 22:57:59 +020021ifneq (,$(findstring -mwindows,$(libs_softmmu)))
Stefan Weil0fa54912011-12-22 11:18:53 +010022# Terminate program name with a 'w' because the linker builds a windows executable.
Paolo Bonzinic1799a82013-06-14 15:19:07 +010023QEMU_PROGW=qemu-system-$(TARGET_NAME)w$(EXESUF)
Stefan Weil0fa54912011-12-22 11:18:53 +010024endif # windows executable
Paolo Bonzinic1799a82013-06-14 15:19:07 +010025QEMU_PROG=qemu-system-$(TARGET_NAME)$(EXESUF)
bellardde5eaa62003-11-16 23:18:17 +000026endif
bellard728c9fd2004-01-05 00:08:14 +000027
bellard40293e52008-01-31 11:32:10 +000028PROGS=$(QEMU_PROG)
Stefan Weil0fa54912011-12-22 11:18:53 +010029ifdef QEMU_PROGW
30PROGS+=$(QEMU_PROGW)
31endif
Peter Maydellb8841702010-11-16 20:07:07 +000032STPFILES=
bellard626df762003-08-10 21:39:31 +000033
Juan Quintela91880d92009-10-07 02:41:01 +020034config-target.h: config-target.h-timestamp
35config-target.h-timestamp: config-target.mak
36
Lluís6d8a7642011-08-31 20:30:43 +020037ifdef CONFIG_TRACE_SYSTEMTAP
Alon Levyc14518e2013-06-14 15:19:07 +010038stap: $(QEMU_PROG).stp-installed $(QEMU_PROG).stp
Daniel P. Berrangec276b172010-11-12 13:20:25 +000039
40ifdef CONFIG_USER_ONLY
41TARGET_TYPE=user
42else
43TARGET_TYPE=system
44endif
45
Alon Levyc14518e2013-06-14 15:19:07 +010046$(QEMU_PROG).stp-installed: $(SRC_PATH)/trace-events
Lluís Vilanovac0424932012-04-18 20:15:45 +020047 $(call quiet-command,$(TRACETOOL) \
Lluís Vilanova650ab982012-04-03 20:47:39 +020048 --format=stap \
49 --backend=$(TRACE_BACKEND) \
50 --binary=$(bindir)/$(QEMU_PROG) \
Paolo Bonzinib9a7b742013-06-04 14:45:26 +020051 --target-name=$(TARGET_NAME) \
Lluís Vilanova650ab982012-04-03 20:47:39 +020052 --target-type=$(TARGET_TYPE) \
Alon Levyc14518e2013-06-14 15:19:07 +010053 < $< > $@," 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) \
Paolo Bonzinib9a7b742013-06-04 14:45:26 +020060 --target-name=$(TARGET_NAME) \
Alon Levyc14518e2013-06-14 15:19:07 +010061 --target-type=$(TARGET_TYPE) \
Paolo Bonziniaaf821f2012-12-21 10:45:20 +010062 < $< > $@," GEN $(TARGET_DIR)$(QEMU_PROG).stp")
Alon Levyc14518e2013-06-14 15:19:07 +010063
Daniel P. Berrangec276b172010-11-12 13:20:25 +000064else
65stap:
66endif
67
68all: $(PROGS) stap
Juan Quintela91880d92009-10-07 02:41:01 +020069
Paul Brookc2fb2632009-05-25 18:54:53 +010070# Dummy command so that make thinks it has done something
71 @true
bellard626df762003-08-10 21:39:31 +000072
Igor Mammedovc4cfef52013-04-23 10:29:35 +020073CONFIG_NO_PCI = $(if $(subst n,,$(CONFIG_PCI)),n,y)
74CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y)
75CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y)
Igor Mammedovc4cfef52013-04-23 10:29:35 +020076
bellard40293e52008-01-31 11:32:10 +000077#########################################################
bellard626df762003-08-10 21:39:31 +000078# cpu emulator library
Paolo Bonzinifbe37ef2012-05-29 11:48:59 +020079obj-y = exec.o translate-all.o cpu-exec.o
Paolo Bonzini9cdc8df2012-05-29 10:55:47 +020080obj-y += tcg/tcg.o tcg/optimize.o
81obj-$(CONFIG_TCG_INTERPRETER) += tci.o
Stefan Weil50348332013-01-01 18:43:56 +010082obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
Paolo Bonzini9cdc8df2012-05-29 10:55:47 +020083obj-y += fpu/softfloat.o
Paolo Bonzini5e8861a2012-05-29 10:23:15 +020084obj-y += target-$(TARGET_BASE_ARCH)/
Paolo Bonzini76cad712012-10-24 11:12:21 +020085obj-y += disas.o
Paolo Bonzini9cdc8df2012-05-29 10:55:47 +020086obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
Igor Mammedovc4cfef52013-04-23 10:29:35 +020087obj-$(CONFIG_NO_KVM) += kvm-stub.o
Paolo Bonzini5e8861a2012-05-29 10:23:15 +020088
bellard40293e52008-01-31 11:32:10 +000089#########################################################
90# Linux user emulator target
91
92ifdef CONFIG_LINUX_USER
93
Mike Frysingerc3109ba2011-02-07 01:05:54 -050094QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) -I$(SRC_PATH)/linux-user
Blue Swirl5ba65312009-08-15 07:52:19 +000095
Paolo Bonzini7fc51522012-05-29 09:33:59 +020096obj-y += linux-user/
Paolo Bonzini8a090702012-12-20 15:40:20 +010097obj-y += gdbstub.o thunk.o user-exec.o
bellard40293e52008-01-31 11:32:10 +000098
bellard40293e52008-01-31 11:32:10 +000099endif #CONFIG_LINUX_USER
100
101#########################################################
blueswir184778502008-10-26 20:33:16 +0000102# BSD user emulator target
103
104ifdef CONFIG_BSD_USER
105
Paolo Bonzinib9a7b742013-06-04 14:45:26 +0200106QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ABI_DIR)
blueswir184778502008-10-26 20:33:16 +0000107
Paolo Bonzini7fc51522012-05-29 09:33:59 +0200108obj-y += bsd-user/
Paolo Bonzini8a090702012-12-20 15:40:20 +0100109obj-y += gdbstub.o user-exec.o
blueswir184778502008-10-26 20:33:16 +0000110
blueswir184778502008-10-26 20:33:16 +0000111endif #CONFIG_BSD_USER
112
113#########################################################
bellard40293e52008-01-31 11:32:10 +0000114# System emulator target
Juan Quintela76dfdd22009-08-03 14:46:41 +0200115ifdef CONFIG_SOFTMMU
Paolo Bonzinifbe37ef2012-05-29 11:48:59 +0200116obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o
Andreas Färber872536b2013-02-16 22:44:03 +0100117obj-y += qtest.o
Paolo Bonzinic353f262012-05-29 11:49:34 +0200118obj-y += hw/
Paolo Bonzini320ba5f2013-02-05 12:36:30 +0100119obj-$(CONFIG_FDT) += device_tree.o
Paolo Bonzinifbe37ef2012-05-29 11:48:59 +0200120obj-$(CONFIG_KVM) += kvm-all.o
Blue Swirl0cac1b62012-04-09 16:50:52 +0000121obj-y += memory.o savevm.o cputlb.o
Andreas Färberc22d8e02013-05-28 14:53:32 +0200122obj-y += memory_mapping.o
Andreas Färber2a786362013-05-17 11:54:40 +0200123obj-y += dump.o
Paolo Bonzinif544a482013-04-17 16:26:44 +0200124LIBS+=$(libs_softmmu)
bellard4fb240a2007-11-07 19:24:02 +0000125
Anthony PERARD3285cf42010-08-19 12:27:56 +0100126# xen support
Paolo Bonzinic353f262012-05-29 11:49:34 +0200127obj-$(CONFIG_XEN) += xen-all.o xen-mapcache.o
Anthony PERARD3285cf42010-08-19 12:27:56 +0100128obj-$(CONFIG_NO_XEN) += xen-stub.o
129
bellarda541f292004-04-12 20:39:29 +0000130# Hardware support
Paolo Bonzinib9a7b742013-06-04 14:45:26 +0200131ifeq ($(TARGET_NAME), sparc64)
Paolo Bonzini5e8861a2012-05-29 10:23:15 +0200132obj-y += hw/sparc64/
bellard34751872005-07-02 14:31:34 +0000133else
Paolo Bonzini5e8861a2012-05-29 10:23:15 +0200134obj-y += hw/$(TARGET_BASE_ARCH)/
bellard34751872005-07-02 14:31:34 +0000135endif
Juan Quintela96374432009-07-16 18:33:58 +0200136
Blue Swirlad960902010-03-29 19:23:52 +0000137main.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
blueswir15824d652009-03-28 06:44:27 +0000138
Paolo Bonzini41158522012-05-29 12:41:34 +0200139GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h
Andreas Färber0e8c9212010-01-06 20:24:05 +0100140
Juan Quintela76dfdd22009-08-03 14:46:41 +0200141endif # CONFIG_SOFTMMU
bellard00a67ba2006-10-28 12:19:07 +0000142
Paolo Bonzinicbdd1992012-11-28 09:40:23 +0100143# Workaround for http://gcc.gnu.org/PR55489, see configure.
144%/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS)
145
Paolo Bonzini99100dc2012-05-22 13:41:27 +0200146nested-vars += obj-y
147
148# This resolves all nested paths, so it must come last
149include $(SRC_PATH)/Makefile.objs
150
151all-obj-y = $(obj-y)
Paolo Bonzini00082342013-01-19 11:06:47 +0100152all-obj-y += $(addprefix ../, $(common-obj-y))
Paolo Bonzini7fc51522012-05-29 09:33:59 +0200153
Paolo Bonzinif544a482013-04-17 16:26:44 +0200154ifndef CONFIG_HAIKU
155LIBS+=-lm
156endif
157
Stefan Weil0fa54912011-12-22 11:18:53 +0100158ifdef QEMU_PROGW
159# The linker builds a windows executable. Make also a console executable.
Paolo Bonzini8a090702012-12-20 15:40:20 +0100160$(QEMU_PROGW): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
Stefan Weil0fa54912011-12-22 11:18:53 +0100161 $(call LINK,$^)
162$(QEMU_PROG): $(QEMU_PROGW)
163 $(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG)," GEN $(TARGET_DIR)$(QEMU_PROG)")
164else
Paolo Bonzini8a090702012-12-20 15:40:20 +0100165$(QEMU_PROG): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
Lluíse03b41d2011-08-31 20:30:30 +0200166 $(call LINK,$^)
Stefan Weil0fa54912011-12-22 11:18:53 +0100167endif
Juan Quintela16394482009-07-16 18:34:04 +0200168
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000169gdbstub-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)$@")
pbrook56aebc82008-10-11 17:55:29 +0000171
Luiz Capitulinoacd0a092010-09-30 16:00:22 -0300172hmp-commands.h: $(SRC_PATH)/hmp-commands.hx
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000173 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
Blue Swirl23130862009-06-06 08:22:04 +0000174
Anthony Liguorie3193602011-09-02 12:34:47 -0500175qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000176 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
blueswir15824d652009-03-28 06:44:27 +0000177
bellard626df762003-08-10 21:39:31 +0000178clean:
Peter Maydellb54fa7d2012-06-20 18:02:33 +0100179 rm -f *.a *~ $(PROGS)
180 rm -f $(shell find . -name '*.[od]')
Anthony Liguorie3193602011-09-02 12:34:47 -0500181 rm -f hmp-commands.h qmp-commands-old.h gdbstub-xml.c
Lluís6d8a7642011-08-31 20:30:43 +0200182ifdef CONFIG_TRACE_SYSTEMTAP
Daniel P. Berrangec276b172010-11-12 13:20:25 +0000183 rm -f *.stp
184endif
bellard1e43adf2003-09-30 20:54:24 +0000185
ths5fafdf22007-09-16 21:08:06 +0000186install: all
bellard9b14bb02004-03-26 22:43:34 +0000187ifneq ($(PROGS),)
Hollis Blanchard52ba7842010-08-04 17:21:34 -0700188 $(INSTALL) -m 755 $(PROGS) "$(DESTDIR)$(bindir)"
189ifneq ($(STRIP),)
190 $(STRIP) $(patsubst %,"$(DESTDIR)$(bindir)/%",$(PROGS))
191endif
bellard9b14bb02004-03-26 22:43:34 +0000192endif
Lluís6d8a7642011-08-31 20:30:43 +0200193ifdef CONFIG_TRACE_SYSTEMTAP
Eduardo Habkost6aae2a22012-04-18 16:55:41 -0300194 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset"
Alon Levyc14518e2013-06-14 15:19:07 +0100195 $(INSTALL_DATA) $(QEMU_PROG).stp-installed "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG).stp"
Daniel P. Berrangec276b172010-11-12 13:20:25 +0000196endif
bellard626df762003-08-10 21:39:31 +0000197
Paolo Bonzini41158522012-05-29 12:41:34 +0200198GENERATED_HEADERS += config-target.h
199Makefile: $(GENERATED_HEADERS)