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 | #
|
---|
15 | # NOTE: if you make changes to this file, please check if the updates should
|
---|
16 | # be also applied to the publicly visible debian/rules file.
|
---|
17 | #
|
---|
18 |
|
---|
19 | #export DH_VERBOSE=1
|
---|
20 | export DH_COMPAT=4
|
---|
21 |
|
---|
22 | # possible overrides:
|
---|
23 | # OSE=1 force VBOX_OSE
|
---|
24 | # NOPARALLEL=1 compile with -j1
|
---|
25 | # LINUX=<dir> compile vboxdrv against Linux found in <dir>
|
---|
26 | # VERBOSE=1 verbose build
|
---|
27 | # DEBUG=1 debug build
|
---|
28 | # NOSUBVER=1 disable generation of the sub-version field (which is
|
---|
29 | # either the subversion rev [if available] or the build date)
|
---|
30 | # NODOCS=1 don't build docs, use precompiled UserManual.pdf and
|
---|
31 | # VirtualBox.chm from $HOME
|
---|
32 | # NOMODS=1 don't build any module
|
---|
33 | # NOQT=1 don't build the Qt GUI
|
---|
34 | # EFI=1 include the EFI binary from prebuild
|
---|
35 | # VERSUFFIX=<suffix> set a particular package version suffix (e.g. _customer)
|
---|
36 | # HEADLESS=1 build the headless version
|
---|
37 | # VNC=1 build VNC code
|
---|
38 | # NOWEBSVC=1 don't build the webservice API, default for OSE
|
---|
39 | # STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
|
---|
40 | # PKGDIR=<path> where to store the final package(s)
|
---|
41 | # BLEEDING_EDGE=xyz
|
---|
42 |
|
---|
43 | package := virtualbox
|
---|
44 | verpkg := virtualbox-5.0
|
---|
45 | current := $(shell pwd)
|
---|
46 | vboxroot := $(shell cd ../../../..; pwd)
|
---|
47 | pkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd ../../../../..; pwd))
|
---|
48 | builddir := $(vboxroot)/out/debian/builddir
|
---|
49 | moddir := $(vboxroot)/out/debian/modules
|
---|
50 | prefix := $(current)/debian/$(verpkg)
|
---|
51 | arch := $(shell dpkg --print-architecture)
|
---|
52 | verfile := $(builddir)/version-generated.mk
|
---|
53 | ose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
|
---|
54 | -include $(vboxroot)/SVN_REVISION
|
---|
55 | svnrev :=$(if $(svn_revision),$(svn_revision),)
|
---|
56 |
|
---|
57 | NOMODS ?= $(ose)
|
---|
58 | NOQT ?= $(HEADLESS)
|
---|
59 | NOWEBSVC ?= $(ose)
|
---|
60 | NOWINE := $(if $(NODOCS),$(if $(STAGEDISO),1,),)$(ose)
|
---|
61 |
|
---|
62 | ifneq ($(wildcard $(verfile)),)
|
---|
63 | include $(verfile)
|
---|
64 | ver := $(VBOX_VERSION_STRING)
|
---|
65 | svnver := $(if $(NOSUBVER),,$(if $(svn_revision),-$(svn_revision),$(shell if \
|
---|
66 | svn info > /dev/null 2>&1; then \
|
---|
67 | svn info|sed -e "s/^Revision: \(.*\)/-\1/;t;d"; else \
|
---|
68 | date +"-%Y%m%d"; fi)))
|
---|
69 | debver :=$(subst _ALPHA,~alpha,$(subst _BETA,~beta,$(subst _RC,~rc,$(subst _OSE,~ose,$(ver)))))$(svnver)$(if \
|
---|
70 | $(BLEEDING_EDGE),-$(BLEEDING_EDGE),)$(VERSUFFIX)$(if \
|
---|
71 | $(HEADLESS),~headless,)$(if $(DEBUG),~dbg,)
|
---|
72 | archdir := $(prefix)/opt/VirtualBox-$(ver)
|
---|
73 | endif
|
---|
74 |
|
---|
75 | ifneq ($(STAGEDISO),)
|
---|
76 | ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
|
---|
77 | $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
|
---|
78 | endif
|
---|
79 | endif
|
---|
80 |
|
---|
81 | debrel := $(if $(shell which lsb_release),_$(shell lsb_release -si)_$(shell lsb_release -sc),unknown)
|
---|
82 |
|
---|
83 | # shipping Linux kernel modules with bleeding-edge releases doesn't make sense
|
---|
84 | instmod := $(if $(filter _Ubuntu_lucid _Ubuntu_maverick _Ubuntu_natty _Ubuntu_oneiric _Debian_sid,$(debrel)),,1)
|
---|
85 |
|
---|
86 | ifneq ($(MAKECMDGOALS),clean)
|
---|
87 | debdist := $(strip $(shell grep $(debrel) $(current)/distributions_deb | cut -d'=' -f2))
|
---|
88 | ifeq ($(debdist),)
|
---|
89 | $(error package distribution not detected (debrel=$(debrel)))
|
---|
90 | endif
|
---|
91 | endif
|
---|
92 |
|
---|
93 | # Location of custom built Qt libraries (see below)
|
---|
94 | qtstdc6 := /home/vbox/Qt-4.8.6-stdc++6-$(arch)
|
---|
95 |
|
---|
96 | cfg_flags := $(if $(NOQT),--disable-qt,) \
|
---|
97 | $(if $(filter _Debian_squeeze,$(debrel)),--with-qt4-dir=$(qtstdc6)) \
|
---|
98 | $(if $(filter _Debian_squeeze,$(debrel)),--build-libvpx,) \
|
---|
99 | $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
|
---|
100 | $(if $(HEADLESS),--build-headless,) \
|
---|
101 | $(if $(DEBUG),--build-debug,) \
|
---|
102 | $(if $(NOWINE),,--setup-wine) \
|
---|
103 | $(if $(NOWEBSVC),,$(if $(ose),--enable-webservice,)) \
|
---|
104 | $(if $(VNC),--enable-vnc,) \
|
---|
105 | --disable-extpack
|
---|
106 |
|
---|
107 | bld_flags := AUTOCFG=$(current)/debian/AutoConfig.kmk \
|
---|
108 | LOCALCFG=$(current)/debian/LocalConfig.kmk \
|
---|
109 | PATH_OUT=$(builddir) \
|
---|
110 | VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
|
---|
111 | VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
|
---|
112 | $(if $(filter _Debian_squeeze _Ubuntu_lucid,$(debrel)),,VBOX_WITH_VMSVGA3D=1) \
|
---|
113 | VBOX_DO_STRIP= \
|
---|
114 | VBOX_WITH_MULTIVERSION_PYTHON= \
|
---|
115 | VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\"" \
|
---|
116 | $(if $(ose),,VBOX_WITH_DOCS_CHM=1) \
|
---|
117 | VBOX_PACKAGE_DIST=$(debdist) \
|
---|
118 | $(if $(svnrev),VBOX_SVN_REV=$(svnrev),) \
|
---|
119 | $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
|
---|
120 | $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
|
---|
121 | $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
|
---|
122 | $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),)
|
---|
123 |
|
---|
124 | configure: debian/configure-stamp
|
---|
125 | debian/configure-stamp:
|
---|
126 | dh_testdir
|
---|
127 | cd $(vboxroot) && ./configure --odir=$(current)/debian $(cfg_flags)
|
---|
128 | touch debian/configure-stamp
|
---|
129 |
|
---|
130 | build: debian/configure-stamp debian/build-stamp
|
---|
131 | debian/build-stamp $(verfile):
|
---|
132 | dh_testdir
|
---|
133 | . debian/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
|
---|
134 | $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
|
---|
135 | $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
|
---|
136 | $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
|
---|
137 | $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
|
---|
138 | mkdir -p $(builddir)/bin/additions
|
---|
139 | $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
|
---|
140 | . debian/env.sh && kmk -C $(vboxroot) $(bld_flags) \
|
---|
141 | VBOX_NO_LINUX_RUN_INSTALLER=1 \
|
---|
142 | VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86.tar.bz2 \
|
---|
143 | VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.tar.bz2 \
|
---|
144 | VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
|
---|
145 | VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
|
---|
146 | packing
|
---|
147 | touch debian/build-stamp
|
---|
148 |
|
---|
149 | # Build modules for every kernel we find in /lib/modules/*
|
---|
150 | modules: debian/build-stamp debian/modules-stamp
|
---|
151 | debian/modules-stamp: debian/build-stamp
|
---|
152 | rm -rf $(moddir)
|
---|
153 | mkdir $(moddir)
|
---|
154 | make -C $(builddir)/bin/src/vboxdrv clean
|
---|
155 | for d in $(wildcard /lib/modules/*); do \
|
---|
156 | if [ -L $$d/build ]; then \
|
---|
157 | make -C $(builddir)/bin/src/vboxdrv KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
158 | make -j4 -C $(builddir)/bin/src/vboxdrv KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
159 | $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
|
---|
160 | $(builddir)/bin/src/vboxdrv/vboxdrv.ko $(moddir)/$$(basename $$d)/vboxdrv.ko); \
|
---|
161 | make -C $(builddir)/bin/src/vboxnetflt KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
162 | (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetflt || true) && \
|
---|
163 | make -j4 -C $(builddir)/bin/src/vboxnetflt KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
164 | $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
|
---|
165 | $(builddir)/bin/src/vboxnetflt/vboxnetflt.ko $(moddir)/$$(basename $$d)/vboxnetflt.ko); \
|
---|
166 | make -C $(builddir)/bin/src/vboxnetadp KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
167 | (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetadp || true) && \
|
---|
168 | make -j4 -C $(builddir)/bin/src/vboxnetadp KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
169 | $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
|
---|
170 | $(builddir)/bin/src/vboxnetadp/vboxnetadp.ko $(moddir)/$$(basename $$d)/vboxnetadp.ko); \
|
---|
171 | make -C $(builddir)/bin/src/vboxpci KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
172 | (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxpci || true) && \
|
---|
173 | make -j4 -C $(builddir)/bin/src/vboxpci KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
174 | $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
|
---|
175 | $(builddir)/bin/src/vboxpci/vboxpci.ko $(moddir)/$$(basename $$d)/vboxpci.ko); \
|
---|
176 | fi; \
|
---|
177 | done
|
---|
178 | make -C $(builddir)/bin/src/vboxdrv clean
|
---|
179 | make -C $(builddir)/bin/src/vboxnetflt clean
|
---|
180 | make -C $(builddir)/bin/src/vboxnetadp clean
|
---|
181 | make -C $(builddir)/bin/src/vboxpci clean
|
---|
182 | touch debian/modules-stamp
|
---|
183 |
|
---|
184 | clean:
|
---|
185 | dh_testdir
|
---|
186 | dh_testroot
|
---|
187 | rm -f debian/changelog
|
---|
188 | rm -f debian/preinst debian/postinst debian/prerm
|
---|
189 | rm -f debian/$(package).init debian/vboxdrv.init
|
---|
190 | rm -f debian/vboxballoonctrl-service.init debian/vboxautostart-service.init debian/vboxweb-service.init
|
---|
191 | rm -f debian/AutoConfig.kmk debian/configure.log debian/env.sh
|
---|
192 | rm -f debian/modules-stamp debian/build-stamp debian/configure-stamp
|
---|
193 | rm -f debian/virtualbox-*.substvars debian/virtualbox*.debhelper
|
---|
194 | rm -f debian/$(verpkg).mime
|
---|
195 | rm -rf $(builddir) $(moddir)
|
---|
196 | rm -rf debian/wine.*
|
---|
197 | dh_clean
|
---|
198 |
|
---|
199 | ifeq ($(VBOX_VERSION_MAJOR),)
|
---|
200 | binary binary-arch binary-indep: build $(verfile)
|
---|
201 | $(MAKE) -f debian/rules binary
|
---|
202 | else
|
---|
203 | # Build architecture-dependent files here.
|
---|
204 | binary binary-arch binary-indep: build $(if $(NOMODS),,modules)
|
---|
205 | dh_testdir
|
---|
206 | dh_testroot
|
---|
207 | dh_clean -k
|
---|
208 | dh_installdirs
|
---|
209 | tar -xjC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar.bz2
|
---|
210 | $(if $(NOQT),,mv $(archdir)/virtualbox.xml debian/$(verpkg).sharedmimeinfo)
|
---|
211 | $(archdir)/scripts/install.sh --package $(package) --root $(prefix) \
|
---|
212 | --prefix /usr $(if $(NOQT),--no-qt) $(if $(ose),--ose) \
|
---|
213 | $(if $(HEADLESS),--headless) $(if $(NOWEBSVC),--no-web-service) \
|
---|
214 | --install-folder /lib/$(package) --no-helpers
|
---|
215 | install -d -g 0 -o 0 $(prefix)/usr/share/doc/$(verpkg)
|
---|
216 | install -d -g 0 -o 0 $(prefix)/usr/share/lintian/overrides
|
---|
217 | sed \
|
---|
218 | -e 's|%VERPKG%|$(verpkg)|g' \
|
---|
219 | debian/lintian-override.in > \
|
---|
220 | $(prefix)/usr/share/lintian/overrides/$(verpkg)
|
---|
221 | $(if $(NOMODS),,for d in $(moddir)/*; do \
|
---|
222 | if [ -f $$d/vboxdrv.ko -a -f $$d/vboxnetflt.ko -a -f $$d/vboxnetadp.ko -a -f $$d/vboxpci.ko ]; then \
|
---|
223 | install -D -g 0 -o 0 -m 0644 \
|
---|
224 | $$d/vboxdrv.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxdrv.ko; \
|
---|
225 | install -D -g 0 -o 0 -m 0644 \
|
---|
226 | $$d/vboxnetflt.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetflt.ko; \
|
---|
227 | install -D -g 0 -o 0 -m 0644 \
|
---|
228 | $$d/vboxnetadp.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetadp.ko; \
|
---|
229 | install -D -g 0 -o 0 -m 0644 \
|
---|
230 | $$d/vboxpci.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxpci.ko; \
|
---|
231 | fi \
|
---|
232 | done)
|
---|
233 | ifeq ($(ose),)
|
---|
234 | dh_installdocs \
|
---|
235 | $(archdir)/UserManual*.pdf $(archdir)/VirtualBox*.chm \
|
---|
236 | $(addprefix $(archdir)/, LICENSE)
|
---|
237 | rm $(addprefix $(archdir)/,UserManual*.pdf VirtualBox*.chm \
|
---|
238 | LICENSE)
|
---|
239 | else
|
---|
240 | dh_installdocs \
|
---|
241 | $(archdir)/UserManual*.pdf
|
---|
242 | rm $(addprefix $(archdir)/,UserManual*.pdf)
|
---|
243 | endif
|
---|
244 | mv $(archdir) $(prefix)/usr/lib/$(package)
|
---|
245 | ln -s ../VBoxVMM.so $(prefix)/usr/lib/$(package)/components/VBoxVMM.so
|
---|
246 | rmdir $(prefix)/opt
|
---|
247 | dh_desktop
|
---|
248 | $(if $(NOMODS),,dh_installmodules)
|
---|
249 | sed \
|
---|
250 | -e 's|%NOLSB%||g' \
|
---|
251 | -e 's|%DEBIAN%|yes|g' \
|
---|
252 | -e 's|%PACKAGE%|virtualbox|g' \
|
---|
253 | -e "s|%VERSION%|$(VBOX_VERSION_STRING)|g" \
|
---|
254 | -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
|
---|
255 | $(vboxroot)/src/VBox/Installer/linux/vboxdrv.sh.in > debian/vboxdrv.init
|
---|
256 | dh_installinit --name=vboxdrv --noscripts
|
---|
257 | cp $(vboxroot)/src/VBox/Installer/linux/vboxballoonctrl-service.sh debian/vboxballoonctrl-service.init
|
---|
258 | dh_installinit --name=vboxballoonctrl-service --noscripts
|
---|
259 | cp $(vboxroot)/src/VBox/Installer/linux/vboxautostart-service.sh debian/vboxautostart-service.init
|
---|
260 | dh_installinit --name=vboxautostart-service --noscripts
|
---|
261 | cp $(vboxroot)/src/VBox/Installer/linux/vboxweb-service.sh debian/vboxweb-service.init
|
---|
262 | dh_installinit --name=vboxweb-service --noscripts
|
---|
263 | sed -e 's|%VER%|$(debver)|g' \
|
---|
264 | -e 's|%DATE%|$(shell date -R)|g' \
|
---|
265 | -e 's|%DEBREL%|$(subst _,~,$(debrel))|g' \
|
---|
266 | -e 's|%VERPKG%|$(verpkg)|g' \
|
---|
267 | debian/changelog.in > debian/changelog
|
---|
268 | sed -e 's|%VER%|$(ver)|g' \
|
---|
269 | debian/preinst.in > debian/preinst
|
---|
270 | sed -e 's|%VER%|$(ver)|g' \
|
---|
271 | debian/prerm.in > debian/prerm
|
---|
272 | sed -e 's|%VER%|$(ver)|g' \
|
---|
273 | -e '/#include installer-common.sh/ {' \
|
---|
274 | -e "r $(vboxroot)/src/VBox/Installer/linux/installer-common.sh" \
|
---|
275 | -e 'd' \
|
---|
276 | -e '}' \
|
---|
277 | debian/postinst.in > debian/postinst
|
---|
278 | dh_installdebconf
|
---|
279 | dh_installchangelogs
|
---|
280 | dh_installmenu
|
---|
281 | dh_installmime
|
---|
282 | dh_link
|
---|
283 | ifeq ($(DEBUG),)
|
---|
284 | dh_strip --keep-debug --exclude=libQtCoreVBox.so.4 --exclude=libQtGuiVBox.so.4 --exclude=libQtNetworkVBox.so.4 --exclude=libQtOpenGLVBox.so.4 --exclude=libqtaccessiblewidgets.so
|
---|
285 | endif
|
---|
286 | mkdir -p $(current)/debian/$(verpkg)-dbg/usr/lib
|
---|
287 | ifeq ($(DEBUG),)
|
---|
288 | mv $(current)/debian/$(verpkg)/usr/lib/debug $(current)/debian/$(verpkg)-dbg/usr/lib
|
---|
289 | endif
|
---|
290 | $(if $(filter _Ubuntu_hardy _Ubuntu_lucid,$(debrel)),dh_pycentral,dh_python2)
|
---|
291 | dh_compress -X.pdf -X.chm -X LICENSE -X.py
|
---|
292 | dh_fixperms
|
---|
293 | dh_makeshlibs
|
---|
294 | dh_installdeb
|
---|
295 | dh_perl
|
---|
296 | # for some reason, the Qt libraries couldn't be found on newer releases (e.g. Ubuntu hardy)
|
---|
297 | LD_LIBRARY_PATH=$(prefix)/usr/lib/virtualbox dh_shlibdeps
|
---|
298 | dh_gencontrol -- \
|
---|
299 | -Valsa=$(if $(HEADLESS),,libasound2) \
|
---|
300 | -Vpulse=$(if $(HEADLESS),,libpulse0) \
|
---|
301 | -Vsdlttf=$(if $(HEADLESS),,libsdl-ttf2.0-0) \
|
---|
302 | -Vdkms=$(if $(filter _Debian_lenny,$(debrel)),,dkms)
|
---|
303 | dh_md5sums
|
---|
304 | dh_builddeb --destdir $(pkgdir) -- \
|
---|
305 | $(if $(filter _Ubuntu_lucid,$(debrel)),,-Zxz)
|
---|
306 | endif
|
---|
307 |
|
---|
308 | .PHONY: binary modules binary-arch binary-indep clean checkroot
|
---|