-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
104 lines (88 loc) · 3.28 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
## If you need to set any of these, always set them when calling make.
# Set this if your ports dir is in a different place.
PORTSDIR?= ${.CURDIR}/../freebsd-ports
# Set this if e.g. you want to test against virtualbox-ose instead
PORTDIR?= virtualbox-ose-additions
# Specify the location of your FreeBSD sources, if needed -- for more
# details see mount_vboxfs/Makefile, where this is actually used:
FREEBSD_SRC?= ${.CURDIR}/../freebsd
# Build invariants.
PORTPATH= ${PORTSDIR}/emulators/${PORTDIR}
MAINPORTPATH= ${PORTSDIR}/emulators/virtualbox-ose
ADDITIONS= src/VBox/Additions/freebsd
VBOXVFS= ${ADDITIONS}/vboxvfs
# Set up the system. This configures the ports, installs mount_vboxfs, and
# finally installs the dependencies required to build the port, from packages.
# This is primarily intended to speed up setup.
#
# NB: Most dependencies are for the main port, not the -additions port.
# Install them anyway since testing will also need to be done on it.
syssetup:
mkdir -p /var/db/ports/emulators_virtualbox-ose \
/var/db/ports/emulators_virtualbox-ose-additions
pwd
cp -f ${.CURDIR}/main.options \
/var/db/ports/emulators_virtualbox-ose/options
cp -f ${.CURDIR}/additions.options \
/var/db/ports/emulators_virtualbox-ose-additions/options
pkg install -y \
expat \
gcc \
kBuild \
pkgconf \
python \
yasm
PORTMAKE= ${MAKE} SRC_BASE=${FREEBSD_SRC} BATCH=1 \
PATCH_DEBUG=1
# Set up the port directory so we can make changes here and have them be
# reflected in the port. The port just serves as a scaffolding to do the
# full build, since this repository only has the work in progress code.
#
# Only do this step after syssetup is done.
portsetup:
cp -f ${.CURDIR}/patch-* ${MAINPORTPATH}/files
cd ${PORTPATH} && sudo ${PORTMAKE} clean && ${PORTMAKE} patch && \
cp -R ${.CURDIR}/vboxvfs/ `${MAKE} -V WRKSRC`/${VBOXVFS} && \
${PORTMAKE} build
# Re-run the port build, if needed.
portbuild:
cd ${PORTPATH} && \
rm -f `${MAKE} -V WRKDIR`/.build_done* && \
${PORTMAKE} build
portinstall:
cd ${PORTPATH} && rm -f `${MAKE} -V WRKDIR`/.{stage,install}_done* && \
${PORTMAKE} deinstall install
# (Re-)Generate the cscope database, storing them in the source directory.
# This will include all of the relevant VirtualBox source code and headers.
cscope:
cd ${PORTPATH} && WRKSRC=`${MAKE} -V WRKSRC` && \
mkdir -p .cscope && cd .cscope && \
cscope -bRq -s $$WRKSRC/src -s $$WRKSRC/include && \
mv cscope.* ${.CURDIR}
# Do the build. Only do this step after portsetup is done.
build:
${MAKE} -C ${.CURDIR}/mount_vboxfs clean obj depend all
cd ${PORTPATH} && \
WRKSRC=`make -V WRKSRC` && \
cp -R ${.CURDIR}/vboxvfs/ $$WRKSRC/${VBOXVFS} && \
cd $$WRKSRC/${VBOXVFS} && kmk BUILD_TYPE=debug
# Load the module from the build.
ADDITIONS_KLDS= ./out/freebsd.amd64/debug/bin/additions
KLDS= ${ADDITIONS_KLDS}/vboxguest.ko \
${ADDITIONS_KLDS}/vboxvfs.ko
install:
${MAKE} -C ${.CURDIR}/mount_vboxfs install
cd `${MAKE} -C ${PORTPATH} -V WRKSRC` && \
cp ${KLDS} /boot/modules && sync -a && sync -a && sync -a
kldload: install
kldload vboxvfs
portenv:
-cd `${MAKE} -C ${PORTPATH} -V WRKSRC` && /bin/sh
testmount:
/sbin/mount_vboxfs test0 /mnt
# Unload the module, for completeness' sake.
kldunload:
-kldunload vboxvfs
-service vboxservice stop
-service vboxguest stop
-kldunload vboxguest