VirtualBox

source: vbox/trunk/debian/rules@ 94521

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

configure, debian/rules, rpm/rules: Fix AUTOCFG handing in configure, eliminating the need to pass it in the build command line. Also fix the out directory handling when it is overridden. In that case there is no additional out subdirectory.

  • 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 92590 2021-11-24 22:32:04Z 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 := LOCALCFG=$(debroot)/debian/LocalConfig.kmk \
114 PATH_OUT=$(builddir) \
115 VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
116 VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
117 VBOX_WITH_VMSVGA3D=1 \
118 VBOX_DO_STRIP= \
119 VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\"" \
120 $(if $(svn_revision),VBOX_SVN_REV=$(svn_revision),) \
121 $(if $(NODOCS),VBOX_WITH_DOCS=,) \
122 $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
123 $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,)
124
125configure: $(bldbase)/configure-stamp
126$(bldbase)/configure-stamp:
127 dh_testdir
128 mkdir -p $(bldbase)
129 cd $(vboxroot) && ./configure --odir=$(bldbase) $(cfg_flags)
130 touch $@
131
132build: $(bldbase)/configure-stamp $(bldbase)/build-stamp
133$(bldbase)/build-stamp $(verfile): $(bldbase)/configure-stamp
134 dh_testdir
135 . $(bldbase)/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
136 # Files from prebuild go to (builddir)/bin to be used during the
137 # packing stage, overriding what the build did/would produce.
138 $(if $(NODOCS),cp $(addprefix $(vboxroot)/prebuild/,UserManual*.pdf UserManual*.qch UserManual*.qhc) $(builddir)/bin,)
139 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
140 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
141 mkdir -p $(builddir)/bin/additions
142 $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
143 . $(bldbase)/env.sh && kmk -C $(vboxroot) $(bld_flags) \
144 VBOX_NO_LINUX_RUN_INSTALLER=1 \
145 VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86.tar.bz2 \
146 VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.tar.bz2 \
147 VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
148 VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
149 packing
150 touch $(bldbase)/build-stamp
151
152# Build modules for every kernel we find in /lib/modules/*
153$(bldbase)/modules-stamp: $(bldbase)/build-stamp
154 rm -rf $(moddir)
155 mkdir $(moddir)
156 for d in $(wildcard /lib/modules/*); do \
157 if [ -L $$d/build ]; then \
158 make -C $(builddir)/bin/src/vboxdrv KERN_VER=$$(basename $$d) clean && \
159 make -C $(builddir)/bin/src/vboxdrv KBUILD_VERBOSE= KERN_VER=$$(basename $$d) all; \
160 make -C $(builddir)/bin/src/vboxnetflt KERN_VER=$$(basename $$d) clean && \
161 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetflt || true) && \
162 make -C $(builddir)/bin/src/vboxnetflt KBUILD_VERBOSE= KERN_VER=$$(basename $$d) KBUILD_EXTRA_SYMBOLS=$(builddir)/bin/src/vboxnetflt/Module.symvers all; \
163 make -C $(builddir)/bin/src/vboxnetadp KERN_VER=$$(basename $$d) clean && \
164 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetadp || true) && \
165 make -C $(builddir)/bin/src/vboxnetadp KBUILD_VERBOSE= KERN_VER=$$(basename $$d) KBUILD_EXTRA_SYMBOLS=$(builddir)/bin/src/vboxnetadp/Module.symvers all; \
166 [ -d $(builddir)/bin/src/vboxpci ] && make -C $(builddir)/bin/src/vboxpci KERN_VER=$$(basename $$d) clean && \
167 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxpci || true) && \
168 make -C $(builddir)/bin/src/vboxpci KBUILD_VERBOSE= KERN_VER=$$(basename $$d) KBUILD_EXTRA_SYMBOLS=$(builddir)/bin/src/vboxpci/Module.symvers all; \
169 true; \
170 fi; \
171 done
172 touch $@
173
174clean:
175 dh_testdir
176 dh_testroot
177 dh_clean
178 rm -rf $(archdir)
179 rm -rf $(builddir)
180 rm -rf $(moddir)
181 rm -rf $(bldbase)/wine.*
182 rm -rf $(bldbase)/VirtualBox-*
183 rm -f $(bldbase)/VirtualBox.tar $(bldbase)/VirtualBox.tar.bz2
184 rm -f $(bldbase)/virtualbox-*.substvars $(bldbase)/virtualbox*.debhelper
185 rm -f $(bldbase)/$(verpkg).mime $(bldbase)/$(verpkg).sharedmimeinfo
186 rm -f $(bldbase)/modules-stamp $(bldbase)/build-stamp $(bldbase)/configure-stamp
187 rm -f $(bldbase)/AutoConfig.kmk $(bldbase)/configure.log $(bldbase)/env.sh
188 rm -f $(addprefix $(bldbase)/,$(DEBPKGFILES))
189 if [ -d $(bldbase) ]; then rmdir $(bldbase); fi
190
191 ifeq ($(VBOX_VERSION_MAJOR),)
192binary: build $(verfile)
193 +$(MAKE) -f debian/rules binary
194
195 else
196# Build architecture-dependent files here.
197binary: build $(if $(NOMODS),,$(bldbase)/modules-stamp)
198 dh_testdir
199 dh_testroot
200 dh_prep
201 dh_installdirs
202 tar -xC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar
203 install -d -g 0 -o 0 $(prefix)/usr/share/applications
204 install -d -g 0 -o 0 $(prefix)/usr/lib
205 install -d -g 0 -o 0 $(prefix)/usr/bin
206 install -d -g 0 -o 0 $(prefix)/usr/share/$(package)
207 mv $(archdir)/UnattendedTemplates $(prefix)/usr/share/$(package)/
208 install -d -g 0 -o 0 $(prefix)/usr/share/doc/$(verpkg)
209 $(if $(NOQT),,mv $(archdir)/virtualbox.desktop \
210 $(prefix)/usr/share/applications/virtualbox.desktop)
211 $(if $(NOQT),,mv $(archdir)/virtualboxvm.desktop \
212 $(prefix)/usr/share/applications/virtualboxvm.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 $(bldbase)/$(verpkg).sharedmimeinfo)
233 install -d -g 0 -o 0 $(prefix)/usr/share/lintian/overrides
234 sed \
235 -e 's|%VERPKG%|$(verpkg)|g' \
236 $(vboxroot)/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 $(instlin)/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)
262 dh_installdocs $(addprefix $(archdir)/,UserManual*.pdf LICENSE)
263 mv $(addprefix $(archdir)/,$(if $(HEADLESS),,rdesktop-vrdp.tar.gz) additions/VBoxGuestAdditions.iso) $(prefix)/usr/share/$(package)
264 $(if $(HEADLESS),,mv $(archdir)/rdesktop-vrdp $(prefix)/usr/bin)
265 $(if $(HEADLESS),,mv $(archdir)/rdesktop-vrdp-keymaps $(prefix)/usr/share/$(package))
266 mv $(archdir) $(prefix)/usr/lib/$(package)
267 if [ -f $(prefix)/usr/lib/$(package)/libQt5CoreVBox.so.5 ]; then \
268 $(vboxroot)/tools/linux.$(chrarch)/bin/chrpath \
269 --keepgoing --replace /usr/lib/$(package) \
270 $(prefix)/usr/lib/$(package)/*.so.5 \
271 $(prefix)/usr/lib/$(package)/plugins/platforms/*.so; \
272 $(prefix)/usr/lib/$(package)/plugins/platformthemes/*.so; \
273 $(prefix)/usr/lib/$(package)/plugins/sqldrivers/*.so; \
274 $(prefix)/usr/lib/$(package)/plugins/styles/*.so; \
275 $(prefix)/usr/lib/$(package)/plugins/xcbglintegrations/*.so; \
276 echo "[Paths]" > $(prefix)/usr/lib/$(package)/qt.conf; \
277 echo "Plugins = /usr/lib/$(package)/plugins" >> $(prefix)/usr/lib/$(package)/qt.conf; \
278 fi
279 export VBOX_INSTALL_PATH=/usr/lib/$(package) && \
280 cd $(builddir)/bin/sdk/installer && \
281 $(PYTHON) ./vboxapisetup.py install --root $(prefix)
282 rm -rf $(prefix)/usr/lib/$(package)/sdk/installer
283 ln -s ../VBoxVMM.so $(prefix)/usr/lib/$(package)/components/VBoxVMM.so
284 rmdir $(prefix)/opt
285 dh_link \
286 $(if $(NOQT),,usr/bin/VBox usr/bin/VirtualBox) \
287 $(if $(NOQT),,usr/bin/VBox usr/bin/virtualbox) \
288 $(if $(NOQT),,usr/bin/VBox usr/bin/VirtualBoxVM) \
289 $(if $(NOQT),,usr/bin/VBox usr/bin/virtualboxvm) \
290 usr/bin/VBox usr/bin/VBoxManage \
291 usr/bin/VBox usr/bin/vboxmanage \
292 $(if $(NOSDL),,usr/bin/VBox usr/bin/VBoxSDL) \
293 $(if $(NOSDL),,usr/bin/VBox usr/bin/vboxsdl) \
294 usr/bin/VBox usr/bin/VBoxHeadless \
295 usr/bin/VBox usr/bin/vboxheadless \
296 usr/bin/VBox usr/bin/VBoxBugReport \
297 usr/bin/VBox usr/bin/vboxbugreport \
298 usr/bin/VBox usr/bin/VBoxBalloonCtrl \
299 usr/bin/VBox usr/bin/vboxballoonctrl \
300 usr/bin/VBox usr/bin/VBoxAutostart \
301 usr/bin/VBox usr/bin/vboxautostart \
302 $(if $(NOWEBSVC),,usr/bin/VBox usr/bin/vboxwebsrv) \
303 $(if $(NOVBOXIMG),,usr/lib/virtualbox/vbox-img usr/bin/vbox-img) \
304 $(if $(NOVBOXIMGMOUNT),,usr/lib/virtualbox/vboximg-mount usr/bin/vboximg-mount) \
305 usr/share/virtualbox/src/vboxhost usr/src/vboxhost-$(ver)
306 $(if $(NOMODS),,dh_installmodules)
307 dh_installdebconf
308 dh_installchangelogs
309 dh_installmenu
310 dh_installmime
311 dh_link
312 ifeq ($(DEBUG),)
313 dh_strip --keep-debug \
314 $(addprefix --exclude=lib,$(addsuffix VBox.so.5,\
315 Qt5Core Qt5Gui Qt5Widgets Qt5PrintSupport Qt5OpenGL Qt5DBus Qt5XcbQpa Qt5X11Extras))
316 endif
317 mkdir -p $(bldbase)/$(verpkg)-dbg/usr/lib/$(package)
318 mv $(prefix)/usr/lib/$(package)/*.debug $(bldbase)/$(verpkg)-dbg/usr/lib/$(package)
319 ifeq ($(DEBUG),)
320 mv $(prefix)/usr/lib/debug $(bldbase)/$(verpkg)-dbg/usr/lib
321 endif
322 $(firstword $(shell which dh_python3) $(shell which dh_python2))
323 dh_compress -X.pdf -X.qch -X.qhc -X LICENSE -X.py
324 dh_fixperms
325 dh_makeshlibs
326 dh_installdeb
327 dh_perl
328 # For some reason, the Qt libraries couldn't be found on newer releases (e.g. Ubuntu hardy).
329 # Python is deliberately not listed as a dependency (see also comment in the "control" file.
330 # It is expected that dh_gencontrol shows a warning "substitution variable ${python:Versions}
331 # used, but is not defined" because of this.
332 LD_LIBRARY_PATH=$(prefix)/usr/lib/virtualbox dh_shlibdeps --exclude=VBoxPython
333 dh_gencontrol -- \
334 -Valsa=$(if $(HEADLESS),,libasound2) \
335 -Vpulse=$(if $(HEADLESS),,libpulse0) \
336 -Vsdlttf=$(if $(HEADLESS),,libsdl-ttf2.0-0)
337 dh_md5sums
338 dh_builddeb --destdir $(pkgdir) -- -Zxz
339 endif
340
341.PHONY: binary configure build clean
342endif
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use