1
2Compiling Xen from source
3
4* Overview
5* Options recognized by configure
6* Variables recognized by make
7* Systemd support
8* History of options
9* Examples
10
11Overview
12========
13
14The xen source contains four subsystems: xen, tools, stubdom and docs.
15All but xen have to be prepared for build with a configure script in the
16toplevel directory. configure recognizes certain arguments and
17environment variables which are used to adjust various aspects of the
18following compile process. Once configure is done, make(1) has to be
19called. Also make(1) recognizes certain arguments. The following sections
20will give an overview.
21
22Options recognized by configure
23===============================
24
25The configure script in the toplevel directory will recognize these
26options. It will pass them to the configure scripts in the tools,
27stubdom, and docs directory.
28
29Individual subsystems can be selected by one of the following options.
30Please note that stubdom requires tools.
31  --disable-xen
32  --disable-tools
33  --enable-stubdom
34  --disable-docs
35
36The well known GNU configure options to specify the target directories.
37Some components of these paths will be compiled into the binaries.
38Note: prefix defaults to /usr/local, sysconfdir defaults to /etc,
39localstatedir defaults to /var.
40  --prefix=DIR
41  --libdir=DIR
42  --libexecdir=BASEDIR
43  --bindir=DIR
44  --sbindir=DIR
45  --sysconfdir=DIR
46  --sharedstatedir=DIR
47  --localstatedir=DIR
48  --includedir=DIR
49  --datarootdir=DIR
50  --datadir=DIR
51  --mandir=DIR
52  --docdir=DIR
53
54To automatically run the toolstack in dom0 during system startup some
55sysv runlevel scripts are installed. This option allows to set the path
56for a given system. Possible values are /etc/init.d, /etc/rc.d/init.d or
57/etc/rc.d. If not specified configure tries to guess the path.
58  --with-initddir=DIR
59
60The runlevel scripts load certain configuration files. They are
61typically located in a subdirectory of /etc. Possible values are this
62subdirectory are "sysconfig" or "default". If not specified configure
63tries to guess the subdir.
64  --with-sysconfig-leaf-dir=SUBDIR
65
66If the tools are configured with a non-standard --prefix the runtime
67linker will either not find the required libraries or it will load them
68from a wrong location. Compiling the tools with rpath will force the
69linker to look in the correct location.
70  --enable-rpath
71
72During build in a git checkout the buildsystem needs to download
73additional tools such as qemu. This is done with either the native git
74protocol, or via http if this option is enabled.
75  --enable-githttp
76
77Disable xenstat and xentop monitoring tools.
78  --disable-monitors
79
80Disable build of certain ocaml libraries and tools. To actually build
81them ocaml development packages must be installed. If they are missing
82configure will automatically disable this option.
83  --disable-ocamltools
84
85Disable XSM policy compilation.
86  --disable-xsmpolicy
87
88Attempt to build of an OVMF firmware binary. This requires special
89versions of development tools. Use at your own risk.
90  --enable-ovmf
91
92Use the given OVMF binary instead of compiling a private copy.
93  --with-system-ovmf=PATH
94
95Build a private copy of SeaBIOS.
96  --disable-seabios
97
98Use the given SeaBIOS binary instead of compiling a private copy.
99  --with-system-seabios=PATH
100
101Build the old qemu used by xm/xend. This is required if existing domUs
102should be migrated to this host, or if existing domU snapshots should be
103started with this version of the tools. Only if all domUs used the new
104upstream qemu during initial start it is safe to disable this option.
105The old qemu requires rombios, which can be disable along with
106qemu-traditional.
107  --enable-qemu-traditional
108  --enable-rombios
109
110The libxl toolstack uses the upstream qemu per default. A private copy
111will be built. If desired this private copy can be configured with
112additional options passed to its configure script.
113  --with-extra-qemuu-configure-args="arg1 arg2"
114
115Use the given qemu binary instead of compiling a private copy.
116  --with-system-qemu=PATH
117
118A dom0 requires a set of backend drivers. The configure script already
119supplies a list of known drivers which are automatically loaded in dom0.
120This internal list can be changed with this option.
121  --with-linux-backend-modules="kmod1 kmod2"
122
123Two variants of a xenstored exist: the original xenstored written in C
124(xenstored) or the newer and robust one written in Ocaml (oxenstored).
125The oxenstored daemon is the default but can only be used if the
126required ocaml packages are installed. In case they are missing the
127original xenstored will be used. Valid names are xenstored and
128oxenstored.
129  --with-xenstored=name
130
131The path where to store core dumps for domUs which are configured with
132coredump-destroy or coredump-restart can be specified with this option.
133  --with-xen-dumpdir=DIR
134
135Instead of starting the tools in dom0 with sysv runlevel scripts they
136can also be started by systemd. If this option is enabled xenstored will
137receive the communication socked directly from systemd. So starting it
138manually will not work anymore. The paths to systemd internals can also
139be changed in case the default paths do not fit anymore.
140NOTE: if systemd development packages are installed the systemd support
141will be the enabled per default. Using --disable-systemd will override
142this detection and the sysv runlevel scripts have to be used.
143  --enable-systemd
144  --with-systemd=DIR
145  --with-systemd-modules-load=DIR
146
147The old backend drivers are disabled because qdisk is now the default.
148This option can be used to build them anyway.
149  --enable-blktap2
150
151Build various stubom components, some are only example code. Its usually
152enough to specify just --enable-stubdom and leave these options alone.
153  --enable-ioemu-stubdom
154  --enable-c-stubdom
155  --enable-caml-stubdom
156  --disable-pv-grub
157  --disable-xenstore-stubdom
158  --enable-vtpm-stubdom
159  --enable-vtpmmgr-stubdom
160  --disable-extfiles
161
162Per default some parts of the tools code will print additional runtime
163debug. This option can be used to disable such code paths.
164  --disable-debug
165
166The configure script recognizes also many environment variables. Calling
167the individual configure scripts in the subdirectories with the "--help"
168option will list these environment variables.
169
170Variables recognized by make
171==========================
172
173The following variables are recognized by the build system. They have to
174be passed as make options, like 'make variable=value'. Having these
175variables in the environment, like 'env variable=value make', will not
176work for most of them.
177
178In addition to pass variables as make options it is also supported to
179create a ".config" file in the toplevel directory. The file will be
180sourced by make(1).
181
182The well known variable to specify an offset during make install,
183useful for packaging.
184DESTDIR=
185
186Per default some parts of the tools code will print additional runtime
187debug. This option can be used to disable such code paths.
188debug=y
189debug_symbols=y
190
191If --prefix= was used during configure the and ocaml was enabled the
192resulting libraries will not be installed in the specified path. Instead
193the path provided by ocamlfind(1) will be used. This variable can be
194used to override this path. Using the environment variable
195OCAMLFIND_DESTDIR= and OCAMLFIND_METADIR= will have the same effect.
196OCAMLDESTDIR=
197
198The xen subsystem will install the hypervisor into fixed locations.
199BOOT_DIR defaults to /boot, DEBUG_DIR defaults to /usr/lib/debug and
200EFI_DIR to /usr/lib64/efi.
201BOOT_DIR=
202DEBUG_DIR=
203EFI_DIR=
204
205The make target 'rpmball' will build a xen.rpm. This variable can be
206used to append a custom string to the name. In addition a string can be
207appended to the rpm Release: tag.
208PKG_SUFFIX=
209PKG_RELEASE=
210
211The hypervisor will report a certain version string. This variable can
212be used to append a custom string to the version.
213XEN_VENDORVERSION=
214
215During boot xen will report a certain user@host string, which can be
216changed with these variables.
217XEN_WHOAMI=
218XEN_DOMAIN=
219
220Some components of xen and tools will include an unpredictable timestamp
221into the binaries. To allow reproducible builds the following variables
222can be used to provide fixed timestamps in the expected format.
223XEN_BUILD_DATE=<output of date(1)>
224XEN_BUILD_TIME=hh:mm:ss
225SMBIOS_REL_DATE=mm/dd/yyyy
226VGABIOS_REL_DATE="dd Mon yyyy"
227
228During tools build external repos will be cloned into the source tree.
229This variable can be used to point to a different git binary to be used.
230GIT=
231
232During tools build external repos will be cloned into the source tree.
233During stubdom build external packages will be downloaded into the
234source tree. These variables can be used to point to a different
235locations.
236XEN_EXTFILES_URL=
237OVMF_UPSTREAM_URL=
238QEMU_UPSTREAM_URL=
239QEMU_TRADITIONAL_URL=
240SEABIOS_UPSTREAM_URL=
241MINIOS_UPSTREAM_URL=
242
243Using additional CFLAGS to build tools which will run in dom0 is
244required when building distro packages. These variables can be used to
245pass RPM_OPT_FLAGS.
246EXTRA_CFLAGS_XEN_TOOLS=
247EXTRA_CFLAGS_QEMU_TRADITIONAL=
248EXTRA_CFLAGS_QEMU_XEN=
249
250This variable can be used to use DIR/include and DIR/lib during build.
251This is the same as PREPEND_LIB and PREPEND_INCLUDES. APPEND_LIB and
252APPEND_INCLUDES= will be appended to the CFLAGS/LDFLAGS variable.
253EXTRA_PREFIX=DIR
254PREPEND_LIB=DIR
255PREPEND_INCLUDES=DIR
256APPEND_LIB=DIR
257APPEND_INCLUDES=DIR
258
259While the tools build will set the path to the python binary with the
260configure script, the hypervisor build has to use this variable to use a
261different python binary.
262PYTHON=
263
264Building the python tools may fail unless certain options are passed to
265setup.py. Config.mk contains additional info how to use this variable.
266PYTHON_PREFIX_ARG=
267
268The hypervisor may be built with XSM/Flask support, which can be changed
269by running:
270make -C xen menuconfig
271and enabling XSM/Flask in the 'Common Features' menu.  A security policy
272is required to use XSM/Flask; if the SELinux policy compiler is
273available, the policy from tools can be included in the hypervisor.
274This option is enabled by default if XSM is enabled and the compiler
275(checkpolicy) is found.  The location of this executable can be set
276using the environment variable.
277CHECKPOLICY=
278
279Use clang instead of GCC.
280clang=y
281
282
283Systemd support
284===============
285
286If the systemd development packages are available then the support for
287systemd will be enabled per default. It is required to manually enable
288the installed systemd service files. Systemd has dependency tracking,
289which means all dependencies will be started automatically:
290
291systemctl enable xen-qemu-dom0-disk-backend.service
292systemctl enable xen-init-dom0.service
293systemctl enable xenconsoled.service
294
295Other optional services are:
296systemctl enable xendomains.service
297systemctl enable xen-watchdog.service
298
299
300QEMU Deprivilege
301================
302It is recommended to run QEMU as non-root.
303See docs/misc/qemu-deprivilege.txt for an explanation on what you need
304to do at installation time to run QEMU as a dedicated user.
305
306
307History of options
308==================
309
310Prior to xen-4.5 configure recognized essentially only the --prefix= and
311--libdir= option to specify target directories. Starting with xen-4.5
312all paths can be adjusted once with configure.
313
314
315Examples
316========
317
318* To build a private copy of tools and xen:
319configure --prefix=/odd/path --sysconfdir=/odd/path/etc --enable-rpath
320make
321sudo make install BOOT_DIR=/ood/path/boot EFI_DIR=/odd/path/efi
322
323
324* Use configure and make to build a distro rpm package (it is required
325  to unset variables set by the rpm configure macro):
326%build
327export WGET=$(type -P false)
328export GIT=$(type -P false)
329export EXTRA_CFLAGS_XEN_TOOLS="$RPM_OPT_FLAGS"
330export EXTRA_CFLAGS_QEMU_TRADITIONAL="$RPM_OPT_FLAGS"
331export EXTRA_CFLAGS_QEMU_XEN="$RPM_OPT_FLAGS"
332%configure \
333        --with-initddir=%{_initddir}
334unset CFLAGS CXXFLAGS FFLAGS LDFLAGS
335make
336%install
337make install \
338        SYSCONFIG_DIR=/var/adm/fillup-templates \
339        DESTDIR=$RPM_BUILD_ROOT
340
341
342* To build xen and tools using a cross compiler:
343./configure --build=x86_64-unknown-linux-gnu --host=aarch64-linux-gnu
344make XEN_TARGET_ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
345make XEN_TARGET_ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \
346        DESTDIR=/some/path install
347
348
349TODO
350====
351
352 - DESTDIR should be empty, not "/"
353 - add make uninstall targets
354 - replace private path variables as needed (SBINDIR/sbindir)
355 - ...
356
357# vim: tw=72 et
358