1 | #!/usr/bin/make -f
|
---|
2 | # $Id: rules 84974 2020-06-26 15:38:55Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # VirtualBox rules.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2006-2020 Oracle Corporation
|
---|
9 | #
|
---|
10 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | # available from http://www.virtualbox.org. This file is free software;
|
---|
12 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | # General Public License (GPL) as published by the Free Software
|
---|
14 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | #
|
---|
18 |
|
---|
19 | # possible overrides:
|
---|
20 | # OSE=1 force VBOX_OSE
|
---|
21 | # NOPARALLEL=1 compile with -j1
|
---|
22 | # LINUX=<dir> compile vboxdrv against Linux found in <dir>
|
---|
23 | # VERBOSE=1 verbose build
|
---|
24 | # DEBUG=1 debug build
|
---|
25 | # NOSUBVER=1 disable generation of the sub-version field (which is
|
---|
26 | # either the subversion rev [if available] or the build date)
|
---|
27 | # NODOCS=1 don't build docs, use precompiled UserManual.pdf and
|
---|
28 | # maybe VirtualBox.chm from $(vboxroot)/prebuild
|
---|
29 | # NOMODS=1 don't build any module
|
---|
30 | # NOQT=1 don't build the Qt GUI
|
---|
31 | # NOSDL=1 don't build VBoxSDL
|
---|
32 | # EFI=1 include the EFI binary from prebuild
|
---|
33 | # VERSUFFIX=<suffix> set a particular package version suffix (e.g. _customer)
|
---|
34 | # HEADLESS=1 build the headless version
|
---|
35 | # VNC=1 build VNC code
|
---|
36 | # NOWEBSVC=1 don't build the webservice API, default for OSE
|
---|
37 | # STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
|
---|
38 | # STAGEDCHM=<path> use VirtualBox*.chm from this directory
|
---|
39 | # PKGDIR=<path> where to store the final package(s)
|
---|
40 | # svn_revision=xxx do not depend on subversion being available, but use this
|
---|
41 | # hard-coded revision number instead
|
---|
42 | #
|
---|
43 | # NODOCS will be set if UserManual*.pdf is placed in $(vboxroot)/prebuild.
|
---|
44 | # STAGEDISO will be set if VBoxGuestAdditions.iso is placed there.
|
---|
45 | # STAGEDCHM will be set if VirtualBox*.chm is placed there.
|
---|
46 | # VirtualBox*.chm is used if it is provided, but never attempted to be built.
|
---|
47 | #
|
---|
48 | # Wine will not be required if either NODOCS or STAGEDISO are set.
|
---|
49 |
|
---|
50 | ifeq ($(wildcard rpm/rules),)
|
---|
51 | $(error call rpm/rules from src/VBox/Installer/linux)
|
---|
52 | endif
|
---|
53 |
|
---|
54 | verpkg := VirtualBox-6.1
|
---|
55 | current := $(shell pwd)
|
---|
56 | vboxroot := $(shell while ! test -r configure && ! test "$PWD" = "/"; do cd ..; done; pwd)
|
---|
57 | pkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd $(vboxroot)/..; pwd))
|
---|
58 | bldbase := $(vboxroot)/out/rpm
|
---|
59 | builddir := $(bldbase)/builddir
|
---|
60 | stagedir := $(bldbase)/rpmbuild
|
---|
61 | rpmlib := $(shell if [ `uname -m` = "x86_64" ]; then echo "lib64"; else echo "lib"; fi)
|
---|
62 | chrarch := $(shell if [ `uname -m` = "x86_64" ]; then echo "amd64"; else echo "x86"; fi)
|
---|
63 | verfile := $(builddir)/version-generated.mk
|
---|
64 | ose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
|
---|
65 | -include $(vboxroot)/SVN_REVISION
|
---|
66 | svnrev :=$(if $(svn_revision),$(svn_revision),)
|
---|
67 |
|
---|
68 | NOMODS ?= $(ose)
|
---|
69 | NOQT ?= $(HEADLESS)
|
---|
70 | NOWEBSVC ?= $(ose)
|
---|
71 | NODOCS ?= $(if $(wildcard $(vboxroot)/prebuild/UserManual*.pdf),1,)
|
---|
72 | STAGEDISO ?= $(if $(wildcard $(vboxroot)/prebuild/VBoxGuestAdditions.iso),$(vboxroot)/prebuild,)
|
---|
73 | STAGEDCHM ?= $(if $(wildcard $(vboxroot)/prebuild/VirtualBox*.chm),$(vboxroot)/prebuild,)
|
---|
74 | NOWINE := $(if $(NODOCS),1,$(if $(STAGEDISO),1,$(ose)))
|
---|
75 |
|
---|
76 | ifneq ($(MAKECMDGOALS),clean)
|
---|
77 | # look for fedora
|
---|
78 | rpmrel := $(shell cat /etc/fedora-release 2> /dev/null | sed -e 's/^Fedora *release *\([1-9][0-9]*\) .*/fedora\1/')
|
---|
79 | ifeq ($(rpmrel),)
|
---|
80 | # look for OEL
|
---|
81 | rpmrel := $(shell cat /etc/enterprise-release 2> /dev/null | sed -ne 's/^Enterprise Linux[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
|
---|
82 | endif
|
---|
83 | ifeq ($(rpmrel),)
|
---|
84 | # look for OL
|
---|
85 | rpmrel := $(shell cat /etc/oracle-release 2> /dev/null | sed -ne 's/^Oracle Linux[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
|
---|
86 | endif
|
---|
87 | ifeq ($(rpmrel),)
|
---|
88 | # look for CentOS
|
---|
89 | rpmrel := $(shell cat /etc/redhat-release 2> /dev/null | sed -ne 's/^CentOS[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
|
---|
90 | endif
|
---|
91 | ifeq ($(rpmrel),)
|
---|
92 | # look for Red Hat
|
---|
93 | rpmrel := $(shell cat /etc/redhat-release 2> /dev/null | sed -ne 's/^Red Hat[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
|
---|
94 | endif
|
---|
95 | ifeq ($(rpmrel),)
|
---|
96 | # look for openSUSE
|
---|
97 | rpmrel := $(shell cat /etc/SUSE-brand 2> /dev/null | sed -ne 's/^VERSION *= *\([0-9]*\)\.\([0-9]*\)/openSUSE\1\2/p')
|
---|
98 | endif
|
---|
99 | # look for openSUSE Tumbleweed
|
---|
100 | ifeq ($(rpmrel),)
|
---|
101 | rpmrel := $(shell cat /etc/SUSE-brand 2> /dev/null | sed -ne 's/^VERSION *= *tumbleweed/openSUSETW/p')
|
---|
102 | endif
|
---|
103 | ifeq ($(rpmrel),)
|
---|
104 | $(error failed to detect the release type. Hack the detection.)
|
---|
105 | endif
|
---|
106 |
|
---|
107 | rpmdist := $(strip $(shell grep $(rpmrel) $(current)/distributions_rpm | cut -d'=' -f2))
|
---|
108 | ifeq ($(rpmdist),)
|
---|
109 | $(error Cannot detect package distribution (rpmrel=$(rpmrel)))
|
---|
110 | endif
|
---|
111 |
|
---|
112 | ifeq ($(filter-out el5 el6 el7 el8 fedora18 fedora19 fedora20 fedora21 fedora22 fedora24 fedora25 fedora26 fedora29 fedora31 fedora32,$(rpmrel)),)
|
---|
113 | rpmspec := rpm_redhat
|
---|
114 | endif
|
---|
115 | ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114 openSUSE123 openSUSE131 openSUSE132 openSUSE150 openSUSETW,$(rpmrel)),)
|
---|
116 | rpmspec := rpm_suse
|
---|
117 | endif
|
---|
118 | ifeq ($(rpmspec),)
|
---|
119 | $(error failed to detect the .spec file (rpmrel=$(rpmrel)))
|
---|
120 | endif
|
---|
121 |
|
---|
122 | # contrary to debian we need the verfile earlier to get the correct rpmname into the bld_flags
|
---|
123 | include $(verfile)
|
---|
124 | $(verfile): $(bldbase)/configure-stamp
|
---|
125 | . $(bldbase)/env.sh && kmk -C $(vboxroot) $(verfile) $(bld_flags)
|
---|
126 |
|
---|
127 | endif
|
---|
128 |
|
---|
129 | ver := $(VBOX_VERSION_STRING)
|
---|
130 | rpmver :=$(ver)$(if $(NOSUBVER),,$(if $(svn_revision),_$(svn_revision),)$(VERSUFFIX)$(if $(HEADLESS),_headless,)$(if $(DEBUG),_dbg,))
|
---|
131 | archdir := $(bldbase)/VirtualBox-$(ver)
|
---|
132 | rpmname := $(verpkg)-$(rpmver)_$(rpmrel)
|
---|
133 |
|
---|
134 | # never ship any modules
|
---|
135 | instmod :=
|
---|
136 |
|
---|
137 | ifneq ($(STAGEDISO),)
|
---|
138 | ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
|
---|
139 | $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
|
---|
140 | endif
|
---|
141 | endif
|
---|
142 |
|
---|
143 | ifeq ($(wildcard /usr/share/doc/packages/bash),)
|
---|
144 | doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\""
|
---|
145 | else
|
---|
146 | # Novell (OpenSUSE, SLES)
|
---|
147 | doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/packages/$(verpkg)\""
|
---|
148 | endif
|
---|
149 |
|
---|
150 | # EL5 ships Python 2.4 while our Python support requires Python 2.6 or later
|
---|
151 | cfg_flags := $(if $(NOQT),--disable-qt,) \
|
---|
152 | $(if $(NOSDL),--disable-vboxsdl,) \
|
---|
153 | $(if $(filter el5 el6,$(rpmrel)),--build-libvpx,) \
|
---|
154 | $(if $(filter el5 el6,$(rpmrel)),--build-libopus,) \
|
---|
155 | $(if $(filter el5 el6,$(rpmrel)),--build-libssl,) \
|
---|
156 | $(if $(filter el5,$(rpmrel)),--build-libcurl,) \
|
---|
157 | $(if $(filter el5,$(rpmrel)),--disable-sdl-ttf,) \
|
---|
158 | $(if $(filter el5,$(rpmrel)),--disable-pulse,) \
|
---|
159 | $(if $(filter el5,$(rpmrel)),--disable-python,) \
|
---|
160 | $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
|
---|
161 | $(if $(HEADLESS),--build-headless,) \
|
---|
162 | $(if $(DEBUG),--build-debug,) \
|
---|
163 | $(if $(NOWINE),,--setup-wine) \
|
---|
164 | $(if $(NOWEBSVC),,$(if $(ose),--enable-webservice,)) \
|
---|
165 | $(if $(VNC),--enable-vnc,) \
|
---|
166 | --disable-extpack
|
---|
167 |
|
---|
168 | bld_flags := AUTOCFG=$(bldbase)/AutoConfig.kmk \
|
---|
169 | LOCALCFG=$(current)/rpm/LocalConfig.kmk \
|
---|
170 | PATH_OUT=$(builddir) \
|
---|
171 | VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
|
---|
172 | VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
|
---|
173 | $(if $(filter el5 el6,$(rpmrel)),,VBOX_WITH_VMSVGA3D=1) \
|
---|
174 | VBOX_DO_STRIP= \
|
---|
175 | $(if $(filter el5,$(rpmrel)),VBOX_BLD_PYTHON=$(strip \
|
---|
176 | $(firstword $(wildcard /usr/local/bin/python2.7) $(wildcard /usr/bin/python2.7) \
|
---|
177 | $(wildcard /usr/bin/python2.6) $(wildcard /usr/bin/python2) $(wildcard /usr/bin/python))),) \
|
---|
178 | $(doc_dir) \
|
---|
179 | $(if $(STAGEDCHM),VBOX_WITH_DOCS_CHM=1,VBOX_WITH_KCHMVIEWER=) \
|
---|
180 | VBOX_PACKAGE_DIST=$(rpmdist) \
|
---|
181 | $(if $(svnrev),VBOX_SVN_REV=$(svnrev),) \
|
---|
182 | $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
|
---|
183 | $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
|
---|
184 | $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
|
---|
185 | $(if $(filter el5,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
|
---|
186 |
|
---|
187 | $(bldbase)/configure-stamp:
|
---|
188 | mkdir -p $(bldbase)
|
---|
189 | cd $(vboxroot) && ./configure --odir=$(bldbase) $(cfg_flags)
|
---|
190 | touch $@
|
---|
191 |
|
---|
192 | $(bldbase)/build-stamp: $(bldbase)/configure-stamp
|
---|
193 | . $(bldbase)/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
|
---|
194 | $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
|
---|
195 | $(if $(STAGEDCHM),cp $(STAGEDCHM)/VirtualBox*.chm $(builddir)/bin,)
|
---|
196 | $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
|
---|
197 | $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
|
---|
198 | mkdir -p $(builddir)/bin/additions
|
---|
199 | $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
|
---|
200 | . $(bldbase)/env.sh && kmk -C $(vboxroot) $(bld_flags) \
|
---|
201 | VBOX_NO_LINUX_RUN_INSTALLER=1 \
|
---|
202 | VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86.tar.bz2 \
|
---|
203 | VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.tar.bz2 \
|
---|
204 | VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
|
---|
205 | VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
|
---|
206 | packing
|
---|
207 | touch $@
|
---|
208 |
|
---|
209 | clean:
|
---|
210 | rm -rf $(archdir)
|
---|
211 | rm -rf $(stagedir)
|
---|
212 | rm -rf $(builddir)
|
---|
213 | rm -rf $(bldbase)/VirtualBox-*
|
---|
214 | rm -f $(bldbase)/VirtualBox.tar $(bldbase)/VirtualBox.tar.bz2
|
---|
215 | rm -f $(bldbase)/VirtualBox.spec
|
---|
216 | rm -f $(bldbase)/build-stamp $(bldbase)/configure-stamp $(bldbase)/configure.log
|
---|
217 | rm -f $(bldbase)/AutoConfig.kmk $(bldbase)/env.sh
|
---|
218 | if [ -d $(bldbase) ]; then rmdir $(bldbase); fi
|
---|
219 |
|
---|
220 | ifeq ($(VBOX_VERSION_MAJOR),)
|
---|
221 | binary: $(bldbase)/build-stamp $(verfile)
|
---|
222 | $(MAKE) -f rpm/rules binary
|
---|
223 | else
|
---|
224 | binary: $(bldbase)/build-stamp
|
---|
225 | rm -rf $(bldbase)/VirtualBox-*
|
---|
226 | tar -xf $(builddir)/bin/VirtualBox.tar -C $(bldbase)
|
---|
227 | sed \
|
---|
228 | -e 's|%VER%|$(ver)|g' \
|
---|
229 | -e 's|%NAME%|$(verpkg)|g' \
|
---|
230 | -e 's|%BUILDVER%|$(rpmver)|g' \
|
---|
231 | -e 's|%BUILDREL%|$(rpmrel)|g' \
|
---|
232 | -e 's|%BUILDROOT%|$(bldbase)/buildroot|g' \
|
---|
233 | -e 's|%OSE%|$(if $(ose),is_ose,not_ose)|g' \
|
---|
234 | -e 's|%SPEC%|$(rpmspec)|g' \
|
---|
235 | -e 's|%CHM%|$(if $(STAGEDCHM),with_chm,without_chm)|g' \
|
---|
236 | -e 's|%PYTHON%|$(if $(filter el5,$(rpmrel)),without_python,with_python)|g' \
|
---|
237 | -e 's|%MACROSPYTHON%|$(if $(wildcard /usr/lib/rpm/macros.d/macros.python3),,$(if $(wildcard /usr/lib/rpm/macros.python),%include /usr/lib/rpm/macros.python,))|g' \
|
---|
238 | -e 's|%INSTMOD%|$(instmod)|g' \
|
---|
239 | -e 's|%LIBASOUND%|$(if $(filter lib64,$(rpmlib)),libasound.so.2()(64bit),libasound.so.2)|g' \
|
---|
240 | -e 's|%INITSCRIPTS%|$(if $(filter fedora,$(rpmspec)),initscripts,)|g' \
|
---|
241 | -e 's|%NETTOOLS%|$(if $(filter fedora18 fedora19 fedora20 fedora21 el5 openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114,$(rpmrel)),net-tools,iproute)|g' \
|
---|
242 | $(current)/rpm/VirtualBox.tmpl.spec > $(archdir)/VirtualBox.spec
|
---|
243 | mv $(bldbase)/VirtualBox-$(ver) $(bldbase)/$(rpmname)
|
---|
244 | cp ../../../../tools/linux.$(chrarch)/bin/chrpath $(bldbase)/$(rpmname) || true
|
---|
245 | tar -cf $(bldbase)/VirtualBox.tar -C $(bldbase) $(rpmname)
|
---|
246 | rm -f $(stagedir)/RPMS/*/VirtualBox*rpm
|
---|
247 | rm -f $(stagedir)/SPECS/*
|
---|
248 | mkdir -p $(stagedir)/BUILD $(stagedir)/RPMS/i386 $(stagedir)/RPMS/x86_64 $(stagedir)/SOURCES $(stagedir)/SPECS $(stagedir)/SRPMS
|
---|
249 | (cd $(bldbase); rpmbuild --define '_topdir $(stagedir)' -tb --clean VirtualBox.tar)
|
---|
250 | mv $(stagedir)/RPMS/*/$(verpkg)-debug* $(pkgdir) || true
|
---|
251 | file=`find $(stagedir)/RPMS -name $(verpkg)*rpm -print`; \
|
---|
252 | mv $$file $(pkgdir)
|
---|
253 | # Note! if rpmbuild fails: sudo chmod a+rw /usr/src/redhat/* /usr/src/redhat/RPMS/*
|
---|
254 | # Note! if find/mv fails: sudo ln -s redhat/ /usr/src/packages
|
---|
255 | endif
|
---|
256 |
|
---|
257 | .PHONY: binary clean
|
---|