-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
174 lines (146 loc) · 4.34 KB
/
Copy pathMakefile
File metadata and controls
174 lines (146 loc) · 4.34 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#
# Define WERROR=0 to disable -Werror.
#
ifeq ($(strip $(V)),)
ifeq ($(findstring s,$(filter-out --%,$(firstword $(MAKEFLAGS)))),)
E = @echo
else
E = @\#
endif
Q = @
else
E = @\#
Q =
endif
export E Q
CC := $(CROSS_COMPILE)gcc
CFLAGS :=
LD := $(CROSS_COMPILE)ld
LDFLAGS :=
OBJCOPY := $(CROSS_COMPILE)objcopy
# Translate uname -m into ARCH string
ARCH ?= $(shell uname -m | sed -e s/i.86/i386/ -e s/ppc.*/powerpc/ \
-e s/armv.*/arm/ -e s/aarch64.*/arm64/ -e s/mips64/mips/ \
-e s/riscv64/riscv/ -e s/riscv32/riscv/)
ifeq ($(ARCH),i386)
override ARCH = x86
DEFINES += -DCONFIG_X86_32
endif
ifeq ($(ARCH),x86_64)
override ARCH = x86
DEFINES += -DCONFIG_X86_64
endif
### Arch-specific stuff
#x86
ifeq ($(ARCH),x86)
DEFINES += -DCONFIG_X86
ARCH_INCLUDE := x86/include
endif
# POWER/ppc: Actually only support ppc64 currently.
ifeq ($(ARCH), powerpc)
DEFINES += -DCONFIG_PPC
ARCH_INCLUDE := powerpc/include
endif
# ARM64
ifeq ($(ARCH), arm64)
DEFINES += -DCONFIG_ARM64
ARCH_INCLUDE := arm64/include
endif
ifeq ($(ARCH),mips)
DEFINES += -DCONFIG_MIPS
ARCH_INCLUDE := mips/include
endif
# RISC-V (RV32 and RV64)
ifeq ($(ARCH),riscv)
DEFINES += -DCONFIG_RISCV
ARCH_INCLUDE := riscv/include
ifeq ($(RISCV_XLEN),32)
CFLAGS += -mabi=ilp32d -march=rv32gc
endif
ifeq ($(RISCV_XLEN),64)
CFLAGS += -mabi=lp64d -march=rv64gc
endif
endif
###
ifeq (,$(ARCH_INCLUDE))
$(error This architecture ($(ARCH)) is not supported in kvmtool)
endif
DEFINES += -D_FILE_OFFSET_BITS=64
DEFINES += -D_GNU_SOURCE
DEFINES += -DKVMTOOLS_VERSION='"$(KVMTOOLS_VERSION)"'
DEFINES += -DBUILD_ARCH='"$(ARCH)"'
KVM_INCLUDE := include
CFLAGS += $(CPPFLAGS) $(DEFINES) -I$(KVM_INCLUDE) -I$(ARCH_INCLUDE) -O2 -fno-strict-aliasing -g
WARNINGS += -Wall
WARNINGS += -Wformat=2
WARNINGS += -Winit-self
WARNINGS += -Wmissing-declarations
WARNINGS += -Wmissing-prototypes
WARNINGS += -Wnested-externs
WARNINGS += -Wno-system-headers
WARNINGS += -Wold-style-definition
WARNINGS += -Wredundant-decls
WARNINGS += -Wsign-compare
WARNINGS += -Wstrict-prototypes
WARNINGS += -Wundef
WARNINGS += -Wvolatile-register-var
WARNINGS += -Wwrite-strings
WARNINGS += -Wno-format-nonliteral
CFLAGS += $(WARNINGS)
ifneq ($(WERROR),0)
CFLAGS += -Werror
endif
#
# BIOS assembly weirdness
#
BIOS_CFLAGS += -m32
BIOS_CFLAGS += -march=i386
BIOS_CFLAGS += -mregparm=3
BIOS_CFLAGS += -fno-stack-protector
BIOS_CFLAGS += -fno-pic
x86/bios.o: x86/bios/bios.bin x86/bios/bios-rom.h
x86/bios/bios.bin.elf: x86/bios/entry.S x86/bios/e820.c x86/bios/int10.c x86/bios/int15.c x86/bios/rom.ld.S
$(E) " CC x86/bios/memcpy.o"
$(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c x86/bios/memcpy.c -o x86/bios/memcpy.o
$(E) " CC x86/bios/e820.o"
$(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c x86/bios/e820.c -o x86/bios/e820.o
$(E) " CC x86/bios/int10.o"
$(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c x86/bios/int10.c -o x86/bios/int10.o
$(E) " CC x86/bios/int15.o"
$(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c x86/bios/int15.c -o x86/bios/int15.o
$(E) " CC x86/bios/entry.o"
$(Q) $(CC) $(CFLAGS) $(BIOS_CFLAGS) -c x86/bios/entry.S -o x86/bios/entry.o
$(E) " LD " $@
$(Q) $(LD) -T x86/bios/rom.ld.S -o x86/bios/bios.bin.elf x86/bios/memcpy.o x86/bios/entry.o x86/bios/e820.o x86/bios/int10.o x86/bios/int15.o
x86/bios/bios.bin: x86/bios/bios.bin.elf
$(E) " OBJCOPY " $@
$(Q) $(OBJCOPY) -O binary -j .text x86/bios/bios.bin.elf x86/bios/bios.bin
x86/bios/bios-rom.o: x86/bios/bios-rom.S x86/bios/bios.bin x86/bios/bios-rom.h
$(E) " CC " $@
$(Q) $(CC) -c $(CFLAGS) x86/bios/bios-rom.S -o x86/bios/bios-rom.o
x86/bios/bios-rom.h: x86/bios/bios.bin.elf
$(E) " NM " $@
$(Q) cd x86/bios && sh gen-offsets.sh > bios-rom.h && cd ..
clean:
$(E) " CLEAN"
$(Q) rm -f x86/bios/*.bin
$(Q) rm -f x86/bios/*.elf
$(Q) rm -f x86/bios/*.o
$(Q) rm -f x86/bios/bios-rom.h
$(Q) rm -f guest/init
$(Q) rm -rf tmp/rootfs
.PHONY: clean
.PHONY: agent
agent:
CGO_ENABLED=0 go build -o bin/init -ldflags="-s -w" ./cmd/agent
tmp/rootfs:
mkdir -p tmp/rootfs
docker export $$(docker create busybox) | tar -C tmp/rootfs -xvf -
.PHONY: gkvm
gkvm: x86/bios/bios-rom.h x86/bios/bios.bin
go build -o bin/gkvm ./cmd/gkvm
.PHONY: shim
shim:
go build -o bin/containerd-shim-gkvm-v1 ./cmd/containerd-shim-gkvm-v1
.PHONY: all
all: gkvm shim agent