xref: /illumos-kvm-cmd/Makefile (revision 5f94182b)
1# Makefile for QEMU.
2#
3# Copyright 2011 QEMU contributors
4# Portions Copyright 2011 Joyent, Inc.
5#
6
7GENERATED_HEADERS = config-host.h trace.h qemu-options.def
8ifeq ($(TRACE_BACKEND),dtrace)
9GENERATED_HEADERS += trace-dtrace.h
10endif
11
12ifneq ($(wildcard config-host.mak),)
13# Put the all: rule here so that config-host.mak can contain dependencies.
14all: build-all
15include config-host.mak
16include $(SRC_PATH)/rules.mak
17config-host.mak: $(SRC_PATH)/configure
18	@echo $@ is out-of-date, running configure
19	@sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
20else
21config-host.mak:
22	@echo "Please call configure before running make!"
23	@exit 1
24endif
25
26# Don't try to regenerate Makefile or configure
27# We don't generate any of them
28Makefile: ;
29configure: ;
30
31.PHONY: all clean cscope distclean dvi html info install install-doc \
32	pdf recurse-all speed tar tarbin test build-all
33
34$(call set-vpath, $(SRC_PATH):$(SRC_PATH)/hw)
35
36LIBS+=-lz $(LIBS_TOOLS)
37
38ifdef BUILD_DOCS
39DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8 QMP/qmp-commands.txt
40else
41DOCS=
42endif
43
44SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory)
45SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(TARGET_DIRS))
46SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %/config-devices.mak.d, $(TARGET_DIRS))
47
48config-all-devices.mak: $(SUBDIR_DEVICES_MAK)
49	$(call quiet-command,cat $(SUBDIR_DEVICES_MAK) | grep =y | sort -u > $@,"  GEN   $@")
50
51-include $(SUBDIR_DEVICES_MAK_DEP)
52
53%/config-devices.mak: default-configs/%.mak
54	$(call quiet-command,$(SHELL) $(SRC_PATH)/scripts/make_device_config.sh $@ $<, "  GEN   $@")
55	@if test -f $@; then \
56	  if cmp -s $@.old $@; then \
57	    mv $@.tmp $@; \
58	    cp -p $@ $@.old; \
59	  else \
60	    if test -f $@.old; then \
61	      echo "WARNING: $@ (user modified) out of date.";\
62	    else \
63	      echo "WARNING: $@ out of date.";\
64	    fi; \
65	    echo "Run \"make defconfig\" to regenerate."; \
66	    rm $@.tmp; \
67	  fi; \
68	 else \
69	  mv $@.tmp $@; \
70	  cp -p $@ $@.old; \
71	 fi
72
73defconfig:
74	rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
75
76-include config-all-devices.mak
77
78build-all: $(DOCS) $(TOOLS) recurse-all
79
80config-host.h: config-host.h-timestamp
81config-host.h-timestamp: config-host.mak
82qemu-options.def: $(SRC_PATH)/qemu-options.hx
83	$(call quiet-command,bash $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $@")
84
85SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
86
87subdir-%: $(GENERATED_HEADERS)
88	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,)
89
90ifneq ($(wildcard config-host.mak),)
91include $(SRC_PATH)/Makefile.objs
92endif
93
94$(common-obj-y): $(GENERATED_HEADERS)
95$(filter %-softmmu,$(SUBDIR_RULES)): $(trace-obj-y) $(common-obj-y) subdir-libdis
96
97$(filter %-user,$(SUBDIR_RULES)): $(GENERATED_HEADERS) $(trace-obj-y) subdir-libdis-user subdir-libuser
98
99ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
100romsubdir-%:
101	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pc-bios/$* V="$(V)" TARGET_DIR="$*/",)
102
103ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
104
105recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
106
107audio/audio.o audio/fmodaudio.o: QEMU_CFLAGS += $(FMOD_CFLAGS)
108
109QEMU_CFLAGS+=$(CURL_CFLAGS)
110
111ui/cocoa.o: ui/cocoa.m
112
113ui/sdl.o audio/sdlaudio.o ui/sdl_zoom.o baum.o: QEMU_CFLAGS += $(SDL_CFLAGS)
114
115ui/vnc.o: QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
116
117bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
118
119ifeq ($(TRACE_BACKEND),dtrace)
120trace.h: trace.h-timestamp trace-dtrace.h
121else
122trace.h: trace.h-timestamp
123endif
124trace.h-timestamp: $(SRC_PATH)/trace-events config-host.mak
125	$(call quiet-command,bash $(SRC_PATH)/scripts/tracetool --$(TRACE_BACKEND) -h < $< > $@,"  GEN   trace.h")
126	@cmp -s $@ trace.h || cp $@ trace.h
127
128trace.c: trace.c-timestamp
129trace.c-timestamp: $(SRC_PATH)/trace-events config-host.mak
130	$(call quiet-command,bash $(SRC_PATH)/scripts/tracetool --$(TRACE_BACKEND) -c < $< > $@,"  GEN   trace.c")
131	@cmp -s $@ trace.c || cp $@ trace.c
132
133trace.o: trace.c $(GENERATED_HEADERS)
134
135trace-dtrace.h: trace-dtrace.dtrace
136	$(call quiet-command,dtrace -o $@ -h -s $<, "  GEN   trace-dtrace.h")
137
138# Normal practice is to name DTrace probe file with a '.d' extension
139# but that gets picked up by QEMU's Makefile as an external dependancy
140# rule file. So we use '.dtrace' instead
141trace-dtrace.dtrace: trace-dtrace.dtrace-timestamp
142trace-dtrace.dtrace-timestamp: $(SRC_PATH)/trace-events config-host.mak
143	$(call quiet-command,bash $(SRC_PATH)/scripts/tracetool --$(TRACE_BACKEND) -d < $< > $@,"  GEN   trace-dtrace.dtrace")
144	@cmp -s $@ trace-dtrace.dtrace || cp $@ trace-dtrace.dtrace
145
146trace-dtrace.o: trace-dtrace.dtrace $(GENERATED_HEADERS)
147	/bin/true
148#	$(call quiet-command,dtrace $(CONFIG_DTRACE_FLAGS) -o $@ -G -s $<, "  GEN trace-dtrace.o")
149
150simpletrace.o: simpletrace.c $(GENERATED_HEADERS)
151
152version.o: $(SRC_PATH)/version.rc config-host.mak
153	$(call quiet-command,$(WINDRES) -I. -o $@ $<,"  RC    $(TARGET_DIR)$@")
154
155version-obj-$(CONFIG_WIN32) += version.o
156######################################################################
157
158qemu-img.o: qemu-img-cmds.h
159qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o: $(GENERATED_HEADERS)
160
161qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) qemu-timer-common.o
162
163qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) qemu-timer-common.o
164
165qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) qemu-timer-common.o
166
167qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
168	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $@")
169
170check-qint.o check-qstring.o check-qdict.o check-qlist.o check-qfloat.o check-qjson.o: $(GENERATED_HEADERS)
171
172CHECK_PROG_DEPS = qemu-malloc.o $(oslib-obj-y) $(trace-obj-y)
173
174check-qint: check-qint.o qint.o $(CHECK_PROG_DEPS)
175check-qstring: check-qstring.o qstring.o $(CHECK_PROG_DEPS)
176check-qdict: check-qdict.o qdict.o qfloat.o qint.o qstring.o qbool.o qlist.o $(CHECK_PROG_DEPS)
177check-qlist: check-qlist.o qlist.o qint.o $(CHECK_PROG_DEPS)
178check-qfloat: check-qfloat.o qfloat.o $(CHECK_PROG_DEPS)
179check-qjson: check-qjson.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o qjson.o json-streamer.o json-lexer.o json-parser.o $(CHECK_PROG_DEPS)
180
181clean:
182# avoid old build problems by removing potentially incorrect old files
183	rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
184	rm -f qemu-options.def
185	rm -f *.o *.d *.a $(TOOLS) TAGS cscope.* *.pod *~ */*~
186	rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d net/*.o net/*.d fsdev/*.o fsdev/*.d ui/*.o ui/*.d
187	rm -f qemu-img-cmds.h
188	rm -f trace.c trace.h trace.c-timestamp trace.h-timestamp
189	rm -f trace-dtrace.dtrace trace-dtrace.dtrace-timestamp
190	rm -f trace-dtrace.h trace-dtrace.h-timestamp
191	$(MAKE) -C tests clean
192	for d in $(ALL_SUBDIRS) libhw32 libhw64 libuser libdis libdis-user; do \
193	if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
194	rm -f $$d/qemu-options.def; \
195        done
196
197distclean: clean
198	rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi
199	rm -f config-all-devices.mak
200	rm -f roms/seabios/config.mak roms/vgabios/config.mak
201	rm -f qemu-doc.info qemu-doc.aux qemu-doc.cp qemu-doc.dvi qemu-doc.fn qemu-doc.info qemu-doc.ky qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp qemu-doc.vr
202	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
203	for d in $(TARGET_DIRS) libhw32 libhw64 libuser libdis libdis-user; do \
204	rm -rf $$d || exit 1 ; \
205        done
206
207KEYMAPS=da     en-gb  et  fr     fr-ch  is  lt  modifiers  no  pt-br  sv \
208ar      de     en-us  fi  fr-be  hr     it  lv  nl         pl  ru     th \
209common  de-ch  es     fo  fr-ca  hu     ja  mk  nl-be      pt  sl     tr
210
211ifdef INSTALL_BLOBS
212BLOBS=bios.bin vgabios.bin vgabios-cirrus.bin \
213vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin \
214ppc_rom.bin openbios-sparc32 openbios-sparc64 openbios-ppc \
215gpxe-eepro100-80861209.rom \
216pxe-e1000.bin \
217pxe-ne2k_pci.bin pxe-pcnet.bin \
218pxe-rtl8139.bin pxe-virtio.bin \
219bamboo.dtb petalogix-s3adsp1800.dtb \
220multiboot.bin linuxboot.bin \
221s390-zipl.rom
222BLOBS += extboot.bin
223BLOBS += vapic.bin
224else
225BLOBS=
226endif
227
228install-doc: $(DOCS)
229	$(INSTALL_DIR) "$(DESTDIR)$(docdir)"
230	$(INSTALL_DATA) qemu-doc.html  qemu-tech.html "$(DESTDIR)$(docdir)"
231ifdef CONFIG_POSIX
232	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
233	$(INSTALL_DATA) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
234	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
235	$(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
236endif
237
238install-sysconfig:
239	$(INSTALL_DIR) "$(DESTDIR)$(sysconfdir)/qemu"
240	$(INSTALL_DATA) $(SRC_PATH)/sysconfigs/target/target-x86_64.conf "$(DESTDIR)$(sysconfdir)/qemu"
241
242install: all $(if $(BUILD_DOCS),install-doc) install-sysconfig
243	$(INSTALL_DIR) "$(DESTDIR)$(bindir)"
244ifneq ($(TOOLS),)
245	$(INSTALL_PROG) $(STRIP_OPT) $(TOOLS) "$(DESTDIR)$(bindir)"
246endif
247ifneq ($(BLOBS),)
248	$(INSTALL_DIR) "$(DESTDIR)$(datadir)"
249	set -e; for x in $(BLOBS); do \
250	    if [ -f $(SRC_PATH)/pc-bios/$$x ];then \
251		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
252	    fi \
253	    ; if [ -f pc-bios/optionrom/$$x ];then \
254		$(INSTALL_DATA) pc-bios/optionrom/$$x "$(DESTDIR)$(datadir)"; \
255	    fi \
256	done
257endif
258	$(INSTALL_DIR) "$(DESTDIR)$(datadir)/keymaps"
259	set -e; for x in $(KEYMAPS); do \
260		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
261	done
262	for d in $(TARGET_DIRS); do \
263	$(MAKE) -C $$d $@ || exit 1 ; \
264        done
265
266# various test targets
267test speed: all
268	$(MAKE) -C tests $@
269
270.PHONY: TAGS
271TAGS:
272	find "$(SRC_PATH)" -name '*.[hc]' -print0 | xargs -0 etags
273
274cscope:
275	rm -f ./cscope.*
276	find . -name "*.[ch]" -print | sed 's,^\./,,' > ./cscope.files
277	cscope -b
278
279# documentation
280MAKEINFO=makeinfo
281MAKEINFOFLAGS=--no-headers --no-split --number-sections
282TEXIFLAG=$(if $(V),,--quiet)
283%.dvi: %.texi
284	$(call quiet-command,texi2dvi $(TEXIFLAG) -I . $<,"  GEN   $@")
285
286%.html: %.texi
287	$(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) --html $< -o $@, \
288	"  GEN   $@")
289
290%.info: %.texi
291	$(call quiet-command,$(MAKEINFO) $< -o $@,"  GEN   $@")
292
293%.pdf: %.texi
294	$(call quiet-command,texi2pdf $(TEXIFLAG) -I . $<,"  GEN   $@")
295
296qemu-options.texi: $(SRC_PATH)/qemu-options.hx
297	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
298
299qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx
300	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
301
302QMP/qmp-commands.txt: $(SRC_PATH)/qmp-commands.hx
303	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -q < $< > $@,"  GEN   $@")
304
305qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx
306	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
307
308qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi
309	$(call quiet-command, \
310	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu.pod && \
311	  pod2man --section=1 --center=" " --release=" " qemu.pod > $@, \
312	  "  GEN   $@")
313
314qemu-img.1: qemu-img.texi qemu-img-cmds.texi
315	$(call quiet-command, \
316	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-img.pod && \
317	  pod2man --section=1 --center=" " --release=" " qemu-img.pod > $@, \
318	  "  GEN   $@")
319
320qemu-nbd.8: qemu-nbd.texi
321	$(call quiet-command, \
322	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-nbd.pod && \
323	  pod2man --section=8 --center=" " --release=" " qemu-nbd.pod > $@, \
324	  "  GEN   $@")
325
326dvi: qemu-doc.dvi qemu-tech.dvi
327html: qemu-doc.html qemu-tech.html
328info: qemu-doc.info qemu-tech.info
329pdf: qemu-doc.pdf qemu-tech.pdf
330
331qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \
332	qemu-img.texi qemu-nbd.texi qemu-options.texi \
333	qemu-monitor.texi qemu-img-cmds.texi
334
335VERSION ?= $(shell cat VERSION)
336FILE = qemu-$(VERSION)
337
338# tar release (use 'make -k tar' on a checkouted tree)
339tar:
340	rm -rf /tmp/$(FILE)
341	cp -r . /tmp/$(FILE)
342	cd /tmp && tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS --exclude .git --exclude .svn
343	rm -rf /tmp/$(FILE)
344
345SYSTEM_TARGETS=$(filter %-softmmu,$(TARGET_DIRS))
346SYSTEM_PROGS=$(patsubst qemu-system-i386,qemu, \
347             $(patsubst %-softmmu,qemu-system-%, \
348             $(SYSTEM_TARGETS)))
349
350USER_TARGETS=$(filter %-user,$(TARGET_DIRS))
351USER_PROGS=$(patsubst %-bsd-user,qemu-%, \
352           $(patsubst %-darwin-user,qemu-%, \
353           $(patsubst %-linux-user,qemu-%, \
354           $(USER_TARGETS))))
355
356# generate a binary distribution
357tarbin:
358	cd / && tar zcvf ~/qemu-$(VERSION)-$(ARCH).tar.gz \
359	$(patsubst %,$(bindir)/%, $(SYSTEM_PROGS)) \
360	$(patsubst %,$(bindir)/%, $(USER_PROGS)) \
361	$(bindir)/qemu-img \
362	$(bindir)/qemu-nbd \
363	$(datadir)/bios.bin \
364	$(datadir)/vgabios.bin \
365	$(datadir)/vgabios-cirrus.bin \
366	$(datadir)/ppc_rom.bin \
367	$(datadir)/openbios-sparc32 \
368	$(datadir)/openbios-sparc64 \
369	$(datadir)/openbios-ppc \
370	$(datadir)/pxe-ne2k_pci.bin \
371	$(datadir)/pxe-rtl8139.bin \
372	$(datadir)/pxe-pcnet.bin \
373	$(datadir)/pxe-e1000.bin \
374	$(datadir)/extboot.bin \
375	$(docdir)/qemu-doc.html \
376	$(docdir)/qemu-tech.html \
377	$(mandir)/man1/qemu.1 \
378	$(mandir)/man1/qemu-img.1 \
379	$(mandir)/man8/qemu-nbd.8
380
381# Include automatically generated dependency files
382-include $(wildcard *.d audio/*.d slirp/*.d block/*.d net/*.d ui/*.d)
383