blob: af6ac7eaa19f922cf5d006ee7eebd8ef2dfde3d4 [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
bellard40293e52008-01-31 11:32:10 +000073#########################################################
bellard626df762003-08-10 21:39:31 +000074# cpu emulator library
Paolo Bonzinifbe37ef2012-05-29 11:48:59 +020075obj-y = exec.o translate-all.o cpu-exec.o
Paolo Bonzini9cdc8df2012-05-29 10:55:47 +020076obj-y += tcg/tcg.o tcg/optimize.o
77obj-$(CONFIG_TCG_INTERPRETER) += tci.o
Stefan Weil50348332013-01-01 18:43:56 +010078obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
Paolo Bonzini9cdc8df2012-05-29 10:55:47 +020079obj-y += fpu/softfloat.o
Paolo Bonzini5e8861a2012-05-29 10:23:15 +020080obj-y += target-$(TARGET_BASE_ARCH)/
Paolo Bonzini76cad712012-10-24 11:12:21 +020081obj-y += disas.o
Ákos Kovácsb77abd92013-09-13 18:25:54 +010082obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
Ákos Kovácscf01ba92013-09-13 18:25:53 +010083obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
Paolo Bonzini5e8861a2012-05-29 10:23:15 +020084
bellard40293e52008-01-31 11:32:10 +000085#########################################################
86# Linux user emulator target
87
88ifdef CONFIG_LINUX_USER
89
Mike Frysingerc3109ba2011-02-07 01:05:54 -050090QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) -I$(SRC_PATH)/linux-user
Blue Swirl5ba65312009-08-15 07:52:19 +000091
Paolo Bonzini7fc51522012-05-29 09:33:59 +020092obj-y += linux-user/
Paolo Bonzini8a090702012-12-20 15:40:20 +010093obj-y += gdbstub.o thunk.o user-exec.o
bellard40293e52008-01-31 11:32:10 +000094
bellard40293e52008-01-31 11:32:10 +000095endif #CONFIG_LINUX_USER
96
97#########################################################
blueswir184778502008-10-26 20:33:16 +000098# BSD user emulator target
99
100ifdef CONFIG_BSD_USER
101
Paolo Bonzinib9a7b742013-06-04 14:45:26 +0200102QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ABI_DIR)
blueswir184778502008-10-26 20:33:16 +0000103
Paolo Bonzini7fc51522012-05-29 09:33:59 +0200104obj-y += bsd-user/
Paolo Bonzini8a090702012-12-20 15:40:20 +0100105obj-y += gdbstub.o user-exec.o
blueswir184778502008-10-26 20:33:16 +0000106
blueswir184778502008-10-26 20:33:16 +0000107endif #CONFIG_BSD_USER
108
109#########################################################
bellard40293e52008-01-31 11:32:10 +0000110# System emulator target
Juan Quintela76dfdd22009-08-03 14:46:41 +0200111ifdef CONFIG_SOFTMMU
Paolo Bonzinifbe37ef2012-05-29 11:48:59 +0200112obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o
Andreas Färber872536b2013-02-16 22:44:03 +0100113obj-y += qtest.o
Paolo Bonzinic353f262012-05-29 11:49:34 +0200114obj-y += hw/
Paolo Bonzini320ba5f2013-02-05 12:36:30 +0100115obj-$(CONFIG_FDT) += device_tree.o
Paolo Bonzinifbe37ef2012-05-29 11:48:59 +0200116obj-$(CONFIG_KVM) += kvm-all.o
Blue Swirl0cac1b62012-04-09 16:50:52 +0000117obj-y += memory.o savevm.o cputlb.o
Andreas Färberc22d8e02013-05-28 14:53:32 +0200118obj-y += memory_mapping.o
Andreas Färber2a786362013-05-17 11:54:40 +0200119obj-y += dump.o
Paolo Bonzinif544a482013-04-17 16:26:44 +0200120LIBS+=$(libs_softmmu)
bellard4fb240a2007-11-07 19:24:02 +0000121
Anthony PERARD3285cf42010-08-19 12:27:56 +0100122# xen support
Paolo Bonzinic353f262012-05-29 11:49:34 +0200123obj-$(CONFIG_XEN) += xen-all.o xen-mapcache.o
Ákos Kovácscf01ba92013-09-13 18:25:53 +0100124obj-$(call lnot,$(CONFIG_XEN)) += xen-stub.o
Anthony PERARD3285cf42010-08-19 12:27:56 +0100125
bellarda541f292004-04-12 20:39:29 +0000126# Hardware support
Paolo Bonzinib9a7b742013-06-04 14:45:26 +0200127ifeq ($(TARGET_NAME), sparc64)
Paolo Bonzini5e8861a2012-05-29 10:23:15 +0200128obj-y += hw/sparc64/
bellard34751872005-07-02 14:31:34 +0000129else
Paolo Bonzini5e8861a2012-05-29 10:23:15 +0200130obj-y += hw/$(TARGET_BASE_ARCH)/
bellard34751872005-07-02 14:31:34 +0000131endif
Juan Quintela96374432009-07-16 18:33:58 +0200132
Blue Swirlad960902010-03-29 19:23:52 +0000133main.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
blueswir15824d652009-03-28 06:44:27 +0000134
Paolo Bonzini41158522012-05-29 12:41:34 +0200135GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h
Andreas Färber0e8c9212010-01-06 20:24:05 +0100136
Juan Quintela76dfdd22009-08-03 14:46:41 +0200137endif # CONFIG_SOFTMMU
bellard00a67ba2006-10-28 12:19:07 +0000138
Paolo Bonzinicbdd1992012-11-28 09:40:23 +0100139# Workaround for http://gcc.gnu.org/PR55489, see configure.
140%/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS)
141
Paolo Bonzini99100dc2012-05-22 13:41:27 +0200142nested-vars += obj-y
143
144# This resolves all nested paths, so it must come last
145include $(SRC_PATH)/Makefile.objs
146
147all-obj-y = $(obj-y)
Paolo Bonzini00082342013-01-19 11:06:47 +0100148all-obj-y += $(addprefix ../, $(common-obj-y))
Paolo Bonzini7fc51522012-05-29 09:33:59 +0200149
Paolo Bonzinif544a482013-04-17 16:26:44 +0200150ifndef CONFIG_HAIKU
151LIBS+=-lm
152endif
153
Stefan Weil0fa54912011-12-22 11:18:53 +0100154ifdef QEMU_PROGW
155# The linker builds a windows executable. Make also a console executable.
Paolo Bonzini8a090702012-12-20 15:40:20 +0100156$(QEMU_PROGW): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
Stefan Weil0fa54912011-12-22 11:18:53 +0100157 $(call LINK,$^)
158$(QEMU_PROG): $(QEMU_PROGW)
159 $(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG)," GEN $(TARGET_DIR)$(QEMU_PROG)")
160else
Paolo Bonzini8a090702012-12-20 15:40:20 +0100161$(QEMU_PROG): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
Lluíse03b41d2011-08-31 20:30:30 +0200162 $(call LINK,$^)
Stefan Weil0fa54912011-12-22 11:18:53 +0100163endif
Juan Quintela16394482009-07-16 18:34:04 +0200164
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000165gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
166 $(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 +0000167
Luiz Capitulinoacd0a092010-09-30 16:00:22 -0300168hmp-commands.h: $(SRC_PATH)/hmp-commands.hx
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000169 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
Blue Swirl23130862009-06-06 08:22:04 +0000170
Anthony Liguorie3193602011-09-02 12:34:47 -0500171qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000172 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
blueswir15824d652009-03-28 06:44:27 +0000173
bellard626df762003-08-10 21:39:31 +0000174clean:
Peter Maydellb54fa7d2012-06-20 18:02:33 +0100175 rm -f *.a *~ $(PROGS)
176 rm -f $(shell find . -name '*.[od]')
Anthony Liguorie3193602011-09-02 12:34:47 -0500177 rm -f hmp-commands.h qmp-commands-old.h gdbstub-xml.c
Lluís6d8a7642011-08-31 20:30:43 +0200178ifdef CONFIG_TRACE_SYSTEMTAP
Daniel P. Berrangec276b172010-11-12 13:20:25 +0000179 rm -f *.stp
180endif
bellard1e43adf2003-09-30 20:54:24 +0000181
ths5fafdf22007-09-16 21:08:06 +0000182install: all
bellard9b14bb02004-03-26 22:43:34 +0000183ifneq ($(PROGS),)
Hollis Blanchard52ba7842010-08-04 17:21:34 -0700184 $(INSTALL) -m 755 $(PROGS) "$(DESTDIR)$(bindir)"
185ifneq ($(STRIP),)
186 $(STRIP) $(patsubst %,"$(DESTDIR)$(bindir)/%",$(PROGS))
187endif
bellard9b14bb02004-03-26 22:43:34 +0000188endif
Lluís6d8a7642011-08-31 20:30:43 +0200189ifdef CONFIG_TRACE_SYSTEMTAP
Eduardo Habkost6aae2a22012-04-18 16:55:41 -0300190 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset"
Alon Levyc14518e2013-06-14 15:19:07 +0100191 $(INSTALL_DATA) $(QEMU_PROG).stp-installed "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG).stp"
Daniel P. Berrangec276b172010-11-12 13:20:25 +0000192endif
bellard626df762003-08-10 21:39:31 +0000193
Paolo Bonzini41158522012-05-29 12:41:34 +0200194GENERATED_HEADERS += config-target.h
195Makefile: $(GENERATED_HEADERS)