rules revision 90bfe7905f962c9c30f653670ac7fdadbd8f27cd
2N/A#!/usr/bin/make -f
2N/A
2N/A#
2N/A# Copyright (C) 2006-2010 Oracle Corporation
2N/A#
2N/A# This file is part of VirtualBox Open Source Edition (OSE), as
2N/A# available from http://www.virtualbox.org. This file is free software;
2N/A# you can redistribute it and/or modify it under the terms of the GNU
2N/A# General Public License as published by the Free Software Foundation,
2N/A# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
2N/A# distribution. VirtualBox OSE is distributed in the hope that it will
2N/A# be useful, but WITHOUT ANY WARRANTY of any kind.
2N/A#
2N/A
2N/Aifeq ($(wildcard rpm/rules),)
2N/A$(error call rpm/rules from src/VBox/Installer/linux)
2N/Aendif
2N/A
2N/Aifneq ($(wildcard /usr/lib/rpm/find-requires.ksyms),)
2N/A# don't allow to check for kernel syms, otherwise we depend on specific kernel versions!
2N/A$(error /usr/lib/rpm/find-requires.ksyms must not be installed)
2N/Aendif
2N/Aifneq ($(wildcard /usr/lib/rpm/find-supplements.ksyms),)
2N/A# same for openSUSE
2N/A$(error /usr/lib/rpm/find-supplements.ksyms must not be installed)
2N/Aendif
2N/Aifeq ($(shell if grep -q '^/usr/lib/virtualbox' /etc/permissions* 2>/dev/null; then echo yes; fi),yes)
2N/A# make sure openSUSE permissions fixes don't interfere with us
2N/A$(error Fix /etc/permissions*)
2N/Aendif
2N/A
2N/Averpkg := VirtualBox-4.0
2N/Acurrent := $(shell pwd)
2N/Avboxroot := $(shell cd ../../../../; pwd)
2N/Apkgdir := $(shell cd ../../../../..; pwd)
2N/Abuilddir := $(current)/rpm/builddir
2N/Arpmlib := $(shell if [ `uname -m` = "x86_64" ]; then echo "lib64"; else echo "lib"; fi)
2N/Aarch := $(shell if [ `uname -m` = "x86_64" ]; then echo "amd64"; else echo "i386"; fi)
2N/Averfile := $(builddir)/version-generated.mk
2N/A-include $(vboxroot)/SVN_REVISION
2N/Asvnrev :=$(if $(svn_revision),$(svn_revision),0)
2N/A
2N/Aifneq ($(MAKECMDGOALS),clean)
2N/A rpmrel := $(shell cat /etc/distname)
2N/A ifeq ($(rpmrel),)
2N/A # look for fedora
2N/A rpmrel := $(shell cat /etc/fedora-release | sed -e 's/^Fedora *release *\([1-9][0-9]*\) .*/fedora\1/')
2N/A endif
2N/A ifeq ($(rpmrel),)
2N/A $(error failed to detect the release type. Add /etc/distname or hack the detection.)
2N/A endif
2N/A
2N/A rpmdist := $(strip $(shell grep $(rpmrel) $(current)/distributions_rpm | cut -d'=' -f2))
2N/A ifeq ($(rpmdist),)
2N/A $(error Cannot detect package distribution (rpmrel=$(rpmrel)))
2N/A endif
2N/A
2N/A ifeq ($(filter-out rhel4 rhel5 rhel6 fedora9 fedora11 fedora12 fedora13 fedora14 pclinuxos2007 turbolinux11,$(rpmrel)),)
2N/A rpmspec := rpm_redhat
2N/A endif
2N/A ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 sles10.1 sles11.0,$(rpmrel)),)
2N/A rpmspec := rpm_suse
2N/A endif
2N/A ifeq ($(filter-out mdv2009.1 mdv2010.0,$(rpmrel)),)
2N/A rpmspec := rpm_mdv
2N/A endif
2N/A ifeq ($(rpmspec),)
2N/A $(error failed to detect the .spec file (rpmrel=$(rpmrel)))
2N/A endif
2N/A
2N/A include $(verfile)
2N/A$(verfile): rpm/configure-stamp
2N/A . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) $(verfile)
2N/Aendif
2N/A
2N/Aver := $(VBOX_VERSION_STRING)
2N/Arpmver :=$(ver)$(if $(NOSUBVER),,$(if $(svn_revision),_$(svn_revision),)$(VERSUFFIX)$(if $(DEBUG),_dbg,))$(if $(BLEEDING_EDGE),_$(BLEEDING_EDGE),)
2N/Aarchdir := $(current)/rpm/VirtualBox-$(ver)
2N/Arpmname := $(verpkg)-$(rpmver)_$(rpmrel)
2N/A
2N/A# Fedora13/14 is bleeding edge, the other jails have outdated kernel headers
2N/Ainstmod := $(if $(filter rhel4 rhel5 rhel6 sles10.1 sles11.0 pclinuxos2007 fedora13 fedora14,$(rpmrel)),,install_rpm)
2N/A
2N/Aifneq ($(STAGEDISO),)
2N/Aifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
2N/A$(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
2N/Aendif
2N/Aendif
2N/A
2N/Aifeq ($(wildcard /usr/share/doc/packages/bash),)
2N/A ifeq ($(wildcard /usr/share/doc/bash),)
2N/A # Mandriva 2007.1, Redhat
2N/A doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(rpmname)\""
2N/A else
2N/A # Mandriva 2008.0
2N/A doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\""
2N/A endif
2N/Aelse
2N/A # Novell (OpenSUSE, SLES)
2N/A doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/packages/$(verpkg)\""
2N/Aendif
2N/A
2N/Acfg_flags := $(if $(filter rhel4 sles10.1,$(rpmrel)),--build-libxml2,) \
2N/A $(if $(filter rhel4 sles10.1,$(rpmrel)),--build-libxslt,) \
2N/A $(if $(filter rhel4,$(rpmrel)),--build-libssl,) \
2N/A $(if $(filter rhel4 rhel5 sles10.1,$(rpmrel)),--build-libcurl,) \
2N/A $(if $(filter rhel5 sles10.1,$(rpmrel)),--disable-sdl-ttf,) \
2N/A $(if $(filter sles10.1 turbolinux11,$(rpmrel)),--disable-pulse,) \
2N/A $(if $(filter rhel4 rhel5,$(rpmrel)),--enable-pulse,) \
2N/A $(if $(filter rhel4 rhel5 sles10.1 turbolinux11,$(rpmrel)),--with-qt4-dir=/home/vbox/Qt-4.4.3-stdc++6-$(arch)) \
2N/A $(if $(DEBUG),--build-debug,)
2N/A
2N/Abld_flags := AUTOCFG=$(current)/rpm/AutoConfig.kmk \
2N/A LOCALCFG=$(current)/rpm/LocalConfig.kmk \
2N/A PATH_OUT=$(builddir) \
2N/A VBOX_DO_STRIP= \
2N/A VBOX_WITH_MULTIVERSION_PYTHON= \
2N/A $(doc_dir) \
2N/A VBOX_WITH_DOCS_CHM=1 \
2N/A VBOX_PACKAGE_DIST=$(rpmdist) \
2N/A VBOX_SVN_REV=$(svnrev) \
2N/A $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
2N/A $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
2N/A $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
2N/A $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),) \
2N/A $(if $(filter rhel4 rhel5 fedora9 fedora10 sles10.1 turbolinux11,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
2N/A
2N/Arpm/configure-stamp:
2N/A cd $(vboxroot) && ./configure --odir=$(current)/rpm $(cfg_flags)
2N/A touch $(current)/rpm/configure-stamp
2N/A
2N/Arpm/build-stamp: rpm/configure-stamp
2N/A . rpm/env.sh && kmk -C $(vboxroot) $(if $(NOPARALLEL),-j1,) $(bld_flags) all
2N/A $(if $(NODOCS),,. rpm/env.sh && kmk -C $(vboxroot)/src/VBox/Main $(bld_flags) docs)
2N/A $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
2N/A $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
2N/A $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
2N/A $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
2N/A mkdir -p $(builddir)/bin/additions
2N/A $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
2N/A . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) \
2N/A VBOX_NO_LINUX_RUN_INSTALLER=1 \
2N/A packing
2N/A touch rpm/build-stamp
2N/A
2N/Aclean:
2N/A rm -rf $(archdir)
2N/A rm -rf $(builddir) rpm/VirtualBox-*
2N/A rm -f rpm/VirtualBox.tar.bz2
2N/A rm -f rpm/VirtualBox.spec
2N/A rm -f rpm/build-stamp rpm/configure-stamp rpm/configure.log
2N/A rm -f rpm/AutoConfig.kmk rpm/env.sh
2N/A
2N/Aifeq ($(VBOX_VERSION_MAJOR),)
2N/Abinary: rpm/build-stamp $(verfile)
2N/A $(MAKE) -f rpm/rules binary
2N/Aelse
2N/Abinary: rpm/build-stamp
2N/A rm -rf rpm/VirtualBox-*
2N/A tar -xjf $(builddir)/bin/VirtualBox.tar.bz2 -C rpm
2N/A sed \
2N/A -e 's|%VER%|$(ver)|g' \
2N/A -e 's|%NAME%|$(verpkg)|g' \
2N/A -e 's|%BUILDVER%|$(rpmver)|g' \
2N/A -e 's|%BUILDREL%|$(rpmrel)|g' \
2N/A -e 's|%BUILDROOT%|$(current)/rpm/buildroot|g' \
2N/A -e 's|%LIB%|$(rpmlib)|g' \
2N/A -e 's|%SPEC%|$(rpmspec)|g' \
2N/A -e 's|%MACROSPYTHON%|$(if $(wildcard /usr/lib/rpm/macros.python),%include /usr/lib/rpm/macros.python,)|g' \
2N/A -e 's|%INSTMOD%|$(instmod)|g' \
2N/A -e 's|%LIBASOUND%|$(if $(filter lib64,$(rpmlib)),libasound.so.2()(64bit),libasound.so.2)|g' \
2N/A rpm/VirtualBox.tmpl.spec > $(archdir)/VirtualBox.spec
2N/A sed \
2N/A -e 's|%NOLSB%|yes|g' \
2N/A -e 's|%DEBIAN%||g' \
2N/A -e 's|%PACKAGE%|virtualbox|g' \
2N/A -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
2N/A vboxdrv.sh.in > $(archdir)/vboxdrv.init
2N/A sed \
2N/A -e 's|%NOLSB%|yes|g' \
2N/A -e 's|%DEBIAN%||g' \
2N/A -e 's|%PACKAGE%|virtualbox|g' \
2N/A vboxweb-service.sh.in > $(archdir)/vboxweb-service.init
2N/A cp debian/VBox.sh $(archdir)
2N/A mv rpm/VirtualBox-$(ver) rpm/$(rpmname)
2N/A tar -cjf rpm/VirtualBox.tar.bz2 -C rpm $(rpmname)
2N/A rm -f /usr/src/packages/RPMS/*/VirtualBox*rpm
2N/A rm -f /usr/src/packages/SPECS/*
2N/A rpmbuild -tb --clean rpm/VirtualBox.tar.bz2
2N/A mv /usr/src/packages/RPMS/*/$(verpkg)-debug* $(vboxroot)/.. || true
2N/A file=`find /usr/src/packages/RPMS -name $(verpkg)*rpm -print`; \
2N/A mv $$file $(pkgdir)
2N/A# Note! if rpmbuild fails: sudo chmod a+rw /usr/src/redhat/* /usr/src/redhat/RPMS/*
2N/A# Note! if find/mv fails: sudo ln -s redhat/ /usr/src/packages
2N/Aendif
2N/A
2N/A.PHONY: binary clean
2N/A