-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
153 lines (117 loc) · 4.5 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
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
-include config.mk
ifndef BLIKVM_PLATFORM
$(error Must specify BLIKVM_PLATFORM variable as one of: v1-cm4, v2-pcie, or v3-hat)
endif
ifeq ($(BLIKVM_PLATFORM),v1-cm4)
export PLATFORM = v3-hdmi
export BOARD = rpi4
export EDIDTYPE = v4mini
export SUFFIX = -box
export FAN = 1
export OLED = 1
export BLIKVM_BOARD = cm4
else ifeq ($(BLIKVM_PLATFORM),v2-pcie)
export PLATFORM = v3-hdmi
export BOARD = rpi4
export EDIDTYPE = v4mini
export SUFFIX = -box
export FAN = 1
export OLED = 1
export BLIKVM_BOARD = cm4
else ifeq ($(BLIKVM_PLATFORM),v3-hat)
export PLATFORM = v3-hdmi
export BOARD = rpi4
export EDIDTYPE = v3
export SUFFIX = -box
export FAN = 1
export OLED = 1
export BLIKVM_BOARD = rpi4
else
$(error Must specify BLIKVM_PLATFORM variable as one of: v1-cm4, v2-pcie, or v3-hat)
endif
export PROJECT ?= blikvm-pikvm-os.$(BLIKVM_PLATFORM)$(BLIKVM_SUFFIX)
export STAGES ?= __init__ os pikvm-repo pistat watchdog rootdelay ro pikvm restore-mirrorlist blikvm __cleanup__
export NC ?=
export HOSTNAME ?= pikvm
export LOCALE ?= en_US
export TIMEZONE ?= UTC
export ARCH_DIST_REPO_URL ?= https://mirrors.ocf.berkeley.edu/archlinuxarm/
export BUILD_OPTS ?=
export ROOT_PASSWD ?= root
export WEBUI_ADMIN_PASSWD ?= admin
export IPMI_ADMIN_PASSWD ?= admin
export DISK ?= $(shell pwd)/upstream_os/disk/$(word 1,$(subst -, ,$(PLATFORM))).conf
export CARD ?= /dev/null
export IMAGE_XZ ?= 1
export DEPLOY_USER ?= root
# =====
export SHELL = /usr/bin/env bash
_BUILDER_DIR = ./.pi-builder/$(BLIKVM_PLATFORM)-$(BLIKVM_BOARD)$(BLIKVM_SUFFIX)
_UPSTREAM_OS_DIR = ./upstream_os
_BLIKVM_SOURCE_DIR = $(_BUILDER_DIR)/stages/arch/blikvm_source
define optbool
$(filter $(shell echo $(1) | tr A-Z a-z),yes on 1)
endef
define fv
$(shell curl --silent "https://files.pikvm.org/repos/arch/$(BOARD)/latest/$(1)")
endef
# =====
all:
@ echo "Available commands:"
@ echo " make # Print this help"
@ echo " make os # Build OS with your default config"
@ echo " make shell # Run Arch-ARM shell"
@ echo " make install # Install rootfs to partitions on $(CARD)"
@ echo " make image # Create a binary image for burning outside of make install"
@ echo " make scan # Find all RPi devices in the local network"
@ echo " make clean # Remove the generated rootfs"
@ echo " make clean-all # Remove the generated rootfs and pi-builder toolchain"
shell: $(_BUILDER_DIR)
$(MAKE) -C $(_BUILDER_DIR) shell
os: $(_BUILDER_DIR) $(_UPSTREAM_OS_DIR) $(_BLIKVM_SOURCE_DIR)
rm -rf $(_BUILDER_DIR)/stages/arch/{pikvm,pikvm-otg-console,blikvm}
cp -a stages/arch/blikvm $(_BUILDER_DIR)/stages/arch
cp -a $(_UPSTREAM_OS_DIR)/stages/arch/{pikvm,pikvm-otg-console} $(_BUILDER_DIR)/stages/arch
$(MAKE) -C $(_BUILDER_DIR) os \
BUILD_OPTS=' $(BUILD_OPTS) \
--build-arg PLATFORM=$(PLATFORM) \
--build-arg VERSIONS=$(call fv,ustreamer)/$(call fv,kvmd)/$(call fv,kvmd-webterm)/$(call fv,kvmd-fan) \
--build-arg EDIDTYPE=$(EDIDTYPE) \
--build-arg OLED=$(call optbool,$(OLED)) \
--build-arg FAN=$(call optbool,$(FAN)) \
--build-arg ROOT_PASSWD=$(ROOT_PASSWD) \
--build-arg WEBUI_ADMIN_PASSWD=$(WEBUI_ADMIN_PASSWD) \
--build-arg IPMI_ADMIN_PASSWD=$(IPMI_ADMIN_PASSWD) \
'
$(_BUILDER_DIR):
mkdir -p `dirname $(_BUILDER_DIR)`
git clone --depth=1 https://github.com/pikvm/pi-builder $(_BUILDER_DIR)
$(_UPSTREAM_OS_DIR):
mkdir -p `dirname $(_UPSTREAM_OS_DIR)`
git clone --depth=1 https://github.com/pikvm/os $(_UPSTREAM_OS_DIR)
$(_BLIKVM_SOURCE_DIR):
mkdir -p `dirname $(_BLIKVM_SOURCE_DIR)`
git clone --depth=1 https://github.com/ThomasVon2021/blikvm $(_BLIKVM_SOURCE_DIR)
update: $(_BUILDER_DIR) $(_BLIKVM_SOURCE_DIR)
cd $(_BUILDER_DIR) && git pull --rebase
cd $(_UPSTREAM_OS_DIR) && git pull --rebase
cd $(_BLIKVM_SOURCE_DIR) && git pull --rebase
git pull --rebase
install: $(_BUILDER_DIR)
$(MAKE) -C $(_BUILDER_DIR) install
image: $(_BUILDER_DIR)
$(eval _dated := blikvm-pikvm-$(BLIKVM_PLATFORM)-$(BLIKVM_BOARD)$(BLIKVM_SUFFIX)-$(shell date +%Y%m%d).img)
mkdir -p images
$(MAKE) -C $(_BUILDER_DIR) image IMAGE=$(shell pwd)/images/$(_dated)
scan: $(_BUILDER_DIR)
$(MAKE) -C $(_BUILDER_DIR) scan
clean: $(_BUILDER_DIR)
$(MAKE) -C $(_BUILDER_DIR) clean
clean-all:
rm -rf $(_BLIKVM_SOURCE_DIR)
- rmdir `dirname $(_BLIKVM_SOURCE_DIR)`
rm -rf $(_UPSTREAM_OS_DIR)
- rmdir `dirname $(_UPSTREAM_OS_DIR)`
- $(MAKE) -C $(_BUILDER_DIR) clean-all
rm -rf $(_BUILDER_DIR)
- rmdir `dirname $(_BUILDER_DIR)`