diff --git a/configure b/configure index 0d28c5ddaa19cdb4fdcd0580b34221b4d3d3d790..f04449ecc8aaa0b7cbfc804255a1e93e76b480a7 100755 --- a/configure +++ b/configure @@ -660,6 +660,7 @@ ac_subst_files='' ac_user_opts=' enable_option_checking with_zlib +with_bzlib with_mpi enable_ld_preload with_mem_align @@ -1294,6 +1295,9 @@ Optional Packages: --with-zlib=DIR root directory path of zlib installation defaults to /usr/local or /usr if not found in /usr/local --without-zlib to disable zlib usage completely + --with-bzlib=DIR root directory path of bzlib installation defaults to + /usr/local or /usr if not found in /usr/local + --without-bzlib to disable bzlib usage completely --with-mpi= Location of the MPI installation --with-mem-align= Memory alignment in bytes --with-zlib-for-mpi= base dir for zlib to use on mpi processes @@ -3565,6 +3569,181 @@ $as_echo "failed" >&6; } fi +# +# Handle user hints +# +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if bzlib is wanted" >&5 +$as_echo_n "checking if bzlib is wanted... " >&6; } + +# Check whether --with-bzlib was given. +if test "${with_bzlib+set}" = set; then : + withval=$with_bzlib; if test "$withval" != no ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + if test -d "$withval" + then + BZLIB_HOME="$withval" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Sorry, $withval does not exist, checking usual places" >&5 +$as_echo "$as_me: WARNING: Sorry, $withval does not exist, checking usual places" >&2;} + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +fi + + +BZLIB_HOME=/usr/local +if test ! -f "${BZLIB_HOME}/include/bzlib.h" +then + BZLIB_HOME=/usr +fi + +# +# Locate bzlib, if wanted +# +if test -n "${BZLIB_HOME}" +then + BZLIB_OLD_LDFLAGS=$LDFLAGS + BZLIB_OLD_CPPFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -L${BZLIB_HOME}/lib" + CPPFLAGS="$CPPFLAGS -I${BZLIB_HOME}/include" + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompressInit in -lbz2" >&5 +$as_echo_n "checking for BZ2_bzCompressInit in -lbz2... " >&6; } +if test "${ac_cv_lib_bz2_BZ2_bzCompressInit+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lbz2 $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 BZ2_bzCompressInit (); +int +main () +{ +return BZ2_bzCompressInit (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_bz2_BZ2_bzCompressInit=yes +else + ac_cv_lib_bz2_BZ2_bzCompressInit=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_bz2_BZ2_bzCompressInit" >&5 +$as_echo "$ac_cv_lib_bz2_BZ2_bzCompressInit" >&6; } +if test "x$ac_cv_lib_bz2_BZ2_bzCompressInit" = x""yes; then : + bzlib_cv_libbz2=yes +else + bzlib_cv_libbz2=no +fi + + ac_fn_c_check_header_mongrel "$LINENO" "bzlib.h" "ac_cv_header_bzlib_h" "$ac_includes_default" +if test "x$ac_cv_header_bzlib_h" = x""yes; then : + bzlib_cv_bzlib_h=yes +else + bzlib_cv_bzlib_h=no +fi + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$bzlib_cv_libbz2" = "yes" -a "$bzlib_cv_bzlib_h" = "yes" + then + # + # If both library and header were found, use them + # + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompressInit in -lbz2" >&5 +$as_echo_n "checking for BZ2_bzCompressInit in -lbz2... " >&6; } +if test "${ac_cv_lib_bz2_BZ2_bzCompressInit+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lbz2 $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 BZ2_bzCompressInit (); +int +main () +{ +return BZ2_bzCompressInit (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_bz2_BZ2_bzCompressInit=yes +else + ac_cv_lib_bz2_BZ2_bzCompressInit=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_bz2_BZ2_bzCompressInit" >&5 +$as_echo "$ac_cv_lib_bz2_BZ2_bzCompressInit" >&6; } +if test "x$ac_cv_lib_bz2_BZ2_bzCompressInit" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBBZ2 1 +_ACEOF + + LIBS="-lbz2 $LIBS" + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking bzlib in ${BZLIB_HOME}" >&5 +$as_echo_n "checking bzlib in ${BZLIB_HOME}... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } + else + # + # If either header or library was not found, revert and bomb + # + { $as_echo "$as_me:${as_lineno-$LINENO}: checking bzlib in ${BZLIB_HOME}" >&5 +$as_echo_n "checking bzlib in ${BZLIB_HOME}... " >&6; } + LDFLAGS="$BZLIB_OLD_LDFLAGS" + CPPFLAGS="$BZLIB_OLD_CPPFLAGS" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 +$as_echo "failed" >&6; } +# Don't fail; this is optional in Darshan +# AC_MSG_ERROR(either specify a valid bzlib installation with --with-bzlib=DIR or disable bzlib usage with --without-bzlib) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libbz2 not found; Darshan utilities will use gzip only." >&5 +$as_echo "$as_me: WARNING: libbz2 not found; Darshan utilities will use gzip only." >&2;} + fi +fi + + # Check whether --with-mpi was given. diff --git a/configure.in b/configure.in index 1235aa1aa27744a543e0f567d6f088fa8f7c96e9..cbc4727d1ea21b8706ab470ecd8d6c1d95f3c389 100644 --- a/configure.in +++ b/configure.in @@ -12,6 +12,7 @@ AC_CONFIG_HEADER(darshan-config.h) AC_PROG_INSTALL CHECK_ZLIB +CHECK_BZLIB AC_ARG_WITH(mpi, [ --with-mpi= Location of the MPI installation], diff --git a/darshan-config.h.in b/darshan-config.h.in index fd1231bd2986043eeda15c396aeff82d33ff741e..de48378e306ab7a10c27a1d62e956de3f2cb1a3c 100644 --- a/darshan-config.h.in +++ b/darshan-config.h.in @@ -9,6 +9,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H +/* Define to 1 if you have the `bz2' library (-lbz2). */ +#undef HAVE_LIBBZ2 + /* Define to 1 if you have the `z' library (-lz). */ #undef HAVE_LIBZ diff --git a/maint/config/check_bzlib.m4 b/maint/config/check_bzlib.m4 new file mode 100644 index 0000000000000000000000000000000000000000..65aedb129958e2f3ad501f2e75ad6a390b98d6bc --- /dev/null +++ b/maint/config/check_bzlib.m4 @@ -0,0 +1,91 @@ +dnl @synopsis CHECK_BZLIB() +dnl +dnl This macro searches for an installed bzlib library. If nothing was +dnl specified when calling configure, it searches first in /usr/local +dnl and then in /usr. If the --with-bzlib=DIR is specified, it will try +dnl to find it in DIR/include/bzlib.h and DIR/lib/libbz2.a. If +dnl --without-bzlib is specified, the library is not searched at all. +dnl +dnl If either the header file (bzlib.h) or the library (libbz2) is not +dnl found, the configuration exits on error, asking for a valid bzlib +dnl installation directory or --without-bzlib. +dnl +dnl The macro defines the symbol HAVE_LIBBZ2 if the library is found. You +dnl should use autoheader to include a definition for this symbol in a +dnl config.h file. Sample usage in a C/C++ source is as follows: +dnl +dnl #ifdef HAVE_LIBBZ2 +dnl #include +dnl #endif /* HAVE_LIBBZ2 */ +dnl +dnl @category InstalledPackages +dnl @author Loic Dachary +dnl @version 2004-09-20 +dnl @license GPLWithACException + +AC_DEFUN([CHECK_BZLIB], +# +# Handle user hints +# +[AC_MSG_CHECKING(if bzlib is wanted) +AC_ARG_WITH(bzlib, +[ --with-bzlib=DIR root directory path of bzlib installation [defaults to + /usr/local or /usr if not found in /usr/local] + --without-bzlib to disable bzlib usage completely], +[if test "$withval" != no ; then + AC_MSG_RESULT(yes) + if test -d "$withval" + then + BZLIB_HOME="$withval" + else + AC_MSG_WARN([Sorry, $withval does not exist, checking usual places]) + fi +else + AC_MSG_RESULT(no) +fi]) + +BZLIB_HOME=/usr/local +if test ! -f "${BZLIB_HOME}/include/bzlib.h" +then + BZLIB_HOME=/usr +fi + +# +# Locate bzlib, if wanted +# +if test -n "${BZLIB_HOME}" +then + BZLIB_OLD_LDFLAGS=$LDFLAGS + BZLIB_OLD_CPPFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -L${BZLIB_HOME}/lib" + CPPFLAGS="$CPPFLAGS -I${BZLIB_HOME}/include" + AC_LANG_SAVE + AC_LANG_C + AC_CHECK_LIB(bz2, BZ2_bzCompressInit, [bzlib_cv_libbz2=yes], [bzlib_cv_libbz2=no]) + AC_CHECK_HEADER(bzlib.h, [bzlib_cv_bzlib_h=yes], [bzlib_cv_bzlib_h=no]) + AC_LANG_RESTORE + if test "$bzlib_cv_libbz2" = "yes" -a "$bzlib_cv_bzlib_h" = "yes" + then + # + # If both library and header were found, use them + # + AC_CHECK_LIB(bz2, BZ2_bzCompressInit) + AC_MSG_CHECKING(bzlib in ${BZLIB_HOME}) + AC_MSG_RESULT(ok) + else + # + # If either header or library was not found, revert and bomb + # + AC_MSG_CHECKING(bzlib in ${BZLIB_HOME}) + LDFLAGS="$BZLIB_OLD_LDFLAGS" + CPPFLAGS="$BZLIB_OLD_CPPFLAGS" + AC_MSG_RESULT(failed) +# Don't fail; this is optional in Darshan +# AC_MSG_ERROR(either specify a valid bzlib installation with --with-bzlib=DIR or disable bzlib usage with --without-bzlib) +# TODO: it would be nice if this showed up at the _end_ of +# configure... + AC_MSG_WARN(libbz2 not found; Darshan utilities will use gzip only.) + fi +fi + +])