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