1 | #!/usr/bin/make -f
|
---|
2 | #
|
---|
3 | # Copyright (C) 2006-2010 Oracle Corporation
|
---|
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 | debrel := $(if $(shell which lsb_release),_$(shell lsb_release -si)_$(shell lsb_release -sc),unknown)
|
---|
63 |
|
---|
64 | # shipping Linux kernel modules with bleeding-edge releases doesn't make sense
|
---|
65 | instmod := $(if $(filter _Ubuntu_lucid _Debian_sid,$(debrel)),,1)
|
---|
66 |
|
---|
67 | # Locations of custom built Qt libraries (see below)
|
---|
68 | qtstdc5 := /home/vbox/Qt-4.4.3-stdc++5-$(arch)
|
---|
69 | qtstdc6 := /home/vbox/Qt-4.4.3-stdc++6-$(arch)
|
---|
70 |
|
---|
71 | cfg_flags := $(if $(NOQT),--disable-qt,) \
|
---|
72 | $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
|
---|
73 | $(if $(filter _Debian_etch,$(debrel)),$(if $(ose),,--build-libcurl),) \
|
---|
74 | $(if $(filter _Debian_etch _Ubuntu_hardy,$(debrel)),--with-qt4-dir=$(qtstdc6)) \
|
---|
75 | $(if $(HEADLESS),--build-headless,) \
|
---|
76 | $(if $(DEBUG),--build-debug,) \
|
---|
77 | $(if $(NOWINE),,--setup-wine) \
|
---|
78 | $(if $(NOWEBSVC),,--enable-webservice)
|
---|
79 |
|
---|
80 | bld_flags := AUTOCFG=$(current)/debian/AutoConfig.kmk \
|
---|
81 | LOCALCFG=$(current)/debian/LocalConfig.kmk \
|
---|
82 | PATH_OUT=$(current)/debian/builddir \
|
---|
83 | VBOX_DO_STRIP= \
|
---|
84 | VBOX_DO_STRIP_MODULES= \
|
---|
85 | VBOX_WITH_MULTIVERSION_PYTHON= \
|
---|
86 | VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\"" \
|
---|
87 | $(if $(NODOCS),VBOX_WITH_DOCS= ,)\
|
---|
88 | $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
|
---|
89 | $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
|
---|
90 | $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),) \
|
---|
91 | $(if $(filter _Debian_etch _Ubuntu_hardy,$(debrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
|
---|
92 |
|
---|
93 | configure: debian/configure-stamp
|
---|
94 | debian/configure-stamp:
|
---|
95 | dh_testdir
|
---|
96 | cd $(vboxroot) && ./configure --odir=$(current)/debian $(cfg_flags)
|
---|
97 | touch debian/configure-stamp
|
---|
98 |
|
---|
99 | build: debian/configure-stamp debian/build-stamp
|
---|
100 | debian/build-stamp $(verfile):
|
---|
101 | dh_testdir
|
---|
102 | . debian/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
|
---|
103 | $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
|
---|
104 | $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
|
---|
105 | mkdir -p $(builddir)/bin/additions
|
---|
106 | $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
|
---|
107 | . debian/env.sh && kmk -C $(vboxroot) $(bld_flags) \
|
---|
108 | VBOX_NO_LINUX_RUN_INSTALLER=1 \
|
---|
109 | VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86-r$(svnrev).tar.bz2 \
|
---|
110 | VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64-r$(svnrev).tar.bz2 \
|
---|
111 | packing
|
---|
112 | touch debian/build-stamp
|
---|
113 |
|
---|
114 | # Build modules for every kernel we find in /lib/modules/*
|
---|
115 | modules: debian/build-stamp debian/modules-stamp
|
---|
116 | debian/modules-stamp: debian/build-stamp
|
---|
117 | rm -rf $(moddir)
|
---|
118 | mkdir $(moddir)
|
---|
119 | make -C $(builddir)/bin/src/vboxdrv clean
|
---|
120 | for d in $(wildcard /lib/modules/*); do \
|
---|
121 | if [ -L $$d/build ]; then \
|
---|
122 | make -C $(builddir)/bin/src/vboxdrv KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
123 | make -j4 -C $(builddir)/bin/src/vboxdrv KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
124 | $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
|
---|
125 | $(builddir)/bin/src/vboxdrv/vboxdrv.ko $(moddir)/$$(basename $$d)/vboxdrv.ko); \
|
---|
126 | make -C $(builddir)/bin/src/vboxnetflt KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
127 | (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetflt || true) && \
|
---|
128 | make -j4 -C $(builddir)/bin/src/vboxnetflt KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
129 | $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
|
---|
130 | $(builddir)/bin/src/vboxnetflt/vboxnetflt.ko $(moddir)/$$(basename $$d)/vboxnetflt.ko); \
|
---|
131 | make -C $(builddir)/bin/src/vboxnetadp KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
132 | (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetadp || true) && \
|
---|
133 | make -j4 -C $(builddir)/bin/src/vboxnetadp KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
134 | $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
|
---|
135 | $(builddir)/bin/src/vboxnetadp/vboxnetadp.ko $(moddir)/$$(basename $$d)/vboxnetadp.ko); \
|
---|
136 | fi; \
|
---|
137 | done
|
---|
138 | make -C $(builddir)/bin/src/vboxdrv clean
|
---|
139 | make -C $(builddir)/bin/src/vboxnetflt clean
|
---|
140 | make -C $(builddir)/bin/src/vboxnetadp clean
|
---|
141 | touch debian/modules-stamp
|
---|
142 |
|
---|
143 | clean:
|
---|
144 | dh_testdir
|
---|
145 | dh_testroot
|
---|
146 | rm -f debian/preinst debian/postinst
|
---|
147 | rm -f debian/$(package).init debian/vboxdrv.init
|
---|
148 | rm -f debian/AutoConfig.kmk debian/configure.log debian/env.sh
|
---|
149 | rm -f debian/modules-stamp debian/build-stamp debian/configure-stamp
|
---|
150 | rm -rf $(builddir) $(moddir)
|
---|
151 | dh_clean
|
---|
152 |
|
---|
153 | ifeq ($(VBOX_VERSION_MAJOR),)
|
---|
154 | binary binary-arch binary-indep: build $(verfile)
|
---|
155 | $(MAKE) -f debian/rules binary
|
---|
156 | else
|
---|
157 | # Build architecture-dependent files here.
|
---|
158 | binary binary-arch binary-indep: build $(if $(NOMODS),,modules)
|
---|
159 | dh_testdir
|
---|
160 | dh_testroot
|
---|
161 | dh_clean -k
|
---|
162 | dh_installdirs
|
---|
163 | tar -xjC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar.bz2
|
---|
164 | install -d -g 0 -o 0 $(prefix)/usr/share/applications
|
---|
165 | install -d -g 0 -o 0 $(prefix)/usr/lib
|
---|
166 | install -d -g 0 -o 0 $(prefix)/usr/bin
|
---|
167 | install -d -g 0 -o 0 $(prefix)/usr/lib/$(package)
|
---|
168 | install -d -g 0 -o 0 $(prefix)/usr/share/$(package)
|
---|
169 | install -d -g 0 -o 0 $(prefix)/usr/share/doc/$(verpkg)
|
---|
170 | $(if $(NOQT),,mv $(archdir)/virtualbox.desktop \
|
---|
171 | $(prefix)/usr/share/applications/virtualbox.desktop)
|
---|
172 | install -d -g 0 -o 0 $(prefix)/usr/share/pixmaps
|
---|
173 | install -d -g 0 -o 0 $(prefix)/usr/share/lintian/overrides
|
---|
174 | sed \
|
---|
175 | -e 's|%VERPKG%|$(verpkg)|g' \
|
---|
176 | debian/lintian-override.in > \
|
---|
177 | $(prefix)/usr/share/lintian/overrides/$(verpkg)
|
---|
178 | mv $(archdir)/VBoxEFI32.fd $(prefix)/usr/lib/$(package)
|
---|
179 | mv $(archdir)/VBoxEFI64.fd $(prefix)/usr/lib/$(package)
|
---|
180 | mv $(archdir)/VBox.png \
|
---|
181 | $(prefix)/usr/share/pixmaps/VBox.png
|
---|
182 | mv $(archdir)/*.gc $(prefix)/usr/lib/$(package)
|
---|
183 | mv $(archdir)/*.r0 $(prefix)/usr/lib/$(package)
|
---|
184 | mv $(archdir)/*.rel $(prefix)/usr/lib/$(package) || true
|
---|
185 | mv $(archdir)/VBoxNetDHCP $(prefix)/usr/lib/$(package)
|
---|
186 | mv $(archdir)/VBoxNetAdpCtl $(prefix)/usr/lib/$(package)
|
---|
187 | mv $(archdir)/VBoxXPCOMIPCD $(prefix)/usr/lib/$(package)
|
---|
188 | mv $(archdir)/components $(prefix)/usr/lib/$(package)/components
|
---|
189 | mv $(archdir)/*.so $(prefix)/usr/lib/$(package)
|
---|
190 | mv $(archdir)/*.so.4 $(prefix)/usr/lib/$(package) || true
|
---|
191 | $(if $(NOQT),,mv $(archdir)/VBoxTestOGL $(prefix)/usr/lib/$(package))
|
---|
192 | $(if $(NOQT),,mv $(archdir)/nls $(prefix)/usr/share/$(package))
|
---|
193 | mv $(archdir)/src $(prefix)/usr/share/$(package)
|
---|
194 | rm $(archdir)/VBox.sh
|
---|
195 | export VBOX_INSTALL_PATH=/usr/lib/$(package) && \
|
---|
196 | cd ./debian/builddir/bin/sdk/installer && \
|
---|
197 | python ./vboxapisetup.py install --root $(prefix)
|
---|
198 | rm -rf $(archdir)/sdk/installer
|
---|
199 | mv $(archdir)/vboxshell.py $(prefix)/usr/lib/$(package)
|
---|
200 | mv $(archdir)/sdk $(prefix)/usr/lib/$(package)
|
---|
201 | install -D -g 0 -o 0 -m 644 debian/VBox.sh $(prefix)/usr/bin/VBox
|
---|
202 | mv $(archdir)/VBoxSysInfo.sh $(prefix)/usr/share/$(package)
|
---|
203 | for i in VBoxManage VBoxSVC $(if $(HEADLESS),,VBoxSDL) \
|
---|
204 | $(if $(NOQT),,VirtualBox) VBoxHeadless \
|
---|
205 | $(if $(NOWEBSVC),,vboxwebsrv webtest); do \
|
---|
206 | mv $(archdir)/$$i $(prefix)/usr/lib/$(package); done
|
---|
207 | mv $(archdir)/VBoxTunctl $(prefix)/usr/bin
|
---|
208 | $(if $(NOMODS),,for d in $(moddir)/*; do \
|
---|
209 | if [ -f $$d/vboxdrv.ko -a -f $$d/vboxnetflt.ko -a -f $$d/vboxnetadp.ko ]; then \
|
---|
210 | install -D -g 0 -o 0 -m 0644 \
|
---|
211 | $$d/vboxdrv.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxdrv.ko; \
|
---|
212 | install -D -g 0 -o 0 -m 0644 \
|
---|
213 | $$d/vboxnetflt.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetflt.ko; \
|
---|
214 | install -D -g 0 -o 0 -m 0644 \
|
---|
215 | $$d/vboxnetadp.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetadp.ko; \
|
---|
216 | fi \
|
---|
217 | done)
|
---|
218 | ifeq ($(ose),)
|
---|
219 | $(if $(NOQT),,mv $(archdir)/kchmviewer $(prefix)/usr/lib/$(package))
|
---|
220 | dh_installdocs \
|
---|
221 | $(archdir)/UserManual*.pdf $(archdir)/VirtualBox*.chm \
|
---|
222 | $(addprefix $(archdir)/, $(if $(HEADLESS),,License-*.html) LICENSE)
|
---|
223 | rm $(addprefix $(archdir)/,UserManual*.pdf VirtualBox*.chm \
|
---|
224 | LICENSE $(if $(HEADLESS),,License-*.html))
|
---|
225 | for i in rdesktop-vrdp.tar.gz additions/VBoxGuestAdditions.iso; do \
|
---|
226 | mv $(archdir)/$$i $(prefix)/usr/share/$(package); done
|
---|
227 | rmdir $(archdir)/additions
|
---|
228 | if [ -d $(archdir)/accessible ]; then mv $(archdir)/accessible $(prefix)/usr/lib/virtualbox; fi
|
---|
229 | else
|
---|
230 | dh_installdocs
|
---|
231 | endif
|
---|
232 | rmdir $(archdir)
|
---|
233 | rmdir $(prefix)/opt
|
---|
234 | dh_link \
|
---|
235 | $(if $(NOQT),,usr/bin/VBox usr/bin/VirtualBox) \
|
---|
236 | usr/bin/VBox usr/bin/VBoxManage \
|
---|
237 | $(if $(HEADLESS),,usr/bin/VBox usr/bin/VBoxSDL) \
|
---|
238 | $(if $(ose),,usr/bin/VBox usr/bin/VBoxVRDP) \
|
---|
239 | usr/bin/VBox usr/bin/VBoxHeadless \
|
---|
240 | $(if $(NOWEBSVC),,usr/bin/VBox usr/bin/vboxwebsrv) \
|
---|
241 | usr/share/virtualbox/src/vboxdrv usr/src/vboxdrv-$(ver) \
|
---|
242 | usr/share/virtualbox/src/vboxnetflt usr/src/vboxnetflt-$(ver) \
|
---|
243 | usr/share/virtualbox/src/vboxnetadp usr/src/vboxnetadp-$(ver)
|
---|
244 | dh_desktop
|
---|
245 | dh_installmenu
|
---|
246 | $(if $(NOMODS),,dh_installmodules)
|
---|
247 | sed \
|
---|
248 | -e 's|%NOLSB%||g' \
|
---|
249 | -e 's|%DEBIAN%|yes|g' \
|
---|
250 | -e 's|%PACKAGE%|virtualbox|g' \
|
---|
251 | $(vboxroot)/src/VBox/Installer/linux/vboxdrv.sh.in > debian/vboxdrv.init
|
---|
252 | dh_installinit --name=vboxdrv --noscripts
|
---|
253 | sed \
|
---|
254 | -e 's|%NOLSB%||g' \
|
---|
255 | -e 's|%DEBIAN%|yes|g' \
|
---|
256 | -e 's|%PACKAGE%|virtualbox|g' \
|
---|
257 | $(vboxroot)/src/VBox/Installer/linux/vboxweb-service.sh.in > debian/vboxweb-service.init
|
---|
258 | dh_installinit --name=vboxweb-service --noscripts
|
---|
259 | cat debian/preinst.in | sed -e 's|%VER%|$(ver)|g' > debian/preinst
|
---|
260 | cat debian/postinst.in | sed -e 's|%VER%|$(ver)|g' > debian/postinst
|
---|
261 | dh_installdebconf
|
---|
262 | dh_installchangelogs
|
---|
263 | dh_link
|
---|
264 | ifeq ($(DEBUG),)
|
---|
265 | dh_strip --keep-debug --exclude=libQtCoreVBox.so.4 --exclude=libQtGuiVBox.so.4 --exclude=libQtNetworkVBox.so.4 --exclude=libQtOpenGLVBox.so.4 --exclude=libqtaccessiblewidgets.so
|
---|
266 | # manually strip our R0/GC modules, dh_strip cannot handle them
|
---|
267 | for f in \
|
---|
268 | $(prefix)/usr/lib/$(package)/*.r0 $(prefix)/usr/lib/$(package)/*.gc; do \
|
---|
269 | objcopy --only-keep-debug \
|
---|
270 | $$f \
|
---|
271 | $(prefix)/usr/lib/debug/usr/lib/$(package)/`basename $$f`; \
|
---|
272 | strip -S --remove-section=.comment $$f; \
|
---|
273 | objcopy --add-gnu-debuglink=$(prefix)/usr/lib/debug/usr/lib/$(package)/`basename $$f` $$f; \
|
---|
274 | done
|
---|
275 | endif
|
---|
276 | mkdir -p $(current)/debian/$(verpkg)-dbg/usr/lib
|
---|
277 | ifeq ($(DEBUG),)
|
---|
278 | mv $(current)/debian/$(verpkg)/usr/lib/debug $(current)/debian/$(verpkg)-dbg/usr/lib
|
---|
279 | endif
|
---|
280 | dh_pycentral
|
---|
281 | dh_compress -X.pdf -X.chm -X LICENSE -X.py
|
---|
282 | dh_fixperms
|
---|
283 | dh_makeshlibs
|
---|
284 | dh_installdeb
|
---|
285 | dh_perl
|
---|
286 | dh_shlibdeps
|
---|
287 | dh_gencontrol -- \
|
---|
288 | -Valsa=$(if $(HEADLESS),,libasound2) \
|
---|
289 | -Vpulse=$(if $(HEADLESS),,libpulse0) \
|
---|
290 | -Vsdlttf=$(if $(HEADLESS),,libsdl-ttf2.0-0) \
|
---|
291 | -Vdkms=$(if $(filter _Ubuntu_hardy _Ubuntu_intrepid _Ubuntu_jaunty _Ubuntu_karmic _Ubuntu_lucid,$(debrel)),dkms,)
|
---|
292 | dh_md5sums
|
---|
293 | dh_builddeb --destdir $(pkgdir)
|
---|
294 | endif
|
---|
295 |
|
---|
296 | .PHONY: binary modules binary-arch binary-indep clean checkroot
|
---|