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