2 # Define WERROR=0 to disable -Werror.
14 include config
/utilities.mak
15 include config
/feature-tests.mak
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
33 OBJS
+= builtin-setup.o
34 OBJS
+= builtin-stop.o
35 OBJS
+= builtin-version.o
39 OBJS
+= guest_compat.o
53 OBJS
+= virtio
/console.o
57 OBJS
+= virtio
/balloon.o
64 OBJS
+= net
/uip
/core.o
66 OBJS
+= net
/uip
/icmp.o
67 OBJS
+= net
/uip
/ipv4.o
71 OBJS
+= net
/uip
/csum.o
72 OBJS
+= net
/uip
/dhcp.o
77 OBJS
+= util
/parse-options.o
78 OBJS
+= util
/rbtree-interval.o
81 OBJS
+= virtio
/9p-pdu.o
85 FLAGS_BFD
:= $(CFLAGS
) -lbfd
86 has_bfd
:= $(call try-cc
,$(SOURCE_BFD
),$(FLAGS_BFD
))
88 CFLAGS
+= -DCONFIG_HAS_BFD
93 FLAGS_VNCSERVER
:= $(CFLAGS
) -lvncserver
94 has_vncserver
:= $(call try-cc
,$(SOURCE_VNCSERVER
),$(FLAGS_VNCSERVER
))
95 ifeq ($(has_vncserver
),y
)
97 CFLAGS
+= -DCONFIG_HAS_VNCSERVER
101 FLAGS_SDL
:= $(CFLAGS
) -lSDL
102 has_SDL
:= $(call try-cc
,$(SOURCE_SDL
),$(FLAGS_SDL
))
105 CFLAGS
+= -DCONFIG_HAS_SDL
109 DEPS
:= $(patsubst %.o
,%.d
,$(OBJS
))
111 # Exclude BIOS object files from header dependencies.
113 OBJS
+= bios
/bios-rom.o
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
/ \
125 uname_M
:= $(shell uname
-m | sed
-e s
/i
.86/i386
/)
126 ifeq ($(uname_M
),i386
)
128 DEFINES
+= -DCONFIG_X86_32
130 ifeq ($(uname_M
),x86_64
)
132 DEFINES
+= -DCONFIG_X86_64
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
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
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
)
173 $(Q
) $(CC
) $(OBJS
) $(LIBS
) -o
$@
175 $(GUEST_INIT
): guest
/init.c
177 $(Q
) $(CC
) -static guest
/init.c
-o
$@
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
189 rbtree.o
: ..
/..
/lib
/rbtree.c
190 $(Q
) $(CC
) -c
$(CFLAGS
) $< -o
$@
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
)
201 $(Q
) util
/generate-cmdlist.sh
> $@
+ && mv
$@
+ $@
204 # BIOS assembly weirdness
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
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
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
230 $(Q
) $(CC
) -c
$(CFLAGS
) bios
/bios-rom.S
-o bios
/bios-rom.o
232 bios
/bios-rom.h
: bios
/bios.bin.elf
234 $(Q
) cd bios
&& sh gen-offsets.sh
> bios-rom.h
&& cd ..
238 .
/$(PROGRAM
) run tests
/pit
/tick.bin
239 .
/$(PROGRAM
) run
-d tests
/boot
/boot_test.iso
-p
"init=init"
244 $(Q
) rm -f bios
/*.bin
245 $(Q
) rm -f bios
/*.elf
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
)
252 $(Q
) rm -f
$(KVM_INCLUDE
)/common-cmds.h
253 $(Q
) rm -f KVMTOOLS-VERSION-FILE
260 $(Q
) mknod
$@ char
10 232
268 $(Q
) $(FIND
) .
-name
'*.[hcS]' -print | xargs etags
-a
274 $(Q
) $(FIND
) .
-name
'*.[hcS]' -print | xargs ctags
-a
279 $(Q
) $(FIND
) .
-name
'*.[hcS]' -print > cscope.files