VirtualBox

source: vbox/trunk/src/VBox/Installer/linux/rpm/rules@ 103131

Last change on this file since 103131 was 102907, checked in by vboxsync, 9 months ago

Installer/linux: Point to website for the changelog in deb/rpm packages.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 12.2 KB
Line 
1#!/usr/bin/make -f
2# $Id: rules 102907 2024-01-16 19:50:33Z 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# possible overrides:
30# OSE=1 force VBOX_OSE
31# NOPARALLEL=1 compile with -j1
32# LINUX=<dir> compile vboxdrv against Linux found in <dir>
33# VERBOSE=1 verbose build
34# DEBUG=1 debug build
35# NOSUBVER=1 disable generation of the sub-version field (which is
36# either the subversion rev [if available] or the build date)
37# NODOCS=1 don't build docs, use precompiled UserManual*.pdf and
38# maybe UserManual*.qch and UserManual*.qhc from $(vboxroot)/prebuild
39# NOMODS=1 don't build any module
40# NOQT=1 don't build the Qt GUI
41# NOSDL=1 don't build VBoxSDL
42# EFI=1 include the EFI binary from prebuild
43# VERSUFFIX=<suffix> set a particular package version suffix (e.g. _customer)
44# HEADLESS=1 build the headless version
45# VNC=1 build VNC code
46# NOWEBSVC=1 don't build the webservice API
47# STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
48# PKGDIR=<path> where to store the final package(s)
49# svn_revision=xxx do not depend on subversion being available, but use this
50# hard-coded revision number instead
51#
52# NODOCS will be set if UserManual*.pdf, UserManual*.qch and UserManual*.qhc are
53# placed in $(vboxroot)/prebuild.
54# STAGEDISO will be set if VBoxGuestAdditions.iso is placed there.
55#
56# Wine will not be required if STAGEDISO is set.
57
58verpkg := VirtualBox-7.0
59vboxroot := $(shell while ! test -r configure && ! test "$$PWD" = "/"; do cd ..; done; pwd)
60instlin := $(vboxroot)/src/VBox/Installer/linux
61pkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd $(vboxroot)/..; pwd))
62outdir := $(if $(PATH_OUT_BASE),$(PATH_OUT_BASE),$(vboxroot)/out)
63bldbase := $(outdir)/rpm
64builddir := $(bldbase)/builddir
65stagedir := $(bldbase)/rpmbuild
66rpmlib := $(shell if [ `uname -m` = "x86_64" ]; then echo "lib64"; else echo "lib"; fi)
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
71
72NOMODS ?= $(ose)
73NOQT ?= $(HEADLESS)
74NOSDL ?= $(HEADLESS)
75NOWEBSVC ?=
76EFI ?= $(if $(wildcard $(vboxroot)/prebuild/VBoxEFI32.fd $(vboxroot)/prebuild/VBoxEFI64.fd),1,)
77NODOCS ?= $(if $(wildcard $(addprefix $(vboxroot)/prebuild/,UserManual*.pdf UserManual*.qch UserManual*.qhc)),1,)
78STAGEDISO ?= $(if $(wildcard $(vboxroot)/prebuild/VBoxGuestAdditions.iso),$(vboxroot)/prebuild,)
79NOWINE := $(if $(STAGEDISO),1,$(ose))
80
81ifneq ($(STAGEDISO),)
82 ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
83 $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
84 endif
85endif
86
87ifeq ($(wildcard rpm/rules),)
88$(error call rpm/rules from src/VBox/Installer/linux)
89endif
90
91ifneq ($(MAKECMDGOALS),clean)
92 # look for fedora
93 rpmrel := $(shell cat /etc/fedora-release 2> /dev/null | sed -e 's/^Fedora *release *\([1-9][0-9]*\) .*/fedora\1/')
94 ifeq ($(rpmrel),)
95 # look for OEL
96 rpmrel := $(shell cat /etc/enterprise-release 2> /dev/null | sed -ne 's/^Enterprise Linux[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
97 endif
98 ifeq ($(rpmrel),)
99 # look for OL
100 rpmrel := $(shell cat /etc/oracle-release 2> /dev/null | sed -ne 's/^Oracle Linux[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
101 endif
102 ifeq ($(rpmrel),)
103 # look for CentOS
104 rpmrel := $(shell cat /etc/redhat-release 2> /dev/null | sed -ne 's/^CentOS[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
105 endif
106 ifeq ($(rpmrel),)
107 # look for Red Hat
108 rpmrel := $(shell cat /etc/redhat-release 2> /dev/null | sed -ne 's/^Red Hat[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
109 endif
110 ifeq ($(rpmrel),)
111 # look for openSUSE
112 rpmrel := $(shell cat /etc/SUSE-brand 2> /dev/null | sed -ne 's/^VERSION *= *\([0-9]*\)\.\([0-9]*\)/openSUSE\1\2/p')
113 endif
114 # look for openSUSE Tumbleweed
115 ifeq ($(rpmrel),)
116 rpmrel := $(shell cat /etc/SUSE-brand 2> /dev/null | sed -ne 's/^VERSION *= *tumbleweed/openSUSETW/p')
117 endif
118 ifeq ($(rpmrel),)
119 $(error failed to detect the release type. Hack the detection.)
120 endif
121
122 rpmdist := $(strip $(shell grep $(rpmrel) $(instlin)/distributions_rpm | cut -d'=' -f2))
123 ifeq ($(rpmdist),)
124 $(error Cannot detect package distribution (rpmrel=$(rpmrel)))
125 endif
126
127 ifeq ($(filter-out el5 el6 el7 el8 el9 fedora18 fedora19 fedora20 fedora21 fedora22 fedora24 fedora25 fedora26 fedora29 fedora31 fedora32 fedora33 fedora35 fedora36,$(rpmrel)),)
128 rpmspec := rpm_redhat
129 endif
130 ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114 openSUSE123 openSUSE131 openSUSE132 openSUSE150 openSUSE153 openSUSETW,$(rpmrel)),)
131 rpmspec := rpm_suse
132 endif
133 ifeq ($(rpmspec),)
134 $(error failed to detect the .spec file (rpmrel=$(rpmrel)))
135 endif
136endif
137
138ifneq ($(wildcard $(verfile)),)
139include $(verfile)
140ver := $(VBOX_VERSION_STRING)
141svnver := $(if $(NOSUBVER),,$(if $(svn_revision),-$(svn_revision),$(shell if \
142 svn info $(vboxroot) > /dev/null 2>&1; then \
143 svn info $(vboxroot)|sed -e "s/^Revision: \(.*\)/-\1/;t;d"; else \
144 date +"-%Y%m%d"; fi)))
145rpmver := $(ver)$(subst -,_,$(svnver))$(VERSUFFIX)$(if $(HEADLESS),_headless,)$(if $(DEBUG),_dbg,)
146archdir := $(bldbase)/VirtualBox-$(ver)
147rpmname := $(verpkg)-$(rpmver)_$(rpmrel)
148endif
149
150# never ship any modules
151instmod :=
152
153ifeq ($(wildcard /usr/share/doc/packages/bash),)
154 doc_dir := VBOX_PATH_PACKAGE_DOCS="/usr/share/doc/$(verpkg)"
155else
156 # Novell (OpenSUSE, SLES)
157 doc_dir := VBOX_PATH_PACKAGE_DOCS="/usr/share/doc/packages/$(verpkg)"
158endif
159
160ifeq ($(NOQT),)
161 ifeq ($(rpmrel),el7)
162 # Protect against the fact that this Makefile is run several times, updating
163 # PATH every time. Still assumes that nothing else is added as a prefix.
164 PATH := $(PATH:/opt/rh/devtoolset-9/root/usr/bin:%=%)
165 export PATH := /opt/rh/devtoolset-9/root/usr/bin:$(PATH)
166 endif
167endif
168
169# EL5 ships Python 2.4 while our Python support requires Python 2.6 or later
170cfg_flags := $(if $(NOQT),--disable-qt,) \
171 $(if $(NOSDL),--disable-vboxsdl,) \
172 $(if $(filter el5 el6,$(rpmrel)),--build-libvpx,) \
173 $(if $(filter el5 el6,$(rpmrel)),--build-libopus,) \
174 $(if $(filter el5 el6,$(rpmrel)),--build-libssl,) \
175 $(if $(filter el5,$(rpmrel)),--build-libcurl,) \
176 $(if $(filter el5,$(rpmrel)),--disable-sdl-ttf,) \
177 $(if $(filter el5,$(rpmrel)),--disable-pulse,) \
178 $(if $(filter el5,$(rpmrel)),--disable-python,) \
179 $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
180 $(if $(HEADLESS),--build-headless,) \
181 $(if $(DEBUG),--build-debug,) \
182 $(if $(NOWINE),,--setup-wine) \
183 $(if $(VNC),--enable-vnc,) \
184 $(if $(PATH_OUT_BASE),--out-base-dir=$(PATH_OUT_BASE),) \
185 --disable-extpack
186
187bld_flags := LOCALCFG=$(instlin)/rpm/LocalConfig.kmk \
188 PATH_OUT=$(builddir) \
189 VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
190 VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
191 $(if $(filter el5 el6,$(rpmrel)),,VBOX_WITH_VMSVGA3D=1) \
192 VBOX_DO_STRIP= \
193 $(if $(filter el5,$(rpmrel)),VBOX_BLD_PYTHON=$(firstword $(wildcard \
194 /usr/local/bin/python2.7 /usr/bin/python2.7 /usr/bin/python2.6 /usr/bin/python2 /usr/bin/python)),) \
195 $(if $(filter el5,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1) \
196 $(doc_dir) \
197 VBOX_PACKAGE_DIST=$(rpmdist) \
198 $(if $(svn_revision),VBOX_SVN_REV=$(svn_revision),) \
199 $(if $(NODOCS),VBOX_WITH_DOCS=,) \
200 $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
201 $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,)
202
203configure: $(bldbase)/configure-stamp
204$(bldbase)/configure-stamp:
205 mkdir -p $(bldbase)
206 cd $(vboxroot) && ./configure --odir=$(bldbase) $(cfg_flags)
207 touch $@
208
209build: $(bldbase)/configure-stamp $(bldbase)/build-stamp
210$(bldbase)/build-stamp $(verfile): $(bldbase)/configure-stamp
211 . $(bldbase)/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
212 # Files from prebuild go to (builddir)/bin to be used during the
213 # packing stage, overriding what the build did/would produce.
214 $(if $(NODOCS),cp $(addprefix $(vboxroot)/prebuild/,UserManual*.pdf UserManual*.qch UserManual*.qhc) $(builddir)/bin,)
215 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
216 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
217 mkdir -p $(builddir)/bin/additions
218 $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
219 . $(bldbase)/env.sh && kmk -C $(vboxroot) $(bld_flags) \
220 VBOX_NO_LINUX_RUN_INSTALLER=1 \
221 VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86.tar.bz2 \
222 VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.tar.bz2 \
223 VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
224 VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
225 packing
226 touch $(bldbase)/build-stamp
227
228clean:
229 rm -rf $(archdir)
230 rm -rf $(stagedir)
231 rm -rf $(builddir)
232 rm -rf $(bldbase)/wine.*
233 rm -rf $(bldbase)/VirtualBox-*
234 rm -f $(bldbase)/VirtualBox.tar $(bldbase)/VirtualBox.tar.bz2
235 rm -f $(bldbase)/build-stamp $(bldbase)/configure-stamp
236 rm -f $(bldbase)/AutoConfig.kmk $(bldbase)/configure.log $(bldbase)/env.sh
237 rm -f $(bldbase)/VirtualBox.spec
238 if [ -d $(bldbase) ]; then rmdir $(bldbase); fi
239
240ifeq ($(VBOX_VERSION_MAJOR),)
241binary: build $(verfile)
242 +$(MAKE) -f rpm/rules binary
243
244else
245binary: build
246 rm -rf $(bldbase)/VirtualBox-*
247 tar -xf $(builddir)/bin/VirtualBox.tar -C $(bldbase)
248 sed \
249 -e 's|%VER%|$(ver)|g' \
250 -e 's|%NAME%|$(verpkg)|g' \
251 -e 's|%BUILDVER%|$(rpmver)|g' \
252 -e 's|%BUILDREL%|$(rpmrel)|g' \
253 -e 's|%BUILDROOT%|$(bldbase)/buildroot|g' \
254 -e 's|%OSE%|$(if $(ose),is_ose,not_ose)|g' \
255 -e 's|%SPEC%|$(rpmspec)|g' \
256 -e 's|%DATE%|$(shell date "+%a %b %d %Y")|g' \
257 -e 's|%QHELP%|$(if $(STAGEDQHELP),with_qhelp,without_qhelp)|g' \
258 -e 's|%PYTHON%|$(if $(filter el5,$(rpmrel)),without_python,with_python)|g' \
259 -e 's|%MACROSPYTHON%|$(if $(wildcard /usr/lib/rpm/macros.d/macros.python3),,$(if $(wildcard /usr/lib/rpm/macros.python),%include /usr/lib/rpm/macros.python,))|g' \
260 -e 's|%INSTMOD%|$(instmod)|g' \
261 -e 's|%LIBASOUND%|$(if $(filter lib64,$(rpmlib)),libasound.so.2()(64bit),libasound.so.2)|g' \
262 -e 's|%INITSCRIPTS%|$(if $(filter fedora,$(rpmspec)),initscripts,)|g' \
263 -e 's|%NETTOOLS%|$(if $(filter fedora18 fedora19 fedora20 fedora21 el5 openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114,$(rpmrel)),net-tools,iproute)|g' \
264 -e 's|%LIBVULKAN%|$(if $(filter el7,$(rpmrel)),vulkan,%LIBVULKAN%)|g' \
265 -e 's|%LIBVULKAN%|$(if $(findstring el,$(rpmrel)),vulkan-loader,%LIBVULKAN%)|g' \
266 -e 's|%LIBVULKAN%|$(if $(findstring fedora,$(rpmrel)),vulkan-loader,%LIBVULKAN%)|g' \
267 -e 's|%LIBVULKAN%|$(if $(filter openSUSE153,$(rpmrel)),libvulkan1,)|g' \
268 $(instlin)/rpm/VirtualBox.tmpl.spec > $(archdir)/VirtualBox.spec
269 mv $(bldbase)/VirtualBox-$(ver) $(bldbase)/$(rpmname)
270 cp $(vboxroot)/tools/linux.$(chrarch)/bin/chrpath $(bldbase)/$(rpmname) || true
271 tar -cf $(bldbase)/VirtualBox.tar -C $(bldbase) $(rpmname)
272 rm -f $(stagedir)/RPMS/*/VirtualBox*rpm
273 rm -f $(stagedir)/SPECS/*
274 mkdir -p $(stagedir)/BUILD $(stagedir)/RPMS/i386 $(stagedir)/RPMS/x86_64 $(stagedir)/SOURCES $(stagedir)/SPECS $(stagedir)/SRPMS
275 (cd $(bldbase); rpmbuild --define '_topdir $(stagedir)' -tb --clean VirtualBox.tar)
276 mv $(stagedir)/RPMS/*/$(verpkg)-debug* $(pkgdir) || true
277 file=`find $(stagedir)/RPMS -name $(verpkg)*rpm -print`; \
278 mv $$file $(pkgdir)
279# Note! if rpmbuild fails: sudo chmod a+rw /usr/src/redhat/* /usr/src/redhat/RPMS/*
280# Note! if find/mv fails: sudo ln -s redhat/ /usr/src/packages
281endif
282
283.PHONY: binary configure build clean
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