1 # Makefile - set up a vkernel environment for testing the vkernel
4 # require it to be specified
5 SRCDIR ?
= ${.CURDIR
}/..
/..
11 scratch
: world32 kernel32 install32
12 @echo
"Run the environment with:"
13 @echo
"make VKDIR=${VKDIR} run"
15 quickw
: quickworld32 quickkernel32 reinstall32 reinstallkernel32
16 @echo
"Run the environment with:"
17 @echo
"make VKDIR=${VKDIR} run"
19 quick
: quickkernel32 reinstallkernel32
20 @echo
"Run the environment with:"
21 @echo
"make VKDIR=${VKDIR} run"
24 @echo
"Setup Instructions:"
26 @echo
" setenv VKDIR target_dir"
28 @echo
"Meta target components:"
30 @echo
" help - this help"
31 @echo
" clean - clean up"
32 @echo
" scratch - build and install everything from scratch"
33 @echo
" (this is absolutely everything)"
34 @echo
" quick - incremental kernel build & reinstall"
35 @echo
" quickw - incremental world & kernel build & reinstall"
36 @echo
" run - run vkernel with VKDIR/root.img"
37 @echo
" mount - mount VKDIR/root.img at VKDIR/root"
38 @echo
" umount - unmount"
40 @echo
"Individual target components:"
42 @echo
" world32 - build the 32 bit world from scratch"
43 @echo
" root32 - create a new, empty root.img"
44 @echo
" install32 - install a 32 bit world & kernel"
45 @echo
" into root.img"
46 @echo
" kernel32 - build 32 bit vkernel"
47 @echo
" quickworld32 - incremental rebuild world32"
48 @echo
" quickkernel32 - incremental rebuild kernel32"
49 @echo
" reinstall32 - reinstall world32 into root.img"
50 @echo
" (just the installworld piece)"
51 @echo
" reinstallkernel32 - reinstall kernel32 into root.img"
54 # Unmount everything, de-configured VN, and clean up.
55 # (check handles umounting/deconfiguring)
58 rm -rf
${VKDIR}/root.img
${VKDIR}/root
60 # Build the 32 bit world and kernel
64 cd
${SRCDIR} && make
-j
4 buildworld
67 cd
${SRCDIR} && make
-j
4 KERNCONF
=VKERNEL buildkernel
69 # Quick build - just rebuild the kernel quickly
73 cd
${SRCDIR} && make
-j
4 quickworld
76 cd
${SRCDIR} && make KERNCONF
=VKERNEL quickkernel
78 # Build and mount an empty filesystem for the emulated root disk
80 # NOTE: root32 must umount when done because a later dependency may
81 # have a dependency on mount.
84 vnconfig
-c
-T
-S
${ROOTSIZE} -s labels \
85 `cat ${VKDIR}/vn.which` ${VKDIR}/root.img
86 dd if
=/dev
/zero of
=/dev
/`cat ${VKDIR}/vn.which` bs
=32k count
=4
87 fdisk
-IB
`cat ${VKDIR}/vn.which`
88 disklabel
-r
-w
`cat ${VKDIR}/vn.which`s1 auto
89 disklabel
`cat ${VKDIR}/vn.which`s1
> ${VKDIR}/label.tmp
90 echo
'a: * 0 4.2BSD' >> ${VKDIR}/label.tmp
91 disklabel
-R
`cat ${VKDIR}/vn.which`s1
${VKDIR}/label.tmp
92 disklabel
-B
`cat ${VKDIR}/vn.which`s1
93 newfs
/dev
/`cat ${VKDIR}/vn.which`s1a
94 mkdir
-p
${VKDIR}/root
95 vnconfig
-u
`cat ${VKDIR}/vn.which` > /dev
/null
2>&1
98 vnconfig
-c
-s labels
`cat ${VKDIR}/vn.which` ${VKDIR}/root.img
99 fsck
-p
/dev
/`cat ${VKDIR}/vn.which`s1a
100 mount
/dev
/`cat ${VKDIR}/vn.which`s1a
${VKDIR}/root
101 @echo
"Mounted ${VKDIR}/root"
105 # Install a fresh 32 bit world & distribution, and kernel
109 make
-j
4 DESTDIR
=${VKDIR}/root installworld
110 cd
${SRCDIR}/etc
&& \
111 make
-j
4 DESTDIR
=${VKDIR}/root distribution
112 echo
'/dev/vkd0s1a / ufs rw 1 1' > ${VKDIR}/root
/etc
/fstab
113 echo
'proc /proc procfs rw 0 0' >> ${VKDIR}/root
/etc
/fstab
114 echo
'vfs.root.mountfrom="ufs:vkds1a"' > ${VKDIR}/root
/boot
/loader.conf
115 #(egrep -v '^console' ${VKDIR}/root/etc/ttys; echo 'console "/usr/libexec/getty Pc" cons25 on secure') > ${VKDIR}/root/etc/ttys.new
116 #mv -f ${VKDIR}/root/etc/ttys.new ${VKDIR}/root/etc/ttys
119 DESTDIR
=${VKDIR}/root KERNCONF
=VKERNEL \
122 cp
${VKDIR}/root
/boot
/kernel
${VKDIR}/vkernel
124 # Quick reinstall - just install a new kernel on top of an existing image
128 cd
${SRCDIR} && make
-j
4 DESTDIR
=${VKDIR}/root installworld
130 reinstallkernel32
: mount
132 make
-j
4 DESTDIR
=${VKDIR}/root KERNCONF
=VKERNEL \
133 NO_MODULES
= installkernel
134 cp
${VKDIR}/root
/boot
/kernel
${VKDIR}/vkernel
137 cp
/boot
/loader
${VKDIR}/root
/boot
/loader
140 # Run the vkernel on our image. Make sure we are unmounted so
141 # we do not compete against the emulated kernel when writing to root.img.
142 # (check does this for us)
145 cd
${VKDIR} && .
/vkernel
-m
128m
-n
2 \
148 # -I /dev/vknet:0.0.0.0:${NETADDR}/16
150 # Make sure we are not mounted and the VN device is unconfigured,
152 # Find an unused VN device but do not do anything with it yet.
156 @
(echo
"must specify VKDIR=target or as an environment variable"; exit
1)
159 @echo
"${VKDIR} found"
165 .if exists
(${VKDIR}/vn.which
)
166 -umount
${VKDIR}/root
> /dev
/null
2>&1
167 -vnconfig
-u
`cat ${VKDIR}/vn.which` > /dev
/null
2>&1
168 rm -f
${VKDIR}/vn.which
170 (vnconfig
-l | fgrep
"not in use" > /dev
/null
) || \
171 (echo
"Cannot find unused VN"; exit
1)
172 vnconfig
-l | fgrep
"not in use" | \
173 cut
-f
1 -d
: | head
-1 > ${VKDIR}/vn.which
174 egrep
'^vn' ${VKDIR}/vn.which
> /dev
/null || \
175 (echo
"VN device selection is bad"; exit
1)