-
Notifications
You must be signed in to change notification settings - Fork 924
configury: revamp the OPAL_CHECK_PACKAGE macro #4823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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], | ||
[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]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current code does not check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ggouaillardet I think the use of the 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 That being said, and since @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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, we were going to get rid of all this... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am puzzled. do we want to check There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, what @rhc54 said. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rhc54 @bwbarrett let me put it this way. If an end user 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rhc54 I fully understand 13 days ago, you wrote
and yesterday
The only point in my previous comment was if we simply do not run And once again, if both of you (@rhc54 and @bwbarrett ) still agree Open MPI should not run There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
]) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.