aboutsummaryrefslogtreecommitdiff
path: root/kvm/user/Makefile
blob: 02d33eb9822553eee63c052ec93512347094bf56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
include config.mak

# cc-option
# Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)

cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \
              > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)

CFLAGS = -I $(KERNELDIR)/include $(autodepend-flags) -g -fomit-frame-pointer \
	-Wall -m$(bits)
CFLAGS += $(call cc-option, -fno-stack-protector, "")
CFLAGS += $(call cc-option, -fno-stack-protector-all, "")

LDFLAGS += $(CFLAGS)

CXXFLAGS = $(autodepend-flags) 

autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d

DESTDIR = 

ifeq ($(shell uname -m), x86_64)
LIBDIR = /lib64
cstart.o = test/cstart64.o
bits = 64
ldarch = elf64-x86-64
else
LIBDIR = /lib
cstart.o = test/cstart.o
bits = 32
ldarch = elf32-i386
endif

all: kvmctl libkvm.a flatfiles

kvmctl: LDFLAGS += -pthread -lrt

kvmctl: kvmctl.o main.o

balloon_ctl: balloon_ctl.o

libkvm.a: kvmctl.o
	$(AR) rcs $@ $^

flatfiles-common = test/bootstrap test/vmexit.flat test/smp.flat

flatfiles-32 =

flatfiles-64 = test/access.flat test/irq.flat test/sieve.flat test/simple.flat test/stringio.flat test/memtest1.flat

flatfiles: $(flatfiles-common) $(flatfiles-$(bits))

install:
	install -D kvmctl.h $(DESTDIR)/$(PREFIX)/include/kvmctl.h
	install -D $(KERNELDIR)/include/linux/kvm.h \
		$(DESTDIR)/$(PREFIX)/include/linux/kvm.h
	install -D libkvm.a $(DESTDIR)/$(PREFIX)/$(LIBDIR)/libkvm.a

%.flat: %.o
	gcc $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds $^

test/bootstrap: test/bootstrap.o
	gcc -nostdlib -o $@ -Wl,-T,bootstrap.lds $^

%.o: %.S
	gcc $(CFLAGS) -c -nostdlib -o $@ $^

test/irq.flat: test/print.o

test/access.flat: $(cstart.o) test/access.o test/printf.o test/print.o \
	test/smp.o

test/sieve.flat: $(cstart.o) test/sieve.o test/print.o test/vm.o

test/vmexit.flat: $(cstart.o) test/vmexit.o test/printf.o test/smp.o

test/test32.flat: test/test32.o

test/smp.flat: $(cstart.o) test/smp.o test/printf.o test/smptest.o

test/%.o: CFLAGS += -std=gnu99 -ffreestanding

-include .*.d

clean:
	$(RM) kvmctl *.o *.a .*.d
	$(RM) test/bootstrap test/*.o test/*.flat test/.*.d