1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ([2.67])
5AC_INIT([Xen Hypervisor Tools], m4_esyscmd([../version.sh ../xen/Makefile]),
6    [xen-devel@lists.xen.org], [xen], [https://www.xen.org/])
7AC_CONFIG_SRCDIR([libxl/libxl.c])
8AC_CONFIG_FILES([
9../config/Tools.mk
10hotplug/FreeBSD/rc.d/xencommons
11hotplug/FreeBSD/rc.d/xendriverdomain
12hotplug/Linux/init.d/sysconfig.xencommons
13hotplug/Linux/init.d/sysconfig.xendomains
14hotplug/Linux/init.d/xen-watchdog
15hotplug/Linux/init.d/xencommons
16hotplug/Linux/init.d/xendomains
17hotplug/Linux/init.d/xendriverdomain
18hotplug/Linux/launch-xenstore
19hotplug/Linux/vif-setup
20hotplug/Linux/xen-hotplug-common.sh
21hotplug/Linux/xendomains
22hotplug/NetBSD/rc.d/xencommons
23hotplug/NetBSD/rc.d/xendriverdomain
24ocaml/xenstored/oxenstored.conf
25])
26AC_CONFIG_HEADERS([config.h])
27AC_CONFIG_AUX_DIR([../])
28
29# Check if CFLAGS, LDFLAGS, LIBS, CPPFLAGS or CPP is set and print a warning
30
31AS_IF([test -n "$CC$CFLAGS$LDFLAGS$LIBS$CPPFLAGS$CPP"], [
32    AC_MSG_WARN(
33[Setting CC, CFLAGS, LDFLAGS, LIBS, CPPFLAGS or CPP is not \
34recommended, use PREPEND_INCLUDES, PREPEND_LIB, \
35APPEND_INCLUDES and APPEND_LIB instead when possible.])
36])
37
38AC_CANONICAL_HOST
39
40case $host_vendor in
41rumpxen|rumprun) CONFIG_RUMP=y; rump=true ;;
42*)               CONFIG_RUMP=n; rump=false ;;
43esac
44AC_SUBST(CONFIG_RUMP)
45
46AC_SYS_LARGEFILE
47
48case $ac_cv_sys_file_offset_bits in #(
49  no | unknown) ;;
50  *)
51  FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits
52;;
53esac
54AC_SUBST(FILE_OFFSET_BITS)
55
56# M4 Macro includes
57m4_include([../m4/savevar.m4])
58m4_include([../m4/features.m4])
59m4_include([../m4/path_or_fail.m4])
60m4_include([../m4/checkpolicy.m4])
61m4_include([../m4/set_cflags_ldflags.m4])
62m4_include([../m4/python_version.m4])
63m4_include([../m4/python_devel.m4])
64m4_include([../m4/python_fortify_noopt.m4])
65m4_include([../m4/ocaml.m4])
66m4_include([../m4/uuid.m4])
67m4_include([../m4/pkg.m4])
68m4_include([../m4/curses.m4])
69m4_include([../m4/pthread.m4])
70m4_include([../m4/ptyfuncs.m4])
71m4_include([../m4/extfs.m4])
72m4_include([../m4/fetcher.m4])
73m4_include([../m4/ax_compare_version.m4])
74m4_include([../m4/paths.m4])
75m4_include([../m4/systemd.m4])
76m4_include([../m4/golang.m4])
77
78AX_XEN_EXPAND_CONFIG()
79
80# Enable/disable options
81AX_ARG_DEFAULT_DISABLE([rpath], [Build tools with -Wl,-rpath,LIBDIR])
82AX_ARG_DEFAULT_DISABLE([githttp], [Download GIT repositories via HTTP])
83AX_ARG_DEFAULT_ENABLE([monitors], [Disable xenstat and xentop monitoring tools])
84AX_ARG_DEFAULT_ENABLE([ocamltools], [Disable Ocaml tools])
85AX_ARG_DEFAULT_ENABLE([xsmpolicy], [Disable XSM policy compilation])
86AX_ARG_DEFAULT_DISABLE([ovmf], [Enable OVMF])
87AX_ARG_DEFAULT_ENABLE([seabios], [Disable SeaBIOS])
88AX_ARG_DEFAULT_ENABLE([golang], [Disable Go tools])
89
90AC_ARG_WITH([linux-backend-modules],
91    AS_HELP_STRING([--with-linux-backend-modules="mod1 mod2"],
92    [List of Linux backend module or modalias names to be autoloaded on startup.]),
93    [LINUX_BACKEND_MODULES="$withval"],
94    [case "$host_os" in
95*linux*)
96LINUX_BACKEND_MODULES="
97xen-evtchn
98xen-gntdev
99xen-gntalloc
100xen-blkback
101xen-netback
102xen-pciback
103evtchn
104gntdev
105netbk
106blkbk
107xen-scsibk
108usbbk
109pciback
110xen-acpi-processor
111"
112;;
113*)
114LINUX_BACKEND_MODULES=
115;;
116esac])
117LINUX_BACKEND_MODULES="`eval echo $LINUX_BACKEND_MODULES`"
118AC_SUBST(LINUX_BACKEND_MODULES)
119
120AC_ARG_ENABLE([qemu-traditional],
121    AS_HELP_STRING([--enable-qemu-traditional],
122                   [Enable qemu traditional device model, (DEFAULT is on for Linux or NetBSD x86, otherwise off)]),,[
123    case "$host_cpu" in
124        i[[3456]]86|x86_64)
125           enable_qemu_traditional="yes";;
126        *) enable_qemu_traditional="no";;
127    esac
128    case "$host_os" in
129        freebsd*)
130           enable_qemu_traditional="no";;
131    esac
132
133])
134AS_IF([test "x$enable_qemu_traditional" = "xyes"], [
135AC_DEFINE([HAVE_QEMU_TRADITIONAL], [1], [Qemu traditional enabled])
136    qemu_traditional=y],[
137    qemu_traditional=n
138])
139AC_SUBST(qemu_traditional)
140
141AC_ARG_ENABLE([rombios],
142    AS_HELP_STRING([--enable-rombios],
143                   [Enable ROMBIOS, (DEFAULT is on if qemu-traditional is enabled, otherwise off)]),,[
144    AS_IF([test "x$enable_qemu_traditional" = "xyes"], [
145        enable_rombios="yes"
146    ], [
147        enable_rombios="no"
148    ])
149])
150AS_IF([test "x$enable_rombios" = "xyes"], [
151    dnl as86, ld86, and bcc are only required when building rombios. They
152    dnl are only needed when the host system is x86 but that check is done
153    dnl for us above when checking if we should build with qemu-traditional.
154    AX_PATH_PROG_OR_FAIL([AS86], [as86])
155    AX_PATH_PROG_OR_FAIL([LD86], [ld86])
156    AX_PATH_PROG_OR_FAIL([BCC], [bcc])
157    AC_CHECK_LIB([lzma], [lzma_version_number], [],
158        [AC_MSG_ERROR([Could not find lzma, needed to build rombios])])
159    AC_DEFINE([HAVE_ROMBIOS], [1], [ROMBIOS enabled])
160    rombios=y],[
161    rombios=n
162])
163AC_SUBST(rombios)
164
165AC_ARG_WITH([system-qemu],
166    AS_HELP_STRING([--with-system-qemu@<:@=PATH@:>@],
167       [Use system supplied qemu PATH or qemu (taken from $PATH) as qemu-xen
168        device model instead of building and installing our own version]),[
169    case $withval in
170        yes)
171            qemu_xen=n ; qemu_xen_path="qemu-system-i386"
172            qemu_xen_systemd="/usr/bin/env $qemu_xen_path" ;;
173        no)
174            qemu_xen=y ;;
175        *)
176            qemu_xen=n ; qemu_xen_path="$withval" ;
177            qemu_xen_systemd="$qemu_xen_path" ;;
178    esac
179],[
180    case "$host_cpu" in
181        i[[3456]]86|x86_64)
182           qemu_xen=y;;
183        arm*|aarch64)
184           qemu_xen=y;;
185        *) qemu_xen=n;;
186    esac
187])
188AS_IF([test "x$qemu_xen" = "xy"], [
189    qemu_xen_path="$LIBEXEC_BIN/qemu-system-i386"
190    qemu_xen_systemd="$qemu_xen_path"
191])
192AC_DEFINE_UNQUOTED([QEMU_XEN_PATH], ["$qemu_xen_path"], [Qemu Xen path])
193AC_SUBST(qemu_xen)
194AC_SUBST(qemu_xen_path)
195AC_SUBST(qemu_xen_systemd)
196
197AC_ARG_WITH([stubdom-qmp-proxy],
198    AC_HELP_STRING([--stubdom-qmp-proxy@<:@=PATH@:>@],
199        [Use supplied binary PATH as a QMP proxy into stubdomain]),[
200    stubdom_qmp_proxy="$withval"
201],[
202    stubdom_qmp_proxy="$bindir/vchan-socket-proxy"
203])
204AC_DEFINE_UNQUOTED([STUBDOM_QMP_PROXY_PATH], ["$stubdom_qmp_proxy"], [QMP proxy path])
205
206AC_ARG_WITH([system-seabios],
207    AS_HELP_STRING([--with-system-seabios@<:@=PATH@:>@],
208       [Use system supplied seabios PATH instead of building and installing
209        our own version]),[
210    # Disable compilation of SeaBIOS.
211    seabios=n
212    case $withval in
213        no) seabios_path= ;;
214        /*)  seabios_path=$withval ;;
215        *) AC_MSG_ERROR([Seabios specified, but is not an absolute path]) ;;
216    esac
217],[])
218AS_IF([test "x$seabios" = "xy" -o -n "$seabios_path" ], [
219    AC_DEFINE_UNQUOTED([SEABIOS_PATH],
220                       ["${seabios_path:-$XENFIRMWAREDIR/seabios.bin}"],
221                       [SeaBIOS path])
222])
223
224AC_ARG_WITH([system-ovmf],
225    AS_HELP_STRING([--with-system-ovmf@<:@=PATH@:>@],
226       [Use system supplied OVMF PATH instead of building and installing
227        our own version]),[
228    # Disable compilation of OVMF.
229    ovmf=n
230    case $withval in
231        no) ovmf_path= ;;
232        /*)  ovmf_path=$withval ;;
233        *) AC_MSG_ERROR([OVMF specified, but is not an absolute path]) ;;
234    esac
235],[])
236AS_IF([test "x$ovmf" = "xy" -o -n "$ovmf_path" ], [
237    AC_DEFINE_UNQUOTED([OVMF_PATH],
238                       ["${ovmf_path:-$XENFIRMWAREDIR/ovmf.bin}"],
239                       [OVMF path])
240])
241
242AC_ARG_ENABLE([ipxe],
243    AS_HELP_STRING([--disable-ipxe],
244                   [Enable in-tree IPXE, (DEFAULT is on if rombios is enabled,
245                    otherwise off, see also --with-system-ipxe)]),
246    [
247     AS_IF([test "x$enable_ipxe" = "xno"], [ipxe=n], [ipxe=y])
248    ],
249    [
250    AS_IF([test "x$enable_rombios" = "xno"], [ipxe=n], [ipxe=y])
251])
252AC_ARG_WITH([system-ipxe],
253    AS_HELP_STRING([--with-system-ipxe@<:@=PATH@:>@],
254       [Use system supplied IPXE PATH instead of building and installing
255        our own version, it takes precedence over --{en,dis}able-ipxe and is
256        bound by the presence of rombios, --without-system-ipxe is an error]),[
257    case $withval in
258        no) AC_MSG_ERROR([--without-system-ipxe has no effect]) ;;
259        /*)  ipxe_path=$withval; ipxe=n ;;
260        *) AC_MSG_ERROR([IPXE specified, but is not an absolute path]) ;;
261    esac
262],[])
263AS_IF([test "x$ipxe" = "xy" -o -n "$ipxe_path" ], [
264
265    AS_IF([test "x$enable_rombios" = "xno"], [
266        AC_MSG_ERROR([Rombios is required to use IPXE])
267    ], [])
268
269    AC_DEFINE_UNQUOTED([IPXE_PATH],
270                       ["${ipxe_path:-$XENFIRMWAREDIR/ipxe.bin}"],
271                       [IPXE path])
272])
273AC_SUBST(ipxe)
274
275AC_ARG_WITH([extra-qemuu-configure-args],
276    AS_HELP_STRING([--with-extra-qemuu-configure-args@<:@="--ARG1 ..."@:>@],
277       [List of additional configure options for upstream qemu]),[
278    case $withval in
279        no) EXTRA_QEMUU_CONFIGURE_ARGS= ;;
280        *)  EXTRA_QEMUU_CONFIGURE_ARGS=$withval ;;
281    esac
282],[])
283AC_SUBST(EXTRA_QEMUU_CONFIGURE_ARGS)
284
285AC_ARG_VAR([PREPEND_INCLUDES],
286    [List of include folders to prepend to CFLAGS (without -I)])
287AC_ARG_VAR([PREPEND_LIB],
288    [List of library folders to prepend to LDFLAGS (without -L)])
289AC_ARG_VAR([APPEND_INCLUDES],
290    [List of include folders to append to CFLAGS (without -I)])
291AC_ARG_VAR([APPEND_LIB],
292    [List of library folders to append to LDFLAGS (without -L)])
293
294AX_SET_FLAGS
295
296AC_ARG_VAR([PYTHON], [Path to the Python parser])
297AC_ARG_VAR([PERL], [Path to Perl parser])
298AC_ARG_VAR([BISON], [Path to Bison parser generator])
299AC_ARG_VAR([FLEX], [Path to Flex lexical analyser generator])
300AC_ARG_VAR([BASH], [Path to bash shell])
301AC_ARG_VAR([XGETTEXT], [Path to xgetttext tool])
302AC_ARG_VAR([AS86], [Path to as86 tool])
303AC_ARG_VAR([LD86], [Path to ld86 tool])
304AC_ARG_VAR([BCC], [Path to bcc tool])
305AC_ARG_VAR([IASL], [Path to iasl tool])
306AC_ARG_VAR([AWK], [Path to awk tool])
307
308# Checks for programs.
309AC_PROG_CC
310AC_PROG_MAKE_SET
311AC_PROG_INSTALL
312AC_PATH_PROG([BISON], [bison])
313AC_PATH_PROG([FLEX], [flex])
314AX_PATH_PROG_OR_FAIL([PERL], [perl])
315AX_PATH_PROG_OR_FAIL([AWK], [awk])
316
317AC_PROG_OCAML
318AC_PROG_FINDLIB
319
320AS_IF([test "x$ocamltools" = "xy"], [
321    AS_IF([test "x$OCAMLOPT" = "xno" || test "x$OCAMLFIND" = "xno"], [
322        AS_IF([test "x$enable_ocamltools" = "xyes"], [
323            AC_MSG_ERROR([Ocaml tools enabled, but missing ocamlopt or ocamlfind])])
324        ocamltools="n"
325    ], [
326        AX_COMPARE_VERSION([$OCAMLVERSION], [lt], [4.02.0], [
327            AS_IF([test "x$enable_ocamltools" = "xyes"], [
328                AC_MSG_ERROR([Your version of OCaml: $OCAMLVERSION is not supported])])
329            ocamltools="n"
330        ])
331    ])
332])
333
334AS_IF([test "x$golang" = "xy"], [
335    AC_PROG_GO
336    AS_IF([test "x$GO" = "xno"], [
337        AS_IF([test "x$enable_golang" =  "xyes"], [
338            AC_MSG_ERROR([Go tools enabled, but missing go compiler])
339        ])
340        golang="n"
341    ], [
342        AX_COMPARE_VERSION([$GOVERSION], [lt], [1.11.1], [
343            AS_IF([test "x$enable_golang" = "xyes"], [
344                AC_MSG_ERROR(["Your version of go: $GOVERSION is not supported"])
345            ])
346            golang="n"
347        ])
348    ])
349])
350
351m4_include([../m4/xenstored.m4])
352AX_XENSTORE_OPTIONS
353AX_XENSTORE_SET
354
355AS_IF([test "x$xsmpolicy" = "xy"], [
356    AC_PROG_CHECKPOLICY
357    AS_IF([test "x$CHECKPOLICY" = "xno"], [
358        AS_IF([test "x$enable_xsmpolicy" = "xyes"], [
359            AC_MSG_ERROR([XSM policy compilation enabled, but unable to find checkpolicy])])
360        xsmpolicy="n"
361    ])
362])
363dnl FreeBSD doesn't require bash (hotplug scripts are in plain sh)
364case "$host_os" in
365  freebsd*) ;;
366  *) AX_PATH_PROG_OR_FAIL([BASH], [bash]);;
367esac
368AS_IF([test -z "$PYTHON"], [AC_CHECK_PROGS([PYTHON], [python3 python python2], err)])
369AS_IF([test "$PYTHON" = "err"], [AC_MSG_ERROR([No python interpreter found])])
370AS_IF([echo "$PYTHON" | grep -q "^/"], [], [AC_PATH_PROG([PYTHON], [$PYTHON])])
371PYTHONPATH=$PYTHON
372PYTHON=`basename $PYTHONPATH`
373
374AX_PATH_PROG_OR_FAIL([PYTHONPATH], [$PYTHON])
375AX_CHECK_PYTHON_VERSION([2], [6])
376
377AS_IF([test "$cross_compiling" != yes], [
378    AX_CHECK_PYTHON_DEVEL()
379    AX_CHECK_PYTHON_FORTIFY_NOOPT()
380])
381
382if ! $rump; then
383
384AX_PATH_PROG_OR_FAIL([XGETTEXT], [xgettext])
385dnl as86, ld86, bcc and iasl are only required when the host system is x86*.
386dnl "host" here means the platform on which the hypervisor and tools is
387dnl going to run, not the platform on which we are building (known as
388dnl "build" in gnu speak).
389case "$host_cpu" in
390i[[3456]]86|x86_64|aarch64)
391    AX_PATH_PROG_OR_FAIL([IASL], [iasl])
392    ;;
393esac
394 AX_CHECK_UUID
395 AX_CHECK_CURSES
396AS_IF([test "$ncurses" = "y"], [
397AC_CHECK_LIB([tinfo], [define_key], [TINFO_LIBS=-ltinfo])
398])
399AC_SUBST(TINFO_LIBS)
400
401dnl The following are only required when upstream QEMU is built
402AS_IF([test "x$qemu_xen" = "xy"], [
403PKG_CHECK_MODULES(glib, [glib-2.0 >= 2.12])
404PKG_CHECK_MODULES(pixman, [pixman-1 >= 0.21.8])
405])
406AX_CHECK_FETCHER
407
408# Checks for libraries.
409AC_CHECK_HEADER([bzlib.h], [
410AC_CHECK_LIB([bz2], [BZ2_bzDecompressInit], [zlib="$zlib -DHAVE_BZLIB -lbz2"])
411])
412AC_CHECK_HEADER([lzma.h], [
413AC_CHECK_LIB([lzma], [lzma_stream_decoder], [zlib="$zlib -DHAVE_LZMA -llzma"])
414])
415AC_CHECK_HEADER([lzo/lzo1x.h], [
416AC_CHECK_LIB([lzo2], [lzo1x_decompress], [zlib="$zlib -DHAVE_LZO1X -llzo2"])
417])
418AC_SUBST(zlib)
419AC_SUBST(system_aio)
420AX_CHECK_EXTFS
421AX_CHECK_PTHREAD
422AX_CHECK_PTYFUNCS
423AC_CHECK_LIB([yajl], [yajl_alloc], [],
424    [AC_MSG_ERROR([Could not find yajl])])
425AC_CHECK_LIB([z], [deflateCopy], [], [AC_MSG_ERROR([Could not find zlib])])
426AC_CHECK_LIB([iconv], [libiconv_open], [libiconv="y"], [libiconv="n"])
427AC_SUBST(libiconv)
428AC_CHECK_HEADER([argp.h], [
429AC_CHECK_LIB([argp], [argp_usage], [argp_ldflags="-largp"])
430], [AC_MSG_ERROR([Could not find argp])])
431AC_SUBST(argp_ldflags)
432
433# FDT is needed only on ARM
434case "$host_cpu" in
435arm*|aarch64)
436AC_CHECK_LIB([fdt], [fdt_create], [], [AC_MSG_ERROR([Could not find libfdt])])
437
438# Check for libfdt >= 1.4.0. If present enable passthrough
439# Note that libfdt doesn't provide versionning. So we need to rely on
440# function present in new version.
441# Use fdt_first_property_offset which has been correctly exported since v1.4.0
442AC_CHECK_FUNC(fdt_first_property_offset, [partial_dt="y"], [partial_dt="n"])
443
444AS_IF([test "x$partial_dt" = "xy" ],
445      [AC_DEFINE([ENABLE_PARTIAL_DEVICE_TREE], [1],
446                 [Enabling support partial device tree in libxl])],
447      [AC_MSG_WARN([Disabling support for partial device tree in libxl.
448       Please install libfdt library - version 1.4.0 or higher])])
449
450# The functions fdt_{first,next}_subnode may not be available because:
451#   * It has been introduced in 2013 => Doesn't work on Wheezy
452#   * The prototype exists but the functions are not exposed. Don't ask why...
453AC_CHECK_FUNCS([fdt_first_subnode fdt_next_subnode])
454AC_CHECK_DECLS([fdt_first_subnode, fdt_next_subnode],,,[#include <libfdt.h>])
455
456# The helper fdt_property_u32 is only present in libfdt >= 1.4.0
457# It's an inline function, so only check if the declaration is present
458AC_CHECK_DECLS([fdt_property_u32],,,[#include <libfdt.h>])
459esac
460
461# Checks for header files.
462AC_CHECK_HEADERS([yajl/yajl_version.h sys/eventfd.h valgrind/memcheck.h utmp.h])
463
464# Check for libnl3 >=3.2.8. If present enable remus network buffering.
465PKG_CHECK_MODULES(LIBNL3, [libnl-3.0 >= 3.2.8 libnl-route-3.0 >= 3.2.8],
466    [libnl3_lib="y"], [libnl3_lib="n"])
467
468AS_IF([test "x$libnl3_lib" = "xn" ], [
469    AC_MSG_WARN([Disabling support for Remus network buffering and COLO.
470    Please install libnl3 libraries (including libnl3-route), command line tools and devel
471    headers - version 3.2.8 or higher])
472    AC_SUBST(libnl, [n])
473    ],[
474    AC_SUBST(libnl, [y])
475])
476
477AC_SUBST(LIBNL3_LIBS)
478AC_SUBST(LIBNL3_CFLAGS)
479
480fi # ! $rump
481
482AX_AVAILABLE_SYSTEMD()
483
484AS_IF([test "x$systemd" = "xy"], [
485    AC_CONFIG_FILES([
486    hotplug/Linux/systemd/proc-xen.mount
487    hotplug/Linux/systemd/var-lib-xenstored.mount
488    hotplug/Linux/systemd/xen-init-dom0.service
489    hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service
490    hotplug/Linux/systemd/xen-watchdog.service
491    hotplug/Linux/systemd/xenconsoled.service
492    hotplug/Linux/systemd/xendomains.service
493    hotplug/Linux/systemd/xendriverdomain.service
494    hotplug/Linux/systemd/xenstored.service
495    ])
496])
497
498AC_ARG_ENABLE([9pfs],
499    AS_HELP_STRING([--enable-9pfs],
500                   [Explicitly enable 9pfs support in QEMU build (default is to defer to QEMU configure default)]),
501    [AS_IF([test "x$enable_9pfs" = "xyes"], [ninepfs=y], [ninepfs=n])],[
502])
503
504AC_SUBST(ninepfs)
505
506AC_ARG_ENABLE([pvshim],
507    AS_HELP_STRING([--disable-pvshim],
508                   [Disable pvshim build (enabled by default on 64bit x86)]),
509    [AS_IF([test "x$enable_pvshim" = "xno"], [pvshim=n], [pvshim=y])], [
510    cpu=`test -z "$target_cpu" && echo "$host_cpu" || echo "$target_cpu"`
511    case "${XEN_COMPILE_ARCH-${XEN_TARGET_ARCH-$cpu}}" in
512        x86_64)
513           pvshim="y";;
514        *) pvshim="n";;
515    esac
516])
517AC_SUBST(pvshim)
518
519AC_OUTPUT()
520