VirtualBox

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

Last change on this file since 56299 was 56299, checked in by vboxsync, 9 years ago

Installer: Updated (C) 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.2 KB
Line 
1#!/usr/bin/make -f
2#
3# Copyright (C) 2006-2015 Oracle Corporation
4#
5# This file is part of VirtualBox Open Source Edition (OSE), as
6# available from http://www.virtualbox.org. This file is free software;
7# you can redistribute it and/or modify it under the terms of the GNU
8# General Public License (GPL) as published by the Free Software
9# Foundation, in version 2 as it comes in the "COPYING" file of the
10# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
11# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
12#
13
14# possible overrides:
15# OSE=1 force VBOX_OSE
16# NOPARALLEL=1 compile with -j1
17# LINUX=<dir> compile vboxdrv against Linux found in <dir>
18# VERBOSE=1 verbose build
19# DEBUG=1 debug build
20# NOSUBVER=1 disable generation of the sub-version field (which is
21# either the subversion rev [if available] or the build date)
22# NODOCS=1 don't build docs, use precompiled UserManual.pdf and
23# VirtualBox.chm from $HOME
24# NOMODS=1 don't build any module
25# NOQT=1 don't build the Qt GUI
26# EFI=1 include the EFI binary from prebuild
27# VERSUFFIX=<suffix> set a particular package version suffix (e.g. _customer)
28# HEADLESS=1 build the headless version
29# VNC=1 build VNC code
30# NOWEBSVC=1 don't build the webservice API, default for OSE
31# STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
32# PKGDIR=<path> where to store the final package(s)
33# BLEEDING_EDGE=xyz
34
35ifeq ($(wildcard rpm/rules),)
36$(error call rpm/rules from src/VBox/Installer/linux)
37endif
38
39ifneq ($(wildcard /usr/lib/rpm/find-requires.ksyms),)
40# don't allow to check for kernel syms, otherwise we depend on specific kernel versions!
41$(error /usr/lib/rpm/find-requires.ksyms must not be installed)
42endif
43ifneq ($(wildcard /usr/lib/rpm/find-supplements.ksyms),)
44# same for openSUSE
45$(error /usr/lib/rpm/find-supplements.ksyms must not be installed)
46endif
47ifeq ($(shell if grep -q '^/usr/lib/virtualbox' /etc/permissions* 2>/dev/null; then echo yes; fi),yes)
48# make sure openSUSE permissions fixes don't interfere with us
49$(error Fix /etc/permissions*)
50endif
51ifeq ($(shell if grep -q '^%disttag' /usr/lib/rpm/macros.d/mandriva 2>/dev/null; then echo yes; fi),yes)
52$(error Fix /usr/lib/rpm/macros.d/mandriva)
53endif
54
55verpkg := VirtualBox-5.0
56current := $(shell pwd)
57vboxroot := $(shell cd ../../../..; pwd)
58pkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd ../../../../..; pwd))
59builddir := $(current)/rpm/builddir
60rpmlib := $(shell if [ `uname -m` = "x86_64" ]; then echo "lib64"; else echo "lib"; fi)
61arch := $(shell if [ `uname -m` = "x86_64" ]; then echo "amd64"; else echo "i386"; fi)
62verfile := $(builddir)/version-generated.mk
63ose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
64-include $(vboxroot)/SVN_REVISION
65svnrev :=$(if $(svn_revision),$(svn_revision),)
66
67NOMODS ?= $(ose)
68NOQT ?= $(HEADLESS)
69NOWEBSVC ?= $(ose)
70NOWINE := $(if $(NODOCS),$(if $(STAGEDISO),1,),)$(ose)
71
72ifneq ($(MAKECMDGOALS),clean)
73 rpmrel := $(subst ol,el,$(subst rhel,el,$(shell cat /etc/distname)))
74 ifeq ($(rpmrel),)
75 # look for fedora
76 rpmrel := $(shell cat /etc/fedora-release | sed -e 's/^Fedora *release *\([1-9][0-9]*\) .*/fedora\1/')
77 endif
78 ifeq ($(rpmrel),)
79 $(error failed to detect the release type. Add /etc/distname or hack the detection.)
80 endif
81
82 rpmdist := $(strip $(shell grep $(rpmrel) $(current)/distributions_rpm | cut -d'=' -f2))
83 ifeq ($(rpmdist),)
84 $(error Cannot detect package distribution (rpmrel=$(rpmrel)))
85 endif
86
87 ifeq ($(filter-out el5 el6 ol5 ol6 el7 centos5 centos6 fedora17 fedora18 fedora19 fedora20 fedora21 fedora22,$(rpmrel)),)
88 rpmspec := rpm_redhat
89 endif
90 ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114 openSUSE123 sles10.1 sles11.0,$(rpmrel)),)
91 rpmspec := rpm_suse
92 endif
93 ifeq ($(filter-out mdv2009.1 mdv2010.0 mdv2011.0,$(rpmrel)),)
94 rpmspec := rpm_mdv
95 endif
96 ifeq ($(rpmspec),)
97 $(error failed to detect the .spec file (rpmrel=$(rpmrel)))
98 endif
99
100 # contrary to debian we need the verfile earlier to get the correct rpmname into the bld_flags
101 include $(verfile)
102$(verfile): rpm/configure-stamp
103 . rpm/env.sh && kmk -C $(vboxroot) $(verfile) $(bld_flags)
104
105endif
106
107ver := $(VBOX_VERSION_STRING)
108rpmver :=$(ver)$(if $(NOSUBVER),,$(if $(svn_revision),_$(svn_revision),)$(VERSUFFIX)$(if $(HEADLESS),_headless,)$(if $(DEBUG),_dbg,))$(if $(BLEEDING_EDGE),_$(BLEEDING_EDGE),)
109archdir := $(current)/rpm/VirtualBox-$(ver)
110rpmname := $(verpkg)-$(rpmver)_$(rpmrel)
111
112# never ship any modules
113instmod :=
114
115ifneq ($(STAGEDISO),)
116 ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
117 $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
118 endif
119endif
120
121ifeq ($(wildcard /usr/share/doc/packages/bash),)
122 ifeq ($(wildcard /usr/share/doc/bash),)
123 # Mandriva 2007.1, Redhat
124 doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(rpmname)\""
125 else
126 # Mandriva 2008.0
127 doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\""
128 endif
129else
130 # Novell (OpenSUSE, SLES)
131 doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/packages/$(verpkg)\""
132endif
133
134cfg_flags := $(if $(NOQT),--disable-qt,) \
135 $(if $(filter sles10.1,$(rpmrel)),--build-libxml2,) \
136 $(if $(filter el5 el6 sles10.1 sles11.0 mdv2011.0,$(rpmrel)),--build-libvpx,) \
137 $(if $(filter el5 ol5 centos5 sles10.1 sles11.0,$(rpmrel)),--build-libcurl,) \
138 $(if $(filter el5 centos5 sles10.1,$(rpmrel)),--disable-sdl-ttf,) \
139 $(if $(filter sles10.1,$(rpmrel)),--disable-pulse,) \
140 $(if $(filter el5 ol5 centos5,$(rpmrel)),--enable-pulse,) \
141 $(if $(filter el5 ol5 centos5 el6 ol6 centos6 sles10.1 sles11.0,$(rpmrel)),--with-qt4-dir=/home/vbox/Qt-4.8.6-stdc++6-$(arch)) \
142 $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
143 $(if $(HEADLESS),--build-headless,) \
144 $(if $(DEBUG),--build-debug,) \
145 $(if $(NOWINE),,--setup-wine) \
146 $(if $(NOWEBSVC),,$(if $(ose),--enable-webservice,)) \
147 $(if $(VNC),--enable-vnc,) \
148 --disable-extpack
149
150bld_flags := AUTOCFG=$(current)/rpm/AutoConfig.kmk \
151 LOCALCFG=$(current)/rpm/LocalConfig.kmk \
152 PATH_OUT=$(builddir) \
153 VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
154 VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
155 $(if $(filter el5 el6 sles10.1 sles11.0,$(rpmrel)),,VBOX_WITH_VMSVGA3D=1) \
156 VBOX_DO_STRIP= \
157 VBOX_WITH_MULTIVERSION_PYTHON= \
158 $(doc_dir) \
159 $(if $(ose),,VBOX_WITH_DOCS_CHM=1) \
160 VBOX_PACKAGE_DIST=$(rpmdist) \
161 $(if $(svnrev),VBOX_SVN_REV=$(svnrev),) \
162 $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
163 $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
164 $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
165 $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),) \
166 $(if $(filter el5 ol5 centos5 sles10.1,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
167
168rpm/configure-stamp:
169 cd $(vboxroot) && ./configure --odir=$(current)/rpm $(cfg_flags)
170 touch rpm/configure-stamp
171
172rpm/build-stamp: rpm/configure-stamp
173 . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
174 $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
175 $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
176 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
177 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
178 mkdir -p $(builddir)/bin/additions
179 $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
180 . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) \
181 VBOX_NO_LINUX_RUN_INSTALLER=1 \
182 VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86.tar.bz2 \
183 VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.tar.bz2 \
184 VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
185 VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
186 packing
187 touch rpm/build-stamp
188
189clean:
190 rm -rf $(archdir)
191 rm -rf $(builddir) rpm/VirtualBox-*
192 rm -f rpm/VirtualBox.tar.bz2
193 rm -f rpm/VirtualBox.spec
194 rm -f rpm/build-stamp rpm/configure-stamp rpm/configure.log
195 rm -f rpm/AutoConfig.kmk rpm/env.sh
196
197ifeq ($(VBOX_VERSION_MAJOR),)
198binary: rpm/build-stamp $(verfile)
199 $(MAKE) -f rpm/rules binary
200else
201binary: rpm/build-stamp
202 rm -rf rpm/VirtualBox-*
203 tar -xjf $(builddir)/bin/VirtualBox.tar.bz2 -C rpm
204 sed \
205 -e 's|%VER%|$(ver)|g' \
206 -e 's|%NAME%|$(verpkg)|g' \
207 -e 's|%BUILDVER%|$(rpmver)|g' \
208 -e 's|%BUILDREL%|$(rpmrel)|g' \
209 -e 's|%BUILDROOT%|$(current)/rpm/buildroot|g' \
210 -e 's|%LIB%|$(rpmlib)|g' \
211 -e 's|%OSE%|$(if $(ose),is_ose,not_ose)|g' \
212 -e 's|%SPEC%|$(rpmspec)|g' \
213 -e 's|%MACROSPYTHON%|$(if $(wildcard /usr/lib/rpm/macros.python),%include /usr/lib/rpm/macros.python,)|g' \
214 -e 's|%INSTMOD%|$(instmod)|g' \
215 -e 's|%LIBASOUND%|$(if $(filter lib64,$(rpmlib)),libasound.so.2()(64bit),libasound.so.2)|g' \
216 -e 's|%INITSCRIPTS%|$(if $(filter fedora,$(rpmspec)),initscripts,)|g' \
217 -e "s|%WEBSVC%|$(if $(NOWEBSVC),false,true)|g" \
218 -e '/#include installer-common.sh/ {' \
219 -e "r $(vboxroot)/src/VBox/Installer/linux/installer-common.sh" \
220 -e 'd' \
221 -e '}' \
222 rpm/VirtualBox.tmpl.spec > $(archdir)/VirtualBox.spec
223 sed \
224 -e 's|%NOLSB%|yes|g' \
225 -e 's|%DEBIAN%||g' \
226 -e 's|%PACKAGE%|virtualbox|g' \
227 -e "s|%VERSION%|$(VBOX_VERSION_STRING)|g" \
228 -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
229 vboxdrv.sh.in > $(archdir)/vboxdrv.init
230 cp vboxballoonctrl-service.sh $(archdir)/vboxballoonctrl-service.init
231 cp vboxautostart-service.sh $(archdir)/vboxautostart-service.init
232 cp vboxweb-service.sh $(archdir)/vboxweb-service.init
233 cp VBox.sh $(archdir)
234 mv rpm/VirtualBox-$(ver) rpm/$(rpmname)
235 tar -cjf rpm/VirtualBox.tar.bz2 -C rpm $(rpmname)
236 rm -f /usr/src/packages/RPMS/*/VirtualBox*rpm
237 rm -f /usr/src/packages/SPECS/*
238 (cd rpm; rpmbuild -tb --clean VirtualBox.tar.bz2)
239 mv /usr/src/packages/RPMS/*/$(verpkg)-debug* $(pkgdir) || true
240 file=`find /usr/src/packages/RPMS -name $(verpkg)*rpm -print`; \
241 mv $$file $(pkgdir)
242# Note! if rpmbuild fails: sudo chmod a+rw /usr/src/redhat/* /usr/src/redhat/RPMS/*
243# Note! if find/mv fails: sudo ln -s redhat/ /usr/src/packages
244endif
245
246.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