VirtualBox

source: vbox/trunk/debian/rules@ 40098

Last change on this file since 40098 was 39266, checked in by vboxsync, 13 years ago

deb: sync

  • Property svn:executable set to *
File size: 15.5 KB
Line 
1#!/usr/bin/make -f
2#
3# Copyright (C) 2006-2011 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 as published by the Free Software Foundation,
9# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
10# distribution. VirtualBox OSE is distributed in the hope that it will
11# be useful, but WITHOUT ANY WARRANTY of any kind.
12#
13
14#export DH_VERBOSE=1
15export 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# HEADLESS=1 build the headless version
30# NOWEBSVC=1 don't build the webservice API, default for OSE
31# STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
32# BLEEDING_EDGE=xyz
33
34package := virtualbox
35verpkg := virtualbox-ose
36current := $(shell pwd)
37vboxroot := $(shell pwd)
38pkgdir := ..
39builddir := $(current)/debian/builddir
40moddir := $(current)/debian/modules
41prefix := $(current)/debian/$(verpkg)
42arch := $(shell dpkg --print-architecture)
43verfile := $(builddir)/version-generated.mk
44ose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
45svnrev := 0
46NOMODS ?= $(ose)
47NOQT ?= $(HEADLESS)
48NOWEBSVC ?= $(ose)
49NOWINE := $(if $(NODOCS),$(if $(STAGEDISO),1,),)$(ose)
50
51ifneq ($(wildcard $(verfile)),)
52include $(verfile)
53ver := $(VBOX_VERSION_STRING)
54archdir := $(prefix)/opt/VirtualBox-$(ver)
55endif
56
57ifneq ($(STAGEDISO),)
58 ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
59 $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
60 endif
61endif
62
63debrel := $(if $(shell which lsb_release),_$(shell lsb_release -si)_$(shell lsb_release -sc),unknown)
64
65# shipping Linux kernel modules with bleeding-edge releases doesn't make sense
66instmod := $(if $(filter _Ubuntu_lucid _Ubuntu_maverick _Ubuntu_natty _Ubuntu_oneiric _Debian_sid,$(debrel)),,1)
67
68# Location of custom built Qt libraries (see below)
69qtstdc6 := /home/vbox/Qt-4.7.4-stdc++6-$(arch)
70
71cfg_flags := $(if $(NOQT),--disable-qt,) \
72 $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
73 $(if $(filter _Ubuntu_hardy,$(debrel)),--with-qt4-dir=$(qtstdc6)) \
74 $(if $(HEADLESS),--build-headless,) \
75 $(if $(DEBUG),--build-debug,) \
76 $(if $(NOWINE),,--setup-wine) \
77 $(if $(NOWEBSVC),,--enable-webservice)
78
79bld_flags := AUTOCFG=$(current)/debian/AutoConfig.kmk \
80 LOCALCFG=$(current)/debian/LocalConfig.kmk \
81 PATH_OUT=$(current)/debian/builddir \
82 VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
83 VBOX_DO_STRIP= \
84 VBOX_DO_STRIP_MODULES= \
85 VBOX_WITH_MULTIVERSION_PYTHON= \
86 VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\"" \
87 $(if $(ose),,VBOX_WITH_DOCS_CHM=1) \
88 VBOX_SVN_REV=$(svnrev) \
89 $(if $(NODOCS),VBOX_WITH_DOCS= ,)\
90 $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
91 $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
92 $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),) \
93 $(if $(filter _Ubuntu_hardy,$(debrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
94
95configure: debian/configure-stamp
96debian/configure-stamp:
97 dh_testdir
98 cd $(vboxroot) && ./configure --odir=$(current)/debian $(cfg_flags)
99 touch debian/configure-stamp
100
101build: debian/configure-stamp debian/build-stamp
102debian/build-stamp $(verfile):
103 dh_testdir
104 . debian/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
105 $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
106 $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
107 mkdir -p $(builddir)/bin/additions
108 $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
109 . debian/env.sh && kmk -C $(vboxroot) $(bld_flags) \
110 VBOX_NO_LINUX_RUN_INSTALLER=1 \
111 VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86-r$(svnrev).tar.bz2 \
112 VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64-r$(svnrev).tar.bz2 \
113 VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
114 VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
115 packing
116 touch debian/build-stamp
117
118# Build modules for every kernel we find in /lib/modules/*
119modules: debian/build-stamp debian/modules-stamp
120debian/modules-stamp: debian/build-stamp
121 rm -rf $(moddir)
122 mkdir $(moddir)
123 make -C $(builddir)/bin/src/vboxdrv clean
124 for d in $(wildcard /lib/modules/*); do \
125 if [ -L $$d/build ]; then \
126 make -C $(builddir)/bin/src/vboxdrv KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
127 make -j4 -C $(builddir)/bin/src/vboxdrv KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
128 $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
129 $(builddir)/bin/src/vboxdrv/vboxdrv.ko $(moddir)/$$(basename $$d)/vboxdrv.ko); \
130 make -C $(builddir)/bin/src/vboxnetflt KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
131 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetflt || true) && \
132 make -j4 -C $(builddir)/bin/src/vboxnetflt KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
133 $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
134 $(builddir)/bin/src/vboxnetflt/vboxnetflt.ko $(moddir)/$$(basename $$d)/vboxnetflt.ko); \
135 make -C $(builddir)/bin/src/vboxnetadp KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
136 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetadp || true) && \
137 make -j4 -C $(builddir)/bin/src/vboxnetadp KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
138 $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
139 $(builddir)/bin/src/vboxnetadp/vboxnetadp.ko $(moddir)/$$(basename $$d)/vboxnetadp.ko); \
140 make -C $(builddir)/bin/src/vboxpci KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
141 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxpci || true) && \
142 make -j4 -C $(builddir)/bin/src/vboxpci KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
143 $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
144 $(builddir)/bin/src/vboxpci/vboxpci.ko $(moddir)/$$(basename $$d)/vboxpci.ko); \
145 fi; \
146 done
147 make -C $(builddir)/bin/src/vboxdrv clean
148 make -C $(builddir)/bin/src/vboxnetflt clean
149 make -C $(builddir)/bin/src/vboxnetadp clean
150 make -C $(builddir)/bin/src/vboxpci clean
151 touch debian/modules-stamp
152
153clean:
154 dh_testdir
155 dh_testroot
156 rm -f debian/preinst debian/postinst debian/prerm
157 rm -f debian/$(package).init debian/vboxdrv.init
158 rm -f debian/vboxballoonctrl-service.init debian/vboxweb-service.init
159 rm -f debian/AutoConfig.kmk debian/configure.log debian/env.sh
160 rm -f debian/modules-stamp debian/build-stamp debian/configure-stamp
161 rm -f debian/virtualbox-*.substvars debian/virtualbox*.debhelper
162 rm -f debian/$(verpkg).mime
163 rm -rf $(builddir) $(moddir)
164 dh_clean
165
166ifeq ($(VBOX_VERSION_MAJOR),)
167binary binary-arch binary-indep: build $(verfile)
168 $(MAKE) -f debian/rules binary
169else
170# Build architecture-dependent files here.
171binary binary-arch binary-indep: build $(if $(NOMODS),,modules)
172 dh_testdir
173 dh_testroot
174 dh_clean -k
175 dh_installdirs
176 tar -xjC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar.bz2
177 install -d -g 0 -o 0 $(prefix)/usr/share/applications
178 install -d -g 0 -o 0 $(prefix)/usr/lib
179 install -d -g 0 -o 0 $(prefix)/usr/bin
180 install -d -g 0 -o 0 $(prefix)/usr/lib/$(package)
181 install -d -g 0 -o 0 $(prefix)/usr/share/$(package)
182 install -d -g 0 -o 0 $(prefix)/usr/share/doc/$(verpkg)
183 $(if $(NOQT),,mv $(archdir)/virtualbox.desktop \
184 $(prefix)/usr/share/applications/virtualbox.desktop)
185 install -d -g 0 -o 0 $(prefix)/usr/share/pixmaps
186 install -d -g 0 -o 0 $(prefix)/usr/share/icons/hicolor
187 cp $(archdir)/icons/128x128/virtualbox.png \
188 $(prefix)/usr/share/pixmaps/virtualbox.png
189 cd $(archdir)/icons; for i in *; do \
190 if [ -f $$i/virtualbox.png ]; then \
191 install -d -g 0 -o 0 $(prefix)/usr/share/icons/hicolor/$$i/apps; \
192 mv $$i/virtualbox.png $(prefix)/usr/share/icons/hicolor/$$i/apps; \
193 fi; \
194 install -d -g 0 -o 0 $(prefix)/usr/share/icons/hicolor/$$i/mimetypes; \
195 mv $$i/* $(prefix)/usr/share/icons/hicolor/$$i/mimetypes || true; \
196 rmdir $$i; \
197 done
198 rmdir $(archdir)/icons
199 install -d -g 0 -o 0 $(prefix)/usr/lib/$(package)/ExtensionPacks
200 mv $(archdir)/virtualbox.xml debian/$(verpkg).sharedmimeinfo
201 install -d -g 0 -o 0 $(prefix)/usr/share/lintian/overrides
202 sed \
203 -e 's|%VERPKG%|$(verpkg)|g' \
204 debian/lintian-override.in > \
205 $(prefix)/usr/share/lintian/overrides/$(verpkg)
206 mv $(archdir)/VBoxEFI32.fd $(prefix)/usr/lib/$(package)
207 mv $(archdir)/VBoxEFI64.fd $(prefix)/usr/lib/$(package)
208 mv $(archdir)/VBox.png \
209 $(prefix)/usr/share/pixmaps/VBox.png
210 mv $(archdir)/*.gc $(prefix)/usr/lib/$(package)
211 mv $(archdir)/*.r0 $(prefix)/usr/lib/$(package)
212 mv $(archdir)/*.rel $(prefix)/usr/lib/$(package) || true
213 mv $(archdir)/VBoxNetDHCP $(prefix)/usr/lib/$(package)
214 mv $(archdir)/VBoxNetAdpCtl $(prefix)/usr/lib/$(package)
215 mv $(archdir)/VBoxXPCOMIPCD $(prefix)/usr/lib/$(package)
216 mv $(archdir)/components $(prefix)/usr/lib/$(package)/components
217 mv $(archdir)/*.so $(prefix)/usr/lib/$(package)
218 mv $(archdir)/*.so.4 $(prefix)/usr/lib/$(package) || true
219 $(if $(NOQT),,mv $(archdir)/VBoxTestOGL $(prefix)/usr/lib/$(package))
220 $(if $(NOQT),,mv $(archdir)/nls $(prefix)/usr/share/$(package))
221 mv $(archdir)/src $(prefix)/usr/share/$(package)
222 rm $(archdir)/VBox.sh
223 export VBOX_INSTALL_PATH=/usr/lib/$(package) && \
224 cd ./debian/builddir/bin/sdk/installer && \
225 python ./vboxapisetup.py install --root $(prefix)
226 rm -rf $(archdir)/sdk/installer
227 mv $(archdir)/vboxshell.py $(prefix)/usr/lib/$(package)
228 mv $(archdir)/sdk $(prefix)/usr/lib/$(package)
229 install -D -g 0 -o 0 -m 644 $(vboxroot)/src/VBox/Installer/linux/debian/VBox.sh $(prefix)/usr/bin/VBox
230 mv $(archdir)/VBoxSysInfo.sh $(prefix)/usr/share/$(package)
231 mv $(archdir)/VBoxCreateUSBNode.sh $(prefix)/usr/share/$(package)
232 for i in VBoxManage VBoxSVC $(if $(HEADLESS),,VBoxSDL) \
233 $(if $(NOQT),,VirtualBox) VBoxHeadless \
234 VBoxExtPackHelperApp VBoxBalloonCtrl \
235 $(if $(NOWEBSVC),,vboxwebsrv webtest); do \
236 mv $(archdir)/$$i $(prefix)/usr/lib/$(package); done
237 mv $(archdir)/VBoxTunctl $(prefix)/usr/bin
238 $(if $(NOMODS),,for d in $(moddir)/*; do \
239 if [ -f $$d/vboxdrv.ko -a -f $$d/vboxnetflt.ko -a -f $$d/vboxnetadp.ko -a -f $$d/vboxpci.ko ]; then \
240 install -D -g 0 -o 0 -m 0644 \
241 $$d/vboxdrv.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxdrv.ko; \
242 install -D -g 0 -o 0 -m 0644 \
243 $$d/vboxnetflt.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetflt.ko; \
244 install -D -g 0 -o 0 -m 0644 \
245 $$d/vboxnetadp.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetadp.ko; \
246 install -D -g 0 -o 0 -m 0644 \
247 $$d/vboxpci.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxpci.ko; \
248 fi \
249 done)
250ifeq ($(ose),)
251 $(if $(NOQT),,mv $(archdir)/kchmviewer $(prefix)/usr/lib/$(package))
252 dh_installdocs \
253 $(archdir)/UserManual*.pdf $(archdir)/VirtualBox*.chm \
254 $(addprefix $(archdir)/, LICENSE)
255 rm $(addprefix $(archdir)/,UserManual*.pdf VirtualBox*.chm \
256 LICENSE)
257 for i in rdesktop-vrdp.tar.gz additions/VBoxGuestAdditions.iso; do \
258 mv $(archdir)/$$i $(prefix)/usr/share/$(package); done
259 $(if $(HEADLESS),,mv $(archdir)/rdesktop-vrdp $(prefix)/usr/bin)
260 $(if $(HEADLESS),,mv $(archdir)/rdesktop-vrdp-keymaps $(prefix)/usr/share/$(package))
261 if [ -d $(archdir)/accessible ]; then mv $(archdir)/accessible $(prefix)/usr/lib/virtualbox; fi
262else
263 dh_installdocs \
264 $(archdir)/UserManual*.pdf
265 rm $(addprefix $(archdir)/,UserManual*.pdf)
266 for i in additions/VBoxGuestAdditions.iso; do \
267 mv $(archdir)/$$i $(prefix)/usr/share/$(package); done
268endif
269 rmdir $(archdir)/additions
270 rmdir $(archdir)
271 rmdir $(prefix)/opt
272 dh_link \
273 $(if $(NOQT),,usr/bin/VBox usr/bin/VirtualBox) \
274 $(if $(NOQT),,usr/bin/VBox usr/bin/virtualbox) \
275 usr/bin/VBox usr/bin/VBoxManage \
276 usr/bin/VBox usr/bin/vboxmanage \
277 $(if $(HEADLESS),,usr/bin/VBox usr/bin/VBoxSDL) \
278 $(if $(HEADLESS),,usr/bin/VBox usr/bin/vboxsdl) \
279 $(if $(ose),,usr/bin/VBox usr/bin/VBoxVRDP) \
280 usr/bin/VBox usr/bin/VBoxHeadless \
281 usr/bin/VBox usr/bin/vboxheadless \
282 usr/bin/VBox usr/bin/VBoxBalloonCtrl \
283 usr/bin/VBox usr/bin/vboxballoonctrl \
284 $(if $(NOWEBSVC),,usr/bin/VBox usr/bin/vboxwebsrv) \
285 usr/share/virtualbox/src/vboxhost usr/src/vboxhost-$(ver)
286 dh_desktop
287 $(if $(NOMODS),,dh_installmodules)
288 sed \
289 -e 's|%NOLSB%||g' \
290 -e 's|%DEBIAN%|yes|g' \
291 -e 's|%PACKAGE%|virtualbox|g' \
292 -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
293 $(vboxroot)/src/VBox/Installer/linux/vboxdrv.sh.in > debian/vboxdrv.init
294 dh_installinit --name=vboxdrv --noscripts
295 sed \
296 -e 's|%NOLSB%||g' \
297 -e 's|%DEBIAN%|yes|g' \
298 -e 's|%PACKAGE%|virtualbox|g' \
299 $(vboxroot)/src/VBox/Installer/linux/vboxballoonctrl-service.sh.in > debian/vboxballoonctrl-service.init
300 dh_installinit --name=vboxballoonctrl-service --noscripts
301 sed \
302 -e 's|%NOLSB%||g' \
303 -e 's|%DEBIAN%|yes|g' \
304 -e 's|%PACKAGE%|virtualbox|g' \
305 $(vboxroot)/src/VBox/Installer/linux/vboxweb-service.sh.in > debian/vboxweb-service.init
306 dh_installinit --name=vboxweb-service --noscripts
307 sed -e 's|%VER%|$(ver)|g' \
308 debian/preinst.in > debian/preinst
309 sed -e 's|%VER%|$(ver)|g' \
310 debian/prerm.in > debian/prerm
311 sed -e 's|%VER%|$(ver)|g' \
312 -e '/#include installer-common.sh/ {' \
313 -e "r $(vboxroot)/src/VBox/Installer/linux/installer-common.sh" \
314 -e 'd' \
315 -e '}' \
316 debian/postinst.in > debian/postinst
317 dh_installdebconf
318 dh_installchangelogs
319 dh_installmenu
320 dh_installmime
321 dh_link
322ifeq ($(DEBUG),)
323 dh_strip --keep-debug --exclude=libQtCoreVBox.so.4 --exclude=libQtGuiVBox.so.4 --exclude=libQtNetworkVBox.so.4 --exclude=libQtOpenGLVBox.so.4 --exclude=libqtaccessiblewidgets.so
324 # manually strip our R0/GC modules, dh_strip cannot handle them
325 for f in \
326 $(prefix)/usr/lib/$(package)/*.r0 $(prefix)/usr/lib/$(package)/*.gc; do \
327 objcopy --only-keep-debug \
328 $$f \
329 $(prefix)/usr/lib/debug/usr/lib/$(package)/`basename $$f`; \
330 strip -S --remove-section=.comment $$f; \
331 objcopy --add-gnu-debuglink=$(prefix)/usr/lib/debug/usr/lib/$(package)/`basename $$f` $$f; \
332 done
333endif
334 mkdir -p $(current)/debian/$(verpkg)-dbg/usr/lib
335ifeq ($(DEBUG),)
336 mv $(current)/debian/$(verpkg)/usr/lib/debug $(current)/debian/$(verpkg)-dbg/usr/lib
337endif
338 dh_pycentral
339 dh_compress -X.pdf -X.chm -X LICENSE -X.py
340 dh_fixperms
341 dh_makeshlibs
342 dh_installdeb
343 dh_perl
344 dh_shlibdeps
345 dh_gencontrol -- \
346 -Valsa=$(if $(HEADLESS),,libasound2) \
347 -Vpulse=$(if $(HEADLESS),,libpulse0) \
348 -Vsdlttf=$(if $(HEADLESS),,libsdl-ttf2.0-0) \
349 -Vdkms=$(if $(filter _Debian_lenny,$(debrel)),,dkms)
350 dh_md5sums
351 dh_builddeb --destdir $(pkgdir)
352endif
353
354.PHONY: binary modules binary-arch binary-indep clean checkroot
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette