VirtualBox

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

Last change on this file since 79862 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 10.3 KB
Line 
1#!/usr/bin/make -f
2# $Id: rules 76553 2019-01-01 01:45:53Z vboxsync $
3## @file
4# VirtualBox rules.
5#
6
7#
8# Copyright (C) 2006-2019 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# VirtualBox.chm 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# PKGDIR=<path> where to store the final package(s)
39# svn_revision=xxx do not depend on subversion being available, but use this
40# hard-coded revision number instead
41#
42# NODOCS will also be set if UserManual*.pdf and VirtualBox*.chm are placed in
43# $(vboxroot)/prebuild. STAGEDISO will be set if VBoxGuestAdditions.iso is
44# placed there. Wine will not be required to be available if both NODOCS and
45# STAGEDISO are set.
46
47ifeq ($(wildcard rpm/rules),)
48$(error call rpm/rules from src/VBox/Installer/linux)
49endif
50
51verpkg := VirtualBox-6.0
52current := $(shell pwd)
53vboxroot := $(shell while ! test -r configure && ! test "$PWD" = "/"; do cd ..; done; pwd)
54pkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd $(vboxroot)/..; pwd))
55builddir := $(vboxroot)/rpm/builddir
56rpmlib := $(shell if [ `uname -m` = "x86_64" ]; then echo "lib64"; else echo "lib"; fi)
57chrarch := $(shell if [ `uname -m` = "x86_64" ]; then echo "amd64"; else echo "x86"; fi)
58verfile := $(builddir)/version-generated.mk
59ose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
60-include $(vboxroot)/SVN_REVISION
61svnrev :=$(if $(svn_revision),$(svn_revision),)
62
63NOMODS ?= $(ose)
64NOQT ?= $(HEADLESS)
65NOWEBSVC ?= $(ose)
66NODOCS ?= $(if $(wildcard $(vboxroot)/prebuild/UserManual*.pdf),$(if $(wildcard $(vboxroot)/prebuild/VirtualBox*.chm),1,),)
67STAGEDISO ?= $(if $(wildcard $(vboxroot)/prebuild/VBoxGuestAdditions.iso),$(vboxroot)/prebuild,)
68NOWINE := $(if $(NODOCS),$(if $(STAGEDISO),1,),)$(ose)
69
70ifneq ($(MAKECMDGOALS),clean)
71 # look for fedora
72 rpmrel := $(shell cat /etc/fedora-release 2> /dev/null | sed -e 's/^Fedora *release *\([1-9][0-9]*\) .*/fedora\1/')
73 ifeq ($(rpmrel),)
74 # look for OL
75 rpmrel := $(shell cat /etc/enterprise-release 2> /dev/null | sed -ne 's/^Enterprise Linux[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
76 endif
77 ifeq ($(rpmrel),)
78 # look for CentOS
79 rpmrel := $(shell cat /etc/redhat-release 2> /dev/null | sed -ne 's/^CentOS[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
80 endif
81 ifeq ($(rpmrel),)
82 # look for Red Hat
83 rpmrel := $(shell cat /etc/redhat-release 2> /dev/null | sed -ne 's/^Red Hat[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
84 endif
85 ifeq ($(rpmrel),)
86 # look for openSUSE
87 rpmrel := $(shell cat /etc/SUSE-brand 2> /dev/null | sed -ne 's/^VERSION *= *\([0-9]*\)\.\([0-9]*\)/openSUSE\1\2/p')
88 endif
89 ifeq ($(rpmrel),)
90 $(error failed to detect the release type. Hack the detection.)
91 endif
92
93 rpmdist := $(strip $(shell grep $(rpmrel) $(current)/distributions_rpm | cut -d'=' -f2))
94 ifeq ($(rpmdist),)
95 $(error Cannot detect package distribution (rpmrel=$(rpmrel)))
96 endif
97
98 ifeq ($(filter-out el5 el6 el7 fedora18 fedora19 fedora20 fedora21 fedora22 fedora24 fedora25 fedora26 fedora29,$(rpmrel)),)
99 rpmspec := rpm_redhat
100 endif
101 ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114 openSUSE123 openSUSE131 openSUSE132 openSUSE150,$(rpmrel)),)
102 rpmspec := rpm_suse
103 endif
104 ifeq ($(rpmspec),)
105 $(error failed to detect the .spec file (rpmrel=$(rpmrel)))
106 endif
107
108 # contrary to debian we need the verfile earlier to get the correct rpmname into the bld_flags
109 include $(verfile)
110$(verfile): rpm/configure-stamp
111 . rpm/env.sh && kmk -C $(vboxroot) $(verfile) $(bld_flags)
112
113endif
114
115ver := $(VBOX_VERSION_STRING)
116rpmver :=$(ver)$(if $(NOSUBVER),,$(if $(svn_revision),_$(svn_revision),)$(VERSUFFIX)$(if $(HEADLESS),_headless,)$(if $(DEBUG),_dbg,))
117archdir := $(current)/rpm/VirtualBox-$(ver)
118rpmname := $(verpkg)-$(rpmver)_$(rpmrel)
119
120# never ship any modules
121instmod :=
122
123ifneq ($(STAGEDISO),)
124 ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
125 $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
126 endif
127endif
128
129ifeq ($(wildcard /usr/share/doc/packages/bash),)
130 doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\""
131else
132 # Novell (OpenSUSE, SLES)
133 doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/packages/$(verpkg)\""
134endif
135
136# EL5 ships Python 2.4 while our Python support requires Python 2.6 or later
137cfg_flags := $(if $(NOQT),--disable-qt,) \
138 $(if $(NOSDL),--disable-vboxsdl,) \
139 $(if $(filter el5 el6,$(rpmrel)),--build-libvpx,) \
140 $(if $(filter el5 el6,$(rpmrel)),--build-libopus,) \
141 $(if $(filter el5 el6,$(rpmrel)),--build-libssl,) \
142 $(if $(filter el5,$(rpmrel)),--build-libcurl,) \
143 $(if $(filter el5,$(rpmrel)),--disable-sdl-ttf,) \
144 $(if $(filter el5,$(rpmrel)),--disable-pulse,) \
145 $(if $(filter el5,$(rpmrel)),--disable-python,) \
146 $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
147 $(if $(HEADLESS),--build-headless,) \
148 $(if $(DEBUG),--build-debug,) \
149 $(if $(NOWINE),,--setup-wine) \
150 $(if $(NOWEBSVC),,$(if $(ose),--enable-webservice,)) \
151 $(if $(VNC),--enable-vnc,) \
152 --disable-extpack
153
154bld_flags := AUTOCFG=$(current)/rpm/AutoConfig.kmk \
155 LOCALCFG=$(current)/rpm/LocalConfig.kmk \
156 PATH_OUT=$(builddir) \
157 VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
158 VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
159 $(if $(filter el5 el6,$(rpmrel)),,VBOX_WITH_VMSVGA3D=1) \
160 VBOX_DO_STRIP= \
161 $(if $(filter el5,$(rpmrel)),VBOX_BLD_PYTHON=$(strip \
162 $(firstword $(wildcard /usr/local/bin/python2.7) \
163 $(wildcard /usr/bin/python2.6) $(wildcard /usr/bin/python))),) \
164 $(doc_dir) \
165 $(if $(ose),,VBOX_WITH_DOCS_CHM=1) \
166 VBOX_PACKAGE_DIST=$(rpmdist) \
167 $(if $(svnrev),VBOX_SVN_REV=$(svnrev),) \
168 $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
169 $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
170 $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
171 $(if $(filter el5,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
172
173rpm/configure-stamp:
174 cd $(vboxroot) && ./configure --odir=$(current)/rpm $(cfg_flags)
175 touch rpm/configure-stamp
176
177rpm/build-stamp: rpm/configure-stamp
178 . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
179 $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
180 $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
181 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
182 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
183 mkdir -p $(builddir)/bin/additions
184 $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
185 . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) \
186 VBOX_NO_LINUX_RUN_INSTALLER=1 \
187 VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86.tar.bz2 \
188 VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.tar.bz2 \
189 VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
190 VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
191 packing
192 touch rpm/build-stamp
193
194clean:
195 rm -rf $(archdir)
196 rm -rf $(builddir) rpm/VirtualBox-*
197 rm -f rpm/VirtualBox.tar
198 rm -f rpm/VirtualBox.tar.bz2
199 rm -f rpm/VirtualBox.spec
200 rm -f rpm/build-stamp rpm/configure-stamp rpm/configure.log
201 rm -f rpm/AutoConfig.kmk rpm/env.sh
202
203ifeq ($(VBOX_VERSION_MAJOR),)
204binary: rpm/build-stamp $(verfile)
205 $(MAKE) -f rpm/rules binary
206else
207binary: rpm/build-stamp
208 rm -rf rpm/VirtualBox-*
209 tar -xf $(builddir)/bin/VirtualBox.tar -C rpm
210 sed \
211 -e 's|%VER%|$(ver)|g' \
212 -e 's|%NAME%|$(verpkg)|g' \
213 -e 's|%BUILDVER%|$(rpmver)|g' \
214 -e 's|%BUILDREL%|$(rpmrel)|g' \
215 -e 's|%BUILDROOT%|$(current)/rpm/buildroot|g' \
216 -e 's|%LIB%|$(rpmlib)|g' \
217 -e 's|%OSE%|$(if $(ose),is_ose,not_ose)|g' \
218 -e 's|%SPEC%|$(rpmspec)|g' \
219 -e 's|%PYTHON%|$(if $(filter el5,$(rpmrel)),,with_python)|g' \
220 -e 's|%MACROSPYTHON%|$(if $(wildcard /usr/lib/rpm/macros.python),%include /usr/lib/rpm/macros.python,)|g' \
221 -e 's|%INSTMOD%|$(instmod)|g' \
222 -e 's|%LIBASOUND%|$(if $(filter lib64,$(rpmlib)),libasound.so.2()(64bit),libasound.so.2)|g' \
223 -e 's|%INITSCRIPTS%|$(if $(filter fedora,$(rpmspec)),initscripts,)|g' \
224 -e 's|%WEBSVC%|$(if $(NOWEBSVC),false,true)|g' \
225 -e 's|%NETTOOLS%|$(if $(filter fedora18 fedora19 fedora20 fedora21 el5 openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114,$(rpmrel)),net-tools,iproute)|g' \
226 rpm/VirtualBox.tmpl.spec > $(archdir)/VirtualBox.spec
227 mv rpm/VirtualBox-$(ver) rpm/$(rpmname)
228 cp ../../../../tools/linux.$(chrarch)/bin/chrpath rpm/$(rpmname) || true
229 tar -cf rpm/VirtualBox.tar -C rpm $(rpmname)
230 rm -f rpmbuild/RPMS/*/VirtualBox*rpm
231 rm -f rpmbuild/SPECS/*
232 mkdir -p rpmbuild/BUILD rpmbuild/RPMS/i386 rpmbuild/RPMS/x86_64 rpmbuild/SOURCES rpmbuild/SPECS rpmbuild/SRPMS
233 (cd rpm; rpmbuild --define '_topdir $(current)/rpmbuild' -tb --clean VirtualBox.tar)
234 mv rpmbuild/RPMS/*/$(verpkg)-debug* $(pkgdir) || true
235 file=`find rpmbuild/RPMS -name $(verpkg)*rpm -print`; \
236 mv $$file $(pkgdir)
237# Note! if rpmbuild fails: sudo chmod a+rw /usr/src/redhat/* /usr/src/redhat/RPMS/*
238# Note! if find/mv fails: sudo ln -s redhat/ /usr/src/packages
239endif
240
241.PHONY: binary 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