VirtualBox

source: vbox/trunk/debian/rules@ 36836

Last change on this file since 36836 was 36782, checked in by vboxsync, 14 years ago

deb/rpm: misc fixes and sync debian/

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