1 # Makefile - set up a vkernel environment for testing the vkernel
4 # require it to be specified
5 SRCDIR ?
= ${.CURDIR
}/..
/..
12 scratch
: world32 kernel32 install32
13 @echo
"Run the environment with:"
14 @echo
"make VKDIR=${VKDIR} run"
16 quickw
: quickworld32 quickkernel32 reinstall32 reinstallkernel32
17 @echo
"Run the environment with:"
18 @echo
"make VKDIR=${VKDIR} run"
20 quick
: quickkernel32 reinstallkernel32
21 @echo
"Run the environment with:"
22 @echo
"make VKDIR=${VKDIR} run"
25 @echo
"Setup Instructions:"
27 @echo
" setenv VKDIR target_dir"
29 @echo
"Meta target components:"
31 @echo
" help - this help"
32 @echo
" clean - clean up"
33 @echo
" scratch - build and install everything from scratch"
34 @echo
" (this is absolutely everything)"
35 @echo
" quick - incremental kernel build & reinstall"
36 @echo
" quickw - incremental world & kernel build & reinstall"
37 @echo
" run - run vkernel with VKDIR/root.img"
38 @echo
" mount - mount VKDIR/root.img at VKDIR/root"
39 @echo
" umount - unmount"
41 @echo
"Individual target components:"
43 @echo
" world32 - build the 32 bit world from scratch"
44 @echo
" root32 - create a new, empty root.img"
45 @echo
" install32 - install a 32 bit world & kernel"
46 @echo
" into root.img"
47 @echo
" kernel32 - build 32 bit vkernel"
48 @echo
" quickworld32 - incremental rebuild world32"
49 @echo
" quickkernel32 - incremental rebuild kernel32"
50 @echo
" reinstall32 - reinstall world32 into root.img"
51 @echo
" (just the installworld piece)"
52 @echo
" reinstallkernel32 - reinstall kernel32 into root.img"
55 # Unmount everything, de-configured VN, and clean up.
56 # (check handles umounting/deconfiguring)
59 rm -rf
${VKDIR}/root.img
${VKDIR}/root
61 # Build the 32 bit world and kernel
65 cd
${SRCDIR} && make
-j
4 buildworld
68 cd
${SRCDIR} && make
-j
4 KERNCONF
=VKERNEL buildkernel
70 # Quick build - just rebuild the kernel quickly
74 cd
${SRCDIR} && make
-j
4 quickworld
77 cd
${SRCDIR} && make KERNCONF
=VKERNEL quickkernel
79 # Build and mount an empty filesystem for the emulated root disk
81 # NOTE: root32 must umount when done because a later dependency may
82 # have a dependency on mount.
85 vnconfig
-c
-T
-S
${ROOTSIZE} -s labels \
86 `cat ${VKDIR}/vn.which` ${VKDIR}/root.img
87 dd if
=/dev
/zero of
=/dev
/`cat ${VKDIR}/vn.which` bs
=32k count
=4
88 fdisk
-IB
`cat ${VKDIR}/vn.which`
89 disklabel
-r
-w
`cat ${VKDIR}/vn.which`s1 auto
90 disklabel
`cat ${VKDIR}/vn.which`s1
> ${VKDIR}/label.tmp
91 echo
'a: * 0 4.2BSD' >> ${VKDIR}/label.tmp
92 disklabel
-R
`cat ${VKDIR}/vn.which`s1
${VKDIR}/label.tmp
93 disklabel
-B
`cat ${VKDIR}/vn.which`s1
94 newfs
/dev
/`cat ${VKDIR}/vn.which`s1a
95 mkdir
-p
${VKDIR}/root
96 vnconfig
-u
`cat ${VKDIR}/vn.which` > /dev
/null
2>&1
99 vnconfig
-c
-s labels
`cat ${VKDIR}/vn.which` ${VKDIR}/root.img
100 fsck
-p
/dev
/`cat ${VKDIR}/vn.which`s1a
101 mount
/dev
/`cat ${VKDIR}/vn.which`s1a
${VKDIR}/root
102 @echo
"Mounted ${VKDIR}/root"
106 # Install a fresh 32 bit world & distribution, and kernel
110 make
-j
4 DESTDIR
=${VKDIR}/root installworld
111 cd
${SRCDIR}/etc
&& \
112 make
-j
4 DESTDIR
=${VKDIR}/root distribution
113 echo
'/dev/vkd0s1a / ufs rw 1 1' > ${VKDIR}/root
/etc
/fstab
114 echo
'proc /proc procfs rw 0 0' >> ${VKDIR}/root
/etc
/fstab
115 echo
'vfs.root.mountfrom="ufs:vkds1a"' > ${VKDIR}/root
/boot
/loader.conf
116 #(egrep -v '^console' ${VKDIR}/root/etc/ttys; echo 'console "/usr/libexec/getty Pc" cons25 on secure') > ${VKDIR}/root/etc/ttys.new
117 #mv -f ${VKDIR}/root/etc/ttys.new ${VKDIR}/root/etc/ttys
120 DESTDIR
=${VKDIR}/root KERNCONF
=VKERNEL \
123 cp
${VKDIR}/root
/boot
/kernel
${VKDIR}/vkernel
125 # Quick reinstall - just install a new kernel on top of an existing image
129 cd
${SRCDIR} && make
-j
4 DESTDIR
=${VKDIR}/root installworld
131 reinstallkernel32
: mount
133 make
-j
4 DESTDIR
=${VKDIR}/root KERNCONF
=VKERNEL \
134 NO_MODULES
= installkernel
135 cp
${VKDIR}/root
/boot
/kernel
${VKDIR}/vkernel
138 cp
/boot
/loader
${VKDIR}/root
/boot
/loader
141 # Run the vkernel on our image. Make sure we are unmounted so
142 # we do not compete against the emulated kernel when writing to root.img.
143 # (check does this for us)
146 cd
${VKDIR} && .
/vkernel
-m
${PHYSMEM} -n
${NCPUS} \
150 # When running w/ a NFS root
153 NFS_NETMASK?
= 255.255.255.0
154 NFS_ROOT_IP?
= 10.0.0.1
155 NFS_ROOT_PATH?
= /netboot2
158 cd
${VKDIR} && .
/vkernel
-m
${PHYSMEM} -n
${NCPUS} -U
-v \
160 -e
'boot.netif.ip=${NFS_IP}:boot.netif.netmask=${NFS_NETMASK}:boot.netif.name=vke0:boot.nfsroot.server=${NFS_ROOT_IP}:boot.nfsroot.path=${NFS_ROOT_PATH}'
162 # Make sure we are not mounted and the VN device is unconfigured,
164 # Find an unused VN device but do not do anything with it yet.
168 @
(echo
"must specify VKDIR=target or as an environment variable"; exit
1)
171 @echo
"${VKDIR} found"
177 .if exists
(${VKDIR}/vn.which
)
178 -umount
${VKDIR}/root
> /dev
/null
2>&1
179 -vnconfig
-u
`cat ${VKDIR}/vn.which` > /dev
/null
2>&1
180 rm -f
${VKDIR}/vn.which
182 (vnconfig
-l | fgrep
"not in use" > /dev
/null
) || \
183 (echo
"Cannot find unused VN"; exit
1)
184 vnconfig
-l | fgrep
"not in use" | \
185 cut
-f
1 -d
: | head
-1 > ${VKDIR}/vn.which
186 egrep
'^vn' ${VKDIR}/vn.which
> /dev
/null || \
187 (echo
"VN device selection is bad"; exit
1)