VirtualBox

source: vbox/trunk/debian/rules@ 35951

Last change on this file since 35951 was 34682, checked in by vboxsync, 14 years ago

deb/rpm: create the ExtensionPacks directory; fix the convenionce lower-case symlinks

  • Property svn:executable set to *
File size: 14.0 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#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 _Debian_sid,$(debrel)),,1)
67
68# Locations of custom built Qt libraries (see below)
69qtstdc5 := /home/vbox/Qt-4.4.3-stdc++5-$(arch)
70qtstdc6 := /home/vbox/Qt-4.4.3-stdc++6-$(arch)
71
72cfg_flags := $(if $(NOQT),--disable-qt,) \
73 $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
74 $(if $(filter _Debian_etch,$(debrel)),$(if $(ose),,--build-libcurl),) \
75 $(if $(filter _Debian_etch _Ubuntu_hardy,$(debrel)),--with-qt4-dir=$(qtstdc6)) \
76 $(if $(HEADLESS),--build-headless,) \
77 $(if $(DEBUG),--build-debug,) \
78 $(if $(NOWINE),,--setup-wine) \
79 $(if $(NOWEBSVC),,--enable-webservice)
80
81bld_flags := AUTOCFG=$(current)/debian/AutoConfig.kmk \
82 LOCALCFG=$(current)/debian/LocalConfig.kmk \
83 PATH_OUT=$(current)/debian/builddir \
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 debian/vboxweb-service.init
153 rm -f debian/AutoConfig.kmk debian/configure.log debian/env.sh
154 rm -f debian/modules-stamp debian/build-stamp debian/configure-stamp
155 rm -f debian/virtualbox-*.substvars debian/virtualbox*.debhelper
156 rm -f debian/$(verpkg).mime
157 rm -rf $(builddir) $(moddir)
158 dh_clean
159
160ifeq ($(VBOX_VERSION_MAJOR),)
161binary binary-arch binary-indep: build $(verfile)
162 $(MAKE) -f debian/rules binary
163else
164# Build architecture-dependent files here.
165binary binary-arch binary-indep: build $(if $(NOMODS),,modules)
166 dh_testdir
167 dh_testroot
168 dh_clean -k
169 dh_installdirs
170 tar -xjC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar.bz2
171 install -d -g 0 -o 0 $(prefix)/usr/share/applications
172 install -d -g 0 -o 0 $(prefix)/usr/lib
173 install -d -g 0 -o 0 $(prefix)/usr/bin
174 install -d -g 0 -o 0 $(prefix)/usr/lib/$(package)
175 install -d -g 0 -o 0 $(prefix)/usr/share/$(package)
176 install -d -g 0 -o 0 $(prefix)/usr/share/doc/$(verpkg)
177 $(if $(NOQT),,mv $(archdir)/virtualbox.desktop \
178 $(prefix)/usr/share/applications/virtualbox.desktop)
179 install -d -g 0 -o 0 $(prefix)/usr/share/pixmaps
180 install -d -g 0 -o 0 $(prefix)/usr/share/icons/hicolor
181 cd $(archdir)/icons; for i in *; do \
182 install -d -g 0 -o 0 $(prefix)/usr/share/icons/hicolor/$$i/mimetypes; \
183 mv $$i/* $(prefix)/usr/share/icons/hicolor/$$i/mimetypes; \
184 rmdir $$i; \
185 done
186 rmdir $(archdir)/icons
187 install -d -g 0 -o 0 $(prefix)/usr/lib/$(package)/ExtensionPacks
188 mv $(archdir)/virtualbox.xml debian/$(verpkg).sharedmimeinfo
189 install -d -g 0 -o 0 $(prefix)/usr/share/lintian/overrides
190 sed \
191 -e 's|%VERPKG%|$(verpkg)|g' \
192 debian/lintian-override.in > \
193 $(prefix)/usr/share/lintian/overrides/$(verpkg)
194 mv $(archdir)/VBoxEFI32.fd $(prefix)/usr/lib/$(package)
195 mv $(archdir)/VBoxEFI64.fd $(prefix)/usr/lib/$(package)
196 mv $(archdir)/VBox.png \
197 $(prefix)/usr/share/pixmaps/VBox.png
198 mv $(archdir)/*.gc $(prefix)/usr/lib/$(package)
199 mv $(archdir)/*.r0 $(prefix)/usr/lib/$(package)
200 mv $(archdir)/*.rel $(prefix)/usr/lib/$(package) || true
201 mv $(archdir)/VBoxNetDHCP $(prefix)/usr/lib/$(package)
202 mv $(archdir)/VBoxNetAdpCtl $(prefix)/usr/lib/$(package)
203 mv $(archdir)/VBoxXPCOMIPCD $(prefix)/usr/lib/$(package)
204 mv $(archdir)/components $(prefix)/usr/lib/$(package)/components
205 mv $(archdir)/*.so $(prefix)/usr/lib/$(package)
206 mv $(archdir)/*.so.4 $(prefix)/usr/lib/$(package) || true
207 $(if $(NOQT),,mv $(archdir)/VBoxTestOGL $(prefix)/usr/lib/$(package))
208 $(if $(NOQT),,mv $(archdir)/nls $(prefix)/usr/share/$(package))
209 mv $(archdir)/src $(prefix)/usr/share/$(package)
210 rm $(archdir)/VBox.sh
211 export VBOX_INSTALL_PATH=/usr/lib/$(package) && \
212 cd ./debian/builddir/bin/sdk/installer && \
213 python ./vboxapisetup.py install --root $(prefix)
214 rm -rf $(archdir)/sdk/installer
215 mv $(archdir)/vboxshell.py $(prefix)/usr/lib/$(package)
216 mv $(archdir)/sdk $(prefix)/usr/lib/$(package)
217 install -D -g 0 -o 0 -m 644 debian/VBox.sh $(prefix)/usr/bin/VBox
218 mv $(archdir)/VBoxSysInfo.sh $(prefix)/usr/share/$(package)
219 mv $(archdir)/VBoxCreateUSBNode.sh $(prefix)/usr/share/$(package)
220 for i in VBoxManage VBoxSVC $(if $(HEADLESS),,VBoxSDL) \
221 $(if $(NOQT),,VirtualBox) VBoxHeadless \
222 VBoxExtPackHelperApp \
223 $(if $(NOWEBSVC),,vboxwebsrv webtest); do \
224 mv $(archdir)/$$i $(prefix)/usr/lib/$(package); done
225 mv $(archdir)/VBoxTunctl $(prefix)/usr/bin
226 $(if $(NOMODS),,for d in $(moddir)/*; do \
227 if [ -f $$d/vboxdrv.ko -a -f $$d/vboxnetflt.ko -a -f $$d/vboxnetadp.ko ]; then \
228 install -D -g 0 -o 0 -m 0644 \
229 $$d/vboxdrv.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxdrv.ko; \
230 install -D -g 0 -o 0 -m 0644 \
231 $$d/vboxnetflt.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetflt.ko; \
232 install -D -g 0 -o 0 -m 0644 \
233 $$d/vboxnetadp.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetadp.ko; \
234 fi \
235 done)
236ifeq ($(ose),)
237 $(if $(NOQT),,mv $(archdir)/kchmviewer $(prefix)/usr/lib/$(package))
238 dh_installdocs \
239 $(archdir)/UserManual*.pdf $(archdir)/VirtualBox*.chm \
240 $(addprefix $(archdir)/, $(if $(HEADLESS),,License-*.html) LICENSE)
241 rm $(addprefix $(archdir)/,UserManual*.pdf VirtualBox*.chm \
242 LICENSE $(if $(HEADLESS),,License-*.html))
243 for i in rdesktop-vrdp.tar.gz additions/VBoxGuestAdditions.iso; do \
244 mv $(archdir)/$$i $(prefix)/usr/share/$(package); done
245 $(if $(HEADLESS),,mv $(archdir)/rdesktop-vrdp $(prefix)/usr/bin)
246 $(if $(HEADLESS),,mv $(archdir)/rdesktop-vrdp-keymaps $(prefix)/usr/share/$(package))
247 if [ -d $(archdir)/accessible ]; then mv $(archdir)/accessible $(prefix)/usr/lib/virtualbox; fi
248else
249 dh_installdocs \
250 $(archdir)/UserManual*.pdf
251 rm $(addprefix $(archdir)/,UserManual*.pdf)
252 for i in additions/VBoxGuestAdditions.iso; do \
253 mv $(archdir)/$$i $(prefix)/usr/share/$(package); done
254endif
255 rmdir $(archdir)/additions
256 rmdir $(archdir)
257 rmdir $(prefix)/opt
258 dh_link \
259 $(if $(NOQT),,usr/bin/VBox usr/bin/VirtualBox) \
260 $(if $(NOQT),,usr/bin/VBox usr/bin/virtualbox) \
261 usr/bin/VBox usr/bin/VBoxManage \
262 usr/bin/VBox usr/bin/vboxmanage \
263 $(if $(HEADLESS),,usr/bin/VBox usr/bin/VBoxSDL) \
264 $(if $(HEADLESS),,usr/bin/VBox usr/bin/vboxsdl) \
265 $(if $(ose),,usr/bin/VBox usr/bin/VBoxVRDP) \
266 usr/bin/VBox usr/bin/VBoxHeadless \
267 usr/bin/VBox usr/bin/vboxheadless \
268 $(if $(NOWEBSVC),,usr/bin/VBox usr/bin/vboxwebsrv) \
269 usr/share/virtualbox/src/vboxhost usr/src/vboxhost-$(ver)
270 dh_desktop
271 $(if $(NOMODS),,dh_installmodules)
272 sed \
273 -e 's|%NOLSB%||g' \
274 -e 's|%DEBIAN%|yes|g' \
275 -e 's|%PACKAGE%|virtualbox|g' \
276 $(vboxroot)/src/VBox/Installer/linux/vboxdrv.sh.in > debian/vboxdrv.init
277 dh_installinit --name=vboxdrv --noscripts
278 sed \
279 -e 's|%NOLSB%||g' \
280 -e 's|%DEBIAN%|yes|g' \
281 -e 's|%PACKAGE%|virtualbox|g' \
282 $(vboxroot)/src/VBox/Installer/linux/vboxweb-service.sh.in > debian/vboxweb-service.init
283 dh_installinit --name=vboxweb-service --noscripts
284 cat debian/preinst.in | sed -e 's|%VER%|$(ver)|g' > debian/preinst
285 cat debian/prerm.in | sed -e 's|%VER%|$(ver)|g' > debian/prerm
286 cat debian/postinst.in | sed -e 's|%VER%|$(ver)|g' > debian/postinst
287 dh_installdebconf
288 dh_installchangelogs
289 dh_installmenu
290 dh_installmime
291 dh_link
292ifeq ($(DEBUG),)
293 dh_strip --keep-debug --exclude=libQtCoreVBox.so.4 --exclude=libQtGuiVBox.so.4 --exclude=libQtNetworkVBox.so.4 --exclude=libQtOpenGLVBox.so.4 --exclude=libqtaccessiblewidgets.so
294 # manually strip our R0/GC modules, dh_strip cannot handle them
295 for f in \
296 $(prefix)/usr/lib/$(package)/*.r0 $(prefix)/usr/lib/$(package)/*.gc; do \
297 objcopy --only-keep-debug \
298 $$f \
299 $(prefix)/usr/lib/debug/usr/lib/$(package)/`basename $$f`; \
300 strip -S --remove-section=.comment $$f; \
301 objcopy --add-gnu-debuglink=$(prefix)/usr/lib/debug/usr/lib/$(package)/`basename $$f` $$f; \
302 done
303endif
304 mkdir -p $(current)/debian/$(verpkg)-dbg/usr/lib
305ifeq ($(DEBUG),)
306 mv $(current)/debian/$(verpkg)/usr/lib/debug $(current)/debian/$(verpkg)-dbg/usr/lib
307endif
308 dh_pycentral
309 dh_compress -X.pdf -X.chm -X LICENSE -X.py
310 dh_fixperms
311 dh_makeshlibs
312 dh_installdeb
313 dh_perl
314 dh_shlibdeps
315 dh_gencontrol -- \
316 -Valsa=$(if $(HEADLESS),,libasound2) \
317 -Vpulse=$(if $(HEADLESS),,libpulse0) \
318 -Vsdlttf=$(if $(HEADLESS),,libsdl-ttf2.0-0) \
319 -Vdkms=$(if $(filter _Debian_etch _Debian_lenny,$(debrel)),,dkms)
320 dh_md5sums
321 dh_builddeb --destdir $(pkgdir)
322endif
323
324.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