xref: /openbmc/qemu/Makefile (revision cc475698)
10cb3fb1eSpbrook# Makefile for QEMU.
20cb3fb1eSpbrook
3519e1693SStefan Weil# Always point to the root of the build tree (needs GNU make).
4519e1693SStefan WeilBUILD_DIR=$(CURDIR)
5388d4758SLluís Vilanova
6250b086eSLluís Vilanova# All following code might depend on configuration variables
755d7e8f6Saurel32ifneq ($(wildcard config-host.mak),)
81ad2134fSPaul Brook# Put the all: rule here so that config-host.mak can contain dependencies.
98f67aa82SStefan Weilall:
10ad064840Spbrookinclude config-host.mak
11d1bd2423SPeter Maydell
12d1bd2423SPeter Maydell# Check that we're not trying to do an out-of-tree build from
13d1bd2423SPeter Maydell# a tree that's been used for an in-tree build.
14d1bd2423SPeter Maydellifneq ($(realpath $(SRC_PATH)),$(realpath .))
15d1bd2423SPeter Maydellifneq ($(wildcard $(SRC_PATH)/config-host.mak),)
16d1bd2423SPeter Maydell$(error This is an out of tree build but your source tree ($(SRC_PATH)) \
17d1bd2423SPeter Maydellseems to have been used for an in-tree build. You can fix this by running \
18d1bd2423SPeter Maydell"make distclean && rm -rf *-linux-user *-softmmu" in your source tree)
19d1bd2423SPeter Maydellendif
20d1bd2423SPeter Maydellendif
21d1bd2423SPeter Maydell
22f3aa844bSPaolo BonziniCONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
23f3aa844bSPaolo BonziniCONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
24f3aa844bSPaolo BonziniCONFIG_ALL=y
25f3aa844bSPaolo Bonzini-include config-all-devices.mak
26f3aa844bSPaolo Bonzini-include config-all-disas.mak
27f3aa844bSPaolo Bonzini
2817759187Saliguoriinclude $(SRC_PATH)/rules.mak
2959bc10eeSPaolo Bonziniconfig-host.mak: $(SRC_PATH)/configure
30e5efe7f5SJuan Quintela	@echo $@ is out-of-date, running configure
31bdf523e6SStefan Weil	@# TODO: The next lines include code which supports a smooth
32bdf523e6SStefan Weil	@# transition from old configurations without config.status.
33bdf523e6SStefan Weil	@# This code can be removed after QEMU 1.7.
34bdf523e6SStefan Weil	@if test -x config.status; then \
35bdf523e6SStefan Weil	    ./config.status; \
36bdf523e6SStefan Weil        else \
37bdf523e6SStefan Weil	    sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh; \
38bdf523e6SStefan Weil	fi
3955d7e8f6Saurel32else
4055d7e8f6Saurel32config-host.mak:
417748b8cbSMike Frysingerifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
4255d7e8f6Saurel32	@echo "Please call configure before running make!"
4355d7e8f6Saurel32	@exit 1
4455d7e8f6Saurel32endif
457748b8cbSMike Frysingerendif
46766a487aSbellard
47eac236eaSLluís VilanovaGENERATED_HEADERS = config-host.h qemu-options.def
48250b086eSLluís VilanovaGENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h
49eac236eaSLluís VilanovaGENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c
50eac236eaSLluís Vilanova
5145be2f5dSLluís VilanovaGENERATED_HEADERS += trace/generated-events.h
5245be2f5dSLluís VilanovaGENERATED_SOURCES += trace/generated-events.c
5345be2f5dSLluís Vilanova
54eac236eaSLluís VilanovaGENERATED_HEADERS += trace/generated-tracers.h
55eac236eaSLluís Vilanovaifeq ($(TRACE_BACKEND),dtrace)
56eac236eaSLluís VilanovaGENERATED_HEADERS += trace/generated-tracers-dtrace.h
57eac236eaSLluís Vilanovaendif
58eac236eaSLluís VilanovaGENERATED_SOURCES += trace/generated-tracers.c
59250b086eSLluís Vilanova
60d9ace8b3SJuan Quintela# Don't try to regenerate Makefile or configure
61d9ace8b3SJuan Quintela# We don't generate any of them
62d9ace8b3SJuan QuintelaMakefile: ;
63d9ace8b3SJuan Quintelaconfigure: ;
64d9ace8b3SJuan Quintela
65818220f5Saliguori.PHONY: all clean cscope distclean dvi html info install install-doc \
6634bb443eSAnthony Liguori	pdf recurse-all speed test dist
670cb3fb1eSpbrook
68fec90ff0SPaolo Bonzini$(call set-vpath, $(SRC_PATH))
698c462f8fSpbrook
703e2e0e6bSJuan QuintelaLIBS+=-lz $(LIBS_TOOLS)
7167c0f08dSJuan Quintela
727b93fadfSCorey BryantHELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF)
737b93fadfSCorey Bryant
74cc8ae6deSpbrookifdef BUILD_DOCS
75d076a2adSLuiz CapitulinoDOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8 qmp-commands.txt
76983eef5aSMeador Ingeifdef CONFIG_VIRTFS
77a2d8f1beSM. Mohan KumarDOCS+=fsdev/virtfs-proxy-helper.1
78983eef5aSMeador Ingeendif
79cc8ae6deSpbrookelse
80cc8ae6deSpbrookDOCS=
81cc8ae6deSpbrookendif
827d13299dSbellard
83388d4758SLluís VilanovaSUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory) BUILD_DIR=$(BUILD_DIR)
841f3d3c8fSJuan QuintelaSUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(TARGET_DIRS))
8588070801SAndreas FärberSUBDIR_DEVICES_MAK_DEP=$(patsubst %, %-config-devices.mak.d, $(TARGET_DIRS))
861f3d3c8fSJuan Quintela
878bdd3d49SStefan Weilifeq ($(SUBDIR_DEVICES_MAK),)
888bdd3d49SStefan Weilconfig-all-devices.mak:
898bdd3d49SStefan Weil	$(call quiet-command,echo '# no devices' > $@,"  GEN   $@")
908bdd3d49SStefan Weilelse
911f3d3c8fSJuan Quintelaconfig-all-devices.mak: $(SUBDIR_DEVICES_MAK)
92bb585a78SPaolo Bonzini	$(call quiet-command, sed -n \
93bb585a78SPaolo Bonzini             's|^\([^=]*\)=\(.*\)$$|\1:=$$(findstring y,$$(\1)\2)|p' \
94bb585a78SPaolo Bonzini             $(SUBDIR_DEVICES_MAK) | sort -u > $@, \
95bb585a78SPaolo Bonzini             "  GEN   $@")
968bdd3d49SStefan Weilendif
971f3d3c8fSJuan Quintela
98bd9141bbSPaul Brook-include $(SUBDIR_DEVICES_MAK_DEP)
99bd9141bbSPaul Brook
100a992fe3dSPaul Brook%/config-devices.mak: default-configs/%.mak
1014c3b5a48SBlue Swirl	$(call quiet-command,$(SHELL) $(SRC_PATH)/scripts/make_device_config.sh $@ $<, "  GEN   $@")
102a992fe3dSPaul Brook	@if test -f $@; then \
103904fe1fbSBlue Swirl	  if cmp -s $@.old $@; then \
104012f0879SStefan Weil	    mv $@.tmp $@; \
105012f0879SStefan Weil	    cp -p $@ $@.old; \
106012f0879SStefan Weil	  else \
107012f0879SStefan Weil	    if test -f $@.old; then \
108012f0879SStefan Weil	      echo "WARNING: $@ (user modified) out of date.";\
109012f0879SStefan Weil	    else \
110a992fe3dSPaul Brook	      echo "WARNING: $@ out of date.";\
111012f0879SStefan Weil	    fi; \
11263e86b2eSStefan Weil	    echo "Run \"make defconfig\" to regenerate."; \
113a992fe3dSPaul Brook	    rm $@.tmp; \
114012f0879SStefan Weil	  fi; \
115a992fe3dSPaul Brook	 else \
116a992fe3dSPaul Brook	  mv $@.tmp $@; \
117012f0879SStefan Weil	  cp -p $@ $@.old; \
118a992fe3dSPaul Brook	 fi
119a992fe3dSPaul Brook
120a992fe3dSPaul Brookdefconfig:
121a992fe3dSPaul Brook	rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
122a992fe3dSPaul Brook
123992aeb8eSPaolo Bonziniifneq ($(wildcard config-host.mak),)
124992aeb8eSPaolo Bonziniinclude $(SRC_PATH)/Makefile.objs
125ba1183daSFam Zhengendif
126ba1183daSFam Zheng
127ba1183daSFam Zhengdummy := $(call unnest-vars,, \
128ba1183daSFam Zheng                stub-obj-y \
129ba1183daSFam Zheng                util-obj-y \
130ba1183daSFam Zheng                qga-obj-y \
131ba1183daSFam Zheng                block-obj-y \
132*cc475698SFam Zheng                block-obj-m \
133*cc475698SFam Zheng                common-obj-y \
134*cc475698SFam Zheng                common-obj-m)
135ba1183daSFam Zheng
136ba1183daSFam Zhengifneq ($(wildcard config-host.mak),)
137992aeb8eSPaolo Bonziniinclude $(SRC_PATH)/tests/Makefile
138992aeb8eSPaolo Bonziniendif
139992aeb8eSPaolo Bonziniifeq ($(CONFIG_SMARTCARD_NSS),y)
140992aeb8eSPaolo Bonziniinclude $(SRC_PATH)/libcacard/Makefile
141992aeb8eSPaolo Bonziniendif
142992aeb8eSPaolo Bonzini
14317969268SFam Zhengall: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
144b9dea4fbSpbrook
145ba1183daSFam Zhengvl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
146ba1183daSFam Zheng
147ba1183daSFam Zhengvl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
148ba1183daSFam Zheng
1491215c6e7SJuan Quintelaconfig-host.h: config-host.h-timestamp
1501215c6e7SJuan Quintelaconfig-host.h-timestamp: config-host.mak
151e14056adSBlue Swirlqemu-options.def: $(SRC_PATH)/qemu-options.hx
1524c3b5a48SBlue Swirl	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $@")
1531215c6e7SJuan Quintela
154cec7d0b6SpbrookSUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
155916359f6SAndreas FärberSOFTMMU_SUBDIR_RULES=$(filter %-softmmu,$(SUBDIR_RULES))
156916359f6SAndreas Färber
157916359f6SAndreas Färber$(SOFTMMU_SUBDIR_RULES): config-all-devices.mak
158cec7d0b6Spbrook
1594115852bSPaolo Bonzinisubdir-%:
1600087375eSPaul Brook	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,)
1614aa42531Spbrook
162e2134eb9SGerd Hoffmannsubdir-pixman: pixman/Makefile
163e2134eb9SGerd Hoffmann	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pixman V="$(V)" all,)
164e2134eb9SGerd Hoffmann
165e2134eb9SGerd Hoffmannpixman/Makefile: $(SRC_PATH)/pixman/configure
166f9943cd5SGerd Hoffmann	(cd pixman; CFLAGS="$(CFLAGS) -fPIC $(extra_cflags) $(extra_ldflags)" $(SRC_PATH)/pixman/configure $(AUTOCONF_HOST) --disable-gtk --disable-shared --enable-static)
167e2134eb9SGerd Hoffmann
168e2134eb9SGerd Hoffmann$(SRC_PATH)/pixman/configure:
169e2134eb9SGerd Hoffmann	(cd $(SRC_PATH)/pixman; autoreconf -v --install)
170e2134eb9SGerd Hoffmann
171a540f158SPeter CrosthwaiteDTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_srcdir=$(SRC_PATH)/dtc/libfdt
172965f486cSPeter MaydellDTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
173965f486cSPeter MaydellDTC_CPPFLAGS=-I$(BUILD_DIR)/dtc -I$(SRC_PATH)/dtc -I$(SRC_PATH)/dtc/libfdt
174a540f158SPeter Crosthwaite
175a540f158SPeter Crosthwaitesubdir-dtc:dtc/libfdt dtc/tests
176965f486cSPeter Maydell	$(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,)
177a540f158SPeter Crosthwaite
178a540f158SPeter Crosthwaitedtc/%:
179a540f158SPeter Crosthwaite	mkdir -p $@
180a540f158SPeter Crosthwaite
18182cb6b04SPaolo Bonzini$(SUBDIR_RULES): libqemuutil.a libqemustub.a $(common-obj-y)
182add16157SBlue Swirl
183c05ac895SPaul BrookROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
184c05ac895SPaul Brookromsubdir-%:
185c05ac895SPaul Brook	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pc-bios/$* V="$(V)" TARGET_DIR="$*/",)
186c05ac895SPaul Brook
187c05ac895SPaul BrookALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
188c05ac895SPaul Brook
189c05ac895SPaul Brookrecurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
1904aa42531Spbrook
191a558ee17SJuan Quintelabt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
1924fb240a4Sbellard
1930b516ef0SStefan Weil$(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc $(BUILD_DIR)/config-host.h | $(BUILD_DIR)/version.lo
1947e75e33eSStefan Weil	$(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"  RC    version.o")
1950b516ef0SStefan Weil$(BUILD_DIR)/version.lo: $(SRC_PATH)/version.rc $(BUILD_DIR)/config-host.h
1967e75e33eSStefan Weil	$(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"  RC    version.lo")
1975354e4d2SMarc-André Lureau
198fba90ac1SPaolo BonziniMakefile: $(version-obj-y) $(version-lobj-y)
1993bc2f570SPaolo Bonzini
2003bc2f570SPaolo Bonzini######################################################################
2018a090705SPaolo Bonzini# Build libraries
2023bc2f570SPaolo Bonzini
2033bc2f570SPaolo Bonzinilibqemustub.a: $(stub-obj-y)
2040b400e79SMichael Rothlibqemuutil.a: $(util-obj-y) qapi-types.o qapi-visit.o
2053bc2f570SPaolo Bonzini
206e26110cfSFam Zhengblock-modules = $(foreach o,$(block-obj-m),"$(basename $(subst /,-,$o))",) NULL
207e26110cfSFam Zhengutil/module.o-cflags = -D'CONFIG_BLOCK_MODULES=$(block-modules)'
208e26110cfSFam Zheng
2094fb240a4Sbellard######################################################################
2104fb240a4Sbellard
2113c089e15SJuan Quintelaqemu-img.o: qemu-img-cmds.h
212153859beSStuart Brady
213ff667e2eSPaolo Bonziniqemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a
214ff667e2eSPaolo Bonziniqemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a
215587da2c3SKevin Wolfqemu-io$(EXESUF): qemu-io.o $(block-obj-y) libqemuutil.a libqemustub.a
2160a8e1acdSaliguori
2177b93fadfSCorey Bryantqemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
2187b93fadfSCorey Bryant
219ff667e2eSPaolo Bonzinifsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/virtio-9p-marshal.o libqemuutil.a libqemustub.a
22017bff52bSM. Mohan Kumarfsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
22117bff52bSM. Mohan Kumar
222153859beSStuart Bradyqemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
2234c3b5a48SBlue Swirl	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $@")
224153859beSStuart Brady
225957f1f99SMichael Rothqemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
22654c2e502SDunrong Huangqemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
227640e5404SMichael Roth
22819bf7c87SAvi Kivitygen-out-type = $(subst .,-,$(suffix $@))
2298d3bc517SAvi Kivity
2300521d375SStefan Hajnocziqapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
2310521d375SStefan Hajnoczi
23254c2e502SDunrong Huangqga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
2332870dc34SPaolo Bonzini$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
23454c2e502SDunrong Huang	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, "  GEN   $@")
23554c2e502SDunrong Huangqga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\
2362870dc34SPaolo Bonzini$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
23754c2e502SDunrong Huang	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, "  GEN   $@")
23854c2e502SDunrong Huangqga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\
2392870dc34SPaolo Bonzini$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
24054c2e502SDunrong Huang	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, "  GEN   $@")
241e3d4d252SMichael Roth
242599825c5SMichael S. Tsirkinqapi-types.c qapi-types.h :\
2430521d375SStefan Hajnoczi$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
2440b400e79SMichael Roth	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o "." -b < $<, "  GEN   $@")
245599825c5SMichael S. Tsirkinqapi-visit.c qapi-visit.h :\
2460521d375SStefan Hajnoczi$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
2470b400e79SMichael Roth	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o "." -b < $<, "  GEN   $@")
248599825c5SMichael S. Tsirkinqmp-commands.h qmp-marshal.c :\
2490521d375SStefan Hajnoczi$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
2508d3bc517SAvi Kivity	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -m -o "." < $<, "  GEN   $@")
251e3193601SAnthony Liguori
25254c2e502SDunrong HuangQGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
2534115852bSPaolo Bonzini$(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
254957f1f99SMichael Roth
255ff667e2eSPaolo Bonziniqemu-ga$(EXESUF): $(qga-obj-y) libqemuutil.a libqemustub.a
2562870dc34SPaolo Bonzini	$(call LINK, $^)
25748ff7a62SMichael Roth
25831e31b8aSbellardclean:
2592d80ae89Sbellard# avoid old build problems by removing potentially incorrect old files
26025be210fSJuan Quintela	rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
261df2943baSMichael S. Tsirkin	rm -f qemu-options.def
2620c3c89d6SPaolo Bonzini	find . -name '*.[oda]' -type f -exec rm -f {} +
2630c3c89d6SPaolo Bonzini	find . -name '*.l[oa]' -type f -exec rm -f {} +
26417969268SFam Zheng	find . -name '*$(DSOSUF)' -type f -exec rm -f {} +
26517969268SFam Zheng	find . -name '*.mo' -type f -exec rm -f {} +
266b39297aeSTomoki Sekiyama	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
2678b6bfc77SStefan Weil	rm -f fsdev/*.pod
2688b6bfc77SStefan Weil	rm -rf .libs */.libs
26907b44ce9SBlue Swirl	rm -f qemu-img-cmds.h
27019ac36b5SLluís Vilanova	@# May not be present in GENERATED_HEADERS
271eac236eaSLluís Vilanova	rm -f trace/generated-tracers-dtrace.dtrace*
272eac236eaSLluís Vilanova	rm -f trace/generated-tracers-dtrace.h*
27319ac36b5SLluís Vilanova	rm -f $(foreach f,$(GENERATED_HEADERS),$(f) $(f)-timestamp)
27419ac36b5SLluís Vilanova	rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp)
2758f0e5c6bSStefan Weil	rm -rf qapi-generated
27654c2e502SDunrong Huang	rm -rf qga/qapi-generated
277781c0c33SStefan Hajnoczi	for d in $(ALL_SUBDIRS); do \
278fc8e320eSMagnus Damm	if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
279df2943baSMichael S. Tsirkin	rm -f $$d/qemu-options.def; \
280626df76aSbellard        done
28131e31b8aSbellard
28234bb443eSAnthony LiguoriVERSION ?= $(shell cat VERSION)
28334bb443eSAnthony Liguori
28434bb443eSAnthony Liguoridist: qemu-$(VERSION).tar.bz2
28534bb443eSAnthony Liguori
28634bb443eSAnthony Liguoriqemu-%.tar.bz2:
28734bb443eSAnthony Liguori	$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
28834bb443eSAnthony Liguori
2897d13299dSbellarddistclean: clean
290fc8e320eSMagnus Damm	rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi
29176cad711SPaolo Bonzini	rm -f config-all-devices.mak config-all-disas.mak
2928b6bfc77SStefan Weil	rm -f po/*.mo
293fc8e320eSMagnus Damm	rm -f roms/seabios/config.mak roms/vgabios/config.mak
2947a734b8fSBrad Hards	rm -f qemu-doc.info qemu-doc.aux qemu-doc.cp qemu-doc.cps qemu-doc.dvi
2957a734b8fSBrad Hards	rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys
2967a734b8fSBrad Hards	rm -f qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp
2977a734b8fSBrad Hards	rm -f qemu-doc.vr
298793553acSAlexandre Raymond	rm -f config.log
29967ed96f9SPeter Maydell	rm -f linux-headers/asm
300e1a068b2SHidetoshi Seto	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
3018e98e2e8SPaolo Bonzini	for d in $(TARGET_DIRS); do \
302bc1b050dSbellard	rm -rf $$d || exit 1 ; \
30376bc6838Sbellard        done
304d9840e25STomoki Sekiyama	rm -Rf .sdk
305a85903ffSWenchao Xia	if test -f pixman/config.log; then make -C pixman distclean; fi
306a540f158SPeter Crosthwaite	if test -f dtc/version_gen.h; then make $(DTC_MAKE_ARGS) clean; fi
3077d13299dSbellard
308fed4a9adSbellardKEYMAPS=da     en-gb  et  fr     fr-ch  is  lt  modifiers  no  pt-br  sv \
309fed4a9adSbellardar      de     en-us  fi  fr-be  hr     it  lv  nl         pl  ru     th \
310471fbf4aSFrédéric Boiteuxcommon  de-ch  es     fo  fr-ca  hu     ja  mk  nl-be      pt  sl     tr \
3113751e722SJan Krupabepo    cz
312fed4a9adSbellard
31377755340Sthsifdef INSTALL_BLOBS
314bf2eaf71SEduardo HabkostBLOBS=bios.bin bios-256k.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
3157943a2faSGerd Hoffmannvgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin \
3167e973bb2SLaszlo Ersekacpi-dsdt.aml q35-acpi-dsdt.aml \
317da87dd7bSMark Cave-Aylandppc_rom.bin openbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin \
3185ee8ad71SAlex Williamsonpxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
3195ee8ad71SAlex Williamsonpxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
3209fd02979SSander Eikelenboomefi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
3219fd02979SSander Eikelenboomefi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
322f7da9c17SAnthony Liguoriqemu-icon.bmp qemu_logo_no_text.svg \
32300914b7dSMichal Simekbamboo.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
3242a2af967SJan Kiszkamultiboot.bin linuxboot.bin kvmvapic.bin \
32539ac8455SDavid Gibsons390-zipl.rom \
3260c1fecddSAlexander Grafs390-ccw.img \
327753d11f2SRichard Hendersonspapr-rtas.bin slof.bin \
328753d11f2SRichard Hendersonpalcode-clipper
32977755340Sthselse
33077755340SthsBLOBS=
33177755340Sthsendif
33277755340Sths
33338954dcaSpbrookinstall-doc: $(DOCS)
334d7dd65baSEduardo Habkost	$(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
335d7dd65baSEduardo Habkost	$(INSTALL_DATA) qemu-doc.html  qemu-tech.html "$(DESTDIR)$(qemu_docdir)"
336d076a2adSLuiz Capitulino	$(INSTALL_DATA) qmp-commands.txt "$(DESTDIR)$(qemu_docdir)"
33796d409ebSJuan Quintelaifdef CONFIG_POSIX
33858f8aeadSaliguori	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
3398a3e8f7fSAndreas Färber	$(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1"
3408a3e8f7fSAndreas Färberifneq ($(TOOLS),)
3418a3e8f7fSAndreas Färber	$(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1"
34258f8aeadSaliguori	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
34358f8aeadSaliguori	$(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
34438954dcaSpbrookendif
3458a3e8f7fSAndreas Färberendif
346a2d8f1beSM. Mohan Kumarifdef CONFIG_VIRTFS
347a2d8f1beSM. Mohan Kumar	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
348a2d8f1beSM. Mohan Kumar	$(INSTALL_DATA) fsdev/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
349a2d8f1beSM. Mohan Kumarendif
350b5ec5ce0Sjohn cooper
351e2d87bffSEduardo Habkostinstall-datadir:
352e2d87bffSEduardo Habkost	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
353e2d87bffSEduardo Habkost
354f2e3978bSLaszlo Ersekinstall-localstatedir:
355f2e3978bSLaszlo Ersekifdef CONFIG_POSIX
356f2e3978bSLaszlo Ersekifneq (,$(findstring qemu-ga,$(TOOLS)))
357f2e3978bSLaszlo Ersek	$(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
358f2e3978bSLaszlo Ersekendif
359f2e3978bSLaszlo Ersekendif
360f2e3978bSLaszlo Ersek
361e2d87bffSEduardo Habkostinstall-confdir:
362e2d87bffSEduardo Habkost	$(INSTALL_DIR) "$(DESTDIR)$(qemu_confdir)"
363e2d87bffSEduardo Habkost
364e2d87bffSEduardo Habkostinstall-sysconfig: install-datadir install-confdir
365e2d87bffSEduardo Habkost	$(INSTALL_DATA) $(SRC_PATH)/sysconfigs/target/target-x86_64.conf "$(DESTDIR)$(qemu_confdir)"
366e2d87bffSEduardo Habkost
367f2e3978bSLaszlo Ersekinstall: all $(if $(BUILD_DOCS),install-doc) install-sysconfig \
368f2e3978bSLaszlo Ersekinstall-datadir install-localstatedir
36958f8aeadSaliguori	$(INSTALL_DIR) "$(DESTDIR)$(bindir)"
370932a79dfSthsifneq ($(TOOLS),)
37158f8aeadSaliguori	$(INSTALL_PROG) $(STRIP_OPT) $(TOOLS) "$(DESTDIR)$(bindir)"
372932a79dfSthsendif
373e3be6f0eSFam Zhengifneq ($(CONFIG_MODULES),)
374e3be6f0eSFam Zheng	$(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
375e3be6f0eSFam Zheng	for s in $(patsubst %.mo,%$(DSOSUF),$(modules-m)); do \
376e3be6f0eSFam Zheng		$(INSTALL_PROG) $(STRIP_OPT) $$s "$(DESTDIR)$(qemu_moddir)/$${s//\//-}"; \
377e3be6f0eSFam Zheng	done
378e3be6f0eSFam Zhengendif
3797b93fadfSCorey Bryantifneq ($(HELPERS-y),)
3807b93fadfSCorey Bryant	$(INSTALL_DIR) "$(DESTDIR)$(libexecdir)"
3817b93fadfSCorey Bryant	$(INSTALL_PROG) $(STRIP_OPT) $(HELPERS-y) "$(DESTDIR)$(libexecdir)"
3827b93fadfSCorey Bryantendif
38377755340Sthsifneq ($(BLOBS),)
38477755340Sths	set -e; for x in $(BLOBS); do \
3856aae2a2eSEduardo Habkost		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
386ad064840Spbrook	done
38777755340Sthsendif
388834574eaSAnthony Liguoriifeq ($(CONFIG_GTK),y)
389834574eaSAnthony Liguori	$(MAKE) -C po $@
390834574eaSAnthony Liguoriendif
3916aae2a2eSEduardo Habkost	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
39218be8d77Sblueswir1	set -e; for x in $(KEYMAPS); do \
3936aae2a2eSEduardo Habkost		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
394ad064840Spbrook	done
395626df76aSbellard	for d in $(TARGET_DIRS); do \
3967d3505c5Sbellard	$(MAKE) -C $$d $@ || exit 1 ; \
397626df76aSbellard        done
398612384d7Sbellard
399367e86e8Sbellard# various test targets
4009b0b8203Sbellardtest speed: all
401c09015ddSAnthony Liguori	$(MAKE) -C tests/tcg $@
40231e31b8aSbellard
40321d4e8e3SAlexandre Bique.PHONY: TAGS
404367e86e8SbellardTAGS:
405b1999e87SDavid Gibson	rm -f $@
406b1999e87SDavid Gibson	find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} +
40731e31b8aSbellard
4086688bc6dSbellardcscope:
4096688bc6dSbellard	rm -f ./cscope.*
41045b75ae4SAlexandre Raymond	find "$(SRC_PATH)" -name "*.[chsS]" -print | sed 's,^\./,,' > ./cscope.files
4116688bc6dSbellard	cscope -b
4126688bc6dSbellard
4133ef693a0Sbellard# documentation
41401668d98SStefan WeilMAKEINFO=makeinfo
41501668d98SStefan WeilMAKEINFOFLAGS=--no-headers --no-split --number-sections
41620cc9997SStefan WeilTEXIFLAG=$(if $(V),,--quiet)
41720cc9997SStefan Weil%.dvi: %.texi
41820cc9997SStefan Weil	$(call quiet-command,texi2dvi $(TEXIFLAG) -I . $<,"  GEN   $@")
41920cc9997SStefan Weil
4201f673135Sbellard%.html: %.texi
421952ef67cSStefan Weil	$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --html $< -o $@, \
42201668d98SStefan Weil	"  GEN   $@")
4233ef693a0Sbellard
424f3548328Sbellard%.info: %.texi
42501668d98SStefan Weil	$(call quiet-command,$(MAKEINFO) $< -o $@,"  GEN   $@")
426f3548328Sbellard
42720cc9997SStefan Weil%.pdf: %.texi
42820cc9997SStefan Weil	$(call quiet-command,texi2pdf $(TEXIFLAG) -I . $<,"  GEN   $@")
4295824d651Sblueswir1
4305824d651Sblueswir1qemu-options.texi: $(SRC_PATH)/qemu-options.hx
4314c3b5a48SBlue Swirl	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
432f3548328Sbellard
433acd0a093SLuiz Capitulinoqemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx
4344c3b5a48SBlue Swirl	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
4352313086aSBlue Swirl
436d076a2adSLuiz Capitulinoqmp-commands.txt: $(SRC_PATH)/qmp-commands.hx
4374c3b5a48SBlue Swirl	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -q < $< > $@,"  GEN   $@")
438b40292e7SJan Kiszka
439153859beSStuart Bradyqemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx
4404c3b5a48SBlue Swirl	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
441153859beSStuart Brady
4422313086aSBlue Swirlqemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi
4430d00e563Saliguori	$(call quiet-command, \
4444c3b5a48SBlue Swirl	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu.pod && \
4453179d694SMichael Tokarev	  $(POD2MAN) --section=1 --center=" " --release=" " qemu.pod > $@, \
4460d00e563Saliguori	  "  GEN   $@")
4475a67135aSbellard
448153859beSStuart Bradyqemu-img.1: qemu-img.texi qemu-img-cmds.texi
4490d00e563Saliguori	$(call quiet-command, \
4504c3b5a48SBlue Swirl	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-img.pod && \
4513179d694SMichael Tokarev	  $(POD2MAN) --section=1 --center=" " --release=" " qemu-img.pod > $@, \
4520d00e563Saliguori	  "  GEN   $@")
453acd935efSbellard
454a2d8f1beSM. Mohan Kumarfsdev/virtfs-proxy-helper.1: fsdev/virtfs-proxy-helper.texi
455a2d8f1beSM. Mohan Kumar	$(call quiet-command, \
456a2d8f1beSM. Mohan Kumar	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< fsdev/virtfs-proxy-helper.pod && \
4573179d694SMichael Tokarev	  $(POD2MAN) --section=1 --center=" " --release=" " fsdev/virtfs-proxy-helper.pod > $@, \
458a2d8f1beSM. Mohan Kumar	  "  GEN   $@")
459a2d8f1beSM. Mohan Kumar
4607a5ca864Sbellardqemu-nbd.8: qemu-nbd.texi
4610d00e563Saliguori	$(call quiet-command, \
4624c3b5a48SBlue Swirl	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-nbd.pod && \
4633179d694SMichael Tokarev	  $(POD2MAN) --section=8 --center=" " --release=" " qemu-nbd.pod > $@, \
4640d00e563Saliguori	  "  GEN   $@")
4657a5ca864Sbellard
4660cb3fb1eSpbrookdvi: qemu-doc.dvi qemu-tech.dvi
4670cb3fb1eSpbrookhtml: qemu-doc.html qemu-tech.html
46820cc9997SStefan Weilinfo: qemu-doc.info qemu-tech.info
46920cc9997SStefan Weilpdf: qemu-doc.pdf qemu-tech.pdf
4700cb3fb1eSpbrook
47120cc9997SStefan Weilqemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \
47220cc9997SStefan Weil	qemu-img.texi qemu-nbd.texi qemu-options.texi \
47320cc9997SStefan Weil	qemu-monitor.texi qemu-img-cmds.texi
474818220f5Saliguori
475f53ec699SStefan Weilifdef CONFIG_WIN32
476f53ec699SStefan Weil
477f53ec699SStefan WeilINSTALLER = qemu-setup-$(VERSION)$(EXESUF)
478f53ec699SStefan Weil
479f53ec699SStefan Weilnsisflags = -V2 -NOCD
480f53ec699SStefan Weil
481f53ec699SStefan Weilifneq ($(wildcard $(SRC_PATH)/dll),)
482f53ec699SStefan Weilifeq ($(ARCH),x86_64)
483f53ec699SStefan Weil# 64 bit executables
484f53ec699SStefan WeilDLL_PATH = $(SRC_PATH)/dll/w64
485f53ec699SStefan Weilnsisflags += -DW64
486f53ec699SStefan Weilelse
487f53ec699SStefan Weil# 32 bit executables
488f53ec699SStefan WeilDLL_PATH = $(SRC_PATH)/dll/w32
489f53ec699SStefan Weilendif
490f53ec699SStefan Weilendif
491f53ec699SStefan Weil
492f53ec699SStefan Weil.PHONY: installer
493f53ec699SStefan Weilinstaller: $(INSTALLER)
494f53ec699SStefan Weil
495f53ec699SStefan WeilINSTDIR=/tmp/qemu-nsis
496f53ec699SStefan Weil
497f53ec699SStefan Weil$(INSTALLER): $(SRC_PATH)/qemu.nsi
498f53ec699SStefan Weil	make install prefix=${INSTDIR}
499f53ec699SStefan Weilifdef SIGNCODE
500f53ec699SStefan Weil	(cd ${INSTDIR}; \
501f53ec699SStefan Weil         for i in *.exe; do \
502f53ec699SStefan Weil           $(SIGNCODE) $${i}; \
503f53ec699SStefan Weil         done \
504f53ec699SStefan Weil        )
505f53ec699SStefan Weilendif # SIGNCODE
506f53ec699SStefan Weil	(cd ${INSTDIR}; \
507f53ec699SStefan Weil         for i in qemu-system-*.exe; do \
508f53ec699SStefan Weil           arch=$${i%.exe}; \
509f53ec699SStefan Weil           arch=$${arch#qemu-system-}; \
510f53ec699SStefan Weil           echo Section \"$$arch\" Section_$$arch; \
511f53ec699SStefan Weil           echo SetOutPath \"\$$INSTDIR\"; \
512f53ec699SStefan Weil           echo File \"\$${BINDIR}\\$$i\"; \
513f53ec699SStefan Weil           echo SectionEnd; \
514f53ec699SStefan Weil         done \
515f53ec699SStefan Weil        ) >${INSTDIR}/system-emulations.nsh
516f53ec699SStefan Weil	makensis $(nsisflags) \
517f53ec699SStefan Weil                $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
518f53ec699SStefan Weil                $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
519f53ec699SStefan Weil                -DBINDIR="${INSTDIR}" \
520f53ec699SStefan Weil                $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
521f53ec699SStefan Weil                -DSRCDIR="$(SRC_PATH)" \
522f53ec699SStefan Weil                -DOUTFILE="$(INSTALLER)" \
523f53ec699SStefan Weil                $(SRC_PATH)/qemu.nsi
524f53ec699SStefan Weil	rm -r ${INSTDIR}
525f53ec699SStefan Weilifdef SIGNCODE
526f53ec699SStefan Weil	$(SIGNCODE) $(INSTALLER)
527f53ec699SStefan Weilendif # SIGNCODE
528f53ec699SStefan Weilendif # CONFIG_WIN
529f53ec699SStefan Weil
530cb5fc67dSAnthony Liguori# Add a dependency on the generated files, so that they are always
531cb5fc67dSAnthony Liguori# rebuilt before other object files
5327748b8cbSMike Frysingerifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
533cb5fc67dSAnthony LiguoriMakefile: $(GENERATED_HEADERS)
5347748b8cbSMike Frysingerendif
535cb5fc67dSAnthony Liguori
5364fb240a4Sbellard# Include automatically generated dependency files
5371435ddb8SPaolo Bonzini# Dependencies in Makefile.objs files come from our recursive subdir rules
5381435ddb8SPaolo Bonzini-include $(wildcard *.d tests/*.d)
539