kvm tools, setup: Create private directory
[linux-2.6/next.git] / tools / kvm / Makefile
blob25cbd7e966ba3fe677786284487e9e2076678408
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
85 FLAGS_BFD := $(CFLAGS) -lbfd
86 has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD))
87 ifeq ($(has_bfd),y)
88 CFLAGS += -DCONFIG_HAS_BFD
89 OBJS += symbol.o
90 LIBS += -lbfd
91 endif
93 FLAGS_VNCSERVER := $(CFLAGS) -lvncserver
94 has_vncserver := $(call try-cc,$(SOURCE_VNCSERVER),$(FLAGS_VNCSERVER))
95 ifeq ($(has_vncserver),y)
96 OBJS += ui/vnc.o
97 CFLAGS += -DCONFIG_HAS_VNCSERVER
98 LIBS += -lvncserver
99 endif
101 FLAGS_SDL := $(CFLAGS) -lSDL
102 has_SDL := $(call try-cc,$(SOURCE_SDL),$(FLAGS_SDL))
103 ifeq ($(has_SDL),y)
104 OBJS += ui/sdl.o
105 CFLAGS += -DCONFIG_HAS_SDL
106 LIBS += -lSDL
107 endif
109 DEPS := $(patsubst %.o,%.d,$(OBJS))
111 # Exclude BIOS object files from header dependencies.
112 OBJS += bios.o
113 OBJS += bios/bios-rom.o
115 LIBS += -lrt
116 LIBS += -lpthread
118 # Additional ARCH settings for x86
119 ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
120 -e s/arm.*/arm/ -e s/sa110/arm/ \
121 -e s/s390x/s390/ -e s/parisc64/parisc/ \
122 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
123 -e s/sh[234].*/sh/ )
125 uname_M := $(shell uname -m | sed -e s/i.86/i386/)
126 ifeq ($(uname_M),i386)
127 ARCH := x86
128 DEFINES += -DCONFIG_X86_32
129 endif
130 ifeq ($(uname_M),x86_64)
131 ARCH := x86
132 DEFINES += -DCONFIG_X86_64
133 endif
135 DEFINES += -D_FILE_OFFSET_BITS=64
136 DEFINES += -D_GNU_SOURCE
137 DEFINES += -DKVMTOOLS_VERSION='"$(KVMTOOLS_VERSION)"'
139 KVM_INCLUDE := include
140 CFLAGS += $(CPPFLAGS) $(DEFINES) -I$(KVM_INCLUDE) -I../../include -I../../arch/$(ARCH)/include/ -Os -g
142 ifneq ($(WERROR),0)
143 WARNINGS += -Werror
144 endif
146 WARNINGS += -Wall
147 WARNINGS += -Wcast-align
148 WARNINGS += -Wformat=2
149 WARNINGS += -Winit-self
150 WARNINGS += -Wmissing-declarations
151 WARNINGS += -Wmissing-prototypes
152 WARNINGS += -Wnested-externs
153 WARNINGS += -Wno-system-headers
154 WARNINGS += -Wold-style-definition
155 WARNINGS += -Wredundant-decls
156 WARNINGS += -Wsign-compare
157 WARNINGS += -Wstrict-prototypes
158 WARNINGS += -Wundef
159 WARNINGS += -Wvolatile-register-var
160 WARNINGS += -Wwrite-strings
161 WARNINGS += -Wunused-result
163 CFLAGS += $(WARNINGS)
165 all: $(PROGRAM) $(GUEST_INIT)
167 KVMTOOLS-VERSION-FILE:
168 @$(SHELL_PATH) util/KVMTOOLS-VERSION-GEN $(OUTPUT)
169 -include $(OUTPUT)KVMTOOLS-VERSION-FILE
171 $(PROGRAM): $(DEPS) $(OBJS)
172 $(E) " LINK " $@
173 $(Q) $(CC) $(OBJS) $(LIBS) -o $@
175 $(GUEST_INIT): guest/init.c
176 $(E) " LINK " $@
177 $(Q) $(CC) -static guest/init.c -o $@
179 $(DEPS):
181 %.d: %.c
182 $(Q) $(CC) -M -MT $(patsubst %.d,%.o,$@) $(CFLAGS) $< -o $@
184 # The header file common-cmds.h is needed for compilation of builtin-help.c.
185 builtin-help.d: $(KVM_INCLUDE)/common-cmds.h
187 $(OBJS):
189 rbtree.o: ../../lib/rbtree.c
190 $(Q) $(CC) -c $(CFLAGS) $< -o $@
192 %.o: %.c
193 $(E) " CC " $@
194 $(Q) $(CC) -c $(CFLAGS) $< -o $@
197 $(KVM_INCLUDE)/common-cmds.h: util/generate-cmdlist.sh command-list.txt
199 $(KVM_INCLUDE)/common-cmds.h: $(wildcard Documentation/kvm-*.txt)
200 $(E) " GEN " $@
201 $(Q) util/generate-cmdlist.sh > $@+ && mv $@+ $@
204 # BIOS assembly weirdness
206 BIOS_CFLAGS += -m32
207 BIOS_CFLAGS += -march=i386
208 BIOS_CFLAGS += -mregparm=3
210 bios.o: bios/bios.bin bios/bios-rom.h
212 bios/bios.bin.elf: bios/entry.S bios/e820.c bios/int10.c bios/int15.c bios/rom.ld.S
213 $(E) " CC bios/e820.o"
214 $(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/e820.c -o bios/e820.o
215 $(E) " CC bios/int10.o"
216 $(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/int10.c -o bios/int10.o
217 $(E) " CC bios/int15.o"
218 $(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/int15.c -o bios/int15.o
219 $(E) " CC bios/entry.o"
220 $(Q) $(CC) $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/entry.S -o bios/entry.o
221 $(E) " LD " $@
222 $(Q) ld -T bios/rom.ld.S -o bios/bios.bin.elf bios/entry.o bios/e820.o bios/int10.o bios/int15.o
224 bios/bios.bin: bios/bios.bin.elf
225 $(E) " OBJCOPY " $@
226 $(Q) objcopy -O binary -j .text bios/bios.bin.elf bios/bios.bin
228 bios/bios-rom.o: bios/bios-rom.S bios/bios.bin bios/bios-rom.h
229 $(E) " CC " $@
230 $(Q) $(CC) -c $(CFLAGS) bios/bios-rom.S -o bios/bios-rom.o
232 bios/bios-rom.h: bios/bios.bin.elf
233 $(E) " NM " $@
234 $(Q) cd bios && sh gen-offsets.sh > bios-rom.h && cd ..
236 check: $(PROGRAM)
237 $(MAKE) -C tests
238 ./$(PROGRAM) run tests/pit/tick.bin
239 ./$(PROGRAM) run -d tests/boot/boot_test.iso -p "init=init"
240 .PHONY: check
242 clean:
243 $(E) " CLEAN"
244 $(Q) rm -f bios/*.bin
245 $(Q) rm -f bios/*.elf
246 $(Q) rm -f bios/*.o
247 $(Q) rm -f bios/bios-rom.h
248 $(Q) rm -f tests/boot/boot_test.iso
249 $(Q) rm -rf tests/boot/rootfs/
250 $(Q) rm -f $(DEPS) $(OBJS) $(PROGRAM) $(GUEST_INIT)
251 $(Q) rm -f cscope.*
252 $(Q) rm -f $(KVM_INCLUDE)/common-cmds.h
253 $(Q) rm -f KVMTOOLS-VERSION-FILE
254 .PHONY: clean
256 KVM_DEV ?= /dev/kvm
258 $(KVM_DEV):
259 $(E) " MKNOD " $@
260 $(Q) mknod $@ char 10 232
262 devices: $(KVM_DEV)
263 .PHONY: devices
265 TAGS:
266 $(E) " GEN" $@
267 $(Q) $(RM) -f TAGS
268 $(Q) $(FIND) . -name '*.[hcS]' -print | xargs etags -a
269 .PHONY: TAGS
271 tags:
272 $(E) " GEN" $@
273 $(Q) $(RM) -f tags
274 $(Q) $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
275 .PHONY: tags
277 cscope:
278 $(E) " GEN" $@
279 $(Q) $(FIND) . -name '*.[hcS]' -print > cscope.files
280 $(Q) $(CSCOPE) -bkqu
281 .PHONY: cscope
283 # Deps
284 -include $(DEPS)