1 | #!/usr/bin/make -f
|
---|
2 | #
|
---|
3 | # Copyright (C) 2006-2012 Oracle Corporation
|
---|
4 | #
|
---|
5 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
6 | # available from http://www.virtualbox.org. This file is free software;
|
---|
7 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
8 | # General Public License (GPL) as published by the Free Software
|
---|
9 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
10 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
11 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
12 | #
|
---|
13 |
|
---|
14 | #export DH_VERBOSE=1
|
---|
15 | export DH_COMPAT=4
|
---|
16 |
|
---|
17 | # possible overrides:
|
---|
18 | # OSE=1 force VBOX_OSE
|
---|
19 | # NOPARALLEL=1 compile with -j1
|
---|
20 | # LINUX=<dir> compile vboxdrv against Linux found in <dir>
|
---|
21 | # VERBOSE=1 verbose build
|
---|
22 | # DEBUG=1 debug build
|
---|
23 | # NOSUBVER=1 disable generation of the sub-version field (which is
|
---|
24 | # either the subversion rev [if available] or the build date)
|
---|
25 | # NODOCS=1 don't build docs, use precompiled UserManual.pdf and
|
---|
26 | # VirtualBox.chm from $HOME
|
---|
27 | # NOMODS=1 don't build any module
|
---|
28 | # NOQT=1 don't build the Qt GUI
|
---|
29 | # EFI=1 include the EFI binary from prebuild
|
---|
30 | # HEADLESS=1 build the headless version
|
---|
31 | # VNC=1 build VNC code
|
---|
32 | # NOWEBSVC=1 don't build the webservice API, default for OSE
|
---|
33 | # STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
|
---|
34 | # PKGDIR=<path> where to store the final package(s)
|
---|
35 |
|
---|
36 | package := virtualbox
|
---|
37 | verpkg := virtualbox-ose
|
---|
38 | current := $(shell pwd)
|
---|
39 | vboxroot := $(shell pwd)
|
---|
40 | pkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd ..; pwd))
|
---|
41 | builddir := $(vboxroot)/out/debian/builddir
|
---|
42 | moddir := $(vboxroot)/out/debian/modules
|
---|
43 | prefix := $(current)/debian/$(verpkg)
|
---|
44 | arch := $(shell dpkg --print-architecture)
|
---|
45 | verfile := $(builddir)/version-generated.mk
|
---|
46 | ose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
|
---|
47 | NOMODS ?= $(ose)
|
---|
48 | NOQT ?= $(HEADLESS)
|
---|
49 | NOWEBSVC ?= $(ose)
|
---|
50 | NOWINE := $(if $(NODOCS),$(if $(STAGEDISO),1,),)$(ose)
|
---|
51 |
|
---|
52 | ifneq ($(wildcard $(verfile)),)
|
---|
53 | include $(verfile)
|
---|
54 | ver := $(VBOX_VERSION_STRING)
|
---|
55 | archdir := $(prefix)/opt/VirtualBox-$(ver)
|
---|
56 | endif
|
---|
57 |
|
---|
58 | ifneq ($(STAGEDISO),)
|
---|
59 | ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
|
---|
60 | $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
|
---|
61 | endif
|
---|
62 | endif
|
---|
63 |
|
---|
64 | debrel := $(if $(shell which lsb_release),_$(shell lsb_release -si)_$(shell lsb_release -sc),unknown)
|
---|
65 |
|
---|
66 | cfg_flags := $(if $(NOQT),--disable-qt,) \
|
---|
67 | $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
|
---|
68 | $(if $(HEADLESS),--build-headless,) \
|
---|
69 | $(if $(DEBUG),--build-debug,) \
|
---|
70 | $(if $(NOWINE),,--setup-wine) \
|
---|
71 | $(if $(NOWEBSVC),,$(if $(ose),--enable-webservice,)) \
|
---|
72 | $(if $(VNC),--enable-vnc,) \
|
---|
73 | --disable-extpack
|
---|
74 |
|
---|
75 | bld_flags := AUTOCFG=$(current)/debian/AutoConfig.kmk \
|
---|
76 | LOCALCFG=$(current)/debian/LocalConfig.kmk \
|
---|
77 | PATH_OUT=$(builddir) \
|
---|
78 | VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
|
---|
79 | VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
|
---|
80 | $(if $(filter _Debian_squeeze _Ubuntu_lucid,$(debrel)),,VBOX_WITH_VMSVGA3D=1) \
|
---|
81 | VBOX_DO_STRIP= \
|
---|
82 | VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\"" \
|
---|
83 | $(if $(ose),,VBOX_WITH_DOCS_CHM=1) \
|
---|
84 | $(if $(svnrev),VBOX_SVN_REV=$(svnrev),) \
|
---|
85 | $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
|
---|
86 | $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
|
---|
87 | $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,)
|
---|
88 |
|
---|
89 | configure: debian/configure-stamp
|
---|
90 | debian/configure-stamp:
|
---|
91 | dh_testdir
|
---|
92 | cd $(vboxroot) && ./configure --odir=$(current)/debian $(cfg_flags)
|
---|
93 | touch debian/configure-stamp
|
---|
94 |
|
---|
95 | build: debian/configure-stamp debian/build-stamp
|
---|
96 | debian/build-stamp $(verfile):
|
---|
97 | dh_testdir
|
---|
98 | . debian/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
|
---|
99 | $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
|
---|
100 | $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
|
---|
101 | $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
|
---|
102 | $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
|
---|
103 | mkdir -p $(builddir)/bin/additions
|
---|
104 | $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
|
---|
105 | . debian/env.sh && kmk -C $(vboxroot) $(bld_flags) \
|
---|
106 | VBOX_NO_LINUX_RUN_INSTALLER=1 \
|
---|
107 | VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86.tar.bz2 \
|
---|
108 | VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.tar.bz2 \
|
---|
109 | VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
|
---|
110 | VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
|
---|
111 | packing
|
---|
112 | touch debian/build-stamp
|
---|
113 |
|
---|
114 | # Build modules for every kernel we find in /lib/modules/*
|
---|
115 | modules: debian/build-stamp debian/modules-stamp
|
---|
116 | debian/modules-stamp: debian/build-stamp
|
---|
117 | rm -rf $(moddir)
|
---|
118 | mkdir $(moddir)
|
---|
119 | make -C $(builddir)/bin/src/vboxdrv clean
|
---|
120 | for d in $(wildcard /lib/modules/*); do \
|
---|
121 | if [ -L $$d/build ]; then \
|
---|
122 | make -C $(builddir)/bin/src/vboxdrv KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
123 | make -j4 -C $(builddir)/bin/src/vboxdrv KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
124 | make -C $(builddir)/bin/src/vboxnetflt KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
125 | (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetflt || true) && \
|
---|
126 | make -j4 -C $(builddir)/bin/src/vboxnetflt KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
127 | make -C $(builddir)/bin/src/vboxnetadp KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
128 | (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetadp || true) && \
|
---|
129 | make -j4 -C $(builddir)/bin/src/vboxnetadp KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
130 | make -C $(builddir)/bin/src/vboxpci KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
131 | (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxpci || true) && \
|
---|
132 | make -j4 -C $(builddir)/bin/src/vboxpci KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
133 | fi; \
|
---|
134 | done
|
---|
135 | make -C $(builddir)/bin/src/vboxdrv clean
|
---|
136 | make -C $(builddir)/bin/src/vboxnetflt clean
|
---|
137 | make -C $(builddir)/bin/src/vboxnetadp clean
|
---|
138 | make -C $(builddir)/bin/src/vboxpci clean
|
---|
139 | touch debian/modules-stamp
|
---|
140 |
|
---|
141 | clean:
|
---|
142 | dh_testdir
|
---|
143 | dh_testroot
|
---|
144 | rm -f debian/preinst debian/postinst debian/prerm
|
---|
145 | rm -f debian/$(package).init debian/vboxdrv.init
|
---|
146 | rm -f debian/vboxballoonctrl-service.init debian/vboxautostart-service.init debian/vboxweb-service.init
|
---|
147 | rm -f debian/AutoConfig.kmk debian/configure.log debian/env.sh
|
---|
148 | rm -f debian/modules-stamp debian/build-stamp debian/configure-stamp
|
---|
149 | rm -f debian/virtualbox-*.substvars debian/virtualbox*.debhelper
|
---|
150 | rm -f debian/$(verpkg).mime
|
---|
151 | rm -rf $(builddir) $(moddir)
|
---|
152 | rm -rf debian/wine.*
|
---|
153 | dh_clean
|
---|
154 |
|
---|
155 | ifeq ($(VBOX_VERSION_MAJOR),)
|
---|
156 | binary binary-arch binary-indep: build $(verfile)
|
---|
157 | $(MAKE) -f debian/rules binary
|
---|
158 | else
|
---|
159 | # Build architecture-dependent files here.
|
---|
160 | binary binary-arch binary-indep: build $(if $(NOMODS),,modules)
|
---|
161 | dh_testdir
|
---|
162 | dh_testroot
|
---|
163 | dh_clean -k
|
---|
164 | dh_installdirs
|
---|
165 | tar -xC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar
|
---|
166 | $(if $(NOQT),,mv $(archdir)/virtualbox.xml debian/$(verpkg).sharedmimeinfo)
|
---|
167 | $(archdir)/scripts/install.sh --package $(package) --root $(prefix) \
|
---|
168 | --prefix /usr $(if $(NOQT),--no-qt) $(if $(ose),--ose) \
|
---|
169 | $(if $(HEADLESS),--headless) $(if $(NOWEBSVC),--no-web-service) \
|
---|
170 | --install-folder /lib/$(package) --no-helpers
|
---|
171 | install -d -g 0 -o 0 $(prefix)/usr/share/doc/$(verpkg)
|
---|
172 | install -d -g 0 -o 0 $(prefix)/usr/share/lintian/overrides
|
---|
173 | sed \
|
---|
174 | -e 's|%VERPKG%|$(verpkg)|g' \
|
---|
175 | debian/lintian-override.in > \
|
---|
176 | $(prefix)/usr/share/lintian/overrides/$(verpkg)
|
---|
177 | $(if $(NOMODS),,for d in $(moddir)/*; do \
|
---|
178 | if [ -f $$d/vboxdrv.ko -a -f $$d/vboxnetflt.ko -a -f $$d/vboxnetadp.ko -a -f $$d/vboxpci.ko ]; then \
|
---|
179 | install -D -g 0 -o 0 -m 0644 \
|
---|
180 | $$d/vboxdrv.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxdrv.ko; \
|
---|
181 | install -D -g 0 -o 0 -m 0644 \
|
---|
182 | $$d/vboxnetflt.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetflt.ko; \
|
---|
183 | install -D -g 0 -o 0 -m 0644 \
|
---|
184 | $$d/vboxnetadp.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetadp.ko; \
|
---|
185 | install -D -g 0 -o 0 -m 0644 \
|
---|
186 | $$d/vboxpci.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxpci.ko; \
|
---|
187 | fi \
|
---|
188 | done)
|
---|
189 | ifeq ($(ose),)
|
---|
190 | dh_installdocs \
|
---|
191 | $(archdir)/UserManual*.pdf $(archdir)/VirtualBox*.chm \
|
---|
192 | $(addprefix $(archdir)/, LICENSE)
|
---|
193 | rm $(addprefix $(archdir)/,UserManual*.pdf VirtualBox*.chm \
|
---|
194 | LICENSE)
|
---|
195 | else
|
---|
196 | dh_installdocs \
|
---|
197 | $(archdir)/UserManual*.pdf
|
---|
198 | rm $(addprefix $(archdir)/,UserManual*.pdf)
|
---|
199 | endif
|
---|
200 | mv $(archdir) $(prefix)/usr/lib/$(package)
|
---|
201 | ln -s ../VBoxVMM.so $(prefix)/usr/lib/$(package)/components/VBoxVMM.so
|
---|
202 | rmdir $(prefix)/opt
|
---|
203 | $(if $(NOMODS),,dh_installmodules)
|
---|
204 | sed \
|
---|
205 | -e 's|%NOLSB%||g' \
|
---|
206 | -e 's|%DEBIAN%|yes|g' \
|
---|
207 | -e 's|%PACKAGE%|virtualbox|g' \
|
---|
208 | -e "s|%VERSION%|$(VBOX_VERSION_STRING)|g" \
|
---|
209 | -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
|
---|
210 | $(vboxroot)/src/VBox/Installer/linux/vboxdrv.sh.in > debian/vboxdrv.init
|
---|
211 | dh_installinit --name=vboxdrv --noscripts
|
---|
212 | cp $(vboxroot)/src/VBox/Installer/linux/vboxballoonctrl-service.sh debian/vboxballoonctrl-service.init
|
---|
213 | dh_installinit --name=vboxballoonctrl-service --noscripts
|
---|
214 | cp $(vboxroot)/src/VBox/Installer/linux/vboxautostart-service.sh debian/vboxautostart-service.init
|
---|
215 | dh_installinit --name=vboxautostart-service --noscripts
|
---|
216 | cp $(vboxroot)/src/VBox/Installer/linux/vboxweb-service.sh debian/vboxweb-service.init
|
---|
217 | dh_installinit --name=vboxweb-service --noscripts
|
---|
218 | sed -e 's|%VER%|$(ver)|g' \
|
---|
219 | debian/preinst.in > debian/preinst
|
---|
220 | sed -e 's|%VER%|$(ver)|g' \
|
---|
221 | debian/prerm.in > debian/prerm
|
---|
222 | sed -e 's|%VER%|$(ver)|g' \
|
---|
223 | -e '/#include installer-common.sh/ {' \
|
---|
224 | -e "r $(vboxroot)/src/VBox/Installer/linux/installer-common.sh" \
|
---|
225 | -e 'd' \
|
---|
226 | -e '}' \
|
---|
227 | debian/postinst.in > debian/postinst
|
---|
228 | dh_installdebconf
|
---|
229 | dh_installchangelogs
|
---|
230 | dh_installmenu
|
---|
231 | dh_installmime
|
---|
232 | dh_link
|
---|
233 | ifeq ($(DEBUG),)
|
---|
234 | dh_strip --keep-debug \
|
---|
235 | $(addprefix --exclude=lib,$(addsuffix VBox.so.5,\
|
---|
236 | Qt5Core Qt5Gui Qt5Widgets Qt5PrintSupport Qt5OpenGL Qt5DBus Qt5XcbQpa Qt5X11Extras)) \
|
---|
237 | --exclude=libqxcb.so
|
---|
238 | endif
|
---|
239 | mkdir -p $(current)/debian/$(verpkg)-dbg/usr/lib
|
---|
240 | ifeq ($(DEBUG),)
|
---|
241 | mv $(current)/debian/$(verpkg)/usr/lib/debug $(current)/debian/$(verpkg)-dbg/usr/lib
|
---|
242 | endif
|
---|
243 | $(firstword $(shell which dh_python2) $(shell which dh_python3))
|
---|
244 | dh_compress -X.pdf -X.chm -X LICENSE -X.py
|
---|
245 | dh_fixperms
|
---|
246 | dh_makeshlibs
|
---|
247 | dh_installdeb
|
---|
248 | dh_perl
|
---|
249 | LD_LIBRARY_PATH=$(prefix)/usr/lib/virtualbox dh_shlibdeps
|
---|
250 | dh_gencontrol -- \
|
---|
251 | -Valsa=$(if $(HEADLESS),,libasound2) \
|
---|
252 | -Vpulse=$(if $(HEADLESS),,libpulse0) \
|
---|
253 | -Vsdlttf=$(if $(HEADLESS),,libsdl-ttf2.0-0)
|
---|
254 | dh_md5sums
|
---|
255 | dh_builddeb --destdir $(pkgdir) -- -Zxz
|
---|
256 | endif
|
---|
257 |
|
---|
258 | .PHONY: binary modules binary-arch binary-indep clean checkroot
|
---|