rules revision 0791c3dcd512eb748830b7b7a0bb244efa59817f
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# Copyright (C) 2006-2012 Oracle Corporation
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# available from http://www.virtualbox.org. This file is free software;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# you can redistribute it and/or modify it under the terms of the GNU
d63de4508a08b11f57c307a15eda3cd95485bf2cvboxsync# General Public License (GPL) as published by the Free Software
d63de4508a08b11f57c307a15eda3cd95485bf2cvboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
d63de4508a08b11f57c307a15eda3cd95485bf2cvboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
d63de4508a08b11f57c307a15eda3cd95485bf2cvboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# possible overrides:
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# OSE=1 force VBOX_OSE
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# NOPARALLEL=1 compile with -j1
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# LINUX=<dir> compile vboxdrv against Linux found in <dir>
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# VERBOSE=1 verbose build
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# DEBUG=1 debug build
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# NOSUBVER=1 disable generation of the sub-version field (which is
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# either the subversion rev [if available] or the build date)
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# NODOCS=1 don't build docs, use precompiled UserManual.pdf and
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# NOMODS=1 don't build any module
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# NOQT=1 don't build the Qt GUI
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# EFI=1 include the EFI binary from prebuild
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# VERSUFFIX=<suffix> set a particular package version suffix (e.g. _customer)
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# HEADLESS=1 build the headless version
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# VNC=1 build VNC code
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# NOWEBSVC=1 don't build the webservice API, default for OSE
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# PKGDIR=<path> where to store the final package(s)
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# BLEEDING_EDGE=xyz
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync$(error call rpm/rules from src/VBox/Installer/linux)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncifneq ($(wildcard /usr/lib/rpm/find-requires.ksyms),)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# don't allow to check for kernel syms, otherwise we depend on specific kernel versions!
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync$(error /usr/lib/rpm/find-requires.ksyms must not be installed)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncifneq ($(wildcard /usr/lib/rpm/find-supplements.ksyms),)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# same for openSUSE
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync$(error /usr/lib/rpm/find-supplements.ksyms must not be installed)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncifeq ($(shell if grep -q '^/usr/lib/virtualbox' /etc/permissions* 2>/dev/null; then echo yes; fi),yes)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# make sure openSUSE permissions fixes don't interfere with us
cb172d105a87f41489b1553fbd99ec97932609ffvboxsyncifeq ($(shell if grep -q '^%disttag' /usr/lib/rpm/macros.d/mandriva 2>/dev/null; then echo yes; fi),yes)
2c691730ab202620fe427110841aa4e0075b7ccavboxsyncpkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd ../../../../..; pwd))
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncrpmlib := $(shell if [ `uname -m` = "x86_64" ]; then echo "lib64"; else echo "lib"; fi)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncarch := $(shell if [ `uname -m` = "x86_64" ]; then echo "amd64"; else echo "i386"; fi)
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsyncose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsyncNOWINE := $(if $(NODOCS),$(if $(STAGEDISO),1,),)$(ose)
2da06c2eb59b63010b1998799c719272c0be0f99vboxsync rpmrel := $(subst ol,el,$(subst rhel,el,$(shell cat /etc/distname)))
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync # look for fedora
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync rpmrel := $(shell cat /etc/fedora-release | sed -e 's/^Fedora *release *\([1-9][0-9]*\) .*/fedora\1/')
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync $(error failed to detect the release type. Add /etc/distname or hack the detection.)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync rpmdist := $(strip $(shell grep $(rpmrel) $(current)/distributions_rpm | cut -d'=' -f2))
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync $(error Cannot detect package distribution (rpmrel=$(rpmrel)))
2da06c2eb59b63010b1998799c719272c0be0f99vboxsync ifeq ($(filter-out el5 el6 ol5 ol6 el7 centos5 centos6 fedora15 fedora16 fedora17 fedora18,$(rpmrel)),)
dae00a0203dc968ada4b4241dfbcd937974140e2vboxsync ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114 openSUSE123 sles10.1 sles11.0,$(rpmrel)),)
cb172d105a87f41489b1553fbd99ec97932609ffvboxsync ifeq ($(filter-out mdv2009.1 mdv2010.0 mdv2011.0,$(rpmrel)),)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync $(error failed to detect the .spec file (rpmrel=$(rpmrel)))
4c07a936250bec9628653237718068d59914cdcevboxsync # contrary to debian we need the verfile earlier to get the correct rpmname into the bld_flags
4c07a936250bec9628653237718068d59914cdcevboxsync . rpm/env.sh && kmk -C $(vboxroot) $(verfile) $(bld_flags)
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsyncrpmver :=$(ver)$(if $(NOSUBVER),,$(if $(svn_revision),_$(svn_revision),)$(VERSUFFIX)$(if $(HEADLESS),_headless,)$(if $(DEBUG),_dbg,))$(if $(BLEEDING_EDGE),_$(BLEEDING_EDGE),)
8632da57318dd02e08198ceb832c636dc7da6a30vboxsync# never ship any modules
e361162aaa3f264085c651f9ea83f70d0ff3e431vboxsync ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
e361162aaa3f264085c651f9ea83f70d0ff3e431vboxsync $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync # Mandriva 2007.1, Redhat
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(rpmname)\""
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync # Mandriva 2008.0
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\""
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync # Novell (OpenSUSE, SLES)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/packages/$(verpkg)\""
9abe3d50c6097f794f13626dadf7063ed450163evboxsync $(if $(filter sles10.1,$(rpmrel)),--build-libxml2,) \
9abe3d50c6097f794f13626dadf7063ed450163evboxsync $(if $(filter el5 el6 sles10.1 sles11.0 mdv2011.0,$(rpmrel)),--build-libvpx,) \
9abe3d50c6097f794f13626dadf7063ed450163evboxsync $(if $(filter el5 ol5 centos5 sles10.1 sles11.0,$(rpmrel)),--build-libcurl,) \
0700964a23df46033c8149ee10ce643cd3677061vboxsync $(if $(filter el5 centos5 sles10.1,$(rpmrel)),--disable-sdl-ttf,) \
08879243dd70cdd8c01c3a5941c82c96c45a7e32vboxsync $(if $(filter sles10.1,$(rpmrel)),--disable-pulse,) \
9abe3d50c6097f794f13626dadf7063ed450163evboxsync $(if $(filter el5 ol5 centos5,$(rpmrel)),--enable-pulse,) \
9abe3d50c6097f794f13626dadf7063ed450163evboxsync $(if $(filter el5 ol5 centos5 sles10.1 sles11.0,$(rpmrel)),--with-qt4-dir=/home/vbox/Qt-4.7.4-stdc++6-$(arch)) \
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
080867566ec24e954aac5664d20a8fb364be2ed1vboxsync $(if $(NOWEBSVC),,$(if $(ose),--enable-webservice,)) \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncbld_flags := AUTOCFG=$(current)/rpm/AutoConfig.kmk \
0791c3dcd512eb748830b7b7a0bb244efa59817fvboxsync $(if $(filter el5 el6 sles10.1 sles11.0,$(rpmrel)),,VBOX_WITH_VMSVGA3D=1) \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),) \
0791c3dcd512eb748830b7b7a0bb244efa59817fvboxsync $(if $(filter el5 ol5 centos5 sles10.1,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync cd $(vboxroot) && ./configure --odir=$(current)/rpm $(cfg_flags)
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
b1212d1cdc6c9396aa851ef0a5388edce69806advboxsync VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86.tar.bz2 \
b1212d1cdc6c9396aa851ef0a5388edce69806advboxsync VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.tar.bz2 \
e361162aaa3f264085c651f9ea83f70d0ff3e431vboxsync VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
e361162aaa3f264085c651f9ea83f70d0ff3e431vboxsync VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync rm -f rpm/build-stamp rpm/configure-stamp rpm/configure.log
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync -e 's|%VER%|$(ver)|g' \
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync -e 's|%NAME%|$(verpkg)|g' \
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync -e 's|%BUILDVER%|$(rpmver)|g' \
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync -e 's|%BUILDREL%|$(rpmrel)|g' \
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync -e 's|%BUILDROOT%|$(current)/rpm/buildroot|g' \
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync -e 's|%LIB%|$(rpmlib)|g' \
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync -e 's|%OSE%|$(if $(ose),is_ose,not_ose)|g' \
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync -e 's|%SPEC%|$(rpmspec)|g' \
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync -e 's|%MACROSPYTHON%|$(if $(wildcard /usr/lib/rpm/macros.python),%include /usr/lib/rpm/macros.python,)|g' \
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync -e 's|%INSTMOD%|$(instmod)|g' \
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync -e 's|%LIBASOUND%|$(if $(filter lib64,$(rpmlib)),libasound.so.2()(64bit),libasound.so.2)|g' \
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync -e 's|%INITSCRIPTS%|$(if $(filter fedora,$(rpmspec)),initscripts,)|g' \
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync -e '/#include installer-common.sh/ {' \
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync -e "r $(vboxroot)/src/VBox/Installer/linux/installer-common.sh" \
f1517b3016a7e68a8edb55ea82c704af7386c9advboxsync rpm/VirtualBox.tmpl.spec > $(archdir)/VirtualBox.spec
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync -e 's|%NOLSB%|yes|g' \
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync -e 's|%DEBIAN%||g' \
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync -e 's|%PACKAGE%|virtualbox|g' \
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
fe7115bba580b609cb1a233f8e08947d0ee0af8dvboxsync cp vboxballoonctrl-service.sh $(archdir)/vboxballoonctrl-service.init
fe7115bba580b609cb1a233f8e08947d0ee0af8dvboxsync cp vboxautostart-service.sh $(archdir)/vboxautostart-service.init
fe7115bba580b609cb1a233f8e08947d0ee0af8dvboxsync cp vboxweb-service.sh $(archdir)/vboxweb-service.init
2c691730ab202620fe427110841aa4e0075b7ccavboxsync mv /usr/src/packages/RPMS/*/$(verpkg)-debug* $(pkgdir) || true
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync file=`find /usr/src/packages/RPMS -name $(verpkg)*rpm -print`; \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# Note! if rpmbuild fails: sudo chmod a+rw /usr/src/redhat/* /usr/src/redhat/RPMS/*