VirtualBox

source: vbox/trunk/src/VBox/Installer/linux/debian/rules@ 35650

Last change on this file since 35650 was 35230, checked in by vboxsync, 14 years ago

deb/rpm: adaptions to r69058

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