-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile
80 lines (63 loc) · 1.51 KB
/
Makefile
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
include mk/common.mk
ARCH ?= $(shell uname -m)
PWD ?= $(shell pwd)
CC ?= gcc
CFLAGS = -O2
CFLAGS += -Wall -std=gnu99
CFLAGS += -I$(PWD)/src
CFLAGS += -g
LDFLAGS = -lpthread
OUT ?= build
BIN = $(OUT)/kvm-host
all: $(BIN)
FDT_OBJS := \
dtc/libfdt/fdt.o \
dtc/libfdt/fdt_sw.o \
dtc/libfdt/fdt_strerror.o
FDT_CFLAGS := -Isrc/dtc/libfdt
OBJS := \
vm.o \
serial.o \
bus.o \
pci.o \
virtio-pci.o \
virtq.o \
virtio-blk.o \
virtio-net.o \
diskimg.o \
main.o
ifeq ($(ARCH), x86_64)
CFLAGS += -I$(PWD)/src/arch/x86
CFLAGS += -include src/arch/x86/desc.h
OBJS += arch/x86/vm.o
endif
ifeq ($(ARCH), aarch64)
CFLAGS += -I$(PWD)/src/arch/arm64
CFLAGS += -include src/arch/arm64/desc.h
CFLAGS += $(FDT_CFLAGS)
OBJS += arch/arm64/vm.o
OBJS += $(FDT_OBJS)
endif
OBJS := $(addprefix $(OUT)/,$(OBJS))
deps := $(OBJS:%.o=%.o.d)
$(BIN): $(OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LDFLAGS)
$(OUT)/%.o: src/%.c
$(Q)mkdir -p $(shell dirname $@)
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) -c -MMD -MF [email protected] $<
# Rules for downloading and building the minimal Linux system
include mk/external.mk
$(OUT)/ext4.img:
$(Q)dd if=/dev/zero of=$@ bs=4k count=600
$(Q)mkfs.ext4 -F $@
check: $(BIN) $(LINUX_IMG) $(ROOTFS_IMG) $(OUT)/ext4.img
$(VECHO) "\nOnce the message 'Kernel panic' appears, press Ctrl-C to exit\n\n"
$(Q)sudo $(BIN) -k $(LINUX_IMG) -i $(ROOTFS_IMG) -d $(OUT)/ext4.img
clean:
$(VECHO) "Cleaning...\n"
$(Q)rm -f $(OBJS) $(deps) $(BIN)
distclean: clean
$(Q)rm -rf build
-include $(deps)