rules revision 7a6e7d612d944fea47793954679cb50a1173313f
04428429c4e689333e3ef8d19a2debeb20d4d15dMark Andrews# Copyright (C) 2006-2012 Oracle Corporation
e999539fb3e45b2617571e0e3ecd651992291701Mark Andrews# This file is part of VirtualBox Open Source Edition (OSE), as
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater# available from http://www.virtualbox.org. This file is free software;
555d01f4c02295e896a26c649d0ffc8808a0bbdcAutomatic Updater# you can redistribute it and/or modify it under the terms of the GNU
a3b428812703d22a605a9f882e71ed65f0ffdc65Mark Andrews# General Public License (GPL) as published by the Free Software
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater# Foundation, in version 2 as it comes in the "COPYING" file of the
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
ac4e70ff8955669341f435bc0a734a17c01af124Mark Andrews# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater# possible overrides:
56874aef380a64a2c183b7c282c3e7a361d67fa1Automatic Updater# OSE=1 force VBOX_OSE
56874aef380a64a2c183b7c282c3e7a361d67fa1Automatic Updater# NOPARALLEL=1 compile with -j1
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# LINUX=<dir> compile vboxdrv against Linux found in <dir>
56874aef380a64a2c183b7c282c3e7a361d67fa1Automatic Updater# VERBOSE=1 verbose build
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews# DEBUG=1 debug build
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# NOSUBVER=1 disable generation of the sub-version field (which is
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# either the subversion rev [if available] or the build date)
04eba969cb9a54bbda2896db2067c07b2ac5ba16Automatic Updater# NODOCS=1 don't build docs, use precompiled UserManual.pdf and
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# NOMODS=1 don't build any module
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews# NOQT=1 don't build the Qt GUI
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews# EFI=1 include the EFI binary from prebuild
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews# VERSUFFIX=<suffix> set a particular package version suffix (e.g. _customer)
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# HEADLESS=1 build the headless version
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews# VNC=1 build VNC code
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews# NOWEBSVC=1 don't build the webservice API, default for OSE
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews# PKGDIR=<path> where to store the final package(s)
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# BLEEDING_EDGE=xyz
bac1bc98410bd876b8d38a6de6126709a7f8cc5aAutomatic Updater$(error call rpm/rules from src/VBox/Installer/linux)
f8448666aa53603696bea83de971a05007735d8fMark Andrewsifneq ($(wildcard /usr/lib/rpm/find-requires.ksyms),)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# don't allow to check for kernel syms, otherwise we depend on specific kernel versions!
3098364bcdd7a719fbafa5fc8d2cc9e90e5a5989Automatic Updater$(error /usr/lib/rpm/find-requires.ksyms must not be installed)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsifneq ($(wildcard /usr/lib/rpm/find-supplements.ksyms),)
3098364bcdd7a719fbafa5fc8d2cc9e90e5a5989Automatic Updater# same for openSUSE
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews$(error /usr/lib/rpm/find-supplements.ksyms must not be installed)
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrewsifeq ($(shell if grep -q '^/usr/lib/virtualbox' /etc/permissions* 2>/dev/null; then echo yes; fi),yes)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# make sure openSUSE permissions fixes don't interfere with us
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrewsifeq ($(shell if grep -q '^%disttag' /usr/lib/rpm/macros.d/mandriva 2>/dev/null; then echo yes; fi),yes)
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafssonpkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd ../../../../..; pwd))
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtonrpmlib := $(shell if [ `uname -m` = "x86_64" ]; then echo "lib64"; else echo "lib"; fi)
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updaterarch := $(shell if [ `uname -m` = "x86_64" ]; then echo "amd64"; else echo "i386"; fi)
6f046a065e5543f8cd7e2f24991c65d2372f4c8dMark Andrewsose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewssvnrev :=$(if $(svn_revision),$(svn_revision),0)
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic UpdaterNOWINE := $(if $(NODOCS),$(if $(STAGEDISO),1,),)$(ose)
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews rpmrel := $(subst rhel,el,$(shell cat /etc/distname))
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson # look for fedora
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews rpmrel := $(shell cat /etc/fedora-release | sed -e 's/^Fedora *release *\([1-9][0-9]*\) .*/fedora\1/')
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews $(error failed to detect the release type. Add /etc/distname or hack the detection.)
96ea71632887c58a9d00f47eb318bf76b35903c3Mark Andrews rpmdist := $(strip $(shell grep $(rpmrel) $(current)/distributions_rpm | cut -d'=' -f2))
80f9a970ae6681c08529ef209eaabbe078c27ca3Mark Andrews $(error Cannot detect package distribution (rpmrel=$(rpmrel)))
dde4bc92964ec60a35212dfed59562580e3265e3Mark Andrews ifeq ($(filter-out el4 el5 el6 ol4 ol5 ol6 centos4 centos5 centos6 fedora9 fedora11 fedora12 fedora13 fedora14 fedora15 fedora16 fedora17 fedora18 turbolinux11,$(rpmrel)),)
dde4bc92964ec60a35212dfed59562580e3265e3Mark Andrews ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114 sles10.1 sles11.0,$(rpmrel)),)
04eba969cb9a54bbda2896db2067c07b2ac5ba16Automatic Updater ifeq ($(filter-out mdv2009.1 mdv2010.0 mdv2011.0,$(rpmrel)),)
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater $(error failed to detect the .spec file (rpmrel=$(rpmrel)))
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater # contrary to debian we need the verfile earlier to get the correct rpmname into the bld_flags
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater . rpm/env.sh && kmk -C $(vboxroot) $(verfile) $(bld_flags)
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updaterrpmver :=$(ver)$(if $(NOSUBVER),,$(if $(svn_revision),_$(svn_revision),)$(VERSUFFIX)$(if $(HEADLESS),_headless,)$(if $(DEBUG),_dbg,))$(if $(BLEEDING_EDGE),_$(BLEEDING_EDGE),)
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updaterarchdir := $(current)/rpm/VirtualBox-$(ver)
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater# never ship any modules
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
ea935c46e8261ea10621e5b038426539fe8a7cc5Mark Andrews $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updaterifeq ($(wildcard /usr/share/doc/packages/bash),)
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater # Mandriva 2007.1, Redhat
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(rpmname)\""
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater # Mandriva 2008.0
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\""
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews # Novell (OpenSUSE, SLES)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/packages/$(verpkg)\""
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $(if $(filter el4 sles10.1,$(rpmrel)),--build-libxml2,) \
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews $(if $(filter el4,$(rpmrel)),--build-libssl,) \
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $(if $(filter el4 el5 ol4 ol5 centos4 centos5 sles10.1 sles11.0,$(rpmrel)),--build-libcurl,) \
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews $(if $(filter el5 centos5 sles10.1,$(rpmrel)),--disable-sdl-ttf,) \
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $(if $(filter sles10.1 turbolinux11,$(rpmrel)),--disable-pulse,) \
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater $(if $(filter el4 el5 ol4 ol5 centos4 centos5,$(rpmrel)),--enable-pulse,) \
5147281cb8e25c599d759dfa65fdb6f9125efefbMark Andrews $(if $(filter el4 el5 ol4 ol5 centos4 centos5 mdv2010.0 sles10.1 sles11.0 turbolinux11,$(rpmrel)),--with-qt4-dir=/home/vbox/Qt-4.7.4-stdc++6-$(arch)) \
6a78eb0a8677dca8817233799a715de27f9c2cbbMark Andrews $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
04eba969cb9a54bbda2896db2067c07b2ac5ba16Automatic Updaterbld_flags := AUTOCFG=$(current)/rpm/AutoConfig.kmk \
703b7fa47ef96b4d2ae1a61cde773c98824a25f2Automatic Updater $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),) \
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews $(if $(filter el4 el5 ol4 ol5 centos4 centos5 fedora9 fedora10 sles10.1 turbolinux11,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington cd $(vboxroot) && ./configure --odir=$(current)/rpm $(cfg_flags)
56874aef380a64a2c183b7c282c3e7a361d67fa1Automatic Updater . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
56874aef380a64a2c183b7c282c3e7a361d67fa1Automatic Updater $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) \
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86-r$(svnrev).tar.bz2 \
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64-r$(svnrev).tar.bz2 \
e076d0c88be69de7c190ab924d095e69d2e11f7aAndreas Gustafsson VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson rm -f rpm/build-stamp rpm/configure-stamp rpm/configure.log
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater tar -xjf $(builddir)/bin/VirtualBox.tar.bz2 -C rpm
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater -e 's|%VER%|$(ver)|g' \
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater -e 's|%NAME%|$(verpkg)|g' \
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater -e 's|%BUILDVER%|$(rpmver)|g' \
bc0a4c01beede169df81a3ee5b614ed9e82339dbAutomatic Updater -e 's|%BUILDREL%|$(rpmrel)|g' \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e 's|%BUILDROOT%|$(current)/rpm/buildroot|g' \
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater -e 's|%LIB%|$(rpmlib)|g' \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e 's|%OSE%|$(if $(ose),is_ose,not_ose)|g' \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e 's|%SPEC%|$(rpmspec)|g' \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e 's|%MACROSPYTHON%|$(if $(wildcard /usr/lib/rpm/macros.python),%include /usr/lib/rpm/macros.python,)|g' \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e 's|%INSTMOD%|$(instmod)|g' \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e 's|%LIBASOUND%|$(if $(filter lib64,$(rpmlib)),libasound.so.2()(64bit),libasound.so.2)|g' \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e 's|%INITSCRIPTS%|$(if $(filter fedora,$(rpmspec)),initscripts,)|g' \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e "s|%WEBSVC%|$(if $(NOWEBSVC),false,true)|g" \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e '/#include installer-common.sh/ {' \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e "r $(vboxroot)/src/VBox/Installer/linux/installer-common.sh" \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington rpm/VirtualBox.tmpl.spec > $(archdir)/VirtualBox.spec
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e 's|%NOLSB%|yes|g' \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e 's|%DEBIAN%||g' \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e 's|%PACKAGE%|virtualbox|g' \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e "s|%VERSION%|$(VBOX_VERSION_STRING)|g" \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington cp vboxballoonctrl-service.sh $(archdir)/vboxballoonctrl-service.init
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington cp vboxautostart-service.sh $(archdir)/vboxautostart-service.init
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington cp vboxweb-service.sh $(archdir)/vboxweb-service.init
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington tar -cjf rpm/VirtualBox.tar.bz2 -C rpm $(rpmname)
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington rm -f /usr/src/packages/RPMS/*/VirtualBox*rpm
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington (cd rpm; rpmbuild -tb --clean VirtualBox.tar.bz2)
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington mv /usr/src/packages/RPMS/*/$(verpkg)-debug* $(pkgdir) || true
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington file=`find /usr/src/packages/RPMS -name $(verpkg)*rpm -print`; \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# Note! if rpmbuild fails: sudo chmod a+rw /usr/src/redhat/* /usr/src/redhat/RPMS/*
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# Note! if find/mv fails: sudo ln -s redhat/ /usr/src/packages