Commit 74c16584 authored by Philip Carns's avatar Philip Carns

autoconf tests for bz2 library


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@433 3b7491f3-a168-0410-bf4b-c445ed680a29
parent 93612809
......@@ -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=<dir> Location of the MPI installation
--with-mem-align=<num> Memory alignment in bytes
--with-zlib-for-mpi=<dir> 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.
......
......@@ -12,6 +12,7 @@ AC_CONFIG_HEADER(darshan-config.h)
AC_PROG_INSTALL
CHECK_ZLIB
CHECK_BZLIB
AC_ARG_WITH(mpi,
[ --with-mpi=<dir> Location of the MPI installation],
......
......@@ -9,6 +9,9 @@
/* Define to 1 if you have the <inttypes.h> 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
......
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 <bzlib.h>
dnl #endif /* HAVE_LIBBZ2 */
dnl
dnl @category InstalledPackages
dnl @author Loic Dachary <loic@senga.org>
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
])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment