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