1 | #!/usr/bin/make -f
|
---|
2 | #
|
---|
3 | # Copyright (C) 2006-2009 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 | # NOWEBSVC=1 don't build the webservice API, default for OSE
|
---|
31 | # STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
|
---|
32 | # BLEEDING_EDGE=xyz
|
---|
33 |
|
---|
34 | package := virtualbox
|
---|
35 | verpkg := virtualbox-ose
|
---|
36 | current := $(shell pwd)
|
---|
37 | vboxroot := $(shell pwd)
|
---|
38 | pkgdir := ..
|
---|
39 | builddir := $(current)/debian/builddir
|
---|
40 | moddir := $(current)/debian/modules
|
---|
41 | prefix := $(current)/debian/$(verpkg)
|
---|
42 | arch := $(shell dpkg --print-architecture)
|
---|
43 | verfile := $(builddir)/version-generated.mk
|
---|
44 | ose := 1
|
---|
45 | NOMODS ?= $(ose)
|
---|
46 | NOQT ?= $(HEADLESS)
|
---|
47 | NOWEBSVC ?= $(ose)
|
---|
48 | NOWINE := $(if $(NODOCS),$(if $(STAGEDISO),1,),)$(ose)
|
---|
49 |
|
---|
50 | ifneq ($(wildcard $(verfile)),)
|
---|
51 | include $(verfile)
|
---|
52 | ver := $(VBOX_VERSION_STRING)
|
---|
53 | archdir := $(prefix)/opt/VirtualBox-$(ver)
|
---|
54 | endif
|
---|
55 |
|
---|
56 | ifneq ($(STAGEDISO),)
|
---|
57 | ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
|
---|
58 | $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
|
---|
59 | endif
|
---|
60 | endif
|
---|
61 |
|
---|
62 | # Hack: Xandros is actually Debian/sarge ... :(
|
---|
63 | ifneq ($(wildcard /etc/xandros-desktop-version),)
|
---|
64 | debrel := _xandros4.1
|
---|
65 | else
|
---|
66 | ifneq ($(wildcard /etc/univention),)
|
---|
67 | debrel := _ucs1.3
|
---|
68 | else
|
---|
69 | debrel := $(if $(shell which lsb_release),_$(shell lsb_release -si)_$(shell lsb_release -sc),unknown)
|
---|
70 | endif
|
---|
71 | endif
|
---|
72 |
|
---|
73 | debcfgs := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\""
|
---|
74 |
|
---|
75 | # Locations of custom built Qt libraries (see below)
|
---|
76 | qtstdc5 := /home/vbox/Qt-4.4.3-stdc++5-$(arch)
|
---|
77 | qtstdc6 := /home/vbox/Qt-4.4.3-stdc++6-$(arch)
|
---|
78 |
|
---|
79 | # Ubuntu dapper: gcc-4.0 does not work with recompiler, use gcc-3.4 instead
|
---|
80 | # Ubuntu gutsy: gcc-4.1 does not work for the webservices, use gcc-4.2 instead
|
---|
81 | configure: debian/configure-stamp
|
---|
82 | debian/configure-stamp:
|
---|
83 | dh_testdir
|
---|
84 | cd $(vboxroot) && ./configure --odir=$(current)/debian $(if \
|
---|
85 | $(NOQT),--disable-qt,) $(if \
|
---|
86 | $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) $(if \
|
---|
87 | $(filter _Ubuntu_dapper,$(debrel)),--with-gcc=gcc-3.4 --with-g++=g++-3.4,) $(if \
|
---|
88 | $(filter _Ubuntu_gutsy,$(debrel)),--with-gcc=gcc-4.2 --with-g++=g++-4.2,) $(if \
|
---|
89 | $(filter _xandros4.1 _ucs1.3 _Debian_sarge _Ubuntu_dapper,$(debrel)),--build-libxml2,) $(if \
|
---|
90 | $(filter _xandros4.1 _ucs1.3 _Debian_sarge _Ubuntu_dapper,$(debrel)),--build-libxslt,) $(if \
|
---|
91 | $(filter _Debian_etch,$(debrel)),$(if $(ose),,--build-libcurl),) $(if \
|
---|
92 | $(filter _Debian_sarge _xandros4.1 _ucs1.3,$(debrel)),--with-qt4-dir=$(qtstdc5)) $(if \
|
---|
93 | $(filter _Debian_etch _Ubuntu_dapper _Ubuntu_edgy _Ubuntu_feisty,$(debrel)),--with-qt4-dir=$(qtstdc6)) $(if \
|
---|
94 | $(filter _xandros4.1 _ucs1.3,$(debrel)),--disable-sdl-ttf,) $(if \
|
---|
95 | $(filter _Debian_sarge _Ubuntu_dapper _Ubuntu_edgy _xandros4.1 _ucs1.3,$(debrel)),--disable-pulse,) $(if \
|
---|
96 | $(HEADLESS),--build-headless,) $(if $(DEBUG),--build-debug,) $(if \
|
---|
97 | $(NOWINE),,--setup-wine) $(if $(NOWEBSVC),,--enable-webservice)
|
---|
98 | touch debian/configure-stamp
|
---|
99 |
|
---|
100 | build: debian/configure-stamp debian/build-stamp
|
---|
101 | debian/build-stamp $(verfile):
|
---|
102 | dh_testdir
|
---|
103 | . debian/env.sh && kmk -C $(vboxroot) $(if \
|
---|
104 | $(VERBOSE),--print-directory,--no-print-directory) $(if \
|
---|
105 | $(NOPARALLEL),-j1,) $(if \
|
---|
106 | $(VERBOSE),KBUILD_VERBOSE=2,) $(if \
|
---|
107 | $(NODOCS),VBOX_WITH_DOCS= ,)\
|
---|
108 | $(if $(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 | $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),) \
|
---|
114 | VBOX_WITH_MULTIVERSION_PYTHON= \
|
---|
115 | $(if $(filter _Debian_sarge _xandros4.1 _ucs1.3,$(debrel)),VBOX_LD_as_needed= ,) \
|
---|
116 | $(debcfgs) \
|
---|
117 | all
|
---|
118 | $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
|
---|
119 | $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
|
---|
120 | mkdir -p $(builddir)/bin/additions
|
---|
121 | $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
|
---|
122 | . debian/env.sh && kmk -C $(vboxroot) $(if \
|
---|
123 | $(VERBOSE),--print-directory,--no-print-directory) $(if \
|
---|
124 | $(VERBOSE),KBUILD_VERBOSE=2,) $(if \
|
---|
125 | $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
|
---|
126 | AUTOCFG=$(current)/debian/AutoConfig.kmk \
|
---|
127 | LOCALCFG=$(current)/debian/LocalConfig.kmk \
|
---|
128 | PATH_OUT=$(current)/debian/builddir \
|
---|
129 | VBOX_DO_STRIP= VBOX_DO_STRIP_MODULES= \
|
---|
130 | $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),) \
|
---|
131 | VBOX_WITH_MULTIVERSION_PYTHON= \
|
---|
132 | $(if $(filter _Debian_sarge _xandros4.1 _ucs1.3,$(debrel)),VBOX_LD_as_needed= ,) \
|
---|
133 | VBOX_NO_LINUX_RUN_INSTALLER=1 $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
|
---|
134 | VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
|
---|
135 | $(debcfgs) \
|
---|
136 | packing
|
---|
137 | touch debian/build-stamp
|
---|
138 |
|
---|
139 | # Build modules for every kernel we find in /lib/modules/*
|
---|
140 | modules: debian/build-stamp debian/modules-stamp
|
---|
141 | debian/modules-stamp: debian/build-stamp
|
---|
142 | rm -rf $(moddir)
|
---|
143 | mkdir $(moddir)
|
---|
144 | make -C $(builddir)/bin/src/vboxdrv clean
|
---|
145 | for d in $(wildcard /lib/modules/*); do \
|
---|
146 | if [ -L $$d/build ]; then \
|
---|
147 | make -C $(builddir)/bin/src/vboxdrv KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
148 | make -C $(builddir)/bin/src/vboxdrv KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all && \
|
---|
149 | install -D -m 0644 -g 0 -o 0 \
|
---|
150 | $(builddir)/bin/src/vboxdrv/vboxdrv.ko $(moddir)/$$(basename $$d)/vboxdrv.ko && \
|
---|
151 | make -C $(builddir)/bin/src/vboxnetflt KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
152 | (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetflt || true) && \
|
---|
153 | make -C $(builddir)/bin/src/vboxnetflt KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all && \
|
---|
154 | install -D -m 0644 -g 0 -o 0 \
|
---|
155 | $(builddir)/bin/src/vboxnetflt/vboxnetflt.ko $(moddir)/$$(basename $$d)/vboxnetflt.ko; \
|
---|
156 | make -C $(builddir)/bin/src/vboxnetadp KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
157 | (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetadp || true) && \
|
---|
158 | make -C $(builddir)/bin/src/vboxnetadp KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all && \
|
---|
159 | install -D -m 0644 -g 0 -o 0 \
|
---|
160 | $(builddir)/bin/src/vboxnetadp/vboxnetadp.ko $(moddir)/$$(basename $$d)/vboxnetadp.ko; \
|
---|
161 | fi; \
|
---|
162 | done
|
---|
163 | make -C $(builddir)/bin/src/vboxdrv clean
|
---|
164 | make -C $(builddir)/bin/src/vboxnetflt clean
|
---|
165 | make -C $(builddir)/bin/src/vboxnetadp clean
|
---|
166 | touch debian/modules-stamp
|
---|
167 |
|
---|
168 | clean:
|
---|
169 | dh_testdir
|
---|
170 | dh_testroot
|
---|
171 | rm -f debian/$(package).init debian/vboxdrv.init
|
---|
172 | rm -f debian/AutoConfig.kmk debian/configure.log debian/env.sh debian/preinst
|
---|
173 | rm -f debian/modules-stamp debian/build-stamp debian/configure-stamp
|
---|
174 | rm -rf $(builddir) $(moddir)
|
---|
175 | dh_clean
|
---|
176 |
|
---|
177 | ifeq ($(VBOX_VERSION_MAJOR),)
|
---|
178 | binary binary-arch binary-indep: build $(verfile)
|
---|
179 | $(MAKE) -f debian/rules binary
|
---|
180 | else
|
---|
181 | # Build architecture-dependent files here.
|
---|
182 | binary binary-arch binary-indep: build $(if $(NOMODS),,modules)
|
---|
183 | dh_testdir
|
---|
184 | dh_testroot
|
---|
185 | dh_clean -k
|
---|
186 | dh_installdirs
|
---|
187 | tar -xjC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar.bz2
|
---|
188 | install -d -g 0 -o 0 $(prefix)/usr/share/applications
|
---|
189 | install -d -g 0 -o 0 $(prefix)/usr/lib
|
---|
190 | install -d -g 0 -o 0 $(prefix)/usr/bin
|
---|
191 | install -d -g 0 -o 0 $(prefix)/usr/lib/$(package)
|
---|
192 | install -d -g 0 -o 0 $(prefix)/usr/share/$(package)
|
---|
193 | install -d -g 0 -o 0 $(prefix)/usr/share/doc/$(verpkg)
|
---|
194 | $(if $(NOQT),,mv $(archdir)/virtualbox.desktop \
|
---|
195 | $(prefix)/usr/share/applications/virtualbox.desktop)
|
---|
196 | install -d -g 0 -o 0 $(prefix)/usr/share/pixmaps
|
---|
197 | install -d -g 0 -o 0 $(prefix)/usr/share/lintian/overrides
|
---|
198 | sed \
|
---|
199 | -e 's|%VERPKG%|$(verpkg)|g' \
|
---|
200 | debian/lintian-override.in > \
|
---|
201 | $(prefix)/usr/share/lintian/overrides/$(verpkg)
|
---|
202 | mv $(archdir)/VBox.png \
|
---|
203 | $(prefix)/usr/share/pixmaps/VBox.png
|
---|
204 | mv $(archdir)/*.gc $(prefix)/usr/lib/$(package)
|
---|
205 | mv $(archdir)/*.r0 $(prefix)/usr/lib/$(package)
|
---|
206 | mv $(archdir)/*.rel $(prefix)/usr/lib/$(package) || true
|
---|
207 | mv $(archdir)/VBoxNetDHCP $(prefix)/usr/lib/$(package)
|
---|
208 | mv $(archdir)/VBoxNetAdpCtl $(prefix)/usr/lib/$(package)
|
---|
209 | mv $(archdir)/VBoxXPCOMIPCD $(prefix)/usr/lib/$(package)
|
---|
210 | mv $(archdir)/components $(prefix)/usr/lib/$(package)/components
|
---|
211 | mv $(archdir)/*.so $(prefix)/usr/lib/$(package)
|
---|
212 | mv $(archdir)/*.so.4 $(prefix)/usr/lib/$(package) || true
|
---|
213 | mv $(archdir)/VBoxTestOGL $(prefix)/usr/lib/$(package)
|
---|
214 | $(if $(NOQT),,mv $(archdir)/nls $(prefix)/usr/share/$(package))
|
---|
215 | mv $(archdir)/src $(prefix)/usr/share/$(package)
|
---|
216 | rm $(archdir)/VBox.sh
|
---|
217 | export VBOX_INSTALL_PATH=/usr/lib/$(package) && \
|
---|
218 | cd ./debian/builddir/bin/sdk/installer && \
|
---|
219 | python ./vboxapisetup.py install --root $(prefix)
|
---|
220 | rm -rf $(archdir)/sdk/installer
|
---|
221 | mv $(archdir)/vboxshell.py $(prefix)/usr/lib/$(package)
|
---|
222 | mv $(archdir)/sdk $(prefix)/usr/lib/$(package)
|
---|
223 | install -D -g 0 -o 0 -m 644 debian/VBox.sh $(prefix)/usr/bin/VBox
|
---|
224 | mv $(archdir)/VBoxSysInfo.sh $(prefix)/usr/share/$(package)
|
---|
225 | for i in VBoxManage VBoxSVC $(if $(HEADLESS),,VBoxSDL) \
|
---|
226 | $(if $(NOQT),,VirtualBox) VBoxHeadless \
|
---|
227 | $(if $(NOWEBSVC),,vboxwebsrv webtest); do \
|
---|
228 | mv $(archdir)/$$i $(prefix)/usr/lib/$(package); done
|
---|
229 | mv $(archdir)/VBoxTunctl $(prefix)/usr/bin
|
---|
230 | $(if $(NOMODS),,for d in $(moddir)/*; do \
|
---|
231 | install -D -g 0 -o 0 -m 0644 \
|
---|
232 | $$d/vboxdrv.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxdrv.ko; \
|
---|
233 | install -D -g 0 -o 0 -m 0644 \
|
---|
234 | $$d/vboxnetflt.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetflt.ko; \
|
---|
235 | install -D -g 0 -o 0 -m 0644 \
|
---|
236 | $$d/vboxnetadp.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetadp.ko; \
|
---|
237 | done)
|
---|
238 | ifeq ($(ose),)
|
---|
239 | $(if $(NOQT),,mv $(archdir)/kchmviewer $(prefix)/usr/lib/$(package))
|
---|
240 | dh_installdocs \
|
---|
241 | $(archdir)/UserManual*.pdf $(archdir)/VirtualBox*.chm \
|
---|
242 | LICENSE
|
---|
243 | rm $(addprefix $(archdir)/,UserManual*.pdf VirtualBox*.chm LICENSE)
|
---|
244 | for i in rdesktop-vrdp.tar.gz additions/VBoxGuestAdditions.iso; do \
|
---|
245 | mv $(archdir)/$$i $(prefix)/usr/share/$(package); done
|
---|
246 | rmdir $(archdir)/additions
|
---|
247 | if [ -d $(archdir)/accessible ]; then mv $(archdir)/accessible $(prefix)/usr/lib/virtualbox; fi
|
---|
248 | else
|
---|
249 | dh_installdocs
|
---|
250 | endif
|
---|
251 | rmdir $(archdir)
|
---|
252 | rmdir $(prefix)/opt
|
---|
253 | dh_link \
|
---|
254 | $(if $(NOQT),,usr/bin/VBox usr/bin/VirtualBox) \
|
---|
255 | usr/bin/VBox usr/bin/VBoxManage \
|
---|
256 | $(if $(HEADLESS),,usr/bin/VBox usr/bin/VBoxSDL) \
|
---|
257 | $(if $(ose),,usr/bin/VBox usr/bin/VBoxVRDP) \
|
---|
258 | usr/bin/VBox usr/bin/VBoxHeadless \
|
---|
259 | $(if $(NOWEBSVC),,usr/bin/VBox usr/bin/vboxwebsrv) \
|
---|
260 | usr/share/virtualbox/src/vboxdrv usr/src/vboxdrv-$(ver) \
|
---|
261 | usr/share/virtualbox/src/vboxnetflt usr/src/vboxnetflt-$(ver) \
|
---|
262 | usr/share/virtualbox/src/vboxnetadp usr/src/vboxnetadp-$(ver)
|
---|
263 | dh_desktop
|
---|
264 | dh_installmenu
|
---|
265 | $(if $(NOMODS),,dh_installmodules)
|
---|
266 | sed \
|
---|
267 | -e 's|%NOLSB%|$(if $(filter _Debian_sarge ucs1.3,$(debrel)),yes,)|g' \
|
---|
268 | -e 's|%PACKAGE%|virtualbox|g' \
|
---|
269 | src/VBox/Installer/linux/vboxdrv.sh.in > debian/vboxdrv.init
|
---|
270 | dh_installinit --name=vboxdrv
|
---|
271 | cat debian/preinst.in | sed -e 's|%VER%|$(ver)|g' > debian/preinst
|
---|
272 | if [ "$(debrel)" = "_Ubuntu_dapper" -o "$(debrel)" = "_Debian_sarge" ]; then \
|
---|
273 | cat debian/postrm.dapper > debian/postrm; fi
|
---|
274 | dh_installdebconf
|
---|
275 | dh_installchangelogs
|
---|
276 | dh_link
|
---|
277 | ifeq ($(DEBUG),)
|
---|
278 | dh_strip --keep-debug --exclude=libQtCoreVBox.so.4 --exclude=libQtGuiVBox.so.4 --exclude=libQtNetworkVBox.so.4 --exclude=libqtaccessiblewidgets.so
|
---|
279 | # manually strip our R0/GC modules, dh_strip cannot handle them
|
---|
280 | for f in \
|
---|
281 | $(prefix)/usr/lib/$(package)/*.r0 $(prefix)/usr/lib/$(package)/*.gc; do \
|
---|
282 | objcopy --only-keep-debug \
|
---|
283 | $$f \
|
---|
284 | $(prefix)/usr/lib/debug/usr/lib/$(package)/`basename $$f`; \
|
---|
285 | strip -S --remove-section=.comment $$f; \
|
---|
286 | objcopy --add-gnu-debuglink=$(prefix)/usr/lib/debug/usr/lib/$(package)/`basename $$f` $$f; \
|
---|
287 | done
|
---|
288 | endif
|
---|
289 | mkdir -p $(current)/debian/$(verpkg)-dbg/usr/lib
|
---|
290 | ifeq ($(DEBUG),)
|
---|
291 | mv $(current)/debian/$(verpkg)/usr/lib/debug $(current)/debian/$(verpkg)-dbg/usr/lib
|
---|
292 | endif
|
---|
293 | dh_pycentral
|
---|
294 | dh_compress -X.pdf -X.chm -X LICENSE -X.py
|
---|
295 | dh_fixperms
|
---|
296 | dh_makeshlibs
|
---|
297 | dh_installdeb
|
---|
298 | dh_perl
|
---|
299 | dh_shlibdeps
|
---|
300 | dh_gencontrol -- \
|
---|
301 | -Valsa=$(if $(HEADLESS),,libasound2) \
|
---|
302 | -Vpulse=$(if $(HEADLESS),,libpulse0) \
|
---|
303 | -Vsdlttf=$(if $(HEADLESS),,libsdl-ttf2.0-0) \
|
---|
304 | -Vdkms=$(if $(filter _Ubuntu_gutsy _Ubuntu_hardy _Ubuntu_intrepid _Ubuntu_jaunty,$(debrel)),dkms,)
|
---|
305 | dh_md5sums
|
---|
306 | dh_builddeb --destdir $(pkgdir)
|
---|
307 | endif
|
---|
308 |
|
---|
309 | .PHONY: binary modules binary-arch binary-indep clean checkroot
|
---|