blob: bdff4e468462a2908b358966fd8db48a0141b732 [file] [log] [blame]
pbrook0cb3fb12006-05-14 12:07:53 +00001# Makefile for QEMU.
2
Stefan Weil519e1692011-09-16 21:50:43 +02003# Always point to the root of the build tree (needs GNU make).
4BUILD_DIR=$(CURDIR)
Lluís Vilanova388d4752011-09-15 22:45:35 +02005
Lluís Vilanova250b0862012-03-06 19:50:38 +01006# All following code might depend on configuration variables
aurel3255d7e8f2009-04-15 14:42:57 +00007ifneq ($(wildcard config-host.mak),)
Paul Brook1ad21342009-05-19 16:17:58 +01008# Put the all: rule here so that config-host.mak can contain dependencies.
Stefan Weil8f67aa82012-07-09 20:36:36 +02009all:
pbrookad064842006-04-16 12:41:07 +000010include config-host.mak
Peter Maydelld1bd2422012-10-19 14:54:23 +010011
12# Check that we're not trying to do an out-of-tree build from
13# a tree that's been used for an in-tree build.
14ifneq ($(realpath $(SRC_PATH)),$(realpath .))
15ifneq ($(wildcard $(SRC_PATH)/config-host.mak),)
16$(error This is an out of tree build but your source tree ($(SRC_PATH)) \
17seems to have been used for an in-tree build. You can fix this by running \
18"make distclean && rm -rf *-linux-user *-softmmu" in your source tree)
19endif
20endif
21
Paolo Bonzinif3aa8442013-04-16 10:50:38 +020022CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
23CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
24CONFIG_ALL=y
25-include config-all-devices.mak
26-include config-all-disas.mak
27
aliguori17759182009-01-21 18:12:52 +000028include $(SRC_PATH)/rules.mak
Paolo Bonzini59bc10e2010-01-04 11:02:28 +010029config-host.mak: $(SRC_PATH)/configure
Juan Quintelae5efe7f2009-10-07 02:40:59 +020030 @echo $@ is out-of-date, running configure
Stefan Weilbdf523e2013-10-20 18:39:21 +020031 @# TODO: The next lines include code which supports a smooth
32 @# transition from old configurations without config.status.
33 @# This code can be removed after QEMU 1.7.
34 @if test -x config.status; then \
35 ./config.status; \
36 else \
37 sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh; \
38 fi
aurel3255d7e8f2009-04-15 14:42:57 +000039else
40config-host.mak:
Mike Frysinger7748b8c2012-09-16 16:07:13 -040041ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
aurel3255d7e8f2009-04-15 14:42:57 +000042 @echo "Please call configure before running make!"
43 @exit 1
44endif
Mike Frysinger7748b8c2012-09-16 16:07:13 -040045endif
bellard766a4872003-02-18 23:35:48 +000046
Lluís Vilanovaeac236e2012-12-14 20:13:09 +010047GENERATED_HEADERS = config-host.h qemu-options.def
Lluís Vilanova250b0862012-03-06 19:50:38 +010048GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h
Lluís Vilanovaeac236e2012-12-14 20:13:09 +010049GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c
50
Lluís Vilanova45be2f52013-03-05 14:47:32 +010051GENERATED_HEADERS += trace/generated-events.h
52GENERATED_SOURCES += trace/generated-events.c
53
Lluís Vilanovaeac236e2012-12-14 20:13:09 +010054GENERATED_HEADERS += trace/generated-tracers.h
55ifeq ($(TRACE_BACKEND),dtrace)
56GENERATED_HEADERS += trace/generated-tracers-dtrace.h
57endif
58GENERATED_SOURCES += trace/generated-tracers.c
Lluís Vilanova250b0862012-03-06 19:50:38 +010059
Juan Quintelad9ace8b2009-10-06 21:11:15 +020060# Don't try to regenerate Makefile or configure
61# We don't generate any of them
62Makefile: ;
63configure: ;
64
aliguori818220f2008-09-24 01:13:40 +000065.PHONY: all clean cscope distclean dvi html info install install-doc \
Anthony Liguori34bb4432012-07-17 13:33:32 -050066 pdf recurse-all speed test dist
pbrook0cb3fb12006-05-14 12:07:53 +000067
Paolo Bonzinifec90ff2012-05-29 11:49:50 +020068$(call set-vpath, $(SRC_PATH))
pbrook8c462f82007-11-18 21:12:37 +000069
Juan Quintela3e2e0e62009-08-03 14:47:06 +020070LIBS+=-lz $(LIBS_TOOLS)
Juan Quintela67c0f082009-07-27 16:12:51 +020071
Corey Bryant7b93fad2012-01-26 09:42:24 -050072HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF)
73
pbrookcc8ae6d2006-04-23 17:57:59 +000074ifdef BUILD_DOCS
Luiz Capitulinod076a2a2013-09-10 16:56:14 -040075DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8 qmp-commands.txt
Meador Inge983eef52012-02-24 14:00:42 +053076ifdef CONFIG_VIRTFS
M. Mohan Kumara2d8f1b2011-12-14 13:58:47 +053077DOCS+=fsdev/virtfs-proxy-helper.1
Meador Inge983eef52012-02-24 14:00:42 +053078endif
pbrookcc8ae6d2006-04-23 17:57:59 +000079else
80DOCS=
81endif
bellard7d132992003-03-06 23:23:54 +000082
Lluís Vilanova388d4752011-09-15 22:45:35 +020083SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory) BUILD_DIR=$(BUILD_DIR)
Juan Quintela1f3d3c82009-10-07 02:41:02 +020084SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(TARGET_DIRS))
Andreas Färber88070802013-02-21 16:26:46 +010085SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %-config-devices.mak.d, $(TARGET_DIRS))
Juan Quintela1f3d3c82009-10-07 02:41:02 +020086
Stefan Weil8bdd3d42012-09-14 19:02:30 +020087ifeq ($(SUBDIR_DEVICES_MAK),)
88config-all-devices.mak:
89 $(call quiet-command,echo '# no devices' > $@," GEN $@")
90else
Juan Quintela1f3d3c82009-10-07 02:41:02 +020091config-all-devices.mak: $(SUBDIR_DEVICES_MAK)
Paolo Bonzinibb585a72013-04-03 17:53:21 +020092 $(call quiet-command, sed -n \
93 's|^\([^=]*\)=\(.*\)$$|\1:=$$(findstring y,$$(\1)\2)|p' \
94 $(SUBDIR_DEVICES_MAK) | sort -u > $@, \
95 " GEN $@")
Stefan Weil8bdd3d42012-09-14 19:02:30 +020096endif
Juan Quintela1f3d3c82009-10-07 02:41:02 +020097
Paul Brookbd9141b2010-11-26 18:47:45 +000098-include $(SUBDIR_DEVICES_MAK_DEP)
99
Paul Brooka992fe32009-11-22 16:25:30 +0000100%/config-devices.mak: default-configs/%.mak
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000101 $(call quiet-command,$(SHELL) $(SRC_PATH)/scripts/make_device_config.sh $@ $<, " GEN $@")
Stefan Weil012f0872009-12-20 15:39:03 +0100102 @if test -f $@; then \
Blue Swirl904fe1f2010-10-02 14:28:08 +0000103 if cmp -s $@.old $@; then \
Paul Brookbd9141b2010-11-26 18:47:45 +0000104 mv $@.tmp $@; \
105 cp -p $@ $@.old; \
Stefan Weil012f0872009-12-20 15:39:03 +0100106 else \
107 if test -f $@.old; then \
108 echo "WARNING: $@ (user modified) out of date.";\
109 else \
110 echo "WARNING: $@ out of date.";\
111 fi; \
112 echo "Run \"make defconfig\" to regenerate."; \
113 rm $@.tmp; \
114 fi; \
Paul Brooka992fe32009-11-22 16:25:30 +0000115 else \
Stefan Weil012f0872009-12-20 15:39:03 +0100116 mv $@.tmp $@; \
117 cp -p $@ $@.old; \
Paul Brooka992fe32009-11-22 16:25:30 +0000118 fi
119
120defconfig:
121 rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
122
Paolo Bonzini992aeb82012-12-21 08:34:49 +0100123ifneq ($(wildcard config-host.mak),)
124include $(SRC_PATH)/Makefile.objs
125include $(SRC_PATH)/tests/Makefile
126endif
127ifeq ($(CONFIG_SMARTCARD_NSS),y)
128include $(SRC_PATH)/libcacard/Makefile
129endif
130
Stefan Weil8f67aa82012-07-09 20:36:36 +0200131all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all
pbrookb9dea4f2006-05-13 16:54:03 +0000132
Juan Quintela1215c6e2009-10-07 02:40:58 +0200133config-host.h: config-host.h-timestamp
134config-host.h-timestamp: config-host.mak
Blue Swirle14056a2010-11-01 18:09:38 +0000135qemu-options.def: $(SRC_PATH)/qemu-options.hx
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000136 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $@")
Juan Quintela1215c6e2009-10-07 02:40:58 +0200137
pbrookcec7d0b2008-05-28 16:44:57 +0000138SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
Andreas Färber916359f2013-02-21 16:26:47 +0100139SOFTMMU_SUBDIR_RULES=$(filter %-softmmu,$(SUBDIR_RULES))
140
141$(SOFTMMU_SUBDIR_RULES): config-all-devices.mak
pbrookcec7d0b2008-05-28 16:44:57 +0000142
Paolo Bonzini41158522012-05-29 12:41:34 +0200143subdir-%:
Paul Brook00873752009-05-07 02:00:31 +0100144 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,)
pbrook4aa42532006-05-13 13:55:08 +0000145
Gerd Hoffmanne2134eb2012-09-25 16:04:58 +0200146subdir-pixman: pixman/Makefile
147 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pixman V="$(V)" all,)
148
149pixman/Makefile: $(SRC_PATH)/pixman/configure
Gerd Hoffmannf9943cd2013-01-04 10:15:53 +0100150 (cd pixman; CFLAGS="$(CFLAGS) -fPIC $(extra_cflags) $(extra_ldflags)" $(SRC_PATH)/pixman/configure $(AUTOCONF_HOST) --disable-gtk --disable-shared --enable-static)
Gerd Hoffmanne2134eb2012-09-25 16:04:58 +0200151
152$(SRC_PATH)/pixman/configure:
153 (cd $(SRC_PATH)/pixman; autoreconf -v --install)
154
Peter Crosthwaitea540f152013-04-18 14:47:31 +1000155DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_srcdir=$(SRC_PATH)/dtc/libfdt
Peter Maydell965f4862013-06-21 14:00:17 +0100156DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
157DTC_CPPFLAGS=-I$(BUILD_DIR)/dtc -I$(SRC_PATH)/dtc -I$(SRC_PATH)/dtc/libfdt
Peter Crosthwaitea540f152013-04-18 14:47:31 +1000158
159subdir-dtc:dtc/libfdt dtc/tests
Peter Maydell965f4862013-06-21 14:00:17 +0100160 $(call quiet-command,$(MAKE) $(DTC_MAKE_ARGS) CPPFLAGS="$(DTC_CPPFLAGS)" CFLAGS="$(DTC_CFLAGS)" LDFLAGS="$(LDFLAGS)" ARFLAGS="$(ARFLAGS)" CC="$(CC)" AR="$(AR)" LD="$(LD)" $(SUBDIR_MAKEFLAGS) libfdt/libfdt.a,)
Peter Crosthwaitea540f152013-04-18 14:47:31 +1000161
162dtc/%:
163 mkdir -p $@
164
Paolo Bonzini82cb6b02013-01-19 11:06:48 +0100165$(SUBDIR_RULES): libqemuutil.a libqemustub.a $(common-obj-y)
Blue Swirladd16152009-09-27 16:26:02 +0000166
Paul Brookc05ac892009-07-31 13:18:32 +0100167ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
168romsubdir-%:
169 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pc-bios/$* V="$(V)" TARGET_DIR="$*/",)
170
171ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
172
173recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
bellard83f64092006-08-01 16:21:11 +0000174
Juan Quintelaa558ee12009-08-03 14:46:21 +0200175bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
bellard4fb240a2007-11-07 19:24:02 +0000176
Stefan Weil0b516ef2013-08-08 20:18:07 +0200177$(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc $(BUILD_DIR)/config-host.h | $(BUILD_DIR)/version.lo
Stefan Weil7e75e332013-08-16 21:51:53 +0200178 $(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<," RC version.o")
Stefan Weil0b516ef2013-08-08 20:18:07 +0200179$(BUILD_DIR)/version.lo: $(SRC_PATH)/version.rc $(BUILD_DIR)/config-host.h
Stefan Weil7e75e332013-08-16 21:51:53 +0200180 $(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<," RC version.lo")
Marc-André Lureau5354e4d2013-02-25 23:31:13 +0100181
Paolo Bonzinifba90ac2013-05-01 18:30:15 +0200182Makefile: $(version-obj-y) $(version-lobj-y)
Paolo Bonzini3bc2f572012-11-16 18:35:27 +0100183
184######################################################################
Paolo Bonzini8a090702012-12-20 15:40:20 +0100185# Build libraries
Paolo Bonzini3bc2f572012-11-16 18:35:27 +0100186
187libqemustub.a: $(stub-obj-y)
Michael Roth0b400e72013-05-10 17:46:03 -0500188libqemuutil.a: $(util-obj-y) qapi-types.o qapi-visit.o
Paolo Bonzini3bc2f572012-11-16 18:35:27 +0100189
bellard4fb240a2007-11-07 19:24:02 +0000190######################################################################
191
Juan Quintela3c089e12010-01-20 20:54:18 +0100192qemu-img.o: qemu-img-cmds.h
Stuart Brady153859b2009-06-07 00:42:17 +0100193
Paolo Bonziniff667e22012-12-21 09:45:20 +0100194qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a
195qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a
Kevin Wolf587da2c2013-06-05 14:19:41 +0200196qemu-io$(EXESUF): qemu-io.o $(block-obj-y) libqemuutil.a libqemustub.a
aliguori0a8e1ac2009-04-05 18:41:23 +0000197
Corey Bryant7b93fad2012-01-26 09:42:24 -0500198qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
199
Paolo Bonziniff667e22012-12-21 09:45:20 +0100200fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/virtio-9p-marshal.o libqemuutil.a libqemustub.a
M. Mohan Kumar17bff522011-12-14 13:58:42 +0530201fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
202
Stuart Brady153859b2009-06-07 00:42:17 +0100203qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000204 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $@")
Stuart Brady153859b2009-06-07 00:42:17 +0100205
Michael Roth957f1f92011-08-11 15:38:12 -0500206qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
Dunrong Huang54c2e502012-07-29 03:11:24 +0800207qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
Michael Roth640e5402011-07-19 14:50:44 -0500208
Avi Kivity19bf7c82011-12-28 12:26:58 +0200209gen-out-type = $(subst .,-,$(suffix $@))
Avi Kivity8d3bc512011-12-27 16:02:16 +0200210
Stefan Hajnoczi0521d372012-08-10 14:08:42 +0100211qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
212
Dunrong Huang54c2e502012-07-29 03:11:24 +0800213qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
Paolo Bonzini2870dc32012-10-24 11:26:49 +0200214$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
Dunrong Huang54c2e502012-07-29 03:11:24 +0800215 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@")
216qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\
Paolo Bonzini2870dc32012-10-24 11:26:49 +0200217$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
Dunrong Huang54c2e502012-07-29 03:11:24 +0800218 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@")
219qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\
Paolo Bonzini2870dc32012-10-24 11:26:49 +0200220$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
Dunrong Huang54c2e502012-07-29 03:11:24 +0800221 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@")
Michael Rothe3d4d252011-07-19 15:41:55 -0500222
Michael S. Tsirkin599825c2011-11-16 23:58:18 +0200223qapi-types.c qapi-types.h :\
Stefan Hajnoczi0521d372012-08-10 14:08:42 +0100224$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
Michael Roth0b400e72013-05-10 17:46:03 -0500225 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o "." -b < $<, " GEN $@")
Michael S. Tsirkin599825c2011-11-16 23:58:18 +0200226qapi-visit.c qapi-visit.h :\
Stefan Hajnoczi0521d372012-08-10 14:08:42 +0100227$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
Michael Roth0b400e72013-05-10 17:46:03 -0500228 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o "." -b < $<, " GEN $@")
Michael S. Tsirkin599825c2011-11-16 23:58:18 +0200229qmp-commands.h qmp-marshal.c :\
Stefan Hajnoczi0521d372012-08-10 14:08:42 +0100230$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
Avi Kivity8d3bc512011-12-27 16:02:16 +0200231 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -m -o "." < $<, " GEN $@")
Anthony Liguorie3193602011-09-02 12:34:47 -0500232
Dunrong Huang54c2e502012-07-29 03:11:24 +0800233QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
Paolo Bonzini41158522012-05-29 12:41:34 +0200234$(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
Michael Roth957f1f92011-08-11 15:38:12 -0500235
Paolo Bonziniff667e22012-12-21 09:45:20 +0100236qemu-ga$(EXESUF): $(qga-obj-y) libqemuutil.a libqemustub.a
Paolo Bonzini2870dc32012-10-24 11:26:49 +0200237 $(call LINK, $^)
Michael Roth48ff7a62011-07-20 15:19:37 -0500238
bellard31e31b82003-02-18 22:55:36 +0000239clean:
bellard2d80ae82003-08-11 23:01:33 +0000240# avoid old build problems by removing potentially incorrect old files
Juan Quintela25be210f2009-10-07 02:41:00 +0200241 rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
Michael S. Tsirkindf2943b2010-10-26 17:53:41 +0200242 rm -f qemu-options.def
Paolo Bonzini0c3c89d2013-01-15 09:49:37 +0100243 find . -name '*.[oda]' -type f -exec rm -f {} +
244 find . -name '*.l[oa]' -type f -exec rm -f {} +
Tomoki Sekiyamab39297a2013-08-07 11:40:18 -0400245 rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
Stefan Weil8b6bfc72013-07-25 18:24:58 +0200246 rm -f fsdev/*.pod
247 rm -rf .libs */.libs
Blue Swirl07b44ce2009-06-09 18:45:16 +0000248 rm -f qemu-img-cmds.h
Lluís Vilanova19ac36b2012-04-18 20:15:39 +0200249 @# May not be present in GENERATED_HEADERS
Lluís Vilanovaeac236e2012-12-14 20:13:09 +0100250 rm -f trace/generated-tracers-dtrace.dtrace*
251 rm -f trace/generated-tracers-dtrace.h*
Lluís Vilanova19ac36b2012-04-18 20:15:39 +0200252 rm -f $(foreach f,$(GENERATED_HEADERS),$(f) $(f)-timestamp)
253 rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp)
Stefan Weil8f0e5c6bb2012-06-09 09:08:39 +0200254 rm -rf qapi-generated
Dunrong Huang54c2e502012-07-29 03:11:24 +0800255 rm -rf qga/qapi-generated
Stefan Hajnoczi781c0c32013-01-15 08:47:26 +0100256 for d in $(ALL_SUBDIRS); do \
Magnus Dammfc8e3202009-11-13 18:51:05 +0900257 if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
Michael S. Tsirkindf2943b2010-10-26 17:53:41 +0200258 rm -f $$d/qemu-options.def; \
bellard626df762003-08-10 21:39:31 +0000259 done
bellard31e31b82003-02-18 22:55:36 +0000260
Anthony Liguori34bb4432012-07-17 13:33:32 -0500261VERSION ?= $(shell cat VERSION)
262
263dist: qemu-$(VERSION).tar.bz2
264
265qemu-%.tar.bz2:
266 $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
267
bellard7d132992003-03-06 23:23:54 +0000268distclean: clean
Magnus Dammfc8e3202009-11-13 18:51:05 +0900269 rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi
Paolo Bonzini76cad712012-10-24 11:12:21 +0200270 rm -f config-all-devices.mak config-all-disas.mak
Stefan Weil8b6bfc72013-07-25 18:24:58 +0200271 rm -f po/*.mo
Magnus Dammfc8e3202009-11-13 18:51:05 +0900272 rm -f roms/seabios/config.mak roms/vgabios/config.mak
Brad Hards7a734b82011-04-13 16:42:16 +1000273 rm -f qemu-doc.info qemu-doc.aux qemu-doc.cp qemu-doc.cps qemu-doc.dvi
274 rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys
275 rm -f qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp
276 rm -f qemu-doc.vr
Alexandre Raymond793553a2011-07-25 23:56:02 -0400277 rm -f config.log
Peter Maydell67ed96f2012-02-01 18:50:42 +0000278 rm -f linux-headers/asm
Hidetoshi Setoe1a068b2010-07-08 14:26:18 +0900279 rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi qemu-tech.fn qemu-tech.info qemu-tech.ky qemu-tech.log qemu-tech.pdf qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr
Paolo Bonzini8e98e2e2012-10-24 11:16:01 +0200280 for d in $(TARGET_DIRS); do \
bellardbc1b0502003-10-28 00:12:52 +0000281 rm -rf $$d || exit 1 ; \
bellard76bc6832003-08-10 23:41:46 +0000282 done
Tomoki Sekiyamad9840e22013-08-07 11:40:03 -0400283 rm -Rf .sdk
Wenchao Xiaa85903f2012-11-24 17:27:18 +0800284 if test -f pixman/config.log; then make -C pixman distclean; fi
Peter Crosthwaitea540f152013-04-18 14:47:31 +1000285 if test -f dtc/version_gen.h; then make $(DTC_MAKE_ARGS) clean; fi
bellard7d132992003-03-06 23:23:54 +0000286
bellardfed4a9a2004-12-12 22:18:34 +0000287KEYMAPS=da en-gb et fr fr-ch is lt modifiers no pt-br sv \
288ar de en-us fi fr-be hr it lv nl pl ru th \
Frédéric Boiteux471fbf42012-06-08 20:06:25 +0200289common de-ch es fo fr-ca hu ja mk nl-be pt sl tr \
Jan Krupa3751e722013-10-16 14:40:04 +0200290bepo cz
bellardfed4a9a2004-12-12 22:18:34 +0000291
ths77755342008-11-27 15:45:16 +0000292ifdef INSTALL_BLOBS
Paolo Bonzini63298662011-11-03 15:14:00 +0100293BLOBS=bios.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
Gerd Hoffmann7943a2f2010-11-30 11:54:33 +0100294vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin \
Laszlo Ersek7e973bb2013-01-08 19:52:20 +0100295acpi-dsdt.aml q35-acpi-dsdt.aml \
Mark Cave-Aylandda87dd72013-11-02 16:03:50 +0000296ppc_rom.bin openbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin \
Alex Williamson5ee8ad72011-04-18 11:46:01 -0600297pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
298pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
Sander Eikelenboom9fd02972013-04-08 23:08:13 +0200299efi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
300efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
Anthony Liguorif7da9c12013-06-07 13:24:17 -0500301qemu-icon.bmp qemu_logo_no_text.svg \
Michal Simek00914b72011-03-14 11:29:19 +0100302bamboo.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
Jan Kiszka2a2af962012-02-17 18:31:18 +0100303multiboot.bin linuxboot.bin kvmvapic.bin \
David Gibson39ac8452011-04-01 15:15:23 +1100304s390-zipl.rom \
Alexander Graf0c1fecdd2013-04-22 21:10:50 +0200305s390-ccw.img \
Richard Henderson753d11f2011-06-24 11:58:37 -0700306spapr-rtas.bin slof.bin \
307palcode-clipper
ths77755342008-11-27 15:45:16 +0000308else
309BLOBS=
310endif
311
pbrook38954dc2006-04-30 23:54:18 +0000312install-doc: $(DOCS)
Eduardo Habkostd7dd65b2012-04-18 16:55:44 -0300313 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
314 $(INSTALL_DATA) qemu-doc.html qemu-tech.html "$(DESTDIR)$(qemu_docdir)"
Luiz Capitulinod076a2a2013-09-10 16:56:14 -0400315 $(INSTALL_DATA) qmp-commands.txt "$(DESTDIR)$(qemu_docdir)"
Juan Quintela96d409e2009-08-03 14:47:00 +0200316ifdef CONFIG_POSIX
aliguori58f8aea2009-04-18 15:36:02 +0000317 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
Andreas Färber8a3e8f72013-06-11 13:13:58 +0200318 $(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1"
319ifneq ($(TOOLS),)
320 $(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1"
aliguori58f8aea2009-04-18 15:36:02 +0000321 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
322 $(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
pbrook38954dc2006-04-30 23:54:18 +0000323endif
Andreas Färber8a3e8f72013-06-11 13:13:58 +0200324endif
M. Mohan Kumara2d8f1b2011-12-14 13:58:47 +0530325ifdef CONFIG_VIRTFS
326 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
327 $(INSTALL_DATA) fsdev/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
328endif
john cooperb5ec5ce2010-02-20 11:14:59 -0600329
Eduardo Habkoste2d87bf2012-05-02 13:07:30 -0300330install-datadir:
331 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
332
Laszlo Ersekf2e39782013-05-18 07:13:14 +0200333install-localstatedir:
334ifdef CONFIG_POSIX
335ifneq (,$(findstring qemu-ga,$(TOOLS)))
336 $(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
337endif
338endif
339
Eduardo Habkoste2d87bf2012-05-02 13:07:30 -0300340install-confdir:
341 $(INSTALL_DIR) "$(DESTDIR)$(qemu_confdir)"
342
343install-sysconfig: install-datadir install-confdir
344 $(INSTALL_DATA) $(SRC_PATH)/sysconfigs/target/target-x86_64.conf "$(DESTDIR)$(qemu_confdir)"
Eduardo Habkoste2d87bf2012-05-02 13:07:30 -0300345
Laszlo Ersekf2e39782013-05-18 07:13:14 +0200346install: all $(if $(BUILD_DOCS),install-doc) install-sysconfig \
347install-datadir install-localstatedir
aliguori58f8aea2009-04-18 15:36:02 +0000348 $(INSTALL_DIR) "$(DESTDIR)$(bindir)"
ths932a79d2007-10-20 18:29:34 +0000349ifneq ($(TOOLS),)
aliguori58f8aea2009-04-18 15:36:02 +0000350 $(INSTALL_PROG) $(STRIP_OPT) $(TOOLS) "$(DESTDIR)$(bindir)"
ths932a79d2007-10-20 18:29:34 +0000351endif
Corey Bryant7b93fad2012-01-26 09:42:24 -0500352ifneq ($(HELPERS-y),)
353 $(INSTALL_DIR) "$(DESTDIR)$(libexecdir)"
354 $(INSTALL_PROG) $(STRIP_OPT) $(HELPERS-y) "$(DESTDIR)$(libexecdir)"
355endif
ths77755342008-11-27 15:45:16 +0000356ifneq ($(BLOBS),)
ths77755342008-11-27 15:45:16 +0000357 set -e; for x in $(BLOBS); do \
Eduardo Habkost6aae2a22012-04-18 16:55:41 -0300358 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
pbrookad064842006-04-16 12:41:07 +0000359 done
ths77755342008-11-27 15:45:16 +0000360endif
Anthony Liguori834574e2013-02-20 07:43:24 -0600361ifeq ($(CONFIG_GTK),y)
362 $(MAKE) -C po $@
363endif
Eduardo Habkost6aae2a22012-04-18 16:55:41 -0300364 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
blueswir118be8d72008-03-05 18:16:09 +0000365 set -e; for x in $(KEYMAPS); do \
Eduardo Habkost6aae2a22012-04-18 16:55:41 -0300366 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
pbrookad064842006-04-16 12:41:07 +0000367 done
bellard626df762003-08-10 21:39:31 +0000368 for d in $(TARGET_DIRS); do \
bellard7d3505c2004-05-12 19:32:15 +0000369 $(MAKE) -C $$d $@ || exit 1 ; \
bellard626df762003-08-10 21:39:31 +0000370 done
bellard612384d2003-03-22 17:31:19 +0000371
bellard367e86e2003-03-01 17:13:26 +0000372# various test targets
bellard9b0b8202007-11-14 10:34:57 +0000373test speed: all
Anthony Liguoric09015d2012-01-10 13:10:42 -0600374 $(MAKE) -C tests/tcg $@
bellard31e31b82003-02-18 22:55:36 +0000375
Alexandre Bique21d4e8e2009-08-07 15:43:11 +0100376.PHONY: TAGS
ths5fafdf22007-09-16 21:08:06 +0000377TAGS:
David Gibsonb1999e82013-03-12 13:57:28 +1100378 rm -f $@
379 find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} +
bellard31e31b82003-02-18 22:55:36 +0000380
bellard6688bc62005-08-21 09:23:39 +0000381cscope:
382 rm -f ./cscope.*
Alexandre Raymond45b75ae2011-07-20 23:12:15 -0400383 find "$(SRC_PATH)" -name "*.[chsS]" -print | sed 's,^\./,,' > ./cscope.files
bellard6688bc62005-08-21 09:23:39 +0000384 cscope -b
385
bellard3ef693a2003-03-23 20:17:16 +0000386# documentation
Stefan Weil01668d92010-03-04 22:21:02 +0100387MAKEINFO=makeinfo
388MAKEINFOFLAGS=--no-headers --no-split --number-sections
Stefan Weil20cc9992010-01-29 23:16:50 +0100389TEXIFLAG=$(if $(V),,--quiet)
390%.dvi: %.texi
391 $(call quiet-command,texi2dvi $(TEXIFLAG) -I . $<," GEN $@")
392
bellard1f673132004-04-04 15:21:17 +0000393%.html: %.texi
Stefan Weil952ef672012-03-27 19:15:27 +0200394 $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --html $< -o $@, \
Stefan Weil01668d92010-03-04 22:21:02 +0100395 " GEN $@")
bellard3ef693a2003-03-23 20:17:16 +0000396
bellardf3548322006-04-30 22:51:54 +0000397%.info: %.texi
Stefan Weil01668d92010-03-04 22:21:02 +0100398 $(call quiet-command,$(MAKEINFO) $< -o $@," GEN $@")
bellardf3548322006-04-30 22:51:54 +0000399
Stefan Weil20cc9992010-01-29 23:16:50 +0100400%.pdf: %.texi
401 $(call quiet-command,texi2pdf $(TEXIFLAG) -I . $<," GEN $@")
blueswir15824d652009-03-28 06:44:27 +0000402
403qemu-options.texi: $(SRC_PATH)/qemu-options.hx
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000404 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@," GEN $@")
bellardf3548322006-04-30 22:51:54 +0000405
Luiz Capitulinoacd0a092010-09-30 16:00:22 -0300406qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000407 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@," GEN $@")
Blue Swirl23130862009-06-06 08:22:04 +0000408
Luiz Capitulinod076a2a2013-09-10 16:56:14 -0400409qmp-commands.txt: $(SRC_PATH)/qmp-commands.hx
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000410 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -q < $< > $@," GEN $@")
Jan Kiszkab40292e2010-05-31 14:43:31 -0300411
Stuart Brady153859b2009-06-07 00:42:17 +0100412qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000413 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@," GEN $@")
Stuart Brady153859b2009-06-07 00:42:17 +0100414
Blue Swirl23130862009-06-06 08:22:04 +0000415qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi
aliguori0d00e562009-04-05 17:40:46 +0000416 $(call quiet-command, \
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000417 perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu.pod && \
Michael Tokarev3179d692012-03-20 02:25:57 +0400418 $(POD2MAN) --section=1 --center=" " --release=" " qemu.pod > $@, \
aliguori0d00e562009-04-05 17:40:46 +0000419 " GEN $@")
bellard5a671352003-10-01 00:13:48 +0000420
Stuart Brady153859b2009-06-07 00:42:17 +0100421qemu-img.1: qemu-img.texi qemu-img-cmds.texi
aliguori0d00e562009-04-05 17:40:46 +0000422 $(call quiet-command, \
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000423 perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-img.pod && \
Michael Tokarev3179d692012-03-20 02:25:57 +0400424 $(POD2MAN) --section=1 --center=" " --release=" " qemu-img.pod > $@, \
aliguori0d00e562009-04-05 17:40:46 +0000425 " GEN $@")
bellardacd935e2004-11-15 22:57:26 +0000426
M. Mohan Kumara2d8f1b2011-12-14 13:58:47 +0530427fsdev/virtfs-proxy-helper.1: fsdev/virtfs-proxy-helper.texi
428 $(call quiet-command, \
429 perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< fsdev/virtfs-proxy-helper.pod && \
Michael Tokarev3179d692012-03-20 02:25:57 +0400430 $(POD2MAN) --section=1 --center=" " --release=" " fsdev/virtfs-proxy-helper.pod > $@, \
M. Mohan Kumara2d8f1b2011-12-14 13:58:47 +0530431 " GEN $@")
432
bellard7a5ca862008-05-27 21:13:40 +0000433qemu-nbd.8: qemu-nbd.texi
aliguori0d00e562009-04-05 17:40:46 +0000434 $(call quiet-command, \
Blue Swirl4c3b5a42011-01-20 20:54:21 +0000435 perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-nbd.pod && \
Michael Tokarev3179d692012-03-20 02:25:57 +0400436 $(POD2MAN) --section=8 --center=" " --release=" " qemu-nbd.pod > $@, \
aliguori0d00e562009-04-05 17:40:46 +0000437 " GEN $@")
bellard7a5ca862008-05-27 21:13:40 +0000438
pbrook0cb3fb12006-05-14 12:07:53 +0000439dvi: qemu-doc.dvi qemu-tech.dvi
pbrook0cb3fb12006-05-14 12:07:53 +0000440html: qemu-doc.html qemu-tech.html
Stefan Weil20cc9992010-01-29 23:16:50 +0100441info: qemu-doc.info qemu-tech.info
442pdf: qemu-doc.pdf qemu-tech.pdf
pbrook0cb3fb12006-05-14 12:07:53 +0000443
Stefan Weil20cc9992010-01-29 23:16:50 +0100444qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \
445 qemu-img.texi qemu-nbd.texi qemu-options.texi \
446 qemu-monitor.texi qemu-img-cmds.texi
aliguori818220f2008-09-24 01:13:40 +0000447
Stefan Weilf53ec692013-07-15 23:49:57 +0200448ifdef CONFIG_WIN32
449
450INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
451
452nsisflags = -V2 -NOCD
453
454ifneq ($(wildcard $(SRC_PATH)/dll),)
455ifeq ($(ARCH),x86_64)
456# 64 bit executables
457DLL_PATH = $(SRC_PATH)/dll/w64
458nsisflags += -DW64
459else
460# 32 bit executables
461DLL_PATH = $(SRC_PATH)/dll/w32
462endif
463endif
464
465.PHONY: installer
466installer: $(INSTALLER)
467
468INSTDIR=/tmp/qemu-nsis
469
470$(INSTALLER): $(SRC_PATH)/qemu.nsi
471 make install prefix=${INSTDIR}
472ifdef SIGNCODE
473 (cd ${INSTDIR}; \
474 for i in *.exe; do \
475 $(SIGNCODE) $${i}; \
476 done \
477 )
478endif # SIGNCODE
479 (cd ${INSTDIR}; \
480 for i in qemu-system-*.exe; do \
481 arch=$${i%.exe}; \
482 arch=$${arch#qemu-system-}; \
483 echo Section \"$$arch\" Section_$$arch; \
484 echo SetOutPath \"\$$INSTDIR\"; \
485 echo File \"\$${BINDIR}\\$$i\"; \
486 echo SectionEnd; \
487 done \
488 ) >${INSTDIR}/system-emulations.nsh
489 makensis $(nsisflags) \
490 $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
491 $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
492 -DBINDIR="${INSTDIR}" \
493 $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
494 -DSRCDIR="$(SRC_PATH)" \
495 -DOUTFILE="$(INSTALLER)" \
496 $(SRC_PATH)/qemu.nsi
497 rm -r ${INSTDIR}
498ifdef SIGNCODE
499 $(SIGNCODE) $(INSTALLER)
500endif # SIGNCODE
501endif # CONFIG_WIN
502
Anthony Liguoricb5fc672012-07-17 18:58:20 -0500503# Add a dependency on the generated files, so that they are always
504# rebuilt before other object files
Mike Frysinger7748b8c2012-09-16 16:07:13 -0400505ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
Anthony Liguoricb5fc672012-07-17 18:58:20 -0500506Makefile: $(GENERATED_HEADERS)
Mike Frysinger7748b8c2012-09-16 16:07:13 -0400507endif
Anthony Liguoricb5fc672012-07-17 18:58:20 -0500508
bellard4fb240a2007-11-07 19:24:02 +0000509# Include automatically generated dependency files
Paolo Bonzini1435ddb2012-07-11 16:40:21 +0200510# Dependencies in Makefile.objs files come from our recursive subdir rules
511-include $(wildcard *.d tests/*.d)