VirtualBox

source: vbox/trunk/debian/rules@ 92273

Last change on this file since 92273 was 92273, checked in by vboxsync, 3 years ago

debian/rules, rpm/VirtualBox.tmpl.spec: Move the UnattendedTemplates directory to the right location (needs to be in /usr/share/virtualbox).

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