VirtualBox

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

Last change on this file was 106061, checked in by vboxsync, 2 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: 16.6 KB
Line 
1#!/usr/bin/make -f
2# $Id: rules 106061 2024-09-16 14:03:52Z vboxsync $
3## @file
4# VirtualBox rules.
5#
6
7#
8# Copyright (C) 2006-2024 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#
30# NOTE: if you make changes to this file, please check if the updates should
31# be also applied to the publicly visible debian/rules file.
32#
33
34#export DH_VERBOSE=1
35
36# possible overrides:
37# OSE=1 force VBOX_OSE
38# NOPARALLEL=1 compile with -j1
39# LINUX=<dir> compile vboxdrv against Linux found in <dir>
40# VERBOSE=1 verbose build
41# DEBUG=1 debug build
42# NOSUBVER=1 disable generation of the sub-version field (which is
43# either the subversion rev [if available] or the build date)
44# NODOCS=1 don't build docs, use precompiled UserManual*.pdf and
45# maybe UserManual*.qch and UserManual*.qhc from $(vboxroot)/prebuild
46# NOMODS=1 don't build any module
47# NOQT=1 don't build the Qt GUI
48# NOSDL=1 don't build VBoxSDL
49# EFI=1 include the EFI binary from prebuild
50# VERSUFFIX=<suffix> set a particular package version suffix (e.g. _customer)
51# HEADLESS=1 build the headless version
52# VNC=1 build VNC code
53# NOWEBSVC=1 don't build the webservice API
54# STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
55# PKGDIR=<path> where to store the final package(s)
56# svn_revision=xxx do not depend on subversion being available, but use this
57# hard-coded revision number instead
58#
59# NODOCS will be set if UserManual*.pdf, UserManual*.qch and UserManual*.qhc are
60# placed in $(vboxroot)/prebuild.
61# STAGEDISO will be set if VBoxGuestAdditions.iso is placed there.
62#
63# Wine will not be required if STAGEDISO is set.
64
65package := virtualbox
66verpkg := virtualbox-7.1
67vboxroot := $(shell while ! test -r configure && ! test "$$PWD" = "/"; do cd ..; done; pwd)
68debroot := $(vboxroot)/src/VBox/Installer/linux
69instlin := $(vboxroot)/src/VBox/Installer/linux
70pkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd $(vboxroot)/..; pwd))
71outdir := $(if $(PATH_OUT_BASE),$(PATH_OUT_BASE),$(vboxroot)/out)
72bldbase := $(outdir)/debian
73builddir := $(bldbase)/builddir
74moddir := $(bldbase)/modules
75prefix := $(bldbase)/$(verpkg)
76arch := $(shell dpkg --print-architecture)
77verfile := $(builddir)/version-generated.mk
78ose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
79chrarch := $(shell if [ `uname -m` = "x86_64" ]; then echo "amd64"; else echo "x86"; fi)
80-include $(vboxroot)/SVN_REVISION
81
82NOMODS ?= $(ose)
83NOQT ?= $(HEADLESS)
84NOSDL ?= $(HEADLESS)
85NOWEBSVC ?=
86EFI ?= $(if $(wildcard $(vboxroot)/prebuild/VBoxEFI32.fd $(vboxroot)/prebuild/VBoxEFI64.fd),1,)
87NODOCS ?= $(if $(wildcard $(addprefix $(vboxroot)/prebuild/,UserManual*.pdf UserManual*.qch UserManual*.qhc)),1,)
88STAGEDISO ?= $(if $(wildcard $(vboxroot)/prebuild/VBoxGuestAdditions.iso),$(vboxroot)/prebuild,)
89NOWINE := $(if $(STAGEDISO),1,$(ose))
90PYTHON := $(firstword $(shell which python3) $(shell which python))
91
92DEBPKGFILES := changelog compat control dirs postinst postrm preinst prerm rules templates
93
94ifneq ($(STAGEDISO),)
95 ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
96 $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
97 endif
98endif
99
100# Replicate debian package buildfiles to $(bldbase)
101ifneq ($(shell pwd),$(outdir))
102cmd := $(filter-out all Makefile,$(MAKECMDGOALS))
103all:
104 mkdir -p $(bldbase)
105 ln -sf $(addprefix $(debroot)/debian/,$(DEBPKGFILES)) $(bldbase)
106 +$(MAKE) -C $(outdir) vboxroot=$(vboxroot) -f debian/rules $(cmd)
107
108Makefile:
109
110$(cmd): all
111
112.PHONY: all $(MAKECMDGOALS)
113
114else
115 ifneq ($(wildcard $(verfile)),)
116include $(verfile)
117ver := $(VBOX_VERSION_STRING)
118svnver := $(if $(NOSUBVER),,$(if $(svn_revision),-$(svn_revision),$(shell if \
119 svn info $(vboxroot) > /dev/null 2>&1; then \
120 svn info $(vboxroot)|sed -e "s/^Revision: \(.*\)/-\1/;t;d"; else \
121 date +"-%Y%m%d"; fi)))
122debver := $(subst _ALPHA,~alpha,$(subst _BETA,~beta,$(subst _RC,~rc,$(subst _OSE,~ose,$(ver)))))$(svnver)$(VERSUFFIX)$(if $(HEADLESS),~headless,)$(if $(DEBUG),~dbg,)
123archdir := $(prefix)/opt/VirtualBox-$(ver)
124 endif
125
126
127ifneq ($(MAKECMDGOALS),clean)
128 debrel := $(if $(shell which lsb_release),_$(shell lsb_release -si)_$(shell lsb_release -sc),unknown)
129 debdist := $(strip $(shell grep $(debrel) $(debroot)/distributions_deb | cut -d'=' -f2))
130 ifeq ($(debdist),)
131 $(error package distribution not detected (debrel=$(debrel)))
132 endif
133endif
134
135cfg_flags := $(if $(NOQT),--disable-qt,) \
136 $(if $(NOSDL),--disable-vboxsdl,) \
137 $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
138 $(if $(HEADLESS),--build-headless,) \
139 $(if $(DEBUG),--build-debug,) \
140 $(if $(NOWINE),,--setup-wine) \
141 $(if $(VNC),--enable-vnc,) \
142 $(if $(PATH_OUT_BASE),--out-base-dir=$(PATH_OUT_BASE),) \
143 --disable-extpack
144
145bld_flags := LOCALCFG=$(debroot)/debian/LocalConfig.kmk \
146 PATH_OUT=$(builddir) \
147 VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
148 VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
149 VBOX_WITH_VMSVGA3D=1 \
150 VBOX_DO_STRIP= \
151 VBOX_PATH_PACKAGE_DOCS="/usr/share/doc/$(verpkg)" \
152 VBOX_PACKAGE_DIST=$(debdist) \
153 $(if $(svn_revision),VBOX_SVN_REV=$(svn_revision),) \
154 $(if $(NODOCS),VBOX_WITH_DOCS=,) \
155 $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
156 $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,)
157
158configure: $(bldbase)/configure-stamp
159$(bldbase)/configure-stamp:
160 dh_testdir
161 mkdir -p $(bldbase)
162 cd $(vboxroot) && ./configure --odir=$(bldbase) $(cfg_flags)
163 touch $@
164
165build: $(bldbase)/configure-stamp $(bldbase)/build-stamp
166$(bldbase)/build-stamp $(verfile): $(bldbase)/configure-stamp
167 dh_testdir
168 . $(bldbase)/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
169 # Files from prebuild go to (builddir)/bin to be used during the
170 # packing stage, overriding what the build did/would produce.
171 $(if $(NODOCS),cp $(addprefix $(vboxroot)/prebuild/,UserManual*.pdf UserManual*.qch UserManual*.qhc) $(builddir)/bin,)
172 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
173 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
174 mkdir -p $(builddir)/bin/additions
175 $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
176 . $(bldbase)/env.sh && kmk -C $(vboxroot) $(bld_flags) \
177 VBOX_NO_LINUX_RUN_INSTALLER=1 \
178 VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86.tar.bz2 \
179 VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.tar.bz2 \
180 VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
181 VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
182 packing
183 touch $(bldbase)/build-stamp
184
185# Build modules for every kernel we find in /lib/modules/*
186$(bldbase)/modules-stamp: $(bldbase)/build-stamp
187 rm -rf $(moddir)
188 mkdir $(moddir)
189 for d in $(wildcard /lib/modules/*); do \
190 if [ -L $$d/build ]; then \
191 make -C $(builddir)/bin/src/vboxdrv KERN_VER=$$(basename $$d) clean && \
192 make -C $(builddir)/bin/src/vboxdrv KBUILD_VERBOSE= KERN_VER=$$(basename $$d) all; \
193 make -C $(builddir)/bin/src/vboxnetflt KERN_VER=$$(basename $$d) clean && \
194 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetflt || true) && \
195 make -C $(builddir)/bin/src/vboxnetflt KBUILD_VERBOSE= KERN_VER=$$(basename $$d) KBUILD_EXTRA_SYMBOLS=$(builddir)/bin/src/vboxnetflt/Module.symvers all; \
196 make -C $(builddir)/bin/src/vboxnetadp KERN_VER=$$(basename $$d) clean && \
197 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetadp || true) && \
198 make -C $(builddir)/bin/src/vboxnetadp KBUILD_VERBOSE= KERN_VER=$$(basename $$d) KBUILD_EXTRA_SYMBOLS=$(builddir)/bin/src/vboxnetadp/Module.symvers all; \
199 [ -d $(builddir)/bin/src/vboxpci ] && make -C $(builddir)/bin/src/vboxpci KERN_VER=$$(basename $$d) clean && \
200 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxpci || true) && \
201 make -C $(builddir)/bin/src/vboxpci KBUILD_VERBOSE= KERN_VER=$$(basename $$d) KBUILD_EXTRA_SYMBOLS=$(builddir)/bin/src/vboxpci/Module.symvers all; \
202 true; \
203 fi; \
204 done
205 touch $@
206
207clean:
208 dh_testdir
209 dh_testroot
210 dh_clean
211 rm -rf $(archdir)
212 rm -rf $(builddir)
213 rm -rf $(moddir)
214 rm -rf $(bldbase)/wine.*
215 rm -rf $(bldbase)/VirtualBox-*
216 rm -f $(bldbase)/VirtualBox.tar $(bldbase)/VirtualBox.tar.bz2
217 rm -f $(bldbase)/virtualbox-*.substvars $(bldbase)/virtualbox*.debhelper
218 rm -f $(bldbase)/$(verpkg).mime $(bldbase)/$(verpkg).sharedmimeinfo
219 rm -f $(bldbase)/modules-stamp $(bldbase)/build-stamp $(bldbase)/configure-stamp
220 rm -f $(bldbase)/AutoConfig.kmk $(bldbase)/configure.log $(bldbase)/env.sh
221 rm -f $(addprefix $(bldbase)/,$(DEBPKGFILES))
222 if [ -d $(bldbase) ]; then rmdir $(bldbase); fi
223
224 ifeq ($(VBOX_VERSION_MAJOR),)
225binary: build $(verfile)
226 +$(MAKE) -f debian/rules binary
227
228 else
229# Build architecture-dependent files here.
230binary: build $(if $(NOMODS),,$(bldbase)/modules-stamp)
231 dh_testdir
232 dh_testroot
233 dh_prep
234 dh_installdirs
235 tar -xC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar
236 install -d -g 0 -o 0 $(prefix)/usr/share/applications
237 install -d -g 0 -o 0 $(prefix)/usr/lib
238 install -d -g 0 -o 0 $(prefix)/usr/bin
239 install -d -g 0 -o 0 $(prefix)/usr/share/$(package)
240 mv $(archdir)/UnattendedTemplates $(prefix)/usr/share/$(package)/
241 install -d -g 0 -o 0 $(prefix)/usr/share/doc/$(verpkg)
242 $(if $(NOQT),,mv $(archdir)/virtualbox.desktop \
243 $(prefix)/usr/share/applications/virtualbox.desktop)
244 $(if $(NOQT),,mv $(archdir)/virtualboxvm.desktop \
245 $(prefix)/usr/share/applications/virtualboxvm.desktop)
246 install -d -g 0 -o 0 $(prefix)/usr/share/pixmaps
247 $(if $(NOQT),,install -d -g 0 -o 0 $(prefix)/usr/share/icons/hicolor)
248 $(if $(NOQT),,cp $(archdir)/icons/128x128/virtualbox.png \
249 $(prefix)/usr/share/pixmaps/virtualbox.png)
250 $(if $(NOQT),,mv $(archdir)/nls $(prefix)/usr/share/$(package))
251 $(if $(NOQT),,cd $(archdir)/icons; for i in *; do \
252 for j in $$i/virtualbox.*; do \
253 if [ -f $$j ]; then \
254 if [ ! -d $(prefix)/usr/share/icons/hicolor/$$i/apps ]; then \
255 install -d -g 0 -o 0 $(prefix)/usr/share/icons/hicolor/$$i/apps; \
256 fi; \
257 mv $$j $(prefix)/usr/share/icons/hicolor/$$i/apps; \
258 fi; \
259 done; \
260 install -d -g 0 -o 0 $(prefix)/usr/share/icons/hicolor/$$i/mimetypes; \
261 mv $$i/* $(prefix)/usr/share/icons/hicolor/$$i/mimetypes || true; \
262 rmdir $$i; \
263 done)
264 $(if $(NOQT),,rmdir $(archdir)/icons)
265 $(if $(NOQT),,mv $(archdir)/virtualbox.xml $(bldbase)/$(verpkg).sharedmimeinfo)
266 install -d -g 0 -o 0 $(prefix)/usr/share/lintian/overrides
267 sed \
268 -e 's|%VERPKG%|$(verpkg)|g' \
269 $(vboxroot)/debian/lintian-override.in > \
270 $(prefix)/usr/share/lintian/overrides/$(verpkg)
271 mv $(archdir)/VBox.png \
272 $(prefix)/usr/share/pixmaps/VBox.png
273 mv $(archdir)/src $(prefix)/usr/share/$(package)
274 rm $(archdir)/VBox.sh
275 install -D -g 0 -o 0 -m 644 $(instlin)/VBox.sh $(prefix)/usr/bin/VBox
276 mv $(archdir)/VBoxSysInfo.sh $(prefix)/usr/share/$(package)
277 if [ -r $(archdir)/VBoxDTrace ]; then \
278 mv $(archdir)/VBoxDTrace $(prefix)/usr/bin; \
279 fi
280 $(if $(NOMODS),,for d in $(moddir)/*; do \
281 if [ -f $$d/vboxdrv.ko -a -f $$d/vboxnetflt.ko -a -f $$d/vboxnetadp.ko ]; then \
282 install -D -g 0 -o 0 -m 0644 \
283 $$d/vboxdrv.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxdrv.ko; \
284 install -D -g 0 -o 0 -m 0644 \
285 $$d/vboxnetflt.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetflt.ko; \
286 install -D -g 0 -o 0 -m 0644 \
287 $$d/vboxnetadp.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetadp.ko; \
288 if [ -f $$d/vboxpci.ko ]; then \
289 install -D -g 0 -o 0 -m 0644 \
290 $$d/vboxpci.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxpci.ko; \
291 fi \
292 fi \
293 done)
294 dh_installdocs $(addprefix $(archdir)/,UserManual*.pdf UserManual*.qch UserManual*.qhc LICENSE)
295 # Remove User Manual duplicated files, only keep them under location which was used by dh_installdocs.
296 rm -f $(addprefix $(archdir)/,UserManual*.pdf UserManual*.qch UserManual*.qhc LICENSE)
297 mv $(addprefix $(archdir)/,additions/VBoxGuestAdditions.iso) $(prefix)/usr/share/$(package)
298 mv $(archdir) $(prefix)/usr/lib/$(package)
299 if [ -f $(prefix)/usr/lib/$(package)/libQt6CoreVBox.so.6 ]; then \
300 $(vboxroot)/tools/linux.$(chrarch)/bin/chrpath \
301 --keepgoing --replace /usr/lib/$(package) \
302 $(prefix)/usr/lib/$(package)/*.so.6 \
303 $(prefix)/usr/lib/$(package)/plugins/platforms/*.so; \
304 $(prefix)/usr/lib/$(package)/plugins/platformthemes/*.so; \
305 $(prefix)/usr/lib/$(package)/plugins/sqldrivers/*.so; \
306 $(prefix)/usr/lib/$(package)/plugins/styles/*.so; \
307 echo "[Paths]" > $(prefix)/usr/lib/$(package)/qt.conf; \
308 echo "Plugins = /usr/lib/$(package)/plugins" >> $(prefix)/usr/lib/$(package)/qt.conf; \
309 fi
310 export VBOX_INSTALL_PATH=/usr/lib/$(package) && \
311 cd $(builddir)/bin/sdk/installer/python && \
312 $(PYTHON) ./vboxapisetup.py install --root $(prefix)
313 rm -rf $(prefix)/usr/lib/$(package)/sdk/installer
314 ln -s ../VBoxVMM.so $(prefix)/usr/lib/$(package)/components/VBoxVMM.so
315 rmdir $(prefix)/opt
316 dh_link \
317 $(if $(NOQT),,usr/bin/VBox usr/bin/VirtualBox) \
318 $(if $(NOQT),,usr/bin/VBox usr/bin/virtualbox) \
319 $(if $(NOQT),,usr/bin/VBox usr/bin/VirtualBoxVM) \
320 $(if $(NOQT),,usr/bin/VBox usr/bin/virtualboxvm) \
321 usr/bin/VBox usr/bin/VBoxManage \
322 usr/bin/VBox usr/bin/vboxmanage \
323 $(if $(NOSDL),,usr/bin/VBox usr/bin/VBoxSDL) \
324 $(if $(NOSDL),,usr/bin/VBox usr/bin/vboxsdl) \
325 usr/bin/VBox usr/bin/VBoxHeadless \
326 usr/bin/VBox usr/bin/vboxheadless \
327 usr/bin/VBox usr/bin/VBoxBugReport \
328 usr/bin/VBox usr/bin/vboxbugreport \
329 usr/bin/VBox usr/bin/VBoxBalloonCtrl \
330 usr/bin/VBox usr/bin/vboxballoonctrl \
331 usr/bin/VBox usr/bin/VBoxAutostart \
332 usr/bin/VBox usr/bin/vboxautostart \
333 $(if $(NOWEBSVC),,usr/bin/VBox usr/bin/vboxwebsrv) \
334 $(if $(NOVBOXIMG),,usr/lib/virtualbox/vbox-img usr/bin/vbox-img) \
335 $(if $(NOVBOXIMGMOUNT),,usr/lib/virtualbox/vboximg-mount usr/bin/vboximg-mount) \
336 usr/share/virtualbox/src/vboxhost usr/src/vboxhost-$(ver)
337 $(if $(NOMODS),,dh_installmodules)
338 rm -f $(bldbase)/changelog
339 sed -e 's|%VER%|$(debver)|g' \
340 -e 's|%DATE%|$(shell date -R)|g' \
341 -e 's|%DEBREL%|$(subst _,~,$(debrel))|g' \
342 -e 's|%VERPKG%|$(verpkg)|g' \
343 $(debroot)/debian/changelog.in > $(bldbase)/changelog
344 dh_installdebconf
345 dh_installchangelogs
346 dh_installmenu
347 dh_installmime
348 dh_link
349 ifeq ($(DEBUG),)
350 dh_strip --keep-debug \
351 $(addprefix --exclude=lib,$(addsuffix VBox.so.6,\
352 Qt6Core Qt6Gui Qt6Widgets Qt6PrintSupport Qt6StateMachine Qt6DBus Qt6Xml Qt6XcbQpa Qt6Help Qt6Network Qt6Sql))
353 endif
354 mkdir -p $(bldbase)/$(verpkg)-dbg/usr/lib/$(package)
355 mv $(prefix)/usr/lib/$(package)/*.debug $(bldbase)/$(verpkg)-dbg/usr/lib/$(package)
356 ifeq ($(DEBUG),)
357 mv $(prefix)/usr/lib/debug $(bldbase)/$(verpkg)-dbg/usr/lib
358 endif
359 $(firstword $(shell which dh_python3) $(shell which dh_python2))
360 dh_compress -X.pdf -X.qch -X.qhc -X LICENSE -X.py
361 dh_fixperms
362 dh_makeshlibs
363 dh_installdeb
364 dh_perl
365 # For some reason, the Qt libraries couldn't be found on newer releases (e.g. Ubuntu hardy).
366 # Python is deliberately not listed as a dependency (see also comment in the "control" file.
367 # It is expected that dh_gencontrol shows a warning "substitution variable ${python:Versions}
368 # used, but is not defined" because of this.
369 LD_LIBRARY_PATH=$(prefix)/usr/lib/virtualbox dh_shlibdeps --exclude=VBoxPython
370 dh_gencontrol -- \
371 -Valsa=$(if $(HEADLESS),,libasound2) \
372 -Vpulse=$(if $(HEADLESS),,libpulse0) \
373 -Vsdlttf=$(if $(HEADLESS),,libsdl-ttf2.0-0)
374 dh_md5sums
375 dh_builddeb --destdir $(pkgdir) -- -Zxz
376 endif
377
378.PHONY: binary configure build clean
379endif
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