From 19459d56f493b380e2df30e06822cc7b01183186 Mon Sep 17 00:00:00 2001 From: Roger Pau Monne Date: Fri, 14 Sep 2012 10:02:47 +0100 Subject: libfsimage: add ext4 support for CentOS 5.x CentOS 5.x forked e2fs ext4 support into a different package called e4fs, and so headers and library names changed from ext2fs to ext4fs. Check if ext4fs/ext2fs.h and -lext4fs work, and use that instead of ext2fs to build libfsimage. This patch assumes that if the ext4fs library is present it should always be used instead of ext2fs. This patch includes a rework of the ext2fs check, a new ext4fs check and a minor modification in libfsimage to use the correct library. Signed-off-by: Roger Pau Monne Acked-by: Ian Campbell Committed-by: Ian Campbell --- config/Tools.mk.in | 2 +- tools/config.h.in | 3 ++ tools/configure | 90 +++++++++++++++++++++++++++----- tools/configure.ac | 4 +- tools/libfsimage/Makefile | 2 +- tools/libfsimage/ext2fs-lib/Makefile | 5 +- tools/libfsimage/ext2fs-lib/ext2fs-lib.c | 5 +- tools/m4/extfs.m4 | 20 +++++++ 8 files changed, 113 insertions(+), 18 deletions(-) create mode 100644 tools/m4/extfs.m4 diff --git a/config/Tools.mk.in b/config/Tools.mk.in index 21ad0ef270..a6ecf48dfd 100644 --- a/config/Tools.mk.in +++ b/config/Tools.mk.in @@ -57,5 +57,5 @@ CONFIG_SYSTEM_LIBAIO:= @system_aio@ ZLIB := @zlib@ CONFIG_LIBICONV := @libiconv@ CONFIG_GCRYPT := @libgcrypt@ -CONFIG_EXT2FS := @libext2fs@ +EXTFS_LIBS := @EXTFS_LIBS@ CURSES_LIBS := @CURSES_LIBS@ diff --git a/tools/config.h.in b/tools/config.h.in index bc1ed1057b..6d67503de7 100644 --- a/tools/config.h.in +++ b/tools/config.h.in @@ -42,6 +42,9 @@ /* Define curses header to use */ #undef INCLUDE_CURSES_H +/* Define extfs header to use */ +#undef INCLUDE_EXTFS_H + /* libutil header file name */ #undef INCLUDE_LIBUTIL_H diff --git a/tools/configure b/tools/configure index 8368e2cff4..2e20a61ed4 100755 --- a/tools/configure +++ b/tools/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.67 for Xen Hypervisor 4.2. +# Generated by GNU Autoconf 2.67 for Xen Hypervisor 4.3. # # Report bugs to . # @@ -552,8 +552,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Xen Hypervisor' PACKAGE_TARNAME='xen-hypervisor' -PACKAGE_VERSION='4.2' -PACKAGE_STRING='Xen Hypervisor 4.2' +PACKAGE_VERSION='4.3' +PACKAGE_STRING='Xen Hypervisor 4.3' PACKAGE_BUGREPORT='xen-devel@lists.xen.org' PACKAGE_URL='' @@ -603,7 +603,7 @@ PTHREAD_LIBS PTHREAD_LDFLAGS PTHREAD_CFLAGS libgcrypt -libext2fs +EXTFS_LIBS system_aio zlib glib_LIBS @@ -1301,7 +1301,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Xen Hypervisor 4.2 to adapt to many kinds of systems. +\`configure' configures Xen Hypervisor 4.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1366,7 +1366,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Xen Hypervisor 4.2:";; + short | recursive ) echo "Configuration of Xen Hypervisor 4.3:";; esac cat <<\_ACEOF @@ -1490,7 +1490,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Xen Hypervisor configure 4.2 +Xen Hypervisor configure 4.3 generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1792,7 +1792,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Xen Hypervisor $as_me 4.2, which was +It was created by Xen Hypervisor $as_me 4.3, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -2389,6 +2389,8 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + # Enable/disable options # Check whether --enable-githttp was given. @@ -6325,6 +6327,10 @@ else as_fn_error $? "Could not find libcrypto" "$LINENO" 5 fi + +ac_fn_c_check_header_mongrel "$LINENO" "ext2fs/ext2fs.h" "ac_cv_header_ext2fs_ext2fs_h" "$ac_includes_default" +if test "x$ac_cv_header_ext2fs_ext2fs_h" = x""yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ext2fs_open2 in -lext2fs" >&5 $as_echo_n "checking for ext2fs_open2 in -lext2fs... " >&6; } if test "${ac_cv_lib_ext2fs_ext2fs_open2+set}" = set; then : @@ -6362,10 +6368,70 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ext2fs_ext2fs_open2" >&5 $as_echo "$ac_cv_lib_ext2fs_ext2fs_open2" >&6; } if test "x$ac_cv_lib_ext2fs_ext2fs_open2" = x""yes; then : - libext2fs="y" + + +$as_echo "#define INCLUDE_EXTFS_H " >>confdefs.h + + EXTFS_LIBS="-lext2fs" + +fi + + +fi + + +ac_fn_c_check_header_mongrel "$LINENO" "ext4fs/ext2fs.h" "ac_cv_header_ext4fs_ext2fs_h" "$ac_includes_default" +if test "x$ac_cv_header_ext4fs_ext2fs_h" = x""yes; then : + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ext2fs_open2 in -lext4fs" >&5 +$as_echo_n "checking for ext2fs_open2 in -lext4fs... " >&6; } +if test "${ac_cv_lib_ext4fs_ext2fs_open2+set}" = set; then : + $as_echo_n "(cached) " >&6 else - libext2fs="n" + ac_check_lib_save_LIBS=$LIBS +LIBS="-lext4fs $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ext2fs_open2 (); +int +main () +{ +return ext2fs_open2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_ext4fs_ext2fs_open2=yes +else + ac_cv_lib_ext4fs_ext2fs_open2=no fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ext4fs_ext2fs_open2" >&5 +$as_echo "$ac_cv_lib_ext4fs_ext2fs_open2" >&6; } +if test "x$ac_cv_lib_ext4fs_ext2fs_open2" = x""yes; then : + + +$as_echo "#define INCLUDE_EXTFS_H " >>confdefs.h + + EXTFS_LIBS="-lext4fs" + +fi + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcry_md_hash_buffer in -lgcrypt" >&5 @@ -7192,7 +7258,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by Xen Hypervisor $as_me 4.2, which was +This file was extended by Xen Hypervisor $as_me 4.3, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7254,7 +7320,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -Xen Hypervisor config.status 4.2 +Xen Hypervisor config.status 4.3 configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" diff --git a/tools/configure.ac b/tools/configure.ac index 703a24bf33..3b3ce42323 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -34,6 +34,7 @@ m4_include([m4/pkg.m4]) m4_include([m4/curses.m4]) m4_include([m4/pthread.m4]) m4_include([m4/ptyfuncs.m4]) +m4_include([m4/extfs.m4]) # Enable/disable options AX_ARG_DEFAULT_DISABLE([githttp], [Download GIT repositories via HTTP]) @@ -131,8 +132,7 @@ AC_SUBST(zlib) AC_CHECK_LIB([aio], [io_setup], [system_aio="y"], [system_aio="n"]) AC_SUBST(system_aio) AC_CHECK_LIB([crypto], [MD5], [], [AC_MSG_ERROR([Could not find libcrypto])]) -AC_CHECK_LIB([ext2fs], [ext2fs_open2], [libext2fs="y"], [libext2fs="n"]) -AC_SUBST(libext2fs) +AX_CHECK_EXTFS AC_CHECK_LIB([gcrypt], [gcry_md_hash_buffer], [libgcrypt="y"], [libgcrypt="n"]) AC_SUBST(libgcrypt) AX_CHECK_PTHREAD diff --git a/tools/libfsimage/Makefile b/tools/libfsimage/Makefile index 5a506f3325..69fd18a820 100644 --- a/tools/libfsimage/Makefile +++ b/tools/libfsimage/Makefile @@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk SUBDIRS-y = common ufs reiserfs iso9660 fat zfs SUBDIRS-$(CONFIG_X86) += xfs -ifeq ($(CONFIG_EXT2FS), y) +ifneq ($(EXTFS_LIBS), ) SUBDIRS-y += ext2fs-lib else SUBDIRS-y += ext2fs diff --git a/tools/libfsimage/ext2fs-lib/Makefile b/tools/libfsimage/ext2fs-lib/Makefile index 142207f63b..671fbffd73 100644 --- a/tools/libfsimage/ext2fs-lib/Makefile +++ b/tools/libfsimage/ext2fs-lib/Makefile @@ -4,7 +4,10 @@ LIB_SRCS-y = ext2fs-lib.c FS = ext2fs-lib -FS_LIBDEPS = -lext2fs +FS_LIBDEPS = $(EXTFS_LIBS) + +# Include configure output (config.h) to headers search path +CFLAGS += -I$(XEN_ROOT)/tools .PHONY: all all: fs-all diff --git a/tools/libfsimage/ext2fs-lib/ext2fs-lib.c b/tools/libfsimage/ext2fs-lib/ext2fs-lib.c index 36a27dc028..ed471465f9 100644 --- a/tools/libfsimage/ext2fs-lib/ext2fs-lib.c +++ b/tools/libfsimage/ext2fs-lib/ext2fs-lib.c @@ -21,8 +21,11 @@ * Use is subject to license terms. */ +/* Include output from configure */ +#include + #include -#include +#include INCLUDE_EXTFS_H #include #include diff --git a/tools/m4/extfs.m4 b/tools/m4/extfs.m4 new file mode 100644 index 0000000000..7309da978d --- /dev/null +++ b/tools/m4/extfs.m4 @@ -0,0 +1,20 @@ +AC_DEFUN([AX_CHECK_EXTFS], [ +AC_CHECK_HEADER([ext2fs/ext2fs.h], [ +AC_CHECK_LIB([ext2fs], [ext2fs_open2], [ + AC_DEFINE([INCLUDE_EXTFS_H], [], + [Define extfs header to use]) + EXTFS_LIBS="-lext2fs" +]) +]) +dnl This is a temporary hack for CentOS 5.x, which split the ext4 support +dnl of ext2fs in a different package. Once CentOS 5.x is no longer supported +dnl we can remove this. +AC_CHECK_HEADER([ext4fs/ext2fs.h], [ +AC_CHECK_LIB([ext4fs], [ext2fs_open2], [ + AC_DEFINE([INCLUDE_EXTFS_H], [], + [Define extfs header to use]) + EXTFS_LIBS="-lext4fs" +]) +]) +AC_SUBST(EXTFS_LIBS) +]) -- cgit v1.2.3