Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
232 changes: 232 additions & 0 deletions config/opal_check_package2.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
dnl -*- autoconf -*-
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2012-2017 Cisco Systems, Inc. All rights reserved.
dnl Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
dnl Copyright (c) 2014 Intel, Inc. All rights reserved.
dnl Copyright (c) 2015-2018 Research Organization for Information Science
dnl and Technology (RIST). All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl

dnl OPAL_DECLARE_PACKAGE(name,[help],[cppflagshelp],[ldflagshelp])
AC_DEFUN([OPAL_DECLARE_PACKAGE],[
AC_ARG_WITH([$1], [AC_HELP_STRING([--with-$1=DIR], [$2])])
AC_ARG_WITH([$1-cppflags], [AC_HELP_STRING([--with-$1-cppflags=FLAGS], [$3])])
AC_ARG_WITH([$1-ldflags], [AC_HELP_STRING([--with-$1-ldflags=FLAGS], [$4])])
AC_ARG_WITH([$1-libdir], [AC_HELP_STRING([--with-$1-libdir=DIR],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to split OPAL_DECLARE_PACKAGE and OPAL_DECLARE_PACKAGE_DEPRECATED, with only _DEPRECATED adding --with-$1-libdir. Otherwise, we end up adding a deprecated argument for new components, which is weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair point, I will update this.

[Deprecated, use --with-$1-ldflags instead])])
AS_IF([test -n "$with_$1_libdir"],
[AS_IF([test -n "$with_$1_ldflags"],
[AC_MSG_WARN([It is not possible to use both --with-$1-ldflags and --with-$1-libdir])
AC_MSG_ERROR([Cannot continue])],
[AC_MSG_WARN([--with_$1_libdir=DIR is deprecated, use --with-$1_ldflags=FLAGS instead])
with_$1_ldflags="-L$with_$1_libdir"])])
])

dnl --------------------------------------------------------------------
dnl _OPAL_CHECK_PACKAGE2_HEADER(package, prefix, header, includes,
dnl [action-if-found], [action-if-not-found])
dnl --------------------------------------------------------------------
AC_DEFUN([_OPAL_CHECK_PACKAGE2_HEADER], [
AS_VAR_PUSHDEF([opal_With], [with_$1])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This capitalization kind of makes me ragey. Why the semi-CamelCase, with underscores?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opal_Lib and opal_Header have been around for a while, but I get your point and will update this too.

AS_VAR_PUSHDEF([opal_Cppflags], [with_$1_cppflags])

AS_IF([test -n "$opal_Cppflags"],
[$2_CPPFLAGS="$$2_CPPFLAGS $opal_Cppflags"
CPPFLAGS="$CPPFLAGS $opal_Cppflags"
AC_CHECK_HEADERS([$3], [$5], [$6], [$4])],
[AS_IF([test -z "$opal_With" || test "$opal_With" = "yes"],
[AC_CHECK_HEADERS([$3], [$5], [$6], [$4])],
[AS_IF([test -r "$opal_With/$3"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We agreed we were getting rid of this, didn't we? We were only going to check with_dir/include if with_cppflags wasn't set. There should only need to be a single call to AC_CHECK_HEADERS in this function, with a simple set if if statements to set CPPFLAGS as needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current code does not check DIR nor DIR/include if --with-FOO-cppflags is set, did I get that part wrong ?
Also, the current code fails if --with-FOO-cppflags is not used and nor DIR/header.h nor DIR/include/header.h exists. If we move to a single AC_CHECK_HEADERS invokation, handling this bozo case might be a bit convoluted. I am open to suggestions though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ggouaillardet I think the use of the test -n option is what confused here - I honestly don't think we have used that variation elsewhere. Nothing wrong with it - just something I had to look up (and ask about), and still trip over until I get used to it.

The code looks generally correct to me. If they provide the cppflags option, then we just use it. If not, then we check std locations if opal_with is empty or "yes", then DIR, and then DIR/include. The only thing I believe we might change is to reduce the complexity a bit.

I believe what @bwbarrett was getting at is that you could use all those AS_IF's to simply set a local cppflags value, and then set CPPFLAGS and have a single call to AC_CHECK_HEADERS at the end. Would significantly simplify the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test -n didn't confuse me. I was saying that the code structure is way more complicated than it needs to be. It should be something like:

AS_IF([test -n "$with_FOO_cppflags"], [CPPFLAGS=$with_FOO_cppflags],
  AS_IF([test -n "$with_FOO" != "yes"], [CPPFLAGS=$with_foo/include])])
AC_CHECK_HEADERS([....])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhc54 @bwbarrett my question was how to elegantly handle the case in which --with-FOO-cppflags is not set and --with-FOO=DIR is used and nor DIR/foo.h nor DIR/include/foo.h exist.
Ideally, it would fail without aborting nor invoking AC_CHECK_HEADERS.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that ensuring DIR/include/foo.h (and remember, we're NOT checking for DIR/foo.h) is important. If you feel strongly that it is for the case of --with-dir, I'd do something like:

if test -n "$with_FOO_cppflags" ; then
   add_CPPFLAGS="$with_FOO_cppflags"
elif test "$with_FOO" != "yes"; then
    if test ! -r "$with_FOO/include/$header_file"; then
         AC_MSG_ERROR([Didn't find expected header <blah> in <blah>.])
    fi
   add_CPPFLAGS="-I$with_FOO/include"
fi
CPPFLAGS=$CPPFLAGS $add_CPPFLAGS
AC_CHECK_HEADERS

Again, this all got so complicated it had a billion unintended side effects. Our whole goal is to get back to simple, even if we miss some corner cases in testing; we can define what we do, how it doesn't do what the user may want, but that the important part is IT'S DEFINED.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh??? Part of this whole thing was to ensure that we do check for DIR/foo.h, and then for DIR/include/foo.h, as that is where multiple vendors install by default. I don't understand why that is objectionable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's terrible. --with-FOO should never add DIR/foo.h. The whole point of this change is to add --with-FOO-cppflags so that if the header was in an odd spot, customers could add the right CPPFLAGS to get what they need. DIR/foo.h adds a really dangerous -I flag in all but some corner-case situations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I give up - this has morphed into something that doesn't appear to meet my needs at all. I'll just hardcode what I need into the .m4's where I need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bwbarett One motivation for the change is to allow users to install their include files in a non standard location (in this case, it was /usr/include/pmix instead of /usr/include), so we cannot assume we only need to append /include to DIR and look for headers there.

That being said, and since --with-FOO-cppflags and --with-FOO-ldflags are new options, the new macro will have to differ between master and the release branches for a while. As far as I am concerned, I would be fine testing for DIR/foo.h only in the release branches, and master not testing it (since --with-FOO-cppflags can be used to achieve the same goal).

@rhc54 is this acceptable for you ?

[$2_CPPFLAGS="$$2_CPPFLAGS -I$opal_With"
CPPFLAGS="$CPPFLAGS -I$opal_With"
AC_CHECK_HEADERS([$3], [$5], [$6], [$4])],
[AS_IF([test -r "$opal_With/include/$3"],
[$2_CPPFLAGS="$$2_CPPFLAGS -I$opal_With/include"
CPPFLAGS="$CPPFLAGS -I$opal_With/include"
AC_CHECK_HEADERS([$3], [$5], [$6], [$4])],
[$6])])])])

AS_VAR_POPDEF([opal_Cppflags])
AS_VAR_POPDEF([opal_With])
])

dnl _OPAL_CHECK_PACKAGE2_LIB(package, prefix, function, library, extra-libraries,
dnl [action-if-found], [action-if-not-found]])
dnl --------------------------------------------------------------------
AC_DEFUN([_OPAL_CHECK_PACKAGE2_LIB], [
# This is stolen from autoconf to peek under the covers to get the
# cache variable for the library check. one should not copy this
# code into other places unless you want much pain and suffering
AS_VAR_PUSHDEF([opal_Lib], [ac_cv_search_$3])

# so this sucks, but there's no way to get through the progression
# of search libs without killing off the cache variable and trying
# again...
unset opal_Lib
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, we were going to get rid of all this...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am puzzled. do we want to check DIR/lib64 when there is stuff in DIR/lib but AC_CHECK_LIB fails ? If yes, I am afraid we do need something like that, though we should update opal_Lib (or whatever its new name will be) since we moved from AC_SEARCH_LIBS to AC_CHECK_LIB. Makes sense ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ggouaillardet I believe what @bwbarrett is saying is that we agreed not to run AC_CHECK_LIB at all if they provided a location, either in the ldflags option or in a non-default setting of the "with" option. Reason is that you'll get a false positive if the lib in the std location passes the test, even if the lib in the specified location fails. So the best you can do is check for existence in lib and lib64, and if found, then set LDFLAGS and move on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, what @rhc54 said.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhc54 @bwbarrett let me put it this way.

If an end user configure --with-FOO=DIR and in the worst case scenario, you'd rather have configure success (and make might either crash because DIR/lib/libfoo.so is missing the required symbol, or silently use the libraries in the default location because DIR/lib/libfoo.so has the wrong bitness or the linker only accepts static library that is not there) than, silently use a working library in the default location instead or DIR/lib[64].

I fully understand there is not a perfect solution here.

If this is what we want, they I will make the changes, even if I believe this would be a regression (e.g. make fails and we could have trapped that in configure but we chose not to try).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you missed the point. Your configure logic is going to succeed anyway because AC_CHECK_LIB is going to do exactly what you just described - it is a compile test, and so the compiler is going to walk thru all those options and find a working library somewhere, but not necessarily the one you specified. Setting LDFLAGS does not limit the compiler to looking at just that directory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AC_CHECK_LIB is a link test. If --with-foo=DIR (or --with-foo-ldflags) found a library, that's the library it found. That library has the function that's important, in a way that's linkable (has the right size, bitness, static vs. dynamic, etc.). There's still a versioning problem and if callers are sensitive to a particular version, then they probably need extra tests in the higher level check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhc54 I fully understand AC_CHECK_LIB might lead to false positives if libfoo.so in DIR/lib is not usable. (And if it is usable, then this is the one that will be used, not the one in /usr/lib64).

13 days ago, you wrote

I thought we were going to revise the lib section to avoid use of AC_SEARCH_LIB and use AC_CHECK_LIB instead, and only after checking for existence of the specified lib in the target location?

and yesterday

I believe what @bwbarrett is saying is that we agreed not to run AC_CHECK_LIB at all if they provided a location, either in the ldflags option or in a non-default setting of the "with" option.

The only point in my previous comment was if we simply do not run AC_CHECK_LIB at all, then we not only keep the same false positives (and there is virtually nothing we can do about that), but we also miss some false negatives (e.g. configure successes, but make will fail).

And once again, if both of you (@rhc54 and @bwbarrett ) still agree Open MPI should not run AC_CHECK_LIB at all (when --with-FOO-ldflags=LDFLAGS or --with-FOO=DIR is used), then I will implement this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have given up - my head has been spun around on this so many times, I've lost count. You guys do whatever you want.


AS_VAR_PUSHDEF([opal_With], [with_$1])
AS_VAR_PUSHDEF([opal_Ldflags], [with_$1_ldflags])

opal_check_package2_lib_happy="no"
AS_IF([test -n "$opal_Ldflags"],
[# ldflags was specified - use as is
$2_LDFLAGS="$$2_LDFLAGS $opal_Ldflags"
LDFLAGS="$LDFLAGS $opal_Ldflags"
AC_CHECK_LIB([$4], [$3],
[opal_check_package2_lib_happy="yes"],
[opal_check_package2_lib_happy="no"], [$5])
AS_IF([test "$opal_check_package2_lib_happy" = "no"],
[LDFLAGS="$opal_check_package_$2_save_LDFLAGS"
$2_LDFLAGS="$opal_check_package_$2_orig_LDFLAGS"
unset opal_Lib])],
[AS_IF([test -z "$opal_With" || test "$opal_With" = "yes"],
[# no path specified, try the default AC_SEARCH_LIBS
AC_VERBOSE([looking for library without search path])
AC_SEARCH_LIBS([$3], [$4],
[opal_check_package2_lib_happy="yes"],
[opal_check_package2_lib_happy="no"], [$5])
AS_IF([test "$opal_check_package2_lib_happy" = "no"],
[unset opal_Lib])],
[# --with-foo=DIR was specified, try DIR/lib and DIR/lib64 if libraries exist
files=`ls $opal_With/lib/lib$4.* 2> /dev/null | wc -l`
AS_IF([test $files -gt 0],
[$2_LDFLAGS="$$2_LDFLAGS -L$opal_With/lib"
LDFLAGS="$LDFLAGS -L$opal_With/lib"
AC_VERBOSE([looking for library in lib])
AC_CHECK_LIB([$4], [$3],
[opal_check_package2_lib_happy="yes"],
[opal_check_package2_lib_happy="no"], [$5])
AS_IF([test "$opal_check_package2_lib_happy" = "no"],
[# no go on the as is.. see what happens later...
LDFLAGS="$opal_check_package_$2_save_LDFLAGS"
$2_LDFLAGS="$opal_check_package_$2_orig_LDFLAGS"
unset opal_Lib])])
files=`ls $opal_With/lib64/lib$4.* 2> /dev/null | wc -l`
AS_IF([test "$opal_check_package2_lib_happy" = "no" && test -$files -gt 0],
[$2_LDFLAGS="$$2_LDFLAGS -L$opal_With/lib64"
LDFLAGS="$LDFLAGS -L$opal_With/lib64"
AC_VERBOSE([looking for library in lib64])
AC_CHECK_LIB([$4], [$3],
[opal_check_package2_lib_happy="yes"],
[opal_check_package2_lib_happy="no"], [$5])
AS_IF([test "$opal_check_package2_lib_happy" = "no"],
[# no go on the as is.. see what happens later...
LDFLAGS="$opal_check_package_$2_save_LDFLAGS"
$2_LDFLAGS="$opal_check_package_$2_orig_LDFLAGS"
unset opal_Lib])])])])

AS_IF([test "$opal_check_package2_lib_happy" = "yes"],
[ # libnl v1 and libnl3 are known to *not* coexist
# harmoniously in the same process. Check to see if this
# new package will introduce such a conflict.
OPAL_LIBNL_SANITY_CHECK([$4], [$3], [$$2_LIBS],
[opal_check_package_libnl_check_ok])
AS_IF([test $opal_check_package_libnl_check_ok -eq 0],
[opal_check_package2_lib_happy=no])
])

AS_IF([test "$opal_check_package2_lib_happy" = "yes"],
[ # The result of AC SEARCH_LIBS is cached in $ac_cv_search_[function]
AS_IF([test "$ac_cv_search_$3" != "no" &&
test "$ac_cv_search_$3" != "none required"],
[$2_LIBS="$ac_cv_search_$3 $5"],
[$2_LIBS="$5"])
$6],
[$7])

AS_VAR_POPDEF([opal_Ldflags])dnl
AS_VAR_POPDEF([opal_With])dnl
AS_VAR_POPDEF([opal_Lib])dnl
])

dnl OPAL_CHECK_PACKAGE(package,
dnl prefix,
dnl header,
dnl includes,
dnl function,
dnl library,
dnl extra-libraries,
dnl [action-if-found],
dnl [action-if-not-found])
dnl -----------------------------------------------------------
dnl Check for package defined by header and libs, and probably
dnl located in dir-prefix, possibly with libs in libdir-prefix.
dnl Both dir-prefix and libdir-prefix can be empty. Will set
dnl prefix_{CPPFLAGS, LDFLAGS, LIBS} as needed.
dnl
dnl The general intent of this macro is to provide finer-grained scoping
dnl of C preprocessor flags, linker flags, and libraries (as opposed to
dnl unconditionally adding to the top-level CPFLAGS, LDFLAGS, and LIBS,
dnl which get used to compile/link *everything*).
dnl
dnl Here is a breakdown of the parameters:
dnl
dnl * package: the macro checks $with_$package, $with_$package_cppflags
dnl and $with_$package_ldflags
dnl * prefix: the macro sets $prefix_CPPFLAGS, $prefix_LDFLAGS, and
dnl $prefix_LIBS (and AC_SUBSTs all of them). For example, if a
dnl provider uses this macro to check for a header/library that it
dnl needs, it might well set prefix to be its provider name.
dnl * header: the foo.h file to check for
dnl * includes: if including header_filename requires additional
dnl headers to be included first, list them here
dnl * function/library: check for function $function in
dnl -l$library. Specifically, for $library, use the "foo" form,
dnl as opposed to "libfoo".
dnl * extra_libraries: if the $library you are checking for requires
dnl additonal -l arguments to link successfully, list them here.
dnl * action_if_found: if both the header and library are found and
dnl usable, execute action_if_found
dnl * action_if_not_found: otherwise, execute action_if_not_found
dnl
dnl The output _CPPFLAGS, _LDFLAGS, and _LIBS can be used to limit the
dnl scope various flags in Makefiles.
dnl
AC_DEFUN([OPAL_CHECK_PACKAGE2],[
OPAL_VAR_SCOPE_PUSH([opal_check_package2_happy opal_check_package_$2_save_CPPFLAGS opal_check_package_$2_save_LDFLAGS opal_check_package_$2_save_LIBS opal_check_package_$2_orig_CPPFLAGS opal_check_package_$2_orig_LDFLAGS opal_check_package_$2_orig_LIBS opal_check_package2_lib_happy])
opal_check_package_$2_save_CPPFLAGS="$CPPFLAGS"
opal_check_package_$2_save_LDFLAGS="$LDFLAGS"
opal_check_package_$2_save_LIBS="$LIBS"

opal_check_package_$2_orig_CPPFLAGS="$$2_CPPFLAGS"
opal_check_package_$2_orig_LDFLAGS="$$2_LDFLAGS"
opal_check_package_$2_orig_LIBS="$$2_LIBS"

AS_VAR_PUSHDEF([opal_With], [with_$1])

AS_IF([test "$opal_With" != "no"],
[_OPAL_CHECK_PACKAGE2_HEADER([$1], [$2], [$3], [$4],
[_OPAL_CHECK_PACKAGE2_LIB([$1], [$2], [$5], [$6], [$7],
[opal_check_package2_happy="yes"],
[opal_check_package2_happy="no"])])])

AS_IF([test "$opal_check_package2_happy" = "yes"],
[$8],
[$2_CPPFLAGS="$opal_check_package_$2_orig_CPPFLAGS"
$2_LDFLAGS="$opal_check_package_$2_orig_LDFLAGS"
$2_LIBS="$opal_check_package_$2_orig_LIBS"
$9])


CPPFLAGS="$opal_check_package_$2_save_CPPFLAGS"
LDFLAGS="$opal_check_package_$2_save_LDFLAGS"
LIBS="$opal_check_package_$2_save_LIBS"

AS_VAR_POPDEF([opal_With])dnl
OPAL_VAR_SCOPE_POP
])
80 changes: 21 additions & 59 deletions config/opal_setup_zlib.m4
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- shell-script -*-
# -*- autocont -*-
#
# Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved.
# Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
# Copyright (c) 2017 Research Organization for Information Science
# Copyright (c) 2017-2018 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# $COPYRIGHT$
#
Expand All @@ -15,62 +15,25 @@
# MCA_zlib_CONFIG([action-if-found], [action-if-not-found])
# --------------------------------------------------------------------
AC_DEFUN([OPAL_ZLIB_CONFIG],[
OPAL_VAR_SCOPE_PUSH([opal_zlib_dir opal_zlib_libdir opal_zlib_standard_header_location opal_zlib_standard_lib_location])

AC_ARG_WITH([zlib],
[AC_HELP_STRING([--with-zlib=DIR],
[Search for zlib headers and libraries in DIR ])])

AC_ARG_WITH([zlib-libdir],
[AC_HELP_STRING([--with-zlib-libdir=DIR],
[Search for zlib libraries in DIR ])])

opal_zlib_support=0
if test "$with_zlib" != "no"; then
AC_MSG_CHECKING([for zlib in])
if test ! -z "$with_zlib" && test "$with_zlib" != "yes"; then
opal_zlib_dir=$with_zlib
opal_zlib_standard_header_location=no
opal_zlib_standard_lib_location=no
AS_IF([test -z "$with_zlib_libdir" || test "$with_zlib_libdir" = "yes"],
[if test -d $with_zlib/lib; then
opal_zlib_libdir=$with_zlib/lib
elif test -d $with_zlib/lib64; then
opal_zlib_libdir=$with_zlib/lib64
else
AC_MSG_RESULT([Could not find $with_zlib/lib or $with_zlib/lib64])
AC_MSG_ERROR([Can not continue])
fi
AC_MSG_RESULT([$opal_zlib_dir and $opal_zlib_libdir])],
[AC_MSG_RESULT([$with_zlib_libdir])])
else
AC_MSG_RESULT([(default search paths)])
opal_zlib_standard_header_location=yes
opal_zlib_standard_lib_location=yes
fi
AS_IF([test ! -z "$with_zlib_libdir" && test "$with_zlib_libdir" != "yes"],
[opal_zlib_libdir="$with_zlib_libdir"
opal_zlib_standard_lib_location=no])

OPAL_CHECK_PACKAGE([opal_zlib],
[zlib.h],
[z],
[deflate],
[-lz],
[$opal_zlib_dir],
[$opal_zlib_libdir],
[opal_zlib_support=1],
[opal_zlib_support=0])
if test $opal_zlib_support = "1"; then
LIBS="$LIBS -lz"
if test "$opal_zlib_standard_header_location" != "yes"; then
CPPFLAGS="$CPPFLAGS $opal_zlib_CPPFLAGS"
fi
if test "$opal_zlib_standard_lib_location" != "yes"; then
LDFLAGS="$LDFLAGS $opal_zlib_LDFLAGS"
fi
fi
fi
OPAL_DECLARE_PACKAGE([zlib],
[Search for zlib headers and libraries in DIR],
[Search for zlib headers with these CPPFLAGS],
[Search for zlib library with these LDFLAGS])

OPAL_CHECK_PACKAGE2([zlib],
[opal_zlib],
[zlib.h],
[],
[deflate],
[z],
[],
[opal_zlib_support=1],
[opal_zlib_support=0])

AS_IF([test $opal_zlib_support -eq 1],
[LIBS="$LIBS -lz"
CPPFLAGS="$CPPFLAGS $opal_zlib_CPPFLAGS"
LDFLAGS="$LDFLAGS $opal_zlib_LDFLAGS"])

if test ! -z "$with_zlib" && test "$with_zlib" != "no" && test "$opal_zlib_support" != "1"; then
AC_MSG_WARN([ZLIB SUPPORT REQUESTED AND NOT FOUND])
Expand All @@ -86,5 +49,4 @@ AC_DEFUN([OPAL_ZLIB_CONFIG],[

AC_DEFINE_UNQUOTED([OPAL_HAVE_ZLIB], [$opal_zlib_support],
[Whether or not we have zlib support])
OPAL_VAR_SCOPE_POP
])dnl
Loading