#!/usr/bin/make -f
#
# Copyright (C) 2006-2008 innotek GmbH
#
# 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.
#
#export DH_VERBOSE=1
export DH_COMPAT=4
# possible overrides:
# OSE=1 force VBOX_OSE
# NOPARALLEL=1 compile with -j1 (-j2 is default)
# LINUX=
compile vboxdrv against Linux found in
# VERBOSE=1 verbose build
# DEBUG=1 debug build
# NOSUBVER=1 disable generation of the sub-version field (which is
# either the subversion rev [if available] or the build date)
# NODOCS=1 don't build docs, use precompiled UserManual.pdf and
# VirtualBox.chm from $HOME
# NOMODS=1 don't build any module
# HEADLESS=1 build the headless version
# STAGEDISO= don't build the VBoxAdditions, use the precompiled .iso
package := virtualbox-ose
current := $(shell pwd)
vboxroot := $(shell pwd)
builddir := $(current)/debian/builddir
moddir := $(current)/debian/modules
prefix := $(current)/debian/$(package)
arch := $(shell dpkg --print-architecture)
verfile := $(builddir)/version-generated.mk
ose := 1
NOMODS ?= $(ose)
ifneq ($(wildcard $(verfile)),)
include $(verfile)
ver := $(VBOX_VERSION_STRING)
archdir := $(prefix)/opt/VirtualBox-$(ver)
endif
ifneq ($(STAGEDISO),)
ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
$(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
endif
endif
# Hack: Xandros is actually Debian/sarge ... :(
ifneq ($(wildcard /etc/xandros-desktop-version),)
debrel := _xandros4.1
else
ifneq ($(wildcard /etc/univention),)
debrel := _ucs1.3
else
debrel := $(if $(shell which lsb_release),_$(shell lsb_release -si)_$(shell lsb_release -sc),)
endif
endif
debdocs := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/virtualbox\""
# Ubuntu dapper: gcc-4.0 does not work with recompiler, use gcc-3.4 instead
configure: debian/configure-stamp
debian/configure-stamp:
dh_testdir
cd $(vboxroot) && ./configure --odir=$(current)/debian $(if \
$(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) $(if \
$(filter _Ubuntu_dapper,$(debrel)),--with-gcc=gcc-3.4 --with-g++=g++-3.4,) $(if \
$(filter _xandros4.1 _ucs1.3,$(debrel)),--disable-sdl-ttf,) $(if \
$(HEADLESS),--build-headless,) $(if $(DEBUG),--build-debug,)
touch debian/configure-stamp
build: debian/configure-stamp debian/build-stamp
debian/build-stamp $(verfile):
dh_testdir
. debian/env.sh && kmk -C $(vboxroot) $(if \
$(VERBOSE),--print-directory,--no-print-directory) $(if \
$(NOPARALLEL),-j1,-j2) $(if \
$(VERBOSE),KBUILD_VERBOSE=2,) $(if \
$(NODOCS),VBOX_WITH_DOCS=,)\
$(if $(STAGEDISO),\
VBOX_WITH_LINUX_ADDITIONS= VBOX_WITH_WIN32_ADDITIONS=,) \
AUTOCFG=$(current)/debian/AutoConfig.kmk \
LOCALCFG=$(current)/debian/LocalConfig.kmk \
PATH_OUT=$(current)/debian/builddir \
VBOX_DO_STRIP= VBOX_DO_STRIP_MODULES= \
$(debdocs) \
all
$(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual.pdf $(builddir)/bin,)
$(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox.chm $(builddir)/bin,)
mkdir -p $(builddir)/bin/additions
$(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
. debian/env.sh && kmk -C $(vboxroot) $(if \
$(VERBOSE),--print-directory,--no-print-directory) $(if \
$(VERBOSE),KBUILD_VERBOSE=2,) $(if \
$(STAGEDISO),\
VBOX_WITH_LINUX_ADDITIONS= VBOX_WITH_WIN32_ADDITIONS=,) \
AUTOCFG=$(current)/debian/AutoConfig.kmk \
LOCALCFG=$(current)/debian/LocalConfig.kmk \
PATH_OUT=$(current)/debian/builddir \
VBOX_DO_STRIP= VBOX_DO_STRIP_MODULES= \
$(debdocs) \
packing
touch debian/build-stamp
# Build modules for every kernel we find in /lib/modules/*
modules: debian/build-stamp debian/modules-stamp
debian/modules-stamp: debian/build-stamp
rm -rf $(moddir)
mkdir $(moddir)
make -C $(builddir)/bin/src clean
for d in $(wildcard /lib/modules/*); do \
make -C $(builddir)/bin/src KERN_DIR=$$d/build MODULE_DIR=$$d clean all && \
install -D -m 0644 -g 0 -o 0 \
$(builddir)/bin/src/vboxdrv.ko $(moddir)/$$(basename $$d)/vboxdrv.ko; \
done
make -C $(builddir)/bin/src clean
touch debian/modules-stamp
clean:
dh_testdir
dh_testroot
rm -f debian/$(package).init debian/vboxdrv.init debian/vboxnet.init
rm -f debian/AutoConfig.kmk debian/configure.log debian/env.sh
rm -f debian/modules-stamp debian/build-stamp debian/configure-stamp
rm -rf $(builddir) $(moddir)
dh_clean
ifeq ($(VBOX_VERSION_MAJOR),)
binary binary-arch binary-indep: build $(verfile)
$(MAKE) -f debian/rules binary
else
# Build architecture-dependent files here.
binary binary-arch binary-indep: build $(if $(NOMODS),,modules)
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
tar -xjC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar.bz2
install -d -g 0 -o 0 $(prefix)/usr/share/applications
install -d -g 0 -o 0 $(prefix)/usr/lib
install -d -g 0 -o 0 $(prefix)/usr/bin
install -d -g 0 -o 0 $(prefix)/usr/lib/$(package)
install -d -g 0 -o 0 $(prefix)/usr/share/$(package)
install -d -g 0 -o 0 $(prefix)/usr/share/doc/$(package)
$(if $(HEADLESS),,mv $(archdir)/VirtualBox.desktop \
$(prefix)/usr/share/applications/VirtualBox.desktop)
install -d -g 0 -o 0 $(prefix)/usr/share/pixmaps
install -D -g 0 -o 0 -m 644 debian/lintian-override \
$(prefix)/usr/share/lintian/overrides/$(package)
mv $(archdir)/VBox.png \
$(prefix)/usr/share/pixmaps/VBox.png
mv $(archdir)/*.gc $(prefix)/usr/lib/$(package)
mv $(archdir)/*.r0 $(prefix)/usr/lib/$(package)
$(if $(filter amd64,$(arch)),\
mv $(archdir)/VBoxREM2.rel $(prefix)/usr/lib/$(package),)
mv $(archdir)/VBoxXPCOMIPCD $(prefix)/usr/lib/$(package)
mv $(archdir)/components $(prefix)/usr/lib/$(package)/components
mv $(archdir)/*.so $(prefix)/usr/lib
mv $(archdir)/sdk $(prefix)/usr/share/$(package)
$(if $(HEADLESS),,mv $(archdir)/nls $(prefix)/usr/share/$(package))
mv $(archdir)/src $(prefix)/usr/share/$(package)
rm $(archdir)/VBox.sh
install -D -g 0 -o 0 -m 644 debian/VBox.sh $(prefix)/usr/bin/VBox
mv $(archdir)/VBoxSysInfo.sh $(prefix)/usr/share/$(package)
mv $(archdir)/VBoxAddIF.sh $(prefix)/usr/bin/VBoxTAP
for i in VBoxManage VBoxSVC $(if $(HEADLESS),,VBoxSDL) \
$(if $(HEADLESS),,VirtualBox) $(if $(ose),,VBoxVRDP) \
VBoxHeadless; do \
mv $(archdir)/$$i $(prefix)/usr/lib/$(package); done
mv $(archdir)/VBoxTunctl $(prefix)/usr/bin
$(if $(NOMODS),,for d in $(moddir)/*; do \
install -D -g 0 -o 0 -m 0644 \
$$d/vboxdrv.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxdrv.ko; done)
ifeq ($(ose),)
$(if $(HEADLESS),,mv $(archdir)/kchmviewer $(prefix)/usr/lib/$(package))
dh_installdocs $(addprefix $(archdir)/,\
UserManual.pdf VirtualBox.chm LICENSE)
rm $(addprefix $(archdir)/,UserManual.pdf VirtualBox.chm LICENSE)
for i in rdesktop-vrdp.tar.gz additions/VBoxGuestAdditions.iso; do \
mv $(archdir)/$$i $(prefix)/usr/share/$(package); done
rmdir $(archdir)/additions
else
dh_installdocs
endif
rmdir $(archdir)
rmdir $(prefix)/opt
dh_link \
$(if $(HEADLESS),,usr/bin/VBox usr/bin/VirtualBox) \
usr/bin/VBox usr/bin/VBoxManage \
$(if $(HEADLESS),,usr/bin/VBox usr/bin/VBoxSDL) \
$(if $(ose),,usr/bin/VBox usr/bin/VBoxVRDP) \
usr/bin/VBox usr/bin/VBoxHeadless \
usr/bin/VBoxTAP usr/bin/VBoxAddIF \
usr/bin/VBoxTAP usr/bin/VBoxDeleteIF
dh_desktop
dh_installmenu
$(if $(NOMODS),,dh_installmodules)
sed -e 's|%NOLSB%|$(if $(filter _Debian_sarge ucs1.3,$(debrel)),yes,)|g;' \
debian/vboxdrv.init.in > debian/vboxdrv.init
sed -e 's|%NOLSB%|$(if $(filter _Debian_sarge,$(debrel)),yes,)|g;' \
debian/vboxnet.init.in > debian/vboxnet.init
dh_installinit --name=vboxdrv
dh_installinit --name=vboxnet
cat debian/preinst.in | sed -e 's|%VER%|$(ver)|g' > debian/preinst
if [ "$(debrel)" = "_Ubuntu_dapper" -o "$(debrel)" = "_Debian_sarge" ]; then \
cat debian/postrm.dapper > debian/postrm; fi
dh_installdebconf
dh_installchangelogs
dh_link
dh_strip --keep-debug
# manually strip our R0/GC modules, dh_strip cannot handle them
for f in \
$(prefix)/usr/lib/$(package)/*.r0 $(prefix)/usr/lib/$(package)/*.gc; do \
objcopy --only-keep-debug \
$$f \
$(prefix)/usr/lib/debug/usr/lib/$(package)/`basename $$f`; \
strip -S --remove-section=.comment $$f; \
objcopy --add-gnu-debuglink=$(prefix)/usr/lib/debug/usr/lib/$(package)/`basename $$f` $$f; \
done
mkdir -p $(current)/debian/$(package)-dbg/usr/lib
mv $(current)/debian/$(package)/usr/lib/debug $(current)/debian/$(package)-dbg/usr/lib
dh_compress -X.pdf -X.chm -X LICENSE
dh_fixperms
dh_makeshlibs
dh_installdeb
dh_perl
dh_shlibdeps
dh_gencontrol -- \
-Valsa=$(if $(HEADLESS),,libasound2) \
-Vpulse=$(if $(HEADLESS),,libpulse0) \
-Vsdlttf=$(if $(HEADLESS),,libsdl-ttf2.0-0)
dh_md5sums
dh_builddeb
endif
.PHONY: binary modules binary-arch binary-indep clean checkroot