VirtualBox

source: vbox/trunk/debian/rules@ 36663

Last change on this file since 36663 was 36554, checked in by vboxsync, 14 years ago

deb/rpm: VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1

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