Commit bfa8db13 authored by Ian Jackson's avatar Ian Jackson

build: add autoconf to replace custom checks in tools/check

Added autotools magic to replace custom check scripts. The previous
checks have been ported to autoconf, and some additional ones have
been added (plus the suggestions from running autoscan). Two files are
created as a result from executing configure script, config/Tools.mk
and config.h.

conf/Tools.mk is included by tools/Rules.mk, and contains most of the
options previously defined in .config, that can now be set passing
parameters or defining environment variables when executing configure
script.

config.h is only used by libxl/xl to detect yajl_version.h.

[ tools/config.sub and config.guess copied from
  autotools-dev 20100122.1 from Debian squeeze i386,
  which is GPLv2.

  tools/configure generated using the included ./autogen.sh
  which ran autoconf 2.67-2 from Debian squeeze i386.  autoconf
  is GPLv3+ but has a special exception for the autoconf output;
  this exception applies to us and exempts us from complying
  with GPLv3+ for configure, which is good as Xen is GPL2 only.

  - Ian Jackson ]
Signed-off-by: default avatarRoger Pau Monne <roger.pau@entel.upc.edu>
Tested-by: default avatarIan Jackson <ian.jackson@eu.citrix.com>
Committed-by: default avatarIan Jackson <Ian.Jackson@eu.citrix.com>
parent 110672b9
......@@ -303,6 +303,12 @@
^tools/ocaml/libs/xl/xenlight\.ml$
^tools/ocaml/libs/xl/xenlight\.mli$
^tools/ocaml/xenstored/oxenstored$
^tools/autom4te\.cache$
^tools/config\.h$
^tools/config\.log$
^tools/config\.status$
^tools/config\.cache$
^config/Tools\.mk$
^xen/\.banner.*$
^xen/BLOG$
^xen/System.map$
......
......@@ -70,9 +70,6 @@ EXTRA_INCLUDES += $(EXTRA_PREFIX)/include
EXTRA_LIB += $(EXTRA_PREFIX)/$(LIBLEAFDIR)
endif
BISON ?= bison
FLEX ?= flex
PYTHON ?= python
PYTHON_PREFIX_ARG ?= --prefix="$(PREFIX)"
# The above requires that PREFIX contains *no spaces*. This variable is here
......@@ -175,32 +172,9 @@ CFLAGS += $(foreach i, $(PREPEND_INCLUDES), -I$(i))
APPEND_LDFLAGS += $(foreach i, $(APPEND_LIB), -L$(i))
APPEND_CFLAGS += $(foreach i, $(APPEND_INCLUDES), -I$(i))
CHECK_LIB = $(EXTRA_LIB) $(PREPEND_LIB) $(APPEND_LIB)
CHECK_INCLUDES = $(EXTRA_INCLUDES) $(PREPEND_INCLUDES) $(APPEND_INCLUDES)
EMBEDDED_EXTRA_CFLAGS := -nopie -fno-stack-protector -fno-stack-protector-all
EMBEDDED_EXTRA_CFLAGS += -fno-exceptions
CONFIG_LIBICONV := $(shell export OS="`uname -s`"; \
export CHECK_LIB="$(CHECK_LIB)"; \
. $(XEN_ROOT)/tools/check/funcs.sh; \
has_lib libiconv.so && echo 'y' || echo 'n')
CONFIG_YAJL_VERSION := $(shell export OS="`uname -s`"; \
export CHECK_INCLUDES="$(CHECK_INCLUDES)"; \
. $(XEN_ROOT)/tools/check/funcs.sh; \
has_header yajl/yajl_version.h && echo 'y' || echo 'n')
# Enable XSM security module (by default, Flask).
XSM_ENABLE ?= n
FLASK_ENABLE ?= $(XSM_ENABLE)
# Download GIT repositories via HTTP or GIT's own protocol?
# GIT's protocol is faster and more robust, when it works at all (firewalls
# may block it). We make it the default, but if your GIT repository downloads
# fail or hang, please specify GIT_HTTP=y in your environment.
GIT_HTTP ?= n
XEN_EXTFILES_URL=http://xenbits.xensource.com/xen-extfiles
# All the files at that location were downloaded from elsewhere on
# the internet. The original download URL is preserved as a comment
......@@ -239,17 +213,4 @@ QEMU_TAG ?= 128de2549c5f24e4a437b86bd2e46f023976d50a
# Short answer -- do not enable this unless you know what you are
# doing and are prepared for some pain.
# Optional components
XENSTAT_XENTOP ?= y
VTPM_TOOLS ?= n
LIBXENAPI_BINDINGS ?= n
PYTHON_TOOLS ?= y
OCAML_TOOLS ?= y
CONFIG_MINITERM ?= n
CONFIG_LOMOUNT ?= n
CONFIG_SYSTEM_LIBAIO ?= y
CONFIG_TESTS ?= y
ifeq ($(OCAML_TOOLS),y)
OCAML_TOOLS := $(shell ocamlopt -v > /dev/null 2>&1 && echo "y" || echo "n")
endif
......@@ -40,11 +40,10 @@ dist: DESTDIR=$(DISTDIR)/install
dist: dist-xen dist-kernels dist-tools dist-stubdom dist-docs dist-misc
dist-misc:
$(INSTALL_DIR) $(DISTDIR)/check
$(INSTALL_DIR) $(DISTDIR)/
$(INSTALL_DATA) ./COPYING $(DISTDIR)
$(INSTALL_DATA) ./README $(DISTDIR)
$(INSTALL_PROG) ./install.sh $(DISTDIR)
$(INSTALL_PROG) tools/check/chk tools/check/check_* tools/check/funcs.sh $(DISTDIR)/check
dist-%: DESTDIR=$(DISTDIR)/install
dist-%: install-%
@: # do nothing
......
......@@ -89,9 +89,13 @@ performed with root privileges.]
3. For the very first build, or if you want to destroy build trees,
perform the following steps:
# ./configure
# make world
# make install
If you want, you can run ./configure --help to see the list of
options available options when building and installing Xen.
This will create and install onto the local machine. It will build
the xen binary (xen.gz), the tools and the documentation.
......
#!/bin/sh -e
cd tools
autoconf
# Prefix and install folder
PREFIX := @prefix@
LIBLEAFDIR_x86_64 := @LIB_PATH@
# A debug build of tools?
debug := @debug@
# Tools path
BISON := @BISON@
FLEX := @FLEX@
PYTHON := @PYTHON@
PYTHON_PATH := @PYTHONPATH@
PERL := @PERL@
BRCTL := @BRCTL@
IP := @IP@
CURL_CONFIG := @CURL@
XML2_CONFIG := @XML@
BASH := @BASH@
XGETTTEXT := @XGETTEXT@
# Extra folder for libs/includes
PREPEND_INCLUDES := @PREPEND_INCLUDES@
PREPEND_LIB := @PREPEND_LIB@
APPEND_INCLUDES := @APPEND_INCLUDES@
APPEND_LIB := @APPEND_LIB@
# Enable XSM security module (by default, Flask).
XSM_ENABLE := @xsm@
FLASK_ENABLE := @xsm@
# Download GIT repositories via HTTP or GIT's own protocol?
# GIT's protocol is faster and more robust, when it works at all (firewalls
# may block it). We make it the default, but if your GIT repository downloads
# fail or hang, please specify GIT_HTTP=y in your environment.
GIT_HTTP := @githttp@
# Optional components
XENSTAT_XENTOP := @monitors@
VTPM_TOOLS := @vtpm@
LIBXENAPI_BINDINGS := @xapi@
PYTHON_TOOLS := @pythontools@
OCAML_TOOLS := @ocamltools@
CONFIG_MINITERM := @miniterm@
CONFIG_LOMOUNT := @lomount@
#System options
CONFIG_SYSTEM_LIBAIO:= @system_aio@
CONFIG_LIBICONV := @libiconv@
CONFIG_GCRYPT := @libgcrypt@
CONFIG_EXT2FS := @libext2fs@
#!/bin/sh -e
cd tools && ./configure $@
......@@ -6,7 +6,6 @@ SUBDIRS-libaio := libaio
endif
SUBDIRS-y :=
SUBDIRS-y += check
SUBDIRS-y += include
SUBDIRS-y += libxc
SUBDIRS-y += flask
......@@ -79,6 +78,8 @@ clean: subdirs-clean
distclean: subdirs-distclean
rm -rf qemu-xen-traditional-dir qemu-xen-traditional-dir-remote
rm -rf qemu-xen-dir qemu-xen-dir-remote
rm -rf ../config/Tools.mk config.h config.log config.status \
config.cache autom4te.cache
ifneq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
IOEMU_CONFIGURE_CROSS ?= --cpu=$(XEN_TARGET_ARCH) \
......
......@@ -4,6 +4,7 @@
all:
include $(XEN_ROOT)/Config.mk
include $(XEN_ROOT)/config/Tools.mk
export _INSTALL := $(INSTALL)
INSTALL = $(XEN_ROOT)/tools/cross-install
......@@ -80,8 +81,6 @@ check-$(CONFIG_X86) = $(call cc-ver-check,CC,0x030400,\
"Xen requires at least gcc-3.4")
$(eval $(check-y))
_PYTHON_PATH := $(shell which $(PYTHON))
PYTHON_PATH ?= $(_PYTHON_PATH)
INSTALL_PYTHON_PROG = \
$(XEN_ROOT)/tools/python/install-wrap "$(PYTHON_PATH)" $(INSTALL_PROG)
......@@ -109,3 +108,7 @@ subdir-all-% subdir-clean-% subdir-install-%: .phony
subdir-distclean-%: .phony
$(MAKE) -C $* clean
$(XEN_ROOT)/config/Tools.mk:
@echo "You have to run ./configure before building or installing the tools"
@exit 1
......@@ -13,7 +13,7 @@ CFLAGS += $(CFLAGS_libxenstore)
CFLAGS += -I $(MEMSHR_DIR)
CFLAGS += -D_GNU_SOURCE
ifeq ($(shell . ./check_gcrypt $(CC)),yes)
ifeq ($CONFIG_GCRYPT,y)
CFLAGS += -DUSE_GCRYPT
CRYPT_LIB := -lgcrypt
else
......
#!/bin/sh
cat > .gcrypt.c << EOF
#include <gcrypt.h>
int main(void) { return 0; }
EOF
if $1 -o .gcrypt .gcrypt.c -lgcrypt 2>/dev/null ; then
echo "yes"
else
echo "no"
fi
rm -f .gcrypt*
XEN_ROOT = $(CURDIR)/../..
include $(XEN_ROOT)/tools/Rules.mk
# Export the necessary environment variables for the tests
export PYTHON
export LIBXENAPI_BINDINGS
export CHECK_INCLUDES
export CHECK_LIB
export CONFIG_SYSTEM_LIBAIO
.PHONY: all install
all install: check-build
# Check this machine is OK for building on.
.PHONY: check-build
check-build:
./chk build
# Check this machine is OK for installing on.
.PHONY: check-install
check-install:
./chk install
.PHONY: clean
clean:
./chk clean
Checks for the suitability of a machine for Xen build or install.
To check for build suitability use
./chk build
To check for install suitability use
./chk install
The chk script will run checks in this directory and print
the ones that failed. It prints nothing if checks succeed.
The chk script exits with 0 on success and 1 on failure.
The chk script runs executable files in this directory whose
names begin with 'check_'. Files containing CHECK-BUILD
are run for the build check, and files containing CHECK-INSTALL
are run for the install check.
Detailed output from the check scripts is in .chkbuild for build
and .chkinstall for install.
\ No newline at end of file
#!/bin/sh
# CHECK-INSTALL
. ./funcs.sh
case $OS in
OpenBSD|NetBSD|FreeBSD)
has_or_fail brconfig ;;
Linux)
has_or_fail brctl ;;
*)
fail "unknown OS" ;;
esac
#!/bin/sh
# CHECK-BUILD CHECK-INSTALL
. ./funcs.sh
case $OS in
FreeBSD|NetBSD|OpenBSD)
exit 0 ;;
esac
has_lib libcrypto.so || fail "missing libcrypto.so"
#!/bin/sh
# CHECK-BUILD CHECK-INSTALL
. ./funcs.sh
if [ "$LIBXENAPI_BINDINGS" != "y" ]; then
echo -n "unused, "
exit 0
fi
has_or_fail curl-config
curl_libs=`curl-config --libs` || fail "curl-config --libs failed"
test_link $curl_libs || fail "dependency libraries for curl are missing"
#!/bin/sh
# CHECK-INSTALL
. ./funcs.sh
PATH=/sbin:$PATH
case $OS in
OpenBSD|NetBSD|FreeBSD)
has_or_fail ifconfig ;;
Linux)
has_or_fail ip ;;
*)
fail "unknown OS" ;;
esac
#!/bin/sh
# CHECK-BUILD
. ./funcs.sh
if [ X${CONFIG_SYSTEM_LIBAIO} != X"y" ] ; then
exit 0
fi
if ! has_header libaio.h ; then
fail "can't find libaio headers, install libaio devel package or set CONFIG_SYSTEM_LIBAIO=n"
fi
#!/bin/sh
# CHECK-BUILD CHECK-INSTALL
. ./funcs.sh
if [ X${CONFIG_SYSTEM_LIBAIO} != X"y" ] ; then
exit 0
fi
has_lib libaio.so || fail "can't find libaio"
#!/bin/sh
# CHECK-BUILD
. ./funcs.sh
has_header openssl/md5.h || fail "missing openssl headers"
#!/bin/sh
# CHECK-BUILD CHECK-INSTALL
. ./funcs.sh
if test -z ${PYTHON}; then
PYTHON=python
fi
${PYTHON} -c '
import sys
sys.exit(sys.version_info[0] < 2 or sys.version_info[1] < 3)
' || fail "need python version >= 2.3"
#!/bin/sh
# CHECK-BUILD
. ./funcs.sh
if test -z ${PYTHON}; then
PYTHON=python
fi
has_or_fail ${PYTHON}
${PYTHON} -c '
import os.path, sys
for p in sys.path:
if os.path.exists(p + "/config/Makefile"):
sys.exit(0)
sys.exit(1)
' || fail "can't find python devel files"
#!/bin/sh
# CHECK-INSTALL
. ./funcs.sh
if test -z ${PYTHON}; then
PYTHON=python
fi
has_or_fail ${PYTHON}
${PYTHON} -c 'import xml.dom.minidom' 2>/dev/null || \
fail "can't import xml.dom.minidom"
#!/bin/sh
# CHECK-INSTALL
. ./funcs.sh
case $OS in
OpenBSD|NetBSD|FreeBSD)
has_or_fail vnconfig
;;
Linux)
has /sbin/udevadm && \
udevver=`/sbin/udevadm info -V | awk '{print $NF}'`
[ -z "$udevver" ] && has_or_fail udevinfo && \
udevver=`udevinfo -V | awk '{print $NF}'`
[ "$udevver" -ge 59 ] 2>/dev/null || \
has hotplug || \
fail "udev is too old, upgrade to version 59 or later"
;;
*)
fail "unknown OS"
;;
esac
#!/bin/sh
# CHECK-BUILD
. ./funcs.sh
has_header uuid.h || \
has_header uuid/uuid.h || fail "missing uuid headers (package uuid-dev)"
#!/bin/sh
# CHECK-BUILD
. ./funcs.sh
has_header X11/keysymdef.h || \
has_header /usr/X11R6/include/X11/keysymdef.h || \
has_header /usr/X11R7/include/X11/keysymdef.h || \
warning "can't find X11 headers"
#!/bin/sh
# CHECK-BUILD
. ./funcs.sh
has_or_fail xgettext
#!/bin/sh
# CHECK-BUILD CHECK-INSTALL
. ./funcs.sh
if [ ! "$LIBXENAPI_BINDINGS" = "y" ]
then
echo -n "unused, "
exit 0
fi
has_or_fail xml2-config
xml2_libs=`xml2-config --libs` || fail "xml2-config --libs failed"
test_link $xml2_libs || fail "dependency libraries for xml2 are missing"
#!/bin/sh
# CHECK-BUILD
. ./funcs.sh
has_header yajl/yajl_parse.h || fail "can't find yajl/yajl_parse.h"
has_header yajl/yajl_gen.h || fail "can't find yajl/yajl_gen.h"
has_lib libyajl.so || fail "can't find libyajl.so"
#!/bin/sh
# CHECK-BUILD
. ./funcs.sh
has_header zlib.h || fail "can't find zlib headers"
#!/bin/sh
# CHECK-BUILD CHECK-INSTALL
. ./funcs.sh
case $OS in
FreeBSD|NetBSD|OpenBSD)
exit 0
;;
esac
has_lib libz.so || fail "can't find zlib"
#!/bin/sh
func_usage ()
{
echo "Usage:"
echo " $0 [build|install|clean]"
echo
echo "Check suitability for Xen build or install."
echo "Exit with 0 if OK, 1 if not."
echo
echo "Calling with 'clean' removes generated files."
exit 1
}
PATH=$PATH:/sbin:/usr/sbin
OS=`uname -s`
export PATH OS
if [ "$OS" = "SunOS" ]; then
exit 0
fi
case $1 in
build)
check="CHECK-BUILD"
;;
install)
check="CHECK-INSTALL"
;;
clean)
exit 0
;;
*)
func_usage
;;
esac
failed=0
echo "Xen ${check} " `date`
for f in check_* ; do
case $f in
*~)
continue
;;
*)
;;
esac
if ! [ -x $f ] ; then
continue
fi
if ! grep -Fq "$check" $f ; then
continue
fi
echo -n "Checking $f: "
if ./$f 2>&1 ; then
echo OK
else
failed=1
fi
done
exit ${failed}
# has is the same as which, except it handles cross environments
has() {
if [ -z "$CROSS_COMPILE" ]; then
command which "$@"
return $?
fi
check_sys_root || return 1
# subshell to prevent pollution of caller's IFS
(
IFS=:
for p in $PATH; do
if [ -x "$CROSS_SYS_ROOT/$p/$1" ]; then
echo "$CROSS_SYS_ROOT/$p/$1"
return 0
fi
done
return 1
)
}
has_or_fail() {
has "$1" >/dev/null || fail "can't find $1"
}
has_header() {
check_sys_root || return 1
case $1 in
/*) ;;
*)
if [ -r "$CROSS_SYS_ROOT/usr/include/$1" ]; then
return 0
fi
for path in ${CHECK_INCLUDES}; do
if [ -r "$CROSS_SYS_ROOT${path}/$1" ]; then
return 0
fi
done
;;
esac
return 1
}
has_lib() {
check_sys_root || return 1
# subshell to prevent pollution of caller's environment
(
PATH=/sbin:$PATH # for ldconfig
LIBRARIES="$CHECK_LIB /usr/lib"
# This relatively common in a sys-root; libs are installed but
# ldconfig hasn't run there, so ldconfig -p won't work.
if [ "$OS" = Linux -a ! -f "$CROSS_SYS_ROOT/etc/ld.so.cache" ]; then
echo "Please run ldconfig -r \"$CROSS_SYS_ROOT\" to generate ld.so.cache"
# fall through; ldconfig test below should fail
fi
if [ "${OS}" = "Linux" ]; then
ldconfig -p ${CROSS_SYS_ROOT+-r "$CROSS_SYS_ROOT"} | grep -Fq "$1"
return $?
fi
if [ "${OS}" = "NetBSD" ]; then
ls -1 ${LIBRARIES} | grep -Fq "$1"
return $?
fi
return 1
)
}
test_link() {
# subshell to trap removal of tmpfile
(
unset tmpfile
trap 'rm -f "$tmpfile"; exit' 0 1 2 15
tmpfile=`mktemp` || return 1
ld "$@" -o "$tmpfile" >/dev/null 2>&1
return $?
)
}
# this function is used commonly above
check_sys_root() {
[ -z "$CROSS_COMPILE" ] && return 0
if [ -z "$CROSS_SYS_ROOT" ]; then
echo "please set CROSS_SYS_ROOT in the environment"
return 1
fi
if [ ! -d "$CROSS_SYS_ROOT" ]; then
echo "no sys-root found at $CROSS_SYS_ROOT"
return 1
fi
}
warning() {
echo
echo " *** `basename "$0"` FAILED${*+: $*}"
}
fail() {
echo
echo " *** `basename "$0"` FAILED${*+: $*}"
exit 1
}
This diff is collapsed.
/*
* Copyright (C) 2012
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; version 2.1 only. with the special
* exception on linking described in file LICENSE.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/
/* Define to 1 if you have the <yajl/yajl_version.h> header file. */
#undef HAVE_YAJL_YAJL_VERSION_H
This diff is collapsed.
This diff is collapsed.
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.67])
AC_INIT([Xen Hypervisor], m4_esyscmd([../version.sh ../xen/Makefile]),
[xen-devel@lists.xensource.com])
AC_CONFIG_SRCDIR([libxl/libxl.c])
AC_CONFIG_FILES([../config/Tools.mk])
AC_CONFIG_HEADERS([config.h])
AC_PREFIX_DEFAULT([/usr])
AC_CONFIG_AUX_DIR([.])
# Check if CFLAGS, LDFLAGS, LIBS, CPPFLAGS or CPP is set and print a warning
AS_IF([test -n "$CC$CFLAGS$LDFLAGS$LIBS$CPPFLAGS$CPP"], [
AC_MSG_WARN(
[Setting CC, CFLAGS, LDFLAGS, LIBS, CPPFLAGS or CPP is not \
recommended, use PREPEND_INCLUDES, PREPEND_LIB, \
APPEND_INCLUDES and APPEND_LIB instead when possible.])
])
AC_USE_SYSTEM_EXTENSIONS
AC_CANONICAL_HOST
# M4 Macro includes
m4_include([m4/enable_feature.m4])
m4_include([m4/disable_feature.m4])
m4_include([m4/path_or_fail.m4])
m4_include([m4/python_xml.m4])
m4_include([m4/python_version.m4])
m4_include([m4/python_devel.m4])
m4_include([m4/udev.m4])
m4_include([m4/ocaml.m4])
m4_include([m4/default_lib.m4])
m4_include([m4/set_cflags_ldflags.m4])
m4_include([m4/uuid.m4])
m4_include([m4/pkg.m4])
# Enable/disable options
AX_ARG_ENABLE_AND_EXPORT([xsm],
[Enable XSM security module (by default, Flask)])
AX_ARG_ENABLE_AND_EXPORT([githttp], [Download GIT repositories via HTTP])
AX_ARG_DISABLE_AND_EXPORT([monitors],
[Disable xenstat and xentop monitoring tools])
AX_ARG_ENABLE_AND_EXPORT([vtpm], [Enable Virtual Trusted Platform Module])
AX_ARG_ENABLE_AND_EXPORT([xapi], [Enable Xen API Bindings])
AX_ARG_DISABLE_AND_EXPORT([pythontools], [Disable Python tools])
AX_ARG_DISABLE_AND_EXPORT([ocamltools], [Disable Ocaml tools])
AX_ARG_ENABLE_AND_EXPORT([miniterm], [Enable miniterm])
AX_ARG_ENABLE_AND_EXPORT([lomount], [Enable lomount])
AX_ARG_DISABLE_AND_EXPORT([debug], [Disable debug build of Xen and tools])
AC_ARG_VAR([PREPEND_INCLUDES],
[List of include folders to prepend to CFLAGS (without -I)])
AC_ARG_VAR([PREPEND_LIB],