Add linux-next specific files for 20110831
[linux-2.6/next.git] / tools / kvm / Makefile
blobefa032d6ad9de39f8634c07c9444ce37f8fb93af
2 # Define WERROR=0 to disable -Werror.
5 ifeq ($(strip $(V)),)
6 E = @echo
7 Q = @
8 else
9 E = @\#
10 Q =
11 endif
12 export E Q
14 include config/utilities.mak
15 include config/feature-tests.mak
17 FIND := find
18 CSCOPE := cscope
19 TAGS := ctags
21 PROGRAM := kvm
23 GUEST_INIT := guest/init
25 OBJS += builtin-balloon.o
26 OBJS += builtin-debug.o
27 OBJS += builtin-help.o
28 OBJS += builtin-list.o
29 OBJS += builtin-stat.o
30 OBJS += builtin-pause.o
31 OBJS += builtin-resume.o
32 OBJS += builtin-run.o
33 OBJS += builtin-setup.o
34 OBJS += builtin-stop.o
35 OBJS += builtin-version.o
36 OBJS += cpuid.o
37 OBJS += disk/core.o
38 OBJS += framebuffer.o
39 OBJS += guest_compat.o
40 OBJS += hw/rtc.o
41 OBJS += hw/serial.o
42 OBJS += interrupt.o
43 OBJS += ioport.o
44 OBJS += kvm-cpu.o
45 OBJS += kvm.o
46 OBJS += main.o
47 OBJS += mmio.o
48 OBJS += pci.o
49 OBJS += read-write.o
50 OBJS += term.o
51 OBJS += util.o
52 OBJS += virtio/blk.o
53 OBJS += virtio/console.o
54 OBJS += virtio/core.o
55 OBJS += virtio/net.o
56 OBJS += virtio/rng.o
57 OBJS += virtio/balloon.o
58 OBJS += virtio/pci.o
59 OBJS += disk/blk.o
60 OBJS += disk/qcow.o
61 OBJS += disk/raw.o
62 OBJS += ioeventfd.o
63 OBJS += irq.o
64 OBJS += net/uip/core.o
65 OBJS += net/uip/arp.o
66 OBJS += net/uip/icmp.o
67 OBJS += net/uip/ipv4.o
68 OBJS += net/uip/tcp.o
69 OBJS += net/uip/udp.o
70 OBJS += net/uip/buf.o
71 OBJS += net/uip/csum.o
72 OBJS += net/uip/dhcp.o
73 OBJS += kvm-cmd.o
74 OBJS += mptable.o
75 OBJS += rbtree.o
76 OBJS += threadpool.o
77 OBJS += util/parse-options.o
78 OBJS += util/rbtree-interval.o
79 OBJS += util/strbuf.o
80 OBJS += virtio/9p.o
81 OBJS += virtio/9p-pdu.o
82 OBJS += hw/vesa.o
83 OBJS += hw/i8042.o
84 OBJS += hw/pci-shmem.o
86 FLAGS_BFD := $(CFLAGS) -lbfd
87 has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD))
88 ifeq ($(has_bfd),y)
89 CFLAGS += -DCONFIG_HAS_BFD
90 OBJS += symbol.o
91 LIBS += -lbfd
92 endif
94 FLAGS_VNCSERVER := $(CFLAGS) -lvncserver
95 has_vncserver := $(call try-cc,$(SOURCE_VNCSERVER),$(FLAGS_VNCSERVER))
96 ifeq ($(has_vncserver),y)
97 OBJS += ui/vnc.o
98 CFLAGS += -DCONFIG_HAS_VNCSERVER
99 LIBS += -lvncserver
100 endif
102 FLAGS_SDL := $(CFLAGS) -lSDL
103 has_SDL := $(call try-cc,$(SOURCE_SDL),$(FLAGS_SDL))
104 ifeq ($(has_SDL),y)
105 OBJS += ui/sdl.o
106 CFLAGS += -DCONFIG_HAS_SDL
107 LIBS += -lSDL
108 endif
110 DEPS := $(patsubst %.o,%.d,$(OBJS))
112 # Exclude BIOS object files from header dependencies.
113 OBJS += bios.o
114 OBJS += bios/bios-rom.o
116 LIBS += -lrt
117 LIBS += -lpthread
119 # Additional ARCH settings for x86
120 ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
121 -e s/arm.*/arm/ -e s/sa110/arm/ \
122 -e s/s390x/s390/ -e s/parisc64/parisc/ \
123 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
124 -e s/sh[234].*/sh/ )
126 uname_M := $(shell uname -m | sed -e s/i.86/i386/)
127 ifeq ($(uname_M),i386)
128 ARCH := x86
129 DEFINES += -DCONFIG_X86_32
130 endif
131 ifeq ($(uname_M),x86_64)
132 ARCH := x86
133 DEFINES += -DCONFIG_X86_64
134 endif
136 DEFINES += -D_FILE_OFFSET_BITS=64
137 DEFINES += -D_GNU_SOURCE
138 DEFINES += -DKVMTOOLS_VERSION='"$(KVMTOOLS_VERSION)"'
140 KVM_INCLUDE := include
141 CFLAGS += $(CPPFLAGS) $(DEFINES) -I$(KVM_INCLUDE) -I../../include -I../../arch/$(ARCH)/include/ -Os -g
143 ifneq ($(WERROR),0)
144 WARNINGS += -Werror
145 endif
147 WARNINGS += -Wall
148 WARNINGS += -Wcast-align
149 WARNINGS += -Wformat=2
150 WARNINGS += -Winit-self
151 WARNINGS += -Wmissing-declarations
152 WARNINGS += -Wmissing-prototypes
153 WARNINGS += -Wnested-externs
154 WARNINGS += -Wno-system-headers
155 WARNINGS += -Wold-style-definition
156 WARNINGS += -Wredundant-decls
157 WARNINGS += -Wsign-compare
158 WARNINGS += -Wstrict-prototypes
159 WARNINGS += -Wundef
160 WARNINGS += -Wvolatile-register-var
161 WARNINGS += -Wwrite-strings
162 WARNINGS += -Wunused-result
164 CFLAGS += $(WARNINGS)
166 all: $(PROGRAM) $(GUEST_INIT)
168 KVMTOOLS-VERSION-FILE:
169 @$(SHELL_PATH) util/KVMTOOLS-VERSION-GEN $(OUTPUT)
170 -include $(OUTPUT)KVMTOOLS-VERSION-FILE
172 $(PROGRAM): $(DEPS) $(OBJS)
173 $(E) " LINK " $@
174 $(Q) $(CC) $(OBJS) $(LIBS) -o $@
176 $(GUEST_INIT): guest/init.c
177 $(E) " LINK " $@
178 $(Q) $(CC) -static guest/init.c -o $@
180 $(DEPS):
182 %.d: %.c
183 $(Q) $(CC) -M -MT $(patsubst %.d,%.o,$@) $(CFLAGS) $< -o $@
185 # The header file common-cmds.h is needed for compilation of builtin-help.c.
186 builtin-help.d: $(KVM_INCLUDE)/common-cmds.h
188 $(OBJS):
190 rbtree.o: ../../lib/rbtree.c
191 $(Q) $(CC) -c $(CFLAGS) $< -o $@
193 %.o: %.c
194 $(E) " CC " $@
195 $(Q) $(CC) -c $(CFLAGS) $< -o $@
198 $(KVM_INCLUDE)/common-cmds.h: util/generate-cmdlist.sh command-list.txt
200 $(KVM_INCLUDE)/common-cmds.h: $(wildcard Documentation/kvm-*.txt)
201 $(E) " GEN " $@
202 $(Q) util/generate-cmdlist.sh > $@+ && mv $@+ $@
205 # BIOS assembly weirdness
207 BIOS_CFLAGS += -m32
208 BIOS_CFLAGS += -march=i386
209 BIOS_CFLAGS += -mregparm=3
211 bios.o: bios/bios.bin bios/bios-rom.h
213 bios/bios.bin.elf: bios/entry.S bios/e820.c bios/int10.c bios/int15.c bios/rom.ld.S
214 $(E) " CC bios/e820.o"
215 $(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/e820.c -o bios/e820.o
216 $(E) " CC bios/int10.o"
217 $(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/int10.c -o bios/int10.o
218 $(E) " CC bios/int15.o"
219 $(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/int15.c -o bios/int15.o
220 $(E) " CC bios/entry.o"
221 $(Q) $(CC) $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/entry.S -o bios/entry.o
222 $(E) " LD " $@
223 $(Q) ld -T bios/rom.ld.S -o bios/bios.bin.elf bios/entry.o bios/e820.o bios/int10.o bios/int15.o
225 bios/bios.bin: bios/bios.bin.elf
226 $(E) " OBJCOPY " $@
227 $(Q) objcopy -O binary -j .text bios/bios.bin.elf bios/bios.bin
229 bios/bios-rom.o: bios/bios-rom.S bios/bios.bin bios/bios-rom.h
230 $(E) " CC " $@
231 $(Q) $(CC) -c $(CFLAGS) bios/bios-rom.S -o bios/bios-rom.o
233 bios/bios-rom.h: bios/bios.bin.elf
234 $(E) " NM " $@
235 $(Q) cd bios && sh gen-offsets.sh > bios-rom.h && cd ..
237 check: $(PROGRAM)
238 $(MAKE) -C tests
239 ./$(PROGRAM) run tests/pit/tick.bin
240 ./$(PROGRAM) run -d tests/boot/boot_test.iso -p "init=init"
241 .PHONY: check
243 clean:
244 $(E) " CLEAN"
245 $(Q) rm -f bios/*.bin
246 $(Q) rm -f bios/*.elf
247 $(Q) rm -f bios/*.o
248 $(Q) rm -f bios/bios-rom.h
249 $(Q) rm -f tests/boot/boot_test.iso
250 $(Q) rm -rf tests/boot/rootfs/
251 $(Q) rm -f $(DEPS) $(OBJS) $(PROGRAM) $(GUEST_INIT)
252 $(Q) rm -f cscope.*
253 $(Q) rm -f $(KVM_INCLUDE)/common-cmds.h
254 $(Q) rm -f KVMTOOLS-VERSION-FILE
255 .PHONY: clean
257 KVM_DEV ?= /dev/kvm
259 $(KVM_DEV):
260 $(E) " MKNOD " $@
261 $(Q) mknod $@ char 10 232
263 devices: $(KVM_DEV)
264 .PHONY: devices
266 TAGS:
267 $(E) " GEN" $@
268 $(Q) $(RM) -f TAGS
269 $(Q) $(FIND) . -name '*.[hcS]' -print | xargs etags -a
270 .PHONY: TAGS
272 tags:
273 $(E) " GEN" $@
274 $(Q) $(RM) -f tags
275 $(Q) $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
276 .PHONY: tags
278 cscope:
279 $(E) " GEN" $@
280 $(Q) $(FIND) . -name '*.[hcS]' -print > cscope.files
281 $(Q) $(CSCOPE) -bkqu
282 .PHONY: cscope
284 # Deps
285 -include $(DEPS)