VirtualBox

source: vbox/trunk/debian/rules@ 63555

Last change on this file since 63555 was 63555, checked in by vboxsync, 8 years ago

deb: fixes

  • Property svn:executable set to *
File size: 11.7 KB
Line 
1#!/usr/bin/make -f
2#
3# Copyright (C) 2006-2012 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 (GPL) as published by the Free Software
9# Foundation, in version 2 as it comes in the "COPYING" file of the
10# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
11# hope that it will 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# EFI=1 include the EFI binary from prebuild
30# HEADLESS=1 build the headless version
31# VNC=1 build VNC code
32# NOWEBSVC=1 don't build the webservice API, default for OSE
33# STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
34# PKGDIR=<path> where to store the final package(s)
35# BLEEDING_EDGE=xyz
36
37package := virtualbox
38verpkg := virtualbox-ose
39current := $(shell pwd)
40vboxroot := $(shell pwd)
41pkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd ..; pwd))
42builddir := $(vboxroot)/out/debian/builddir
43moddir := $(vboxroot)/out/debian/modules
44prefix := $(current)/debian/$(verpkg)
45arch := $(shell dpkg --print-architecture)
46verfile := $(builddir)/version-generated.mk
47ose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
48NOMODS ?= $(ose)
49NOQT ?= $(HEADLESS)
50NOWEBSVC ?= $(ose)
51NOWINE := $(if $(NODOCS),$(if $(STAGEDISO),1,),)$(ose)
52
53ifneq ($(wildcard $(verfile)),)
54include $(verfile)
55ver := $(VBOX_VERSION_STRING)
56archdir := $(prefix)/opt/VirtualBox-$(ver)
57endif
58
59ifneq ($(STAGEDISO),)
60 ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
61 $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
62 endif
63endif
64
65debrel := $(if $(shell which lsb_release),_$(shell lsb_release -si)_$(shell lsb_release -sc),unknown)
66
67# shipping Linux kernel modules with bleeding-edge releases doesn't make sense
68instmod := $(if $(filter _Ubuntu_lucid _Ubuntu_maverick _Ubuntu_natty _Ubuntu_oneiric _Debian_sid,$(debrel)),,1)
69
70cfg_flags := $(if $(NOQT),--disable-qt,) \
71 $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
72 $(if $(HEADLESS),--build-headless,) \
73 $(if $(DEBUG),--build-debug,) \
74 $(if $(NOWINE),,--setup-wine) \
75 $(if $(NOWEBSVC),,$(if $(ose),--enable-webservice,)) \
76 $(if $(VNC),--enable-vnc,) \
77 --disable-extpack
78
79bld_flags := AUTOCFG=$(current)/debian/AutoConfig.kmk \
80 LOCALCFG=$(current)/debian/LocalConfig.kmk \
81 PATH_OUT=$(builddir) \
82 VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
83 VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
84 $(if $(filter _Debian_squeeze _Ubuntu_lucid,$(debrel)),,VBOX_WITH_VMSVGA3D=1) \
85 VBOX_DO_STRIP= \
86 VBOX_WITH_MULTIVERSION_PYTHON= \
87 VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\"" \
88 $(if $(ose),,VBOX_WITH_DOCS_CHM=1) \
89 $(if $(svnrev),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
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 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
108 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(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.tar.bz2 \
114 VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.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 make -C $(builddir)/bin/src/vboxpci KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
143 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxpci || true) && \
144 make -j4 -C $(builddir)/bin/src/vboxpci KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
145 $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
146 $(builddir)/bin/src/vboxpci/vboxpci.ko $(moddir)/$$(basename $$d)/vboxpci.ko); \
147 fi; \
148 done
149 make -C $(builddir)/bin/src/vboxdrv clean
150 make -C $(builddir)/bin/src/vboxnetflt clean
151 make -C $(builddir)/bin/src/vboxnetadp clean
152 make -C $(builddir)/bin/src/vboxpci clean
153 touch debian/modules-stamp
154
155clean:
156 dh_testdir
157 dh_testroot
158 rm -f debian/preinst debian/postinst debian/prerm
159 rm -f debian/$(package).init debian/vboxdrv.init
160 rm -f debian/vboxballoonctrl-service.init debian/vboxautostart-service.init debian/vboxweb-service.init
161 rm -f debian/AutoConfig.kmk debian/configure.log debian/env.sh
162 rm -f debian/modules-stamp debian/build-stamp debian/configure-stamp
163 rm -f debian/virtualbox-*.substvars debian/virtualbox*.debhelper
164 rm -f debian/$(verpkg).mime
165 rm -rf $(builddir) $(moddir)
166 rm -rf debian/wine.*
167 dh_clean
168
169ifeq ($(VBOX_VERSION_MAJOR),)
170binary binary-arch binary-indep: build $(verfile)
171 $(MAKE) -f debian/rules binary
172else
173# Build architecture-dependent files here.
174binary binary-arch binary-indep: build $(if $(NOMODS),,modules)
175 dh_testdir
176 dh_testroot
177 dh_clean -k
178 dh_installdirs
179 tar -xC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar
180 $(if $(NOQT),,mv $(archdir)/virtualbox.xml debian/$(verpkg).sharedmimeinfo)
181 $(archdir)/scripts/install.sh --package $(package) --root $(prefix) \
182 --prefix /usr $(if $(NOQT),--no-qt) $(if $(ose),--ose) \
183 $(if $(HEADLESS),--headless) $(if $(NOWEBSVC),--no-web-service) \
184 --install-folder /lib/$(package) --no-helpers
185 install -d -g 0 -o 0 $(prefix)/usr/share/doc/$(verpkg)
186 install -d -g 0 -o 0 $(prefix)/usr/share/lintian/overrides
187 sed \
188 -e 's|%VERPKG%|$(verpkg)|g' \
189 debian/lintian-override.in > \
190 $(prefix)/usr/share/lintian/overrides/$(verpkg)
191 $(if $(NOMODS),,for d in $(moddir)/*; do \
192 if [ -f $$d/vboxdrv.ko -a -f $$d/vboxnetflt.ko -a -f $$d/vboxnetadp.ko -a -f $$d/vboxpci.ko ]; then \
193 install -D -g 0 -o 0 -m 0644 \
194 $$d/vboxdrv.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxdrv.ko; \
195 install -D -g 0 -o 0 -m 0644 \
196 $$d/vboxnetflt.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetflt.ko; \
197 install -D -g 0 -o 0 -m 0644 \
198 $$d/vboxnetadp.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetadp.ko; \
199 install -D -g 0 -o 0 -m 0644 \
200 $$d/vboxpci.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxpci.ko; \
201 fi \
202 done)
203ifeq ($(ose),)
204 dh_installdocs \
205 $(archdir)/UserManual*.pdf $(archdir)/VirtualBox*.chm \
206 $(addprefix $(archdir)/, LICENSE)
207 rm $(addprefix $(archdir)/,UserManual*.pdf VirtualBox*.chm \
208 LICENSE)
209else
210 dh_installdocs \
211 $(archdir)/UserManual*.pdf
212 rm $(addprefix $(archdir)/,UserManual*.pdf)
213endif
214 mv $(archdir) $(prefix)/usr/lib/$(package)
215 ln -s ../VBoxVMM.so $(prefix)/usr/lib/$(package)/components/VBoxVMM.so
216 rmdir $(prefix)/opt
217 $(if $(NOMODS),,dh_installmodules)
218 sed \
219 -e 's|%NOLSB%||g' \
220 -e 's|%DEBIAN%|yes|g' \
221 -e 's|%PACKAGE%|virtualbox|g' \
222 -e "s|%VERSION%|$(VBOX_VERSION_STRING)|g" \
223 -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
224 $(vboxroot)/src/VBox/Installer/linux/vboxdrv.sh.in > debian/vboxdrv.init
225 dh_installinit --name=vboxdrv --noscripts
226 cp $(vboxroot)/src/VBox/Installer/linux/vboxballoonctrl-service.sh debian/vboxballoonctrl-service.init
227 dh_installinit --name=vboxballoonctrl-service --noscripts
228 cp $(vboxroot)/src/VBox/Installer/linux/vboxautostart-service.sh debian/vboxautostart-service.init
229 dh_installinit --name=vboxautostart-service --noscripts
230 cp $(vboxroot)/src/VBox/Installer/linux/vboxweb-service.sh debian/vboxweb-service.init
231 dh_installinit --name=vboxweb-service --noscripts
232 sed -e 's|%VER%|$(ver)|g' \
233 debian/preinst.in > debian/preinst
234 sed -e 's|%VER%|$(ver)|g' \
235 debian/prerm.in > debian/prerm
236 sed -e 's|%VER%|$(ver)|g' \
237 -e '/#include installer-common.sh/ {' \
238 -e "r $(vboxroot)/src/VBox/Installer/linux/installer-common.sh" \
239 -e 'd' \
240 -e '}' \
241 debian/postinst.in > debian/postinst
242 dh_installdebconf
243 dh_installchangelogs
244 dh_installmenu
245 dh_installmime
246 dh_link
247ifeq ($(DEBUG),)
248 dh_strip --keep-debug \
249 $(addprefix --exclude=lib,$(addsuffix VBox.so.5,\
250 Qt5Core Qt5Gui Qt5Widgets Qt5PrintSupport Qt5OpenGL Qt5DBus Qt5XcbQpa Qt5X11Extras)) \
251 --exclude=libqxcb.so
252endif
253 mkdir -p $(current)/debian/$(verpkg)-dbg/usr/lib
254ifeq ($(DEBUG),)
255 mv $(current)/debian/$(verpkg)/usr/lib/debug $(current)/debian/$(verpkg)-dbg/usr/lib
256endif
257 $(if $(filter _Ubuntu_hardy _Ubuntu_lucid,$(debrel)),dh_pycentral,dh_python2)
258 dh_compress -X.pdf -X.chm -X LICENSE -X.py
259 dh_fixperms
260 dh_makeshlibs
261 dh_installdeb
262 dh_perl
263 LD_LIBRARY_PATH=$(prefix)/usr/lib/virtualbox dh_shlibdeps
264 dh_gencontrol -- \
265 -Valsa=$(if $(HEADLESS),,libasound2) \
266 -Vpulse=$(if $(HEADLESS),,libpulse0) \
267 -Vsdlttf=$(if $(HEADLESS),,libsdl-ttf2.0-0) \
268 -Vdkms=$(if $(filter _Debian_lenny,$(debrel)),,dkms)
269 dh_md5sums
270 dh_builddeb --destdir $(pkgdir) -- -Zxz
271endif
272
273.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