OK, please take a look at this and see if it works for you. - Ted
commit 2c691fd1bacd553b3de44970aa32808d5434cb13 Author: Theodore Ts'o <[EMAIL PROTECTED]> Date: Tue Jan 1 20:05:04 2008 -0500 Use pkg-config to determine where to find the devmapper library Fedora and Red Hat puts the devmapper library in different locations compared to Debian, so we use pkg-config. Unfortunately Debian's devmapper.pc file is buggy (See Debian Bug #390243), so we have to work around it. Historically, e2fsprogs has tried not to depend on pkg-config, since its answers are so often **wrong** (the Debian bug has been ignored for over a year), so I'm hoping I'm not going to regret this. Signed-off-by: "Theodore Ts'o" <[EMAIL PROTECTED]> diff --git a/MCONFIG.in b/MCONFIG.in index c3e7685..8cd2ccf 100644 --- a/MCONFIG.in +++ b/MCONFIG.in @@ -76,8 +76,8 @@ LIBSS = $(LIB)/[EMAIL PROTECTED]@ LIBCOM_ERR = $(LIB)/[EMAIL PROTECTED]@ LIBE2P = $(LIB)/[EMAIL PROTECTED]@ LIBEXT2FS = $(LIB)/[EMAIL PROTECTED]@ -LIBUUID = $(LIB)/[EMAIL PROTECTED]@ @SOCKET_LIB@ -LIBBLKID = $(LIB)/[EMAIL PROTECTED]@ +LIBUUID = $(LIB)/[EMAIL PROTECTED]@ @SOCKET_LIB@ +LIBBLKID = $(LIB)/[EMAIL PROTECTED]@ @STATIC_BLKID_DEVMAPPER_LIBS@ LIBINTL = @LIBINTL@ DEPLIBUUID = $(LIB)/[EMAIL PROTECTED]@ DEPLIBBLKID = $(LIB)/[EMAIL PROTECTED]@ diff --git a/aclocal.m4 b/aclocal.m4 index fc3ed73..3c32c83 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -2649,3 +2649,48 @@ AC_DEFUN([AX_TLS], [ fi AC_MSG_RESULT($ac_cv_tls) ]) + +# Excerpted from pkg.m4 - Macros to locate and utilise pkg-config +# +# Copyright © 2004 Scott James Remnant <[EMAIL PROTECTED]>. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi + +fi[]dnl +])# PKG_PROG_PKG_CONFIG diff --git a/configure b/configure index 8ecc41a..829765f 100755 --- a/configure +++ b/configure @@ -693,10 +693,12 @@ FSCK_PROG FSCK_MAN E2INITRD_PROG E2INITRD_MAN +PKG_CONFIG DEVMAPPER_REQ DEVMAPPER_PC_LIBS DEVMAPPER_LIBS STATIC_DEVMAPPER_LIBS +STATIC_BLKID_DEVMAPPER_LIBS UUIDD_CMT GETTEXT_PACKAGE PACKAGE @@ -786,7 +788,8 @@ CFLAGS LDFLAGS LIBS CPPFLAGS -CPP' +CPP +PKG_CONFIG' # Initialize some variables set by options. @@ -1407,6 +1410,7 @@ Some influential environment variables: CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> CPP C preprocessor + PKG_CONFIG path to pkg-config utility Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -3835,6 +3839,7 @@ echo "Enabling htree directory support by default" fi +E2_PKG_CONFIG_STATIC=--static # Check whether --enable-elf-shlibs was given. if test "${enable_elf_shlibs+set}" = set; then enableval=$enable_elf_shlibs; if test "$enableval" = "no" @@ -3843,6 +3848,7 @@ then MAKEFILE_ELF=/dev/null echo "Disabling ELF shared libraries" else + E2_PKG_CONFIG_STATIC= ELF_CMT= MAKEFILE_ELF=$srcdir/lib/Makefile.elf-lib case "$host_os" in @@ -3872,6 +3878,7 @@ then MAKEFILE_BSDLIB=/dev/null echo "Disabling BSD shared libraries" else + E2_PKG_CONFIG_STATIC= BSDLIB_CMT= MAKEFILE_BSDLIB=$srcdir/lib/Makefile.bsd-lib LIB_EXT=.so @@ -4138,6 +4145,7 @@ fi +STATIC_BLKID_DEVMAPPER_LIBS='' # Check whether --enable-blkid-devmapper was given. if test "${enable_blkid_devmapper+set}" = set; then enableval=$enable_blkid_devmapper; if test "$enableval" = "no" @@ -4153,11 +4161,212 @@ _ACEOF echo "Enabling device-mapper support" - DEVMAPPER_REQ='libselinux libsepol' - DEVMAPPER_PC_LIBS='-ldevmapper' - DEVMAPPER_LIBS='-ldevmapper -lselinux -lsepol -lpthread' - STATIC_DEVMAPPER_LIBS='/usr/lib/libdevmapper.a /usr/lib/libselinux.a /usr/lib/libsepol.a -lpthread' + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5 +echo "${ECHO_T}$PKG_CONFIG" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_PKG_CONFIG"; then + ac_pt_PKG_CONFIG=$PKG_CONFIG + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $ac_pt_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG +if test -n "$ac_pt_PKG_CONFIG"; then + { echo "$as_me:$LINENO: result: $ac_pt_PKG_CONFIG" >&5 +echo "${ECHO_T}$ac_pt_PKG_CONFIG" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_pt_PKG_CONFIG" = x; then + PKG_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to [EMAIL PROTECTED]" >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to [EMAIL PROTECTED]" >&2;} +ac_tool_warned=yes ;; +esac + PKG_CONFIG=$ac_pt_PKG_CONFIG + fi +else + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +fi + +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=0.9.0 + { echo "$as_me:$LINENO: checking pkg-config is at least version $_pkg_min_version" >&5 +echo $ECHO_N "checking pkg-config is at least version $_pkg_min_version... $ECHO_C" >&6; } + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + PKG_CONFIG="" + fi + +fi + + { echo "$as_me:$LINENO: checking for dm_tree_create in -ldevmapper" >&5 +echo $ECHO_N "checking for dm_tree_create in -ldevmapper... $ECHO_C" >&6; } +if test "${ac_cv_lib_devmapper_dm_tree_create+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldevmapper $DEVMAPPER_LIBS $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 dm_tree_create (); +int +main () +{ +return dm_tree_create (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_devmapper_dm_tree_create=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_devmapper_dm_tree_create=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_devmapper_dm_tree_create" >&5 +echo "${ECHO_T}$ac_cv_lib_devmapper_dm_tree_create" >&6; } +if test $ac_cv_lib_devmapper_dm_tree_create = yes; then + DEVMAPPER_LIBS=`$PKG_CONFIG --libs devmapper`; + STATIC_DEVMAPPER_LIBS=`$PKG_CONFIG --static --libs devmapper`; + DEVMAPPER_REQ="devmapper"; + DEVMAPPER_PC_LIBS="-ldevmapper" +else + { { echo "$as_me:$LINENO: error: device-mapper library not found" >&5 +echo "$as_me: error: device-mapper library not found" >&2;} + { (exit 1); exit 1; }; } +fi + + # work around stupid devmapper.pc bug in Debian + case "$STATIC_DEVMAPPER_LIBS" in + *pthread*) + ;; + *) + echo "Working around Debian bug #390243..." + STATIC_DEVMAPPER_LIBS="-pthread $STATIC_DEVMAPPER_LIBS" + ;; + esac + if test "$E2_PKG_CONFIG_STATIC" = "--static"; then + DEVMAPPER_LIBS="$STATIC_DEVMAPPER_LIBS" + STATIC_BLKID_DEVMAPPER_LIBS="$STATIC_DEVMAPPER_LIBS" + fi fi else @@ -4169,6 +4378,7 @@ fi + # Check whether --enable-tls was given. if test "${enable_tls+set}" = set; then enableval=$enable_tls; if test "$enableval" = "no" @@ -15899,10 +16109,12 @@ FSCK_PROG!$FSCK_PROG$ac_delim FSCK_MAN!$FSCK_MAN$ac_delim E2INITRD_PROG!$E2INITRD_PROG$ac_delim E2INITRD_MAN!$E2INITRD_MAN$ac_delim +PKG_CONFIG!$PKG_CONFIG$ac_delim DEVMAPPER_REQ!$DEVMAPPER_REQ$ac_delim DEVMAPPER_PC_LIBS!$DEVMAPPER_PC_LIBS$ac_delim DEVMAPPER_LIBS!$DEVMAPPER_LIBS$ac_delim STATIC_DEVMAPPER_LIBS!$STATIC_DEVMAPPER_LIBS$ac_delim +STATIC_BLKID_DEVMAPPER_LIBS!$STATIC_BLKID_DEVMAPPER_LIBS$ac_delim UUIDD_CMT!$UUIDD_CMT$ac_delim GETTEXT_PACKAGE!$GETTEXT_PACKAGE$ac_delim PACKAGE!$PACKAGE$ac_delim @@ -15979,7 +16191,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 82; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 84; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/configure.in b/configure.in index 16bab32..aee0177 100644 --- a/configure.in +++ b/configure.in @@ -207,6 +207,10 @@ echo "Enabling htree directory support by default" ) AC_SUBST(HTREE_CMT) dnl +dnl This needs to be before all of the --enable-*-shlibs options +dnl +E2_PKG_CONFIG_STATIC=--static +dnl dnl handle --enable-elf-shlibs dnl AC_ARG_ENABLE([elf-shlibs], @@ -217,6 +221,7 @@ then MAKEFILE_ELF=/dev/null echo "Disabling ELF shared libraries" else + E2_PKG_CONFIG_STATIC= ELF_CMT= MAKEFILE_ELF=$srcdir/lib/Makefile.elf-lib [case "$host_os" in @@ -246,6 +251,7 @@ then MAKEFILE_BSDLIB=/dev/null echo "Disabling BSD shared libraries" else + E2_PKG_CONFIG_STATIC= BSDLIB_CMT= MAKEFILE_BSDLIB=$srcdir/lib/Makefile.bsd-lib LIB_EXT=.so @@ -499,6 +505,7 @@ AC_SUBST(E2INITRD_PROG) AC_SUBST(E2INITRD_MAN) dnl handle --enable-blkid-devmapper dnl +STATIC_BLKID_DEVMAPPER_LIBS='' AC_ARG_ENABLE([blkid-devmapper], [ --enable-blkid-devmapper build with device-mapper support], [if test "$enableval" = "no" @@ -511,11 +518,28 @@ else AC_DEFINE(HAVE_DEVMAPPER) echo "Enabling device-mapper support" - DEVMAPPER_REQ='libselinux libsepol' - DEVMAPPER_PC_LIBS='-ldevmapper' - DEVMAPPER_LIBS='-ldevmapper -lselinux -lsepol -lpthread' - STATIC_DEVMAPPER_LIBS='/usr/lib/libdevmapper.a /usr/lib/libselinux.a /usr/lib/libsepol.a -lpthread' - + PKG_PROG_PKG_CONFIG() + + AC_CHECK_LIB(devmapper, dm_tree_create, + [DEVMAPPER_LIBS=`$PKG_CONFIG --libs devmapper`; + STATIC_DEVMAPPER_LIBS=`$PKG_CONFIG --static --libs devmapper`; + DEVMAPPER_REQ="devmapper"; + DEVMAPPER_PC_LIBS="-ldevmapper"], + [AC_MSG_ERROR([device-mapper library not found])], + [$DEVMAPPER_LIBS]) + # work around stupid devmapper.pc bug in Debian + case "$STATIC_DEVMAPPER_LIBS" in + *pthread*) + ;; + *) + echo "Working around Debian bug #390243..." + STATIC_DEVMAPPER_LIBS="-pthread $STATIC_DEVMAPPER_LIBS" + ;; + esac + if test "$E2_PKG_CONFIG_STATIC" = "--static"; then + DEVMAPPER_LIBS="$STATIC_DEVMAPPER_LIBS" + STATIC_BLKID_DEVMAPPER_LIBS="$STATIC_DEVMAPPER_LIBS" + fi fi] , echo "Disabling device-mapper support by default" @@ -524,6 +548,7 @@ AC_SUBST(DEVMAPPER_REQ) AC_SUBST(DEVMAPPER_PC_LIBS) AC_SUBST(DEVMAPPER_LIBS) AC_SUBST(STATIC_DEVMAPPER_LIBS) +AC_SUBST(STATIC_BLKID_DEVMAPPER_LIBS) dnl dnl dnl