VirtualBox

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

Last change on this file since 90081 was 90081, checked in by vboxsync, 4 years ago

debian/rules, rpm/rules: Make it listen to PATH_OUT_BASE, not VBOX_OUT_BASE as in previous change.

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