15
17
cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \
16
18
> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
18
CFLAGS += -I $(KERNELDIR)/include $(autodepend-flags) -g -fomit-frame-pointer \
20
CFLAGS += $(autodepend-flags) -g -fomit-frame-pointer -Wall
20
21
CFLAGS += $(call cc-option, -fno-stack-protector, "")
21
22
CFLAGS += $(call cc-option, -fno-stack-protector-all, "")
25
CXXFLAGS = $(autodepend-flags)
23
CFLAGS += -I ../libkvm
25
LDFLAGS += $(CFLAGS) -L ../libkvm
27
CXXFLAGS = $(autodepend-flags)
27
29
autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d
29
all: kvmctl libkvm.a flatfiles
31
31
kvmctl: LDFLAGS += -pthread -lrt
33
kvmctl: kvmctl.o main.o
35
balloon_ctl: balloon_ctl.o
40
flatfiles-common = test/bootstrap test/vmexit.flat test/smp.flat
42
flatfiles: $(flatfiles-common) $(flatfiles)
45
install -D kvmctl.h $(DESTDIR)/$(PREFIX)/include/kvmctl.h
46
install -D $(KERNELDIR)/include/linux/kvm.h \
47
$(DESTDIR)/$(PREFIX)/include/linux/kvm.h
48
install -D $(KERNELDIR)/include/linux/kvm_para.h \
49
$(DESTDIR)/$(PREFIX)/include/linux/kvm_para.h
50
install -D libkvm.a $(DESTDIR)/$(PREFIX)/$(LIBDIR)/libkvm.a
33
kvmctl: $(kvmctl_objs)
34
$(CC) $(LDFLAGS) $^ -o $@
53
37
$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds $^
55
test/bootstrap: test/bootstrap.o
56
$(CC) -nostdlib -o $@ -Wl,-T,bootstrap.lds $^
59
40
$(CC) $(CFLAGS) -c -nostdlib -o $@ $^
61
test/irq.flat: test/print.o
63
test/access.flat: $(cstart.o) test/access.o test/printf.o test/print.o \
66
test/sieve.flat: $(cstart.o) test/sieve.o test/print.o test/vm.o
68
test/vmexit.flat: $(cstart.o) test/vmexit.o test/printf.o test/smp.o
70
test/test32.flat: test/test32.o
72
test/smp.flat: $(cstart.o) test/smp.o test/printf.o test/smptest.o
74
test/%.o: CFLAGS += -std=gnu99 -ffreestanding
79
45
$(RM) kvmctl *.o *.a .*.d
80
$(RM) test/bootstrap test/*.o test/*.flat test/.*.d