1 | #!/usr/bin/make -f
|
---|
2 | #
|
---|
3 | # Copyright (C) 2006-2012 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 (GPL) as published by the Free Software
|
---|
9 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
10 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
11 | # hope that it will 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 | # EFI=1 include the EFI binary from prebuild
|
---|
30 | # HEADLESS=1 build the headless version
|
---|
31 | # VNC=1 build VNC code
|
---|
32 | # NOWEBSVC=1 don't build the webservice API, default for OSE
|
---|
33 | # STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
|
---|
34 | # PKGDIR=<path> where to store the final package(s)
|
---|
35 | # BLEEDING_EDGE=xyz
|
---|
36 |
|
---|
37 | package := virtualbox
|
---|
38 | verpkg := virtualbox-ose
|
---|
39 | current := $(shell pwd)
|
---|
40 | vboxroot := $(shell pwd)
|
---|
41 | pkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd ..; pwd))
|
---|
42 | builddir := $(vboxroot)/out/debian/builddir
|
---|
43 | moddir := $(vboxroot)/out/debian/modules
|
---|
44 | prefix := $(current)/debian/$(verpkg)
|
---|
45 | arch := $(shell dpkg --print-architecture)
|
---|
46 | verfile := $(builddir)/version-generated.mk
|
---|
47 | ose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
|
---|
48 | NOMODS ?= $(ose)
|
---|
49 | NOQT ?= $(HEADLESS)
|
---|
50 | NOWEBSVC ?= $(ose)
|
---|
51 | NOWINE := $(if $(NODOCS),$(if $(STAGEDISO),1,),)$(ose)
|
---|
52 |
|
---|
53 | ifneq ($(wildcard $(verfile)),)
|
---|
54 | include $(verfile)
|
---|
55 | ver := $(VBOX_VERSION_STRING)
|
---|
56 | archdir := $(prefix)/opt/VirtualBox-$(ver)
|
---|
57 | endif
|
---|
58 |
|
---|
59 | ifneq ($(STAGEDISO),)
|
---|
60 | ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
|
---|
61 | $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
|
---|
62 | endif
|
---|
63 | endif
|
---|
64 |
|
---|
65 | debrel := $(if $(shell which lsb_release),_$(shell lsb_release -si)_$(shell lsb_release -sc),unknown)
|
---|
66 |
|
---|
67 | # shipping Linux kernel modules with bleeding-edge releases doesn't make sense
|
---|
68 | instmod := $(if $(filter _Ubuntu_lucid _Ubuntu_maverick _Ubuntu_natty _Ubuntu_oneiric _Debian_sid,$(debrel)),,1)
|
---|
69 |
|
---|
70 | # Location of custom built Qt libraries (see below)
|
---|
71 | qtstdc6 := /home/vbox/Qt-4.8.6-stdc++6-$(arch)
|
---|
72 |
|
---|
73 | cfg_flags := $(if $(NOQT),--disable-qt,) \
|
---|
74 | $(if $(filter _Debian_squeeze,$(debrel)),--with-qt-dir=$(qtstdc6)) \
|
---|
75 | $(if $(filter _Debian_squeeze,$(debrel)),--build-libvpx,) \
|
---|
76 | $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
|
---|
77 | $(if $(HEADLESS),--build-headless,) \
|
---|
78 | $(if $(DEBUG),--build-debug,) \
|
---|
79 | $(if $(NOWINE),,--setup-wine) \
|
---|
80 | $(if $(NOWEBSVC),,$(if $(ose),--enable-webservice,)) \
|
---|
81 | $(if $(VNC),--enable-vnc,) \
|
---|
82 | --disable-extpack
|
---|
83 |
|
---|
84 | bld_flags := AUTOCFG=$(current)/debian/AutoConfig.kmk \
|
---|
85 | LOCALCFG=$(current)/debian/LocalConfig.kmk \
|
---|
86 | PATH_OUT=$(builddir) \
|
---|
87 | VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
|
---|
88 | VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
|
---|
89 | $(if $(filter _Debian_squeeze _Ubuntu_lucid,$(debrel)),,VBOX_WITH_VMSVGA3D=1) \
|
---|
90 | VBOX_DO_STRIP= \
|
---|
91 | VBOX_WITH_MULTIVERSION_PYTHON= \
|
---|
92 | VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\"" \
|
---|
93 | $(if $(ose),,VBOX_WITH_DOCS_CHM=1) \
|
---|
94 | $(if $(svnrev),VBOX_SVN_REV=$(svnrev),) \
|
---|
95 | $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
|
---|
96 | $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
|
---|
97 | $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
|
---|
98 | $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),)
|
---|
99 |
|
---|
100 | configure: debian/configure-stamp
|
---|
101 | debian/configure-stamp:
|
---|
102 | dh_testdir
|
---|
103 | cd $(vboxroot) && ./configure --odir=$(current)/debian $(cfg_flags)
|
---|
104 | touch debian/configure-stamp
|
---|
105 |
|
---|
106 | build: debian/configure-stamp debian/build-stamp
|
---|
107 | debian/build-stamp $(verfile):
|
---|
108 | dh_testdir
|
---|
109 | . debian/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
|
---|
110 | $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
|
---|
111 | $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
|
---|
112 | $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
|
---|
113 | $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
|
---|
114 | mkdir -p $(builddir)/bin/additions
|
---|
115 | $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
|
---|
116 | . debian/env.sh && kmk -C $(vboxroot) $(bld_flags) \
|
---|
117 | VBOX_NO_LINUX_RUN_INSTALLER=1 \
|
---|
118 | VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86.tar.bz2 \
|
---|
119 | VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.tar.bz2 \
|
---|
120 | VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
|
---|
121 | VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
|
---|
122 | packing
|
---|
123 | touch debian/build-stamp
|
---|
124 |
|
---|
125 | # Build modules for every kernel we find in /lib/modules/*
|
---|
126 | modules: debian/build-stamp debian/modules-stamp
|
---|
127 | debian/modules-stamp: debian/build-stamp
|
---|
128 | rm -rf $(moddir)
|
---|
129 | mkdir $(moddir)
|
---|
130 | make -C $(builddir)/bin/src/vboxdrv clean
|
---|
131 | for d in $(wildcard /lib/modules/*); do \
|
---|
132 | if [ -L $$d/build ]; then \
|
---|
133 | make -C $(builddir)/bin/src/vboxdrv KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
134 | make -j4 -C $(builddir)/bin/src/vboxdrv KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
135 | $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
|
---|
136 | $(builddir)/bin/src/vboxdrv/vboxdrv.ko $(moddir)/$$(basename $$d)/vboxdrv.ko); \
|
---|
137 | make -C $(builddir)/bin/src/vboxnetflt KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
138 | (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetflt || true) && \
|
---|
139 | make -j4 -C $(builddir)/bin/src/vboxnetflt KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
140 | $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
|
---|
141 | $(builddir)/bin/src/vboxnetflt/vboxnetflt.ko $(moddir)/$$(basename $$d)/vboxnetflt.ko); \
|
---|
142 | make -C $(builddir)/bin/src/vboxnetadp KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
143 | (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetadp || true) && \
|
---|
144 | make -j4 -C $(builddir)/bin/src/vboxnetadp KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
145 | $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
|
---|
146 | $(builddir)/bin/src/vboxnetadp/vboxnetadp.ko $(moddir)/$$(basename $$d)/vboxnetadp.ko); \
|
---|
147 | make -C $(builddir)/bin/src/vboxpci KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
|
---|
148 | (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxpci || true) && \
|
---|
149 | make -j4 -C $(builddir)/bin/src/vboxpci KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
|
---|
150 | $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
|
---|
151 | $(builddir)/bin/src/vboxpci/vboxpci.ko $(moddir)/$$(basename $$d)/vboxpci.ko); \
|
---|
152 | fi; \
|
---|
153 | done
|
---|
154 | make -C $(builddir)/bin/src/vboxdrv clean
|
---|
155 | make -C $(builddir)/bin/src/vboxnetflt clean
|
---|
156 | make -C $(builddir)/bin/src/vboxnetadp clean
|
---|
157 | make -C $(builddir)/bin/src/vboxpci clean
|
---|
158 | touch debian/modules-stamp
|
---|
159 |
|
---|
160 | clean:
|
---|
161 | dh_testdir
|
---|
162 | dh_testroot
|
---|
163 | rm -f debian/preinst debian/postinst debian/prerm
|
---|
164 | rm -f debian/$(package).init debian/vboxdrv.init
|
---|
165 | rm -f debian/vboxballoonctrl-service.init debian/vboxautostart-service.init debian/vboxweb-service.init
|
---|
166 | rm -f debian/AutoConfig.kmk debian/configure.log debian/env.sh
|
---|
167 | rm -f debian/modules-stamp debian/build-stamp debian/configure-stamp
|
---|
168 | rm -f debian/virtualbox-*.substvars debian/virtualbox*.debhelper
|
---|
169 | rm -f debian/$(verpkg).mime
|
---|
170 | rm -rf $(builddir) $(moddir)
|
---|
171 | rm -rf debian/wine.*
|
---|
172 | dh_clean
|
---|
173 |
|
---|
174 | ifeq ($(VBOX_VERSION_MAJOR),)
|
---|
175 | binary binary-arch binary-indep: build $(verfile)
|
---|
176 | $(MAKE) -f debian/rules binary
|
---|
177 | else
|
---|
178 | # Build architecture-dependent files here.
|
---|
179 | binary binary-arch binary-indep: build $(if $(NOMODS),,modules)
|
---|
180 | dh_testdir
|
---|
181 | dh_testroot
|
---|
182 | dh_clean -k
|
---|
183 | dh_installdirs
|
---|
184 | tar -xC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar
|
---|
185 | $(if $(NOQT),,mv $(archdir)/virtualbox.xml debian/$(verpkg).sharedmimeinfo)
|
---|
186 | $(archdir)/scripts/install.sh --package $(package) --root $(prefix) \
|
---|
187 | --prefix /usr $(if $(NOQT),--no-qt) $(if $(ose),--ose) \
|
---|
188 | $(if $(HEADLESS),--headless) $(if $(NOWEBSVC),--no-web-service) \
|
---|
189 | --install-folder /lib/$(package) --no-helpers
|
---|
190 | install -d -g 0 -o 0 $(prefix)/usr/share/doc/$(verpkg)
|
---|
191 | install -d -g 0 -o 0 $(prefix)/usr/share/lintian/overrides
|
---|
192 | sed \
|
---|
193 | -e 's|%VERPKG%|$(verpkg)|g' \
|
---|
194 | debian/lintian-override.in > \
|
---|
195 | $(prefix)/usr/share/lintian/overrides/$(verpkg)
|
---|
196 | $(if $(NOMODS),,for d in $(moddir)/*; do \
|
---|
197 | if [ -f $$d/vboxdrv.ko -a -f $$d/vboxnetflt.ko -a -f $$d/vboxnetadp.ko -a -f $$d/vboxpci.ko ]; then \
|
---|
198 | install -D -g 0 -o 0 -m 0644 \
|
---|
199 | $$d/vboxdrv.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxdrv.ko; \
|
---|
200 | install -D -g 0 -o 0 -m 0644 \
|
---|
201 | $$d/vboxnetflt.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetflt.ko; \
|
---|
202 | install -D -g 0 -o 0 -m 0644 \
|
---|
203 | $$d/vboxnetadp.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetadp.ko; \
|
---|
204 | install -D -g 0 -o 0 -m 0644 \
|
---|
205 | $$d/vboxpci.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxpci.ko; \
|
---|
206 | fi \
|
---|
207 | done)
|
---|
208 | ifeq ($(ose),)
|
---|
209 | dh_installdocs \
|
---|
210 | $(archdir)/UserManual*.pdf $(archdir)/VirtualBox*.chm \
|
---|
211 | $(addprefix $(archdir)/, LICENSE)
|
---|
212 | rm $(addprefix $(archdir)/,UserManual*.pdf VirtualBox*.chm \
|
---|
213 | LICENSE)
|
---|
214 | else
|
---|
215 | dh_installdocs \
|
---|
216 | $(archdir)/UserManual*.pdf
|
---|
217 | rm $(addprefix $(archdir)/,UserManual*.pdf)
|
---|
218 | endif
|
---|
219 | mv $(archdir) $(prefix)/usr/lib/$(package)
|
---|
220 | ln -s ../VBoxVMM.so $(prefix)/usr/lib/$(package)/components/VBoxVMM.so
|
---|
221 | rmdir $(prefix)/opt
|
---|
222 | dh_desktop
|
---|
223 | $(if $(NOMODS),,dh_installmodules)
|
---|
224 | sed \
|
---|
225 | -e 's|%NOLSB%||g' \
|
---|
226 | -e 's|%DEBIAN%|yes|g' \
|
---|
227 | -e 's|%PACKAGE%|virtualbox|g' \
|
---|
228 | -e "s|%VERSION%|$(VBOX_VERSION_STRING)|g" \
|
---|
229 | -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
|
---|
230 | $(vboxroot)/src/VBox/Installer/linux/vboxdrv.sh.in > debian/vboxdrv.init
|
---|
231 | dh_installinit --name=vboxdrv --noscripts
|
---|
232 | cp $(vboxroot)/src/VBox/Installer/linux/vboxballoonctrl-service.sh debian/vboxballoonctrl-service.init
|
---|
233 | dh_installinit --name=vboxballoonctrl-service --noscripts
|
---|
234 | cp $(vboxroot)/src/VBox/Installer/linux/vboxautostart-service.sh debian/vboxautostart-service.init
|
---|
235 | dh_installinit --name=vboxautostart-service --noscripts
|
---|
236 | cp $(vboxroot)/src/VBox/Installer/linux/vboxweb-service.sh debian/vboxweb-service.init
|
---|
237 | dh_installinit --name=vboxweb-service --noscripts
|
---|
238 | sed -e 's|%VER%|$(ver)|g' \
|
---|
239 | debian/preinst.in > debian/preinst
|
---|
240 | sed -e 's|%VER%|$(ver)|g' \
|
---|
241 | debian/prerm.in > debian/prerm
|
---|
242 | sed -e 's|%VER%|$(ver)|g' \
|
---|
243 | -e '/#include installer-common.sh/ {' \
|
---|
244 | -e "r $(vboxroot)/src/VBox/Installer/linux/installer-common.sh" \
|
---|
245 | -e 'd' \
|
---|
246 | -e '}' \
|
---|
247 | debian/postinst.in > debian/postinst
|
---|
248 | dh_installdebconf
|
---|
249 | dh_installchangelogs
|
---|
250 | dh_installmenu
|
---|
251 | dh_installmime
|
---|
252 | dh_link
|
---|
253 | ifeq ($(DEBUG),)
|
---|
254 | dh_strip --keep-debug --exclude=libQtCoreVBox.so.4 --exclude=libQtGuiVBox.so.4 --exclude=libQtNetworkVBox.so.4 --exclude=libQtOpenGLVBox.so.4 --exclude=libqtaccessiblewidgets.so
|
---|
255 | endif
|
---|
256 | mkdir -p $(current)/debian/$(verpkg)-dbg/usr/lib
|
---|
257 | ifeq ($(DEBUG),)
|
---|
258 | mv $(current)/debian/$(verpkg)/usr/lib/debug $(current)/debian/$(verpkg)-dbg/usr/lib
|
---|
259 | endif
|
---|
260 | $(if $(filter _Ubuntu_hardy _Ubuntu_lucid,$(debrel)),dh_pycentral,dh_python2)
|
---|
261 | dh_compress -X.pdf -X.chm -X LICENSE -X.py
|
---|
262 | dh_fixperms
|
---|
263 | dh_makeshlibs
|
---|
264 | dh_installdeb
|
---|
265 | dh_perl
|
---|
266 | LD_LIBRARY_PATH=$(prefix)/usr/lib/virtualbox dh_shlibdeps
|
---|
267 | dh_gencontrol -- \
|
---|
268 | -Valsa=$(if $(HEADLESS),,libasound2) \
|
---|
269 | -Vpulse=$(if $(HEADLESS),,libpulse0) \
|
---|
270 | -Vsdlttf=$(if $(HEADLESS),,libsdl-ttf2.0-0) \
|
---|
271 | -Vdkms=$(if $(filter _Debian_lenny,$(debrel)),,dkms)
|
---|
272 | dh_md5sums
|
---|
273 | dh_builddeb --destdir $(pkgdir) -- -Zxz
|
---|
274 | endif
|
---|
275 |
|
---|
276 | .PHONY: binary modules binary-arch binary-indep clean checkroot
|
---|