rules revision 5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9b
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff# Copyright (C) 2006-2010 Oracle Corporation
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff# This file is part of VirtualBox Open Source Edition (OSE), as
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# available from http://www.virtualbox.org. This file is free software;
15a44745412679c30a6d022733925af70a38b715David Lawrence# you can redistribute it and/or modify it under the terms of the GNU
15a44745412679c30a6d022733925af70a38b715David Lawrence# General Public License as published by the Free Software Foundation,
15a44745412679c30a6d022733925af70a38b715David Lawrence# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
15a44745412679c30a6d022733925af70a38b715David Lawrence# distribution. VirtualBox OSE is distributed in the hope that it will
15a44745412679c30a6d022733925af70a38b715David Lawrence# be useful, but WITHOUT ANY WARRANTY of any kind.
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff$(error call rpm/rules from src/VBox/Installer/linux)
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrenceifneq ($(wildcard /usr/lib/rpm/find-requires.ksyms),)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff# don't allow to check for kernel syms, otherwise we depend on specific kernel versions!
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff$(error /usr/lib/rpm/find-requires.ksyms must not be installed)
74cf566d92d610c2dc090a0dc7f77651c0fb0635David Lawrenceifneq ($(wildcard /usr/lib/rpm/find-supplements.ksyms),)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff# same for openSUSE
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff$(error /usr/lib/rpm/find-supplements.ksyms must not be installed)
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graffifeq ($(shell if grep -q '^/usr/lib/virtualbox' /etc/permissions* 2>/dev/null; then echo yes; fi),yes)
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff# make sure openSUSE permissions fixes don't interfere with us
363cb30a83e8e57bc8874e621910f0e23dd84909Mark Andrewsrpmlib := $(shell if [ `uname -m` = "x86_64" ]; then echo "lib64"; else echo "lib"; fi)
363cb30a83e8e57bc8874e621910f0e23dd84909Mark Andrewsarch := $(shell if [ `uname -m` = "x86_64" ]; then echo "amd64"; else echo "i386"; fi)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graffsvnrev :=$(if $(svn_revision),$(svn_revision),0)
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence # look for fedora
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence rpmrel := $(shell cat /etc/fedora-release | sed -e 's/^Fedora *release *\([1-9][0-9]*\) .*/fedora\1/')
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence $(error failed to detect the release type. Add /etc/distname or hack the detection.)
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence rpmdist := $(strip $(shell grep $(rpmrel) $(current)/distributions_rpm | cut -d'=' -f2))
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington $(error Cannot detect package distribution (rpmrel=$(rpmrel)))
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence ifeq ($(filter-out rhel4 rhel5 fedora9 fedora11 fedora12 fedora13 pclinuxos2007 turbolinux11,$(rpmrel)),)
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 sles10.1 sles11.0,$(rpmrel)),)
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence ifeq ($(filter-out mdv2009.1 mdv2010.0,$(rpmrel)),)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff $(error failed to detect the .spec file (rpmrel=$(rpmrel)))
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) $(verfile)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graffrpmver :=$(ver)$(if $(NOSUBVER),,$(if $(svn_revision),_$(svn_revision),)$(VERSUFFIX)$(if $(DEBUG),_dbg,))$(if $(BLEEDING_EDGE),_$(BLEEDING_EDGE),)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff# Fedora13 is bleeding edge, the other jails have outdated kernel headers
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graffinstmod := $(if $(filter rhel4 rhel5 sles10.1 sles11.0 pclinuxos2007 fedora13,$(rpmrel)),,install_rpm)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graffifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff$(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
8cd870e3f5e3db9808a4a0d6f98db3d1a5348e40Michael Graffifeq ($(wildcard /usr/share/doc/packages/bash),)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff # Mandriva 2007.1, Redhat
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(rpmname)\""
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff # Mandriva 2008.0
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\""
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff # Novell (OpenSUSE, SLES)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/packages/$(verpkg)\""
d736db6dc53e615e3f2d66d1ddbe28473694d107Michael Graffcfg_flags := $(if $(filter rhel4 sles10.1,$(rpmrel)),--build-libxml2,) \
d736db6dc53e615e3f2d66d1ddbe28473694d107Michael Graff $(if $(filter rhel4 sles10.1,$(rpmrel)),--build-libxslt,) \
d736db6dc53e615e3f2d66d1ddbe28473694d107Michael Graff $(if $(filter rhel4,$(rpmrel)),--build-libssl,) \
d736db6dc53e615e3f2d66d1ddbe28473694d107Michael Graff $(if $(filter rhel4 rhel5 sles10.1,$(rpmrel)),--build-libcurl,) \
d736db6dc53e615e3f2d66d1ddbe28473694d107Michael Graff $(if $(filter rhel5 sles10.1,$(rpmrel)),--disable-sdl-ttf,) \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff $(if $(filter sles10.1 turbolinux11,$(rpmrel)),--disable-pulse,) \
8cd870e3f5e3db9808a4a0d6f98db3d1a5348e40Michael Graff $(if $(filter rhel4 rhel5,$(rpmrel)),--enable-pulse,) \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff $(if $(filter rhel4 rhel5 sles10.1 turbolinux11,$(rpmrel)),--with-qt4-dir=/home/vbox/Qt-4.4.3-stdc++6-$(arch)) \
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrencebld_flags := AUTOCFG=$(current)/rpm/AutoConfig.kmk \
c1cfd8ef05f47f2ccb5db80639e9501c9f16864cMichael Graff $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
c1cfd8ef05f47f2ccb5db80639e9501c9f16864cMichael Graff $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
c1cfd8ef05f47f2ccb5db80639e9501c9f16864cMichael Graff $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),) \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff $(if $(filter rhel4 rhel5 fedora9 fedora10 sles10.1 turbolinux11,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
7a166c5c61a5aaa6eeb929bed152dc0a6b128e3dMichael Graff cd $(vboxroot) && ./configure --odir=$(current)/rpm $(cfg_flags)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff . rpm/env.sh && kmk -C $(vboxroot) $(if $(NOPARALLEL),-j1,) $(bld_flags) all
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff $(if $(NODOCS),,. rpm/env.sh && kmk -C $(vboxroot)/src/VBox/Main $(bld_flags) docs)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff rm -f rpm/build-stamp rpm/configure-stamp rpm/configure.log
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff tar -xjf $(builddir)/bin/VirtualBox.tar.bz2 -C rpm
68aa880dd538ab5643abdb07a800d0443e630d2eBrian Wellington -e 's|%VER%|$(ver)|g' \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff -e 's|%NAME%|$(verpkg)|g' \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff -e 's|%BUILDVER%|$(rpmver)|g' \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff -e 's|%BUILDREL%|$(rpmrel)|g' \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff -e 's|%BUILDROOT%|$(current)/rpm/buildroot|g' \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff -e 's|%LIB%|$(rpmlib)|g' \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff -e 's|%LICENSE%|$(notdir $(wildcard $(builddir)/bin/License-*.html))|g' \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff -e 's|%SPEC%|$(rpmspec)|g' \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff -e 's|%MACROSPYTHON%|$(if $(wildcard /usr/lib/rpm/macros.python),%include /usr/lib/rpm/macros.python,)|g' \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff -e 's|%INSTMOD%|$(instmod)|g' \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff -e 's|%LIBASOUND%|$(if $(filter lib64,$(rpmlib)),libasound.so.2()(64bit),libasound.so.2)|g' \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff rpm/VirtualBox.tmpl.spec > $(archdir)/VirtualBox.spec
68aa880dd538ab5643abdb07a800d0443e630d2eBrian Wellington -e 's|%NOLSB%|yes|g' \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff -e 's|%DEBIAN%||g' \
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff -e 's|%PACKAGE%|virtualbox|g' \
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff -e 's|%NOLSB%|yes|g' \
01933e930208da3291de3722cb0d0787636b1e4fMichael Graff -e 's|%DEBIAN%||g' \
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence -e 's|%PACKAGE%|virtualbox|g' \
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff vboxweb-service.sh.in > $(archdir)/vboxweb-service.init
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington tar -cjf rpm/VirtualBox.tar.bz2 -C rpm $(rpmname)
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington rm -f /usr/src/packages/RPMS/*/VirtualBox*rpm
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafsson rpmbuild -tb --clean rpm/VirtualBox.tar.bz2
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington mv /usr/src/packages/RPMS/*/$(verpkg)-debug* $(vboxroot)/.. || true
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington file=`find /usr/src/packages/RPMS -name $(verpkg)*rpm -print`; \
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington# Note! if rpmbuild fails: sudo chmod a+rw /usr/src/redhat/* /usr/src/redhat/RPMS/*
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington# Note! if find/mv fails: sudo ln -s redhat/ /usr/src/packages