VirtualBox

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette