forked from PFLab-OS/Raph_Kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (86 loc) · 3.01 KB
/
Makefile
File metadata and controls
103 lines (86 loc) · 3.01 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
include common.mk
ARCH ?= hw/x86
export ARCH
VNC_PORT = 15900
VDI = disk.vdi
UNAME = ${shell uname}
ifeq ($(OS),Windows_NT)
define vnc
@echo Windows is not supported; exit 1
endef
else ifeq ($(UNAME),Linux)
define vnc
@echo open with VNC Viewer.
@echo Please install it in advance.
vncviewer localhost::$(VNC_PORT)
endef
else ifeq ($(UNAME),Darwin)
define vnc
@echo open with the default VNC viewer.
open vnc://localhost:$(VNC_PORT)
endef
else
define vnc
@echo non supported OS; exit 1
endef
endif
CHECK_REMOTE = ssh -F .ssh_config default "exit"
define check_guest
$(if $(shell if [ -e /etc/bootstrapped ]; then echo "guest"; fi), \
@echo "error: run this command on the host environment."; exit 1)
endef
define run_remote
$(if $(shell (($(CHECK_REMOTE)) & (for i in `seq 0 3`; do sleep 1 ; ps $$! > /dev/null 2>&1 || exit 0 ; done; kill -9 $$! ; exit 1 ) && ($(CHECK_REMOTE))) || echo "no-guest"),
rm -f .ssh_config
vagrant halt
vagrant up
vagrant ssh-config > .ssh_config; )
ssh -F .ssh_config default "$(1)"
endef
define make_wrapper
$(if $(shell if [ -e /etc/bootstrapped ]; then echo "guest"; fi), \
# guest environment
cd /vagrant/source/kernel/arch/$(ARCH); $(MAKE) ARCH=$(ARCH) -f $(BUILD_RULE_FILE) $(1), \
# host environment
$(call run_remote, cd /vagrant/source/kernel/arch/$(ARCH); env MAKEFLAGS=$(MAKEFLAGS) make ARCH=$(ARCH) -f $(BUILD_RULE_FILE) $(1))
)
endef
default:
$(call make_wrapper, all)
.PHONY: vnc debug vboxrun vboxkill run_pxeserver pxeimg burn_ipxe burn_ipxe_remote
vnc:
$(call check_guest)
@echo info: vnc password is "a"
$(call vnc)
debug:
vagrant ssh -c "cd /vagrant/; gdb -x .gdbinit_for_kernel"
vboxrun: vboxkill
$(call make_wrapper, cpimage)
-vboxmanage unregistervm RK_Test --delete
-rm $(VDI)
vboxmanage createvm --name RK_Test --register
vboxmanage modifyvm RK_Test --cpus 4 --ioapic on --chipset ich9 --hpet on --x2apic on --nic1 nat --nictype1 82540EM --firmware efi
vboxmanage convertfromraw $(IMAGEFILE) $(VDI)
vboxmanage storagectl RK_Test --name SATAController --add sata --controller IntelAHCI --bootable on
vboxmanage storageattach RK_Test --storagectl SATAController --port 0 --device 0 --type hdd --medium disk.vdi
vboxmanage startvm RK_Test --type gui
vboxkill:
-vboxmanage controlvm RK_Test poweroff
run_pxeserver:
make pxeimg
@echo info: allow port 8080 in your firewall settings
cd net; python -m SimpleHTTPServer 8080
pxeimg:
$(call make_wrapper, cpimage)
gzip $(IMAGEFILE)
mv $(IMAGEFILE).gz net/
burn_ipxe:
$(call check_guest)
./lan.sh local
$(call run_remote, cd ipxe/src; make bin-x86_64-pcbios/ipxe.usb EMBED=/vagrant/load.cfg; if [ ! -e /dev/sdb ]; then echo 'error: insert usb memory!'; exit -1; fi; sudo dd if=bin-x86_64-pcbios/ipxe.usb of=/dev/sdb)
burn_ipxe_remote:
$(call check_guest)
./lan.sh remote
$(call run_remote, cd ipxe/src; make bin-x86_64-pcbios/ipxe.usb EMBED=/vagrant/load.cfg; if [ ! -e /dev/sdb ]; then echo 'error: insert usb memory!'; exit -1; fi; sudo dd if=bin-x86_64-pcbios/ipxe.usb of=/dev/sdb)
%:
$(call make_wrapper, $@)