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