1 | #!/usr/bin/make -f
|
---|
2 | #
|
---|
3 | # Copyright (C) 2006-2008 Sun Microsystems, Inc.
|
---|
4 | #
|
---|
5 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
6 | # available from http://www.virtualbox.org. This file is free software;
|
---|
7 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
8 | # General Public License as published by the Free Software Foundation,
|
---|
9 | # in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
10 | # distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
11 | # be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
12 | #
|
---|
13 |
|
---|
14 | #export DH_VERBOSE=1
|
---|
15 | export DH_COMPAT=4
|
---|
16 |
|
---|
17 | # possible overrides:
|
---|
18 | # OSE=1 force VBOX_OSE
|
---|
19 | # NOPARALLEL=1 compile with -j1
|
---|
20 | # LINUX=<dir> compile vboxdrv against Linux found in <dir>
|
---|
21 | # VERBOSE=1 verbose build
|
---|
22 | # DEBUG=1 debug build
|
---|
23 | # NOSUBVER=1 disable generation of the sub-version field (which is
|
---|
24 | # either the subversion rev [if available] or the build date)
|
---|
25 | # NODOCS=1 don't build docs, use precompiled UserManual.pdf and
|
---|
26 | # VirtualBox.chm from $HOME
|
---|
27 | # NOMODS=1 don't build any module
|
---|
28 | # NOQT=1 don't build the Qt GUI
|
---|
29 | # HEADLESS=1 build the headless version
|
---|
30 | # STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
|
---|
31 |
|
---|
32 | package := virtualbox
|
---|
33 | verpkg := virtualbox-ose
|
---|
34 | current := $(shell pwd)
|
---|
35 | vboxroot := $(shell pwd)
|
---|
36 | builddir := $(current)/debian/builddir
|
---|
37 | moddir := $(current)/debian/modules
|
---|
38 | prefix := $(current)/debian/$(verpkg)
|
---|
39 | arch := $(shell dpkg --print-architecture)
|
---|
40 | verfile := $(builddir)/version-generated.mk
|
---|
41 | ose := 1
|
---|
42 | NOMODS ?= $(ose)
|
---|
43 | NOQT ?= $(HEADLESS)
|
---|
44 |
|
---|
45 | ifneq ($(wildcard $(verfile)),)
|
---|
46 | include $(verfile)
|
---|
47 | ver := $(VBOX_VERSION_STRING)
|
---|
48 | archdir := $(prefix)/opt/VirtualBox-$(ver)
|
---|
49 | endif
|
---|
50 |
|
---|
51 | ifneq ($(STAGEDISO),)
|
---|
52 | ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
|
---|
53 | $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
|
---|
54 | endif
|
---|
55 | endif
|
---|
56 |
|
---|
57 | # Hack: Xandros is actually Debian/sarge ... :(
|
---|
58 | ifneq ($(wildcard /etc/xandros-desktop-version),)
|
---|
59 | debrel := _xandros4.1
|
---|
60 | else
|
---|
61 | ifneq ($(wildcard /etc/univention),)
|
---|
62 | debrel := _ucs1.3
|
---|
63 | else
|
---|
64 | debrel := $(if $(shell which lsb_release),_$(shell lsb_release -si)_$(shell lsb_release -sc),unknown)
|
---|
65 | endif
|
---|
66 | endif
|
---|
67 |
|
---|
68 | gccver := $(subst ., ,$(shell gcc -dumpversion))
|
---|
69 | gccvmaj := $(word 1,$(gccver))
|
---|
70 | gccvmin := $(word 2,$(gccver))
|
---|
71 | debcfgs := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\""
|
---|
72 |
|
---|
73 | # Ubuntu dapper: gcc-4.0 does not work with recompiler, use gcc-3.4 instead
|
---|
74 | configure: debian/configure-stamp
|
---|
75 | debian/configure-stamp:
|
---|
76 | dh_testdir
|
---|
77 | cd $(vboxroot) && ./configure --odir=$(current)/debian --disable-qt3 $(if \
|
---|
78 | $(NOQT),--disable-qt,) $(if \
|
---|
79 | $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) $(if \
|
---|
80 | $(filter _Ubuntu_dapper,$(debrel)),--with-gcc=gcc-3.4 --with-g++=g++-3.4,) $(if \
|
---|
81 | $(shell test $(gccvmaj) -eq 4 -a $(gccvmin) -gt 2 -o $(gccvmaj) -gt 4 && echo "yes"),--with-gcc=gcc-4.2 --with-g++=g++-4.2,) $(if \
|
---|
82 | $(filter _xandros4.1 _ucs1.3,$(debrel)),--disable-sdl-ttf,) $(if \
|
---|
83 | $(HEADLESS),--build-headless,) $(if $(DEBUG),--build-debug,)
|
---|
84 | touch debian/configure-stamp
|
---|
85 |
|
---|
86 | build: debian/configure-stamp debian/build-stamp
|
---|
87 | debian/build-stamp $(verfile):
|
---|
88 | dh_testdir
|
---|
89 | . debian/env.sh && kmk -C $(vboxroot) $(if \
|
---|
90 | $(VERBOSE),--print-directory,--no-print-directory) $(if \
|
---|
91 | $(NOPARALLEL),-j1,) $(if \
|
---|
92 | $(VERBOSE),KBUILD_VERBOSE=2,) $(if \
|
---|
93 | $(NODOCS),VBOX_WITH_DOCS= ,)\
|
---|
94 | $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
|
---|
95 | AUTOCFG=$(current)/debian/AutoConfig.kmk \
|
---|
96 | LOCALCFG=$(current)/debian/LocalConfig.kmk \
|
---|
97 | PATH_OUT=$(current)/debian/builddir \
|
---|
98 | VBOX_DO_STRIP= VBOX_DO_STRIP_MODULES= \
|
---|
99 | $(debcfgs) \
|
---|
100 | all
|
---|
101 | $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual.pdf $(builddir)/bin,)
|
---|
102 | $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox.chm $(builddir)/bin,)
|
---|
103 | mkdir -p $(builddir)/bin/additions
|
---|
104 | $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
|
---|
105 | . debian/env.sh && kmk -C $(vboxroot) $(if \
|
---|
106 | $(VERBOSE),--print-directory,--no-print-directory) $(if \
|
---|
107 | $(VERBOSE),KBUILD_VERBOSE=2,) $(if \
|
---|
108 | $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
|
---|
109 | AUTOCFG=$(current)/debian/AutoConfig.kmk \
|
---|
110 | LOCALCFG=$(current)/debian/LocalConfig.kmk \
|
---|
111 | PATH_OUT=$(current)/debian/builddir \
|
---|
112 | VBOX_DO_STRIP= VBOX_DO_STRIP_MODULES= \
|
---|
113 | VBOX_NO_LINUX_RUN_INSTALLER=1 \
|
---|
114 | $(debcfgs) \
|
---|
115 | packing
|
---|
116 | touch debian/build-stamp
|
---|
117 |
|
---|
118 | # Build modules for every kernel we find in /lib/modules/*
|
---|
119 | modules: debian/build-stamp debian/modules-stamp
|
---|
120 | debian/modules-stamp: debian/build-stamp
|
---|
121 | rm -rf $(moddir)
|
---|
122 | mkdir $(moddir)
|
---|
123 | make -C $(builddir)/bin/src/vboxdrv clean
|
---|
124 | for d in $(wildcard /lib/modules/*); do \
|
---|
125 | if [ -L $$d/build ]; then \
|
---|
126 | make -C $(builddir)/bin/src/vboxdrv KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
127 | make -C $(builddir)/bin/src/vboxdrv KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all && \
|
---|
128 | install -D -m 0644 -g 0 -o 0 \
|
---|
129 | $(builddir)/bin/src/vboxdrv/vboxdrv.ko $(moddir)/$$(basename $$d)/vboxdrv.ko && \
|
---|
130 | make -C $(builddir)/bin/src/vboxnetflt KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
131 | (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetflt || true) && \
|
---|
132 | make -C $(builddir)/bin/src/vboxnetflt KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all && \
|
---|
133 | install -D -m 0644 -g 0 -o 0 \
|
---|
134 | $(builddir)/bin/src/vboxnetflt/vboxnetflt.ko $(moddir)/$$(basename $$d)/vboxnetflt.ko; \
|
---|
135 | fi; \
|
---|
136 | done
|
---|
137 | make -C $(builddir)/bin/src/vboxdrv clean
|
---|
138 | make -C $(builddir)/bin/src/vboxnetflt clean
|
---|
139 | touch debian/modules-stamp
|
---|
140 |
|
---|
141 | clean:
|
---|
142 | dh_testdir
|
---|
143 | dh_testroot
|
---|
144 | rm -f debian/$(package).init debian/vboxdrv.init
|
---|
145 | rm -f debian/AutoConfig.kmk debian/configure.log debian/env.sh debian/preinst
|
---|
146 | rm -f debian/modules-stamp debian/build-stamp debian/configure-stamp
|
---|
147 | rm -rf $(builddir) $(moddir)
|
---|
148 | dh_clean
|
---|
149 |
|
---|
150 | ifeq ($(VBOX_VERSION_MAJOR),)
|
---|
151 | binary binary-arch binary-indep: build $(verfile)
|
---|
152 | $(MAKE) -f debian/rules binary
|
---|
153 | else
|
---|
154 | # Build architecture-dependent files here.
|
---|
155 | binary binary-arch binary-indep: build $(if $(NOMODS),,modules)
|
---|
156 | dh_testdir
|
---|
157 | dh_testroot
|
---|
158 | dh_clean -k
|
---|
159 | dh_installdirs
|
---|
160 | tar -xjC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar.bz2
|
---|
161 | install -d -g 0 -o 0 $(prefix)/usr/share/applications
|
---|
162 | install -d -g 0 -o 0 $(prefix)/usr/lib
|
---|
163 | install -d -g 0 -o 0 $(prefix)/usr/bin
|
---|
164 | install -d -g 0 -o 0 $(prefix)/usr/lib/$(package)
|
---|
165 | install -d -g 0 -o 0 $(prefix)/usr/share/$(package)
|
---|
166 | install -d -g 0 -o 0 $(prefix)/usr/share/doc/$(verpkg)
|
---|
167 | $(if $(NOQT),,mv $(archdir)/VirtualBox.desktop \
|
---|
168 | $(prefix)/usr/share/applications/VirtualBox.desktop)
|
---|
169 | install -d -g 0 -o 0 $(prefix)/usr/share/pixmaps
|
---|
170 | install -d -g 0 -o 0 $(prefix)/usr/share/lintian/overrides
|
---|
171 | sed \
|
---|
172 | -e 's|%VERPKG%|$(verpkg)|g' \
|
---|
173 | debian/lintian-override.in > \
|
---|
174 | $(prefix)/usr/share/lintian/overrides/$(verpkg)
|
---|
175 | mv $(archdir)/VBox.png \
|
---|
176 | $(prefix)/usr/share/pixmaps/VBox.png
|
---|
177 | mv $(archdir)/*.gc $(prefix)/usr/lib/$(package)
|
---|
178 | mv $(archdir)/*.r0 $(prefix)/usr/lib/$(package)
|
---|
179 | mv $(archdir)/*.rel $(prefix)/usr/lib/$(package) || true
|
---|
180 | mv $(archdir)/VBoxXPCOMIPCD $(prefix)/usr/lib/$(package)
|
---|
181 | mv $(archdir)/components $(prefix)/usr/lib/$(package)/components
|
---|
182 | mv $(archdir)/*.so $(prefix)/usr/lib/$(package)
|
---|
183 | mv $(archdir)/*.so.4 $(prefix)/usr/lib/$(package) || true
|
---|
184 | $(if $(NOQT),,mv $(archdir)/nls $(prefix)/usr/share/$(package))
|
---|
185 | mv $(archdir)/src $(prefix)/usr/share/$(package)
|
---|
186 | rm $(archdir)/VBox.sh
|
---|
187 | install -D -g 0 -o 0 -m 644 debian/VBox.sh $(prefix)/usr/bin/VBox
|
---|
188 | mv $(archdir)/VBoxSysInfo.sh $(prefix)/usr/share/$(package)
|
---|
189 | for i in VBoxManage VBoxSVC $(if $(HEADLESS),,VBoxSDL) \
|
---|
190 | $(if $(NOQT),,VirtualBox) \
|
---|
191 | VBoxHeadless $(if $(ose),,vboxwebsrv webtest); do \
|
---|
192 | mv $(archdir)/$$i $(prefix)/usr/lib/$(package); done
|
---|
193 | mv $(archdir)/VBoxTunctl $(prefix)/usr/bin
|
---|
194 | $(if $(NOMODS),,for d in $(moddir)/*; do \
|
---|
195 | install -D -g 0 -o 0 -m 0644 \
|
---|
196 | $$d/vboxdrv.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxdrv.ko; \
|
---|
197 | install -D -g 0 -o 0 -m 0644 \
|
---|
198 | $$d/vboxnetflt.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetflt.ko; \
|
---|
199 | done)
|
---|
200 | ifeq ($(ose),)
|
---|
201 | $(if $(NOQT),,mv $(archdir)/kchmviewer $(prefix)/usr/lib/$(package))
|
---|
202 | dh_installdocs \
|
---|
203 | $(archdir)/UserManual*.pdf $(archdir)/VirtualBox*.chm \
|
---|
204 | LICENSE
|
---|
205 | rm $(addprefix $(archdir)/,UserManual*.pdf VirtualBox*.chm LICENSE)
|
---|
206 | for i in rdesktop-vrdp.tar.gz additions/VBoxGuestAdditions.iso; do \
|
---|
207 | mv $(archdir)/$$i $(prefix)/usr/share/$(package); done
|
---|
208 | rmdir $(archdir)/additions
|
---|
209 | if [ -d $(archdir)/accessible ]; then mv $(archdir)/accessible $(prefix)/usr/lib/virtualbox; fi
|
---|
210 | else
|
---|
211 | dh_installdocs
|
---|
212 | endif
|
---|
213 | rmdir $(archdir)
|
---|
214 | rmdir $(prefix)/opt
|
---|
215 | dh_link \
|
---|
216 | $(if $(NOQT),,usr/bin/VBox usr/bin/VirtualBox) \
|
---|
217 | usr/bin/VBox usr/bin/VBoxManage \
|
---|
218 | $(if $(HEADLESS),,usr/bin/VBox usr/bin/VBoxSDL) \
|
---|
219 | $(if $(ose),,usr/bin/VBox usr/bin/VBoxVRDP) \
|
---|
220 | usr/bin/VBox usr/bin/VBoxHeadless \
|
---|
221 | $(if $(ose),,usr/bin/VBox usr/bin/vboxwebsrv) \
|
---|
222 | usr/share/virtualbox/src/vboxdrv usr/src/vboxdrv-$(ver) \
|
---|
223 | usr/share/virtualbox/src/vboxnetflt usr/src/vboxnetflt-$(ver)
|
---|
224 | dh_desktop
|
---|
225 | dh_installmenu
|
---|
226 | $(if $(NOMODS),,dh_installmodules)
|
---|
227 | sed \
|
---|
228 | -e 's|%NOLSB%|$(if $(filter _Debian_sarge ucs1.3,$(debrel)),yes,)|g' \
|
---|
229 | -e 's|%PACKAGE%|virtualbox|g' \
|
---|
230 | src/VBox/Installer/linux/vboxdrv.sh.in > debian/vboxdrv.init
|
---|
231 | dh_installinit --name=vboxdrv
|
---|
232 | cat debian/preinst.in | sed -e 's|%VER%|$(ver)|g' > debian/preinst
|
---|
233 | if [ "$(debrel)" = "_Ubuntu_dapper" -o "$(debrel)" = "_Debian_sarge" ]; then \
|
---|
234 | cat debian/postrm.dapper > debian/postrm; fi
|
---|
235 | dh_installdebconf
|
---|
236 | dh_installchangelogs
|
---|
237 | dh_link
|
---|
238 | dh_strip --keep-debug --exclude=libVBoxQtCore.so.4 --exclude=libVBoxQtGui.so.4 --exclude=libVBoxQtNetwork.so.4 --exclude=libqtaccessiblewidgets.so
|
---|
239 | # manually strip our R0/GC modules, dh_strip cannot handle them
|
---|
240 | for f in \
|
---|
241 | $(prefix)/usr/lib/$(package)/*.r0 $(prefix)/usr/lib/$(package)/*.gc; do \
|
---|
242 | objcopy --only-keep-debug \
|
---|
243 | $$f \
|
---|
244 | $(prefix)/usr/lib/debug/usr/lib/$(package)/`basename $$f`; \
|
---|
245 | strip -S --remove-section=.comment $$f; \
|
---|
246 | objcopy --add-gnu-debuglink=$(prefix)/usr/lib/debug/usr/lib/$(package)/`basename $$f` $$f; \
|
---|
247 | done
|
---|
248 | mkdir -p $(current)/debian/$(verpkg)-dbg/usr/lib
|
---|
249 | mv $(current)/debian/$(verpkg)/usr/lib/debug $(current)/debian/$(verpkg)-dbg/usr/lib
|
---|
250 | dh_compress -X.pdf -X.chm -X LICENSE
|
---|
251 | dh_fixperms
|
---|
252 | dh_makeshlibs
|
---|
253 | dh_installdeb
|
---|
254 | dh_perl
|
---|
255 | dh_shlibdeps
|
---|
256 | dh_gencontrol -- \
|
---|
257 | -Valsa=$(if $(HEADLESS),,libasound2) \
|
---|
258 | -Vpulse=$(if $(HEADLESS),,libpulse0) \
|
---|
259 | -Vsdlttf=$(if $(HEADLESS),,libsdl-ttf2.0-0) \
|
---|
260 | -Vdkms=$(if $(filter _Ubuntu_gutsy _Ubuntu_hardy _Ubuntu_intrepid,$(debrel)),dkms,)
|
---|
261 | dh_md5sums
|
---|
262 | dh_builddeb
|
---|
263 | endif
|
---|
264 |
|
---|
265 | .PHONY: binary modules binary-arch binary-indep clean checkroot
|
---|