VirtualBox

source: vbox/trunk/debian/rules@ 100108

Last change on this file since 100108 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 15.4 KB
Line 
1#!/usr/bin/make -f
2# $Id: rules 98103 2023-01-17 14:15:46Z vboxsync $
3## @file
4# VirtualBox rules.
5#
6
7#
8# Copyright (C) 2006-2023 Oracle and/or its affiliates.
9#
10# This file is part of VirtualBox base platform packages, as
11# available from https://www.virtualbox.org.
12#
13# This program is free software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License
15# as published by the Free Software Foundation, in version 3 of the
16# License.
17#
18# This program is distributed in the hope that it will be useful, but
19# WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21# General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program; if not, see <https://www.gnu.org/licenses>.
25#
26# SPDX-License-Identifier: GPL-3.0-only
27#
28
29#export DH_VERBOSE=1
30
31# possible overrides:
32# OSE=1 force VBOX_OSE
33# NOPARALLEL=1 compile with -j1
34# LINUX=<dir> compile vboxdrv against Linux found in <dir>
35# VERBOSE=1 verbose build
36# DEBUG=1 debug build
37# NOSUBVER=1 disable generation of the sub-version field (which is
38# either the subversion rev [if available] or the build date)
39# NODOCS=1 don't build docs, use precompiled UserManual*.pdf and
40# maybe UserManual*.qch and UserManual*.qhc from $(vboxroot)/prebuild
41# NOMODS=1 don't build any module
42# NOQT=1 don't build the Qt GUI
43# NOSDL=1 don't build VBoxSDL
44# EFI=1 include the EFI binary from prebuild
45# HEADLESS=1 build the headless version
46# VNC=1 build VNC code
47# NOWEBSVC=1 don't build the webservice API
48# STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
49# PKGDIR=<path> where to store the final package(s)
50# svn_revision=xxx do not depend on subversion being available, but use this
51# hard-coded revision number instead
52#
53# NODOCS will be set if UserManual*.pdf, UserManual*.qch and UserManual*.qhc are
54# placed in $(vboxroot)/prebuild.
55# STAGEDISO will be set if VBoxGuestAdditions.iso is placed there.
56#
57# Wine will not be required if STAGEDISO is set.
58
59package := virtualbox
60verpkg := virtualbox-ose
61vboxroot := $(shell while ! test -r configure && ! test "$$PWD" = "/"; do cd ..; done; pwd)
62debroot := $(vboxroot)
63instlin := $(vboxroot)/src/VBox/Installer/linux
64pkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd $(vboxroot)/..; pwd))
65outdir := $(if $(PATH_OUT_BASE),$(PATH_OUT_BASE),$(vboxroot)/out)
66bldbase := $(outdir)/debian
67builddir := $(bldbase)/builddir
68moddir := $(bldbase)/modules
69prefix := $(bldbase)/$(verpkg)
70arch := $(shell dpkg --print-architecture)
71verfile := $(builddir)/version-generated.mk
72ose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
73
74NOMODS ?= $(ose)
75NOQT ?= $(HEADLESS)
76NOSDL ?= $(HEADLESS)
77NOWEBSVC ?=
78EFI ?= $(if $(wildcard $(vboxroot)/prebuild/VBoxEFI32.fd $(vboxroot)/prebuild/VBoxEFI64.fd),1,)
79NODOCS ?= $(if $(wildcard $(addprefix $(vboxroot)/prebuild/,UserManual*.pdf UserManual*.qch UserManual*.qhc)),1,)
80STAGEDISO ?= $(if $(wildcard $(vboxroot)/prebuild/VBoxGuestAdditions.iso),$(vboxroot)/prebuild,)
81NOWINE := $(if $(STAGEDISO),1,$(ose))
82PYTHON := $(firstword $(shell which python3) $(shell which python))
83
84DEBPKGFILES := changelog compat control dirs postinst postrm preinst prerm rules templates
85
86ifneq ($(STAGEDISO),)
87 ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
88 $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
89 endif
90endif
91
92# Replicate debian package buildfiles to $(bldbase)
93ifneq ($(shell pwd),$(outdir))
94cmd := $(filter-out all Makefile,$(MAKECMDGOALS))
95all:
96 mkdir -p $(bldbase)
97 ln -sf $(addprefix $(debroot)/debian/,$(DEBPKGFILES)) $(bldbase)
98 +$(MAKE) -C $(outdir) vboxroot=$(vboxroot) -f debian/rules $(cmd)
99
100Makefile:
101
102$(cmd): all
103
104.PHONY: all $(MAKECMDGOALS)
105
106else
107 ifneq ($(wildcard $(verfile)),)
108include $(verfile)
109ver := $(VBOX_VERSION_STRING)
110archdir := $(prefix)/opt/VirtualBox-$(ver)
111 endif
112
113cfg_flags := $(if $(NOQT),--disable-qt,) \
114 $(if $(NOSDL),--disable-vboxsdl,) \
115 $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
116 $(if $(HEADLESS),--build-headless,) \
117 $(if $(DEBUG),--build-debug,) \
118 $(if $(NOWINE),,--setup-wine) \
119 $(if $(VNC),--enable-vnc,) \
120 $(if $(PATH_OUT_BASE),--out-base-dir=$(PATH_OUT_BASE),) \
121 --disable-extpack
122
123bld_flags := LOCALCFG=$(debroot)/debian/LocalConfig.kmk \
124 PATH_OUT=$(builddir) \
125 VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
126 VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
127 VBOX_WITH_VMSVGA3D=1 \
128 VBOX_DO_STRIP= \
129 VBOX_PATH_PACKAGE_DOCS="/usr/share/doc/$(verpkg)" \
130 $(if $(svn_revision),VBOX_SVN_REV=$(svn_revision),) \
131 $(if $(NODOCS),VBOX_WITH_DOCS=,) \
132 $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
133 $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,)
134
135configure: $(bldbase)/configure-stamp
136$(bldbase)/configure-stamp:
137 dh_testdir
138 mkdir -p $(bldbase)
139 cd $(vboxroot) && ./configure --odir=$(bldbase) $(cfg_flags)
140 touch $@
141
142build: $(bldbase)/configure-stamp $(bldbase)/build-stamp
143$(bldbase)/build-stamp $(verfile): $(bldbase)/configure-stamp
144 dh_testdir
145 . $(bldbase)/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
146 # Files from prebuild go to (builddir)/bin to be used during the
147 # packing stage, overriding what the build did/would produce.
148 $(if $(NODOCS),cp $(addprefix $(vboxroot)/prebuild/,UserManual*.pdf UserManual*.qch UserManual*.qhc) $(builddir)/bin,)
149 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
150 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
151 mkdir -p $(builddir)/bin/additions
152 $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
153 . $(bldbase)/env.sh && kmk -C $(vboxroot) $(bld_flags) \
154 VBOX_NO_LINUX_RUN_INSTALLER=1 \
155 VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86.tar.bz2 \
156 VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.tar.bz2 \
157 VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
158 VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
159 packing
160 touch $(bldbase)/build-stamp
161
162# Build modules for every kernel we find in /lib/modules/*
163$(bldbase)/modules-stamp: $(bldbase)/build-stamp
164 rm -rf $(moddir)
165 mkdir $(moddir)
166 for d in $(wildcard /lib/modules/*); do \
167 if [ -L $$d/build ]; then \
168 make -C $(builddir)/bin/src/vboxdrv KERN_VER=$$(basename $$d) clean && \
169 make -C $(builddir)/bin/src/vboxdrv KBUILD_VERBOSE= KERN_VER=$$(basename $$d) all; \
170 make -C $(builddir)/bin/src/vboxnetflt KERN_VER=$$(basename $$d) clean && \
171 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetflt || true) && \
172 make -C $(builddir)/bin/src/vboxnetflt KBUILD_VERBOSE= KERN_VER=$$(basename $$d) KBUILD_EXTRA_SYMBOLS=$(builddir)/bin/src/vboxnetflt/Module.symvers all; \
173 make -C $(builddir)/bin/src/vboxnetadp KERN_VER=$$(basename $$d) clean && \
174 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetadp || true) && \
175 make -C $(builddir)/bin/src/vboxnetadp KBUILD_VERBOSE= KERN_VER=$$(basename $$d) KBUILD_EXTRA_SYMBOLS=$(builddir)/bin/src/vboxnetadp/Module.symvers all; \
176 [ -d $(builddir)/bin/src/vboxpci ] && make -C $(builddir)/bin/src/vboxpci KERN_VER=$$(basename $$d) clean && \
177 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxpci || true) && \
178 make -C $(builddir)/bin/src/vboxpci KBUILD_VERBOSE= KERN_VER=$$(basename $$d) KBUILD_EXTRA_SYMBOLS=$(builddir)/bin/src/vboxpci/Module.symvers all; \
179 true; \
180 fi; \
181 done
182 touch $@
183
184clean:
185 dh_testdir
186 dh_testroot
187 dh_clean
188 rm -rf $(archdir)
189 rm -rf $(builddir)
190 rm -rf $(moddir)
191 rm -rf $(bldbase)/wine.*
192 rm -rf $(bldbase)/VirtualBox-*
193 rm -f $(bldbase)/VirtualBox.tar $(bldbase)/VirtualBox.tar.bz2
194 rm -f $(bldbase)/virtualbox-*.substvars $(bldbase)/virtualbox*.debhelper
195 rm -f $(bldbase)/$(verpkg).mime $(bldbase)/$(verpkg).sharedmimeinfo
196 rm -f $(bldbase)/modules-stamp $(bldbase)/build-stamp $(bldbase)/configure-stamp
197 rm -f $(bldbase)/AutoConfig.kmk $(bldbase)/configure.log $(bldbase)/env.sh
198 rm -f $(addprefix $(bldbase)/,$(DEBPKGFILES))
199 if [ -d $(bldbase) ]; then rmdir $(bldbase); fi
200
201 ifeq ($(VBOX_VERSION_MAJOR),)
202binary: build $(verfile)
203 +$(MAKE) -f debian/rules binary
204
205 else
206# Build architecture-dependent files here.
207binary: build $(if $(NOMODS),,$(bldbase)/modules-stamp)
208 dh_testdir
209 dh_testroot
210 dh_prep
211 dh_installdirs
212 tar -xC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar
213 install -d -g 0 -o 0 $(prefix)/usr/share/applications
214 install -d -g 0 -o 0 $(prefix)/usr/lib
215 install -d -g 0 -o 0 $(prefix)/usr/bin
216 install -d -g 0 -o 0 $(prefix)/usr/share/$(package)
217 mv $(archdir)/UnattendedTemplates $(prefix)/usr/share/$(package)/
218 install -d -g 0 -o 0 $(prefix)/usr/share/doc/$(verpkg)
219 $(if $(NOQT),,mv $(archdir)/virtualbox.desktop \
220 $(prefix)/usr/share/applications/virtualbox.desktop)
221 $(if $(NOQT),,mv $(archdir)/virtualboxvm.desktop \
222 $(prefix)/usr/share/applications/virtualboxvm.desktop)
223 install -d -g 0 -o 0 $(prefix)/usr/share/pixmaps
224 $(if $(NOQT),,install -d -g 0 -o 0 $(prefix)/usr/share/icons/hicolor)
225 $(if $(NOQT),,cp $(archdir)/icons/128x128/virtualbox.png \
226 $(prefix)/usr/share/pixmaps/virtualbox.png)
227 $(if $(NOQT),,mv $(archdir)/nls $(prefix)/usr/share/$(package))
228 $(if $(NOQT),,cd $(archdir)/icons; for i in *; do \
229 for j in $$i/virtualbox.*; do \
230 if [ -f $$j ]; then \
231 if [ ! -d $(prefix)/usr/share/icons/hicolor/$$i/apps ]; then \
232 install -d -g 0 -o 0 $(prefix)/usr/share/icons/hicolor/$$i/apps; \
233 fi; \
234 mv $$j $(prefix)/usr/share/icons/hicolor/$$i/apps; \
235 fi; \
236 done; \
237 install -d -g 0 -o 0 $(prefix)/usr/share/icons/hicolor/$$i/mimetypes; \
238 mv $$i/* $(prefix)/usr/share/icons/hicolor/$$i/mimetypes || true; \
239 rmdir $$i; \
240 done)
241 $(if $(NOQT),,rmdir $(archdir)/icons)
242 $(if $(NOQT),,mv $(archdir)/virtualbox.xml $(bldbase)/$(verpkg).sharedmimeinfo)
243 install -d -g 0 -o 0 $(prefix)/usr/share/lintian/overrides
244 sed \
245 -e 's|%VERPKG%|$(verpkg)|g' \
246 $(vboxroot)/debian/lintian-override.in > \
247 $(prefix)/usr/share/lintian/overrides/$(verpkg)
248 mv $(archdir)/VBox.png \
249 $(prefix)/usr/share/pixmaps/VBox.png
250 mv $(archdir)/src $(prefix)/usr/share/$(package)
251 rm $(archdir)/VBox.sh
252 install -D -g 0 -o 0 -m 644 $(instlin)/VBox.sh $(prefix)/usr/bin/VBox
253 mv $(archdir)/VBoxSysInfo.sh $(prefix)/usr/share/$(package)
254 if [ -r $(archdir)/VBoxDTrace ]; then \
255 mv $(archdir)/VBoxDTrace $(prefix)/usr/bin; \
256 fi
257 mv $(archdir)/VBoxTunctl $(prefix)/usr/bin
258 $(if $(NOMODS),,for d in $(moddir)/*; do \
259 if [ -f $$d/vboxdrv.ko -a -f $$d/vboxnetflt.ko -a -f $$d/vboxnetadp.ko ]; then \
260 install -D -g 0 -o 0 -m 0644 \
261 $$d/vboxdrv.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxdrv.ko; \
262 install -D -g 0 -o 0 -m 0644 \
263 $$d/vboxnetflt.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetflt.ko; \
264 install -D -g 0 -o 0 -m 0644 \
265 $$d/vboxnetadp.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetadp.ko; \
266 if [ -f $$d/vboxpci.ko ]; then \
267 install -D -g 0 -o 0 -m 0644 \
268 $$d/vboxpci.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxpci.ko; \
269 fi \
270 fi \
271 done)
272 dh_installdocs $(addprefix $(archdir)/,UserManual*.pdf LICENSE)
273 mv $(addprefix $(archdir)/,$(if $(HEADLESS),,rdesktop-vrdp.tar.gz) additions/VBoxGuestAdditions.iso) $(prefix)/usr/share/$(package)
274 $(if $(HEADLESS),,mv $(archdir)/rdesktop-vrdp $(prefix)/usr/bin)
275 $(if $(HEADLESS),,mv $(archdir)/rdesktop-vrdp-keymaps $(prefix)/usr/share/$(package))
276 mv $(archdir) $(prefix)/usr/lib/$(package)
277 if [ -f $(prefix)/usr/lib/$(package)/libQt5CoreVBox.so.5 ]; then \
278 $(vboxroot)/tools/linux.$(chrarch)/bin/chrpath \
279 --keepgoing --replace /usr/lib/$(package) \
280 $(prefix)/usr/lib/$(package)/*.so.5 \
281 $(prefix)/usr/lib/$(package)/plugins/platforms/*.so; \
282 $(prefix)/usr/lib/$(package)/plugins/platformthemes/*.so; \
283 $(prefix)/usr/lib/$(package)/plugins/sqldrivers/*.so; \
284 $(prefix)/usr/lib/$(package)/plugins/styles/*.so; \
285 $(prefix)/usr/lib/$(package)/plugins/xcbglintegrations/*.so; \
286 echo "[Paths]" > $(prefix)/usr/lib/$(package)/qt.conf; \
287 echo "Plugins = /usr/lib/$(package)/plugins" >> $(prefix)/usr/lib/$(package)/qt.conf; \
288 fi
289 export VBOX_INSTALL_PATH=/usr/lib/$(package) && \
290 cd $(builddir)/bin/sdk/installer && \
291 $(PYTHON) ./vboxapisetup.py install --root $(prefix)
292 rm -rf $(prefix)/usr/lib/$(package)/sdk/installer
293 ln -s ../VBoxVMM.so $(prefix)/usr/lib/$(package)/components/VBoxVMM.so
294 rmdir $(prefix)/opt
295 dh_link \
296 $(if $(NOQT),,usr/bin/VBox usr/bin/VirtualBox) \
297 $(if $(NOQT),,usr/bin/VBox usr/bin/virtualbox) \
298 $(if $(NOQT),,usr/bin/VBox usr/bin/VirtualBoxVM) \
299 $(if $(NOQT),,usr/bin/VBox usr/bin/virtualboxvm) \
300 usr/bin/VBox usr/bin/VBoxManage \
301 usr/bin/VBox usr/bin/vboxmanage \
302 $(if $(NOSDL),,usr/bin/VBox usr/bin/VBoxSDL) \
303 $(if $(NOSDL),,usr/bin/VBox usr/bin/vboxsdl) \
304 usr/bin/VBox usr/bin/VBoxHeadless \
305 usr/bin/VBox usr/bin/vboxheadless \
306 usr/bin/VBox usr/bin/VBoxBugReport \
307 usr/bin/VBox usr/bin/vboxbugreport \
308 usr/bin/VBox usr/bin/VBoxBalloonCtrl \
309 usr/bin/VBox usr/bin/vboxballoonctrl \
310 usr/bin/VBox usr/bin/VBoxAutostart \
311 usr/bin/VBox usr/bin/vboxautostart \
312 $(if $(NOWEBSVC),,usr/bin/VBox usr/bin/vboxwebsrv) \
313 $(if $(NOVBOXIMG),,usr/lib/virtualbox/vbox-img usr/bin/vbox-img) \
314 $(if $(NOVBOXIMGMOUNT),,usr/lib/virtualbox/vboximg-mount usr/bin/vboximg-mount) \
315 usr/share/virtualbox/src/vboxhost usr/src/vboxhost-$(ver)
316 $(if $(NOMODS),,dh_installmodules)
317 dh_installdebconf
318 dh_installchangelogs
319 dh_installmenu
320 dh_installmime
321 dh_link
322 ifeq ($(DEBUG),)
323 dh_strip --keep-debug \
324 $(addprefix --exclude=lib,$(addsuffix VBox.so.5,\
325 Qt5Core Qt5Gui Qt5Widgets Qt5PrintSupport Qt5OpenGL Qt5DBus Qt5XcbQpa Qt5X11Extras))
326 endif
327 mkdir -p $(bldbase)/$(verpkg)-dbg/usr/lib/$(package)
328 mv $(prefix)/usr/lib/$(package)/*.debug $(bldbase)/$(verpkg)-dbg/usr/lib/$(package)
329 ifeq ($(DEBUG),)
330 mv $(prefix)/usr/lib/debug $(bldbase)/$(verpkg)-dbg/usr/lib
331 endif
332 $(firstword $(shell which dh_python3) $(shell which dh_python2))
333 dh_compress -X.pdf -X.qch -X.qhc -X LICENSE -X.py
334 dh_fixperms
335 dh_makeshlibs
336 dh_installdeb
337 dh_perl
338 # For some reason, the Qt libraries couldn't be found on newer releases (e.g. Ubuntu hardy).
339 # Python is deliberately not listed as a dependency (see also comment in the "control" file.
340 # It is expected that dh_gencontrol shows a warning "substitution variable ${python:Versions}
341 # used, but is not defined" because of this.
342 LD_LIBRARY_PATH=$(prefix)/usr/lib/virtualbox dh_shlibdeps --exclude=VBoxPython
343 dh_gencontrol -- \
344 -Valsa=$(if $(HEADLESS),,libasound2) \
345 -Vpulse=$(if $(HEADLESS),,libpulse0) \
346 -Vsdlttf=$(if $(HEADLESS),,libsdl-ttf2.0-0)
347 dh_md5sums
348 dh_builddeb --destdir $(pkgdir) -- -Zxz
349 endif
350
351.PHONY: binary configure build clean
352endif
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