From 6b3dce2ab984c83dc7df1706aab435ac2a966509 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Fri, 16 Feb 2018 20:03:28 +0900 Subject: [PATCH 1/3] configury: revamp the OPAL_CHECK_PACKAGE macro add the OPAL_DEFINE_PACKAGE helper that define --with-FOO=DIR --with-FOO-cppflags=FLAGS --with-FOO-ldflags=FLAGS --with-FOO-libdir=DIR (deprecated) OPAL_CHECK_PACKAGE2(prefix, header, library, function, extra-libraries, package, [action-if-found], [action-if-not-found], includes) is much easier to use and handle most of the work under the hood. Signed-off-by: Gilles Gouaillardet --- config/opal_check_package2.m4 | 237 +++++++++++++++++++++++++++ config/opal_setup_zlib.m4 | 77 +++------ opal/mca/event/external/configure.m4 | 79 +++------ 3 files changed, 281 insertions(+), 112 deletions(-) create mode 100644 config/opal_check_package2.m4 diff --git a/config/opal_check_package2.m4 b/config/opal_check_package2.m4 new file mode 100644 index 00000000000..e167670b11a --- /dev/null +++ b/config/opal_check_package2.m4 @@ -0,0 +1,237 @@ +dnl -*- shell-script -*- +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(prefix, header, cppflags, +dnl [action-if-found], [action-if-not-found], +dnl includes) +dnl -------------------------------------------------------------------- +AC_DEFUN([_OPAL_CHECK_PACKAGE2_HEADER], [ + # 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_Header], [ac_cv_header_$2]) + + # so this sucks, but there's no way to get through the progression + # of header includes without killing off the cache variable and trying + # again... + unset opal_Header + + # get rid of the trailing slash(es) + opal_check_package_header_happy="no" + AS_IF([test -z "$3"], + [# try as is... + AC_VERBOSE([looking for header]) + AC_CHECK_HEADERS([$2], [opal_check_package_header_happy="yes"], []) + AS_IF([test "$opal_check_package_header_happy" = "no"], + [# no go on the as is - reset the cache and try again + unset opal_Header])], + [$1_CPPFLAGS="$$1_CPPFLAGS $3" + CPPFLAGS="$CPPFLAGS $3" + AC_CHECK_HEADERS([$2], [opal_check_package_header_happy="yes"], [], [$6])]) + + AS_IF([test "$opal_check_package_header_happy" = "yes"], [$4], [$5]) + unset opal_check_package_header_happy + + AS_VAR_POPDEF([opal_Header])dnl +]) + + +dnl _OPAL_CHECK_PACKAGE2_LIB(prefix, library, function, extra-libraries, +dnl package, +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]) + + # see comment above + unset opal_Lib + opal_check_package_lib_happy="no" + AS_IF([test -n "$with_$5_ldflags" || test -z "$with_$5" || test "$with_$5" = "yes"], + [# ldflags was specified - use as is + $1_LDFLAGS="$$1_LDFLAGS $with_$5_ldflags" + LDFLAGS="$LDFLAGS $with_$5_ldflags" + AS_IF([test -z "$with_$5_ldflags"], + [AC_VERBOSE([looking for library without search path])]) + AC_SEARCH_LIBS([$3], [$2], + [opal_check_package_lib_happy="yes"], + [opal_check_package_lib_happy="no"], [$4]) + AS_IF([test "$opal_check_package_lib_happy" = "no"], + [LDFLAGS="$opal_check_package_$1_save_LDFLAGS" + $1_LDFLAGS="$opal_check_package_$1_orig_LDFLAGS" + unset opal_Lib])], + [AS_IF([test -d "$with_$5/lib"], + [$1_LDFLAGS="$$1_LDFLAGS -L$with_$5/lib" + LDFLAGS="$LDFLAGS -L$with_$5/lib" + AC_VERBOSE([looking for library in lib]) + AC_SEARCH_LIBS([$3], [$2], + [opal_check_package_lib_happy="yes"], + [opal_check_package_lib_happy="no"], [$4]) + AS_IF([test "$opal_check_package_lib_happy" = "no"], + [# no go on the as is.. see what happens later... + LDFLAGS="$opal_check_package_$1_save_LDFLAGS" + $1_LDFLAGS="$opal_check_package_$1_orig_LDFLAGS" + unset opal_Lib])]) + + AS_IF([test "$opal_check_package_lib_happy" = "no" && test -d "$with_$5/lib64"], + [$1_LDFLAGS="$$1_LDFLAGS -L$with_$5/lib64" + LDFLAGS="$LDFLAGS -L$with_$5/lib64" + AC_VERBOSE([looking for library in lib64]) + AC_SEARCH_LIBS([$3], [$2], + [opal_check_package_lib_happy="yes"], + [opal_check_package_lib_happy="no"], [$4]) + AS_IF([test "$opal_check_package_lib_happy" = "no"], + [# no go on the as is.. see what happens later... + LDFLAGS="$opal_check_package_$1_save_LDFLAGS" + $1_LDFLAGS="$opal_check_package_$1_orig_LDFLAGS" + unset opal_Lib])])]) + + AS_IF([test "$opal_check_package_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([$2], [$3], [$$1_LIBS], + [opal_check_package_libnl_check_ok]) + AS_IF([test $opal_check_package_libnl_check_ok -eq 0], + [opal_check_package_lib_happy=no]) + ]) + + AS_IF([test "$opal_check_package_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"], + [$1_LIBS="$ac_cv_search_$3 $4"], + [$1_LIBS="$4"]) + $6], + [$7]) + + AS_VAR_POPDEF([opal_Lib])dnl +]) + + +dnl OPAL_CHECK_PACKAGE(prefix, +dnl header, +dnl library, +dnl function, +dnl extra-libraries, +dnl package, +dnl [action-if-found], [action-if-not-found], +dnl includes) +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 * 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_filename: the foo.h file to check for +dnl * library_name / function_name: check for function function_name in +dnl -llibrary_name. Specifically, for library_name, use the "foo" form, +dnl as opposed to "libfoo". +dnl * extra_libraries: if the library_name you are checking for requires +dnl additonal -l arguments to link successfully, list them here. +dnl * dir_prefix: if the header/library is located in a non-standard +dnl location (e.g., /opt/foo as opposed to /usr), list it here +dnl * libdir_prefix: if the library is not under $dir_prefix/lib or +dnl $dir_prefix/lib64, list it 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 * extra_includes: if including header_filename requires additional +dnl headers to be included first, list them here +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_package2_cppflags opal_check_package_$1_save_CPPFLAGS opal_check_package_$1_save_LDFLAGS opal_check_package_$1_save_LIBS opal_check_package_$1_orig_CPPFLAGS opal_check_package_$1_orig_LDFLAGS opal_check_package_$1_orig_LIBS]) + opal_check_package_$1_save_CPPFLAGS="$CPPFLAGS" + opal_check_package_$1_save_LDFLAGS="$LDFLAGS" + opal_check_package_$1_save_LIBS="$LIBS" + + opal_check_package_$1_orig_CPPFLAGS="$$1_CPPFLAGS" + opal_check_package_$1_orig_LDFLAGS="$$1_LDFLAGS" + opal_check_package_$1_orig_LIBS="$$1_LIBS" + + AS_IF([test "$with_$6" != "no"], + [AS_IF([test -n "$with_$6_cppflags" || test -z "$with_$6" || test "$with_$6" = "yes"], + [opal_check_package2_cppflags=$with_$6_cppflags], + [AS_IF([test -n "$with_$6"], + [AS_IF([test -r "$with_$6/$2"], + [opal_check_package2_cppflags="-I$with_$6"], + [AS_IF([test -r "$with_$6/include/$2"], + [opal_check_package2_cppflags="-I$with_$6/include"], + [opal_check_package2_happy=no])])])]) + + AS_IF([test "$opal_check_package2_happy" != "no"], + [_OPAL_CHECK_PACKAGE2_HEADER([$1], [$2], [$opal_check_package2_cppflags], + [_OPAL_CHECK_PACKAGE2_LIB([$1], [$3], [$4], [$5], [$6], + [opal_check_package2_happy="yes"], + [opal_check_package2_happy="no"])], + [opal_check_package2_happy=no], + [$9])])]) + + AS_IF([test "$opal_check_package2_happy" = "yes"], + [$7], + [$1_CPPFLAGS="$opal_check_package_$1_orig_CPPFLAGS" + $1_LDFLAGS="$opal_check_package_$1_orig_LDFLAGS" + $1_LIBS="$opal_check_package_$1_orig_LIBS" + AS_IF([test "$with_$6" != "no"], + [$8])]) + + + CPPFLAGS="$opal_check_package_$1_save_CPPFLAGS" + LDFLAGS="$opal_check_package_$1_save_LDFLAGS" + LIBS="$opal_check_package_$1_save_LIBS" + + OPAL_VAR_SCOPE_POP +]) diff --git a/config/opal_setup_zlib.m4 b/config/opal_setup_zlib.m4 index 55fc55d54bf..0131e24152a 100644 --- a/config/opal_setup_zlib.m4 +++ b/config/opal_setup_zlib.m4 @@ -3,7 +3,7 @@ # 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$ # @@ -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([opal_zlib], + [zlib.h], + [z], + [deflate], + [-lz], + [zlib], + [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]) @@ -86,5 +49,5 @@ 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 diff --git a/opal/mca/event/external/configure.m4 b/opal/mca/event/external/configure.m4 index 498af38b405..29261800a13 100644 --- a/opal/mca/event/external/configure.m4 +++ b/opal/mca/event/external/configure.m4 @@ -58,83 +58,52 @@ AC_DEFUN([MCA_opal_event_external_CONFIG],[ OPAL_VAR_SCOPE_PUSH([opal_event_external_CPPFLAGS_save opal_event_external_CFLAGS_save opal_event_external_LDFLAGS_save opal_event_external_LIBS_save]) - AC_ARG_WITH([libevent], - [AC_HELP_STRING([--with-libevent=DIR], - [Search for libevent headers and libraries in DIR. Should only be used if an external copy of libevent is being used.])]) + OPAL_DECLARE_PACKAGE([libevent], + [Search for libevent headers and libraries in DIR. Should only be used if an external copy of libevent is being used.], + [Search for libevent headers with FLAGS. Should only be used if an external copy of libevent is being used.], + [Search for libevent libraries with FLAGS. Should only be used if an external copy of libevent is being used.]) # Bozo check AS_IF([test "$with_libevent" = "no"], [AC_MSG_WARN([It is not possible to configure Open MPI --without-libevent]) AC_MSG_ERROR([Cannot continue])]) - AC_ARG_WITH([libevent-libdir], - [AC_HELP_STRING([--with-libevent-libdir=DIR], - [Search for libevent libraries in DIR. Should only be used if an external copy of libevent is being used.])]) - # Make sure the user didn't specify --with-libevent=internal and - # --with-libevent-libdir=whatever (because you can only specify - # --with-libevent-libdir when external libevent is being used). - AS_IF([test "$with_libevent" = "internal" && test -n "$with_libevent_libdir"], - [AC_MSG_WARN([Both --with-libevent=internal and --with-libevent-libdir=DIR]) - AC_MSG_WARN([were specified, which does not make sense.]) - AC_MSG_ERROR([Cannot continue])]) + # --with-libevent-{cpp,ld}flags=whatever (because you can only specify + # --with-libevent-{cpp,ld}flags when external libevent is being used). + AS_IF([test "$with_libevent" = "internal"], + [AS_IF([test -n "$with_libevent_cppflags" || test -n "$with_libevent_ldflags"], + [AC_MSG_WARN([Both --with-libevent=internal and --with-libevent-{cpp,ld}flags=FLAGS]) + AC_MSG_WARN([were specified, which does not make sense.]) + AC_MSG_ERROR([Cannot continue])])]) # Do we want this external component? (slightly redundant logic, # but hopefully slightly more clear...) opal_event_external_want=no AS_IF([test "$with_libevent" = "external"], [opal_event_external_want=yes]) - AS_IF([test -n "$with_libevent_libdir"], [opal_event_external_want=yes]) + AS_IF([test -n "$with_libevent_cppflags" || test -n "$with_libevent_ldflags"], [opal_event_external_want=yes]) AS_IF([test -n "$with_libevent" && test "$with_libevent" != "no" && test "$with_libevent" != "internal"], [opal_event_external_want=yes]) # If we want external support, try it AS_IF([test "$opal_event_external_want" = "yes"], - [ # Error out if the specified dir does not exist - OPAL_CHECK_WITHDIR([libevent-libdir], [$with_libevent_libdir], - [libevent.*]) - - AC_MSG_CHECKING([for external libevent in]) - AS_IF([test "$with_libevent" != "external" && test "$with_libevent" != "yes"], - [opal_event_dir=$with_libevent - AC_MSG_RESULT([$opal_event_dir]) - OPAL_CHECK_WITHDIR([libevent], [$opal_event_dir], - [include/event.h]) - AS_IF([test -z "$with_libevent_libdir" || test "$with_libevent_libdir" = "yes"], - [AC_MSG_CHECKING([for $with_libevent/lib64]) - AS_IF([test -d "$with_libevent/lib64"], - [opal_event_libdir_found=yes - AC_MSG_RESULT([found])], - [opal_event_libdir_found=no - AC_MSG_RESULT([not found])]) - AS_IF([test "$opal_event_libdir_found" = "yes"], - [opal_event_libdir="$with_libevent/lib64"], - [AC_MSG_CHECKING([for $with_libevent/lib]) - AS_IF([test -d "$with_libevent/lib"], - [AC_MSG_RESULT([found]) - opal_event_libdir="$with_libevent/lib"], - [AC_MSG_RESULT([not found]) - AC_MSG_WARN([Library directories were not found:]) - AC_MSG_WARN([ $with_libevent/lib64]) - AC_MSG_WARN([ $with_libevent/lib]) - AC_MSG_WARN([Please use --with-libevent-libdir to identify it.]) - AC_MSG_ERROR([Cannot continue])])])])], - [AC_MSG_RESULT([(default search paths)])]) - AS_IF([test ! -z "$with_libevent_libdir" && test "$with_libevent_libdir" != "yes"], - [opal_event_libdir="$with_libevent_libdir"]) + [AC_MSG_CHECKING([for external libevent in]) + AS_IF([test "$with_libevent" = "external" || test "$with_libevent" = "yes"], + [with_libevent= + AC_MSG_RESULT([(default search paths)])]) opal_event_external_CPPFLAGS_save=$CPPFLAGS opal_event_external_CFLAGS_save=$CFLAGS opal_event_external_LDFLAGS_save=$LDFLAGS opal_event_external_LIBS_save=$LIBS - OPAL_CHECK_PACKAGE([opal_event_external], - [event.h], - [event], - [event_config_new], - [-levent_pthreads], - [$opal_event_dir], - [$opal_event_libdir], - [opal_event_external_support=yes], - [opal_event_external_support=no]) + OPAL_CHECK_PACKAGE2([opal_event_external], + [event.h], + [event], + [event_config_new], + [-levent_pthreads], + [libevent], + [opal_event_external_support=yes], + [opal_event_external_support=no]) # Ensure that this libevent has the symbol # "evthread_set_lock_callbacks", which will only exist if From 34145e472d9c40b4f03aa5b827cdcfa439044a68 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Thu, 22 Feb 2018 14:28:28 +0900 Subject: [PATCH 2/3] configury: OPAL_CHECK_PACKAGE2 misc fixes Signed-off-by: Gilles Gouaillardet --- config/opal_check_package2.m4 | 229 +++++++++++++-------------- config/opal_setup_zlib.m4 | 13 +- opal/mca/event/external/configure.m4 | 9 +- 3 files changed, 119 insertions(+), 132 deletions(-) diff --git a/config/opal_check_package2.m4 b/config/opal_check_package2.m4 index e167670b11a..6e2764329e4 100644 --- a/config/opal_check_package2.m4 +++ b/config/opal_check_package2.m4 @@ -1,4 +1,4 @@ -dnl -*- shell-script -*- +dnl -*- autoconf -*- dnl dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana dnl University Research and Technology @@ -38,43 +38,34 @@ AC_DEFUN([OPAL_DECLARE_PACKAGE],[ ]) dnl -------------------------------------------------------------------- -dnl _OPAL_CHECK_PACKAGE2_HEADER(prefix, header, cppflags, -dnl [action-if-found], [action-if-not-found], -dnl includes) +dnl _OPAL_CHECK_PACKAGE2_HEADER(package, prefix, header, includes, +dnl [action-if-found], [action-if-not-found]) dnl -------------------------------------------------------------------- AC_DEFUN([_OPAL_CHECK_PACKAGE2_HEADER], [ - # 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_Header], [ac_cv_header_$2]) - - # so this sucks, but there's no way to get through the progression - # of header includes without killing off the cache variable and trying - # again... - unset opal_Header - - # get rid of the trailing slash(es) - opal_check_package_header_happy="no" - AS_IF([test -z "$3"], - [# try as is... - AC_VERBOSE([looking for header]) - AC_CHECK_HEADERS([$2], [opal_check_package_header_happy="yes"], []) - AS_IF([test "$opal_check_package_header_happy" = "no"], - [# no go on the as is - reset the cache and try again - unset opal_Header])], - [$1_CPPFLAGS="$$1_CPPFLAGS $3" - CPPFLAGS="$CPPFLAGS $3" - AC_CHECK_HEADERS([$2], [opal_check_package_header_happy="yes"], [], [$6])]) - - AS_IF([test "$opal_check_package_header_happy" = "yes"], [$4], [$5]) - unset opal_check_package_header_happy - - AS_VAR_POPDEF([opal_Header])dnl + AS_VAR_PUSHDEF([opal_With], [with_$1]) + 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"], + [$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(prefix, library, function, extra-libraries, -dnl package, +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], [ @@ -83,79 +74,87 @@ AC_DEFUN([_OPAL_CHECK_PACKAGE2_LIB], [ # code into other places unless you want much pain and suffering AS_VAR_PUSHDEF([opal_Lib], [ac_cv_search_$3]) - # see comment above + # 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 - opal_check_package_lib_happy="no" - AS_IF([test -n "$with_$5_ldflags" || test -z "$with_$5" || test "$with_$5" = "yes"], + + 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" || test -z "$opal_With" || test "$opal_With" = "yes"], [# ldflags was specified - use as is - $1_LDFLAGS="$$1_LDFLAGS $with_$5_ldflags" - LDFLAGS="$LDFLAGS $with_$5_ldflags" - AS_IF([test -z "$with_$5_ldflags"], + $2_LDFLAGS="$$2_LDFLAGS $opal_Ldflags" + LDFLAGS="$LDFLAGS $opal_Ldflags" + AS_IF([test -z "$opal_Ldflags"], [AC_VERBOSE([looking for library without search path])]) - AC_SEARCH_LIBS([$3], [$2], - [opal_check_package_lib_happy="yes"], - [opal_check_package_lib_happy="no"], [$4]) - AS_IF([test "$opal_check_package_lib_happy" = "no"], - [LDFLAGS="$opal_check_package_$1_save_LDFLAGS" - $1_LDFLAGS="$opal_check_package_$1_orig_LDFLAGS" + 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"], + [LDFLAGS="$opal_check_package_$2_save_LDFLAGS" + $2_LDFLAGS="$opal_check_package_$2_orig_LDFLAGS" unset opal_Lib])], - [AS_IF([test -d "$with_$5/lib"], - [$1_LDFLAGS="$$1_LDFLAGS -L$with_$5/lib" - LDFLAGS="$LDFLAGS -L$with_$5/lib" + [AS_IF([test -d "$opal_With/lib"], + [$2_LDFLAGS="$$2_LDFLAGS -L$opal_With/lib" + LDFLAGS="$LDFLAGS -L$opal_With/lib" AC_VERBOSE([looking for library in lib]) - AC_SEARCH_LIBS([$3], [$2], - [opal_check_package_lib_happy="yes"], - [opal_check_package_lib_happy="no"], [$4]) - AS_IF([test "$opal_check_package_lib_happy" = "no"], + 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"], [# no go on the as is.. see what happens later... - LDFLAGS="$opal_check_package_$1_save_LDFLAGS" - $1_LDFLAGS="$opal_check_package_$1_orig_LDFLAGS" + LDFLAGS="$opal_check_package_$2_save_LDFLAGS" + $2_LDFLAGS="$opal_check_package_$2_orig_LDFLAGS" unset opal_Lib])]) - AS_IF([test "$opal_check_package_lib_happy" = "no" && test -d "$with_$5/lib64"], - [$1_LDFLAGS="$$1_LDFLAGS -L$with_$5/lib64" - LDFLAGS="$LDFLAGS -L$with_$5/lib64" + AS_IF([test "$opal_check_package2_lib_happy" = "no" && test -d "$opal_With/lib64"], + [$2_LDFLAGS="$$2_LDFLAGS -L$opal_With/lib64" + LDFLAGS="$LDFLAGS -L$opal_With/lib64" AC_VERBOSE([looking for library in lib64]) - AC_SEARCH_LIBS([$3], [$2], - [opal_check_package_lib_happy="yes"], - [opal_check_package_lib_happy="no"], [$4]) - AS_IF([test "$opal_check_package_lib_happy" = "no"], + 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"], [# no go on the as is.. see what happens later... - LDFLAGS="$opal_check_package_$1_save_LDFLAGS" - $1_LDFLAGS="$opal_check_package_$1_orig_LDFLAGS" + LDFLAGS="$opal_check_package_$2_save_LDFLAGS" + $2_LDFLAGS="$opal_check_package_$2_orig_LDFLAGS" unset opal_Lib])])]) - AS_IF([test "$opal_check_package_lib_happy" = "yes"], + 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([$2], [$3], [$$1_LIBS], + 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_package_lib_happy=no]) + [opal_check_package2_lib_happy=no]) ]) - AS_IF([test "$opal_check_package_lib_happy" = "yes"], + 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"], - [$1_LIBS="$ac_cv_search_$3 $4"], - [$1_LIBS="$4"]) + [$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(prefix, +dnl OPAL_CHECK_PACKAGE(package, +dnl prefix, dnl header, -dnl library, +dnl includes, dnl function, +dnl library, dnl extra-libraries, -dnl package, -dnl [action-if-found], [action-if-not-found], -dnl includes) +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. @@ -169,69 +168,57 @@ 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_filename: the foo.h file to check for -dnl * library_name / function_name: check for function function_name in -dnl -llibrary_name. Specifically, for library_name, use the "foo" form, +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_name you are checking for requires +dnl * extra_libraries: if the $library you are checking for requires dnl additonal -l arguments to link successfully, list them here. -dnl * dir_prefix: if the header/library is located in a non-standard -dnl location (e.g., /opt/foo as opposed to /usr), list it here -dnl * libdir_prefix: if the library is not under $dir_prefix/lib or -dnl $dir_prefix/lib64, list it 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 * extra_includes: if including header_filename requires additional -dnl headers to be included first, list them here 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_package2_cppflags opal_check_package_$1_save_CPPFLAGS opal_check_package_$1_save_LDFLAGS opal_check_package_$1_save_LIBS opal_check_package_$1_orig_CPPFLAGS opal_check_package_$1_orig_LDFLAGS opal_check_package_$1_orig_LIBS]) - opal_check_package_$1_save_CPPFLAGS="$CPPFLAGS" - opal_check_package_$1_save_LDFLAGS="$LDFLAGS" - opal_check_package_$1_save_LIBS="$LIBS" - - opal_check_package_$1_orig_CPPFLAGS="$$1_CPPFLAGS" - opal_check_package_$1_orig_LDFLAGS="$$1_LDFLAGS" - opal_check_package_$1_orig_LIBS="$$1_LIBS" - - AS_IF([test "$with_$6" != "no"], - [AS_IF([test -n "$with_$6_cppflags" || test -z "$with_$6" || test "$with_$6" = "yes"], - [opal_check_package2_cppflags=$with_$6_cppflags], - [AS_IF([test -n "$with_$6"], - [AS_IF([test -r "$with_$6/$2"], - [opal_check_package2_cppflags="-I$with_$6"], - [AS_IF([test -r "$with_$6/include/$2"], - [opal_check_package2_cppflags="-I$with_$6/include"], - [opal_check_package2_happy=no])])])]) - - AS_IF([test "$opal_check_package2_happy" != "no"], - [_OPAL_CHECK_PACKAGE2_HEADER([$1], [$2], [$opal_check_package2_cppflags], - [_OPAL_CHECK_PACKAGE2_LIB([$1], [$3], [$4], [$5], [$6], - [opal_check_package2_happy="yes"], - [opal_check_package2_happy="no"])], - [opal_check_package2_happy=no], - [$9])])]) + 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"], - [$7], - [$1_CPPFLAGS="$opal_check_package_$1_orig_CPPFLAGS" - $1_LDFLAGS="$opal_check_package_$1_orig_LDFLAGS" - $1_LIBS="$opal_check_package_$1_orig_LIBS" - AS_IF([test "$with_$6" != "no"], - [$8])]) + [$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_$1_save_CPPFLAGS" - LDFLAGS="$opal_check_package_$1_save_LDFLAGS" - LIBS="$opal_check_package_$1_save_LIBS" + 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 ]) diff --git a/config/opal_setup_zlib.m4 b/config/opal_setup_zlib.m4 index 0131e24152a..32f11a9ffaf 100644 --- a/config/opal_setup_zlib.m4 +++ b/config/opal_setup_zlib.m4 @@ -1,4 +1,4 @@ -# -*- shell-script -*- +# -*- autocont -*- # # Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved. @@ -15,18 +15,18 @@ # MCA_zlib_CONFIG([action-if-found], [action-if-not-found]) # -------------------------------------------------------------------- AC_DEFUN([OPAL_ZLIB_CONFIG],[ - 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([opal_zlib], + OPAL_CHECK_PACKAGE2([zlib], + [opal_zlib], [zlib.h], - [z], + [], [deflate], - [-lz], - [zlib], + [z], + [], [opal_zlib_support=1], [opal_zlib_support=0]) @@ -49,5 +49,4 @@ AC_DEFUN([OPAL_ZLIB_CONFIG],[ AC_DEFINE_UNQUOTED([OPAL_HAVE_ZLIB], [$opal_zlib_support], [Whether or not we have zlib support]) - ])dnl diff --git a/opal/mca/event/external/configure.m4 b/opal/mca/event/external/configure.m4 index 29261800a13..30df2885812 100644 --- a/opal/mca/event/external/configure.m4 +++ b/opal/mca/event/external/configure.m4 @@ -1,4 +1,4 @@ -# -*- shell-script -*- +# -*- autoconf -*- # # Copyright (c) 2009-2013 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved. @@ -96,12 +96,13 @@ AC_DEFUN([MCA_opal_event_external_CONFIG],[ opal_event_external_LDFLAGS_save=$LDFLAGS opal_event_external_LIBS_save=$LIBS - OPAL_CHECK_PACKAGE2([opal_event_external], + OPAL_CHECK_PACKAGE2([libevent], + [opal_event_external], [event.h], - [event], + [], [event_config_new], + [event], [-levent_pthreads], - [libevent], [opal_event_external_support=yes], [opal_event_external_support=no]) From 601c17f250e46f97801627bf21452a7d687f65c4 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Wed, 7 Mar 2018 09:36:22 +0900 Subject: [PATCH 3/3] configury: OPAL_CHECK_PACKAGE2 misc changes only use AC_SEARCH_LIBS when --with-FOO[=yes] if --with-FOO-ldflags=LDFLAGS or --with-FOO=DIR is used, then use AC_CHECK_LIB if --with-FOO=DIR is used, the macro is only tried if 'ls DIR/lib[64]/liblib.*' returns more than one file. This is not yet bulletproof since - if DIR/lib/libLIB.xyz is a match, the linker will not use that and will try lib in the default path instead. - if DIR/lib/libLIB.so has the wrong bitness/arch, the linker will ignore it and try lib in the default path instead Signed-off-by: Gilles Gouaillardet --- config/opal_check_package2.m4 | 62 ++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/config/opal_check_package2.m4 b/config/opal_check_package2.m4 index 6e2764329e4..0d3b5cdc896 100644 --- a/config/opal_check_package2.m4 +++ b/config/opal_check_package2.m4 @@ -83,44 +83,52 @@ AC_DEFUN([_OPAL_CHECK_PACKAGE2_LIB], [ AS_VAR_PUSHDEF([opal_Ldflags], [with_$1_ldflags]) opal_check_package2_lib_happy="no" - AS_IF([test -n "$opal_Ldflags" || test -z "$opal_With" || test "$opal_With" = "yes"], + AS_IF([test -n "$opal_Ldflags"], [# ldflags was specified - use as is $2_LDFLAGS="$$2_LDFLAGS $opal_Ldflags" LDFLAGS="$LDFLAGS $opal_Ldflags" - AS_IF([test -z "$opal_Ldflags"], - [AC_VERBOSE([looking for library without search path])]) - AC_SEARCH_LIBS([$3], [$4], + 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 -d "$opal_With/lib"], - [$2_LDFLAGS="$$2_LDFLAGS -L$opal_With/lib" - LDFLAGS="$LDFLAGS -L$opal_With/lib" - AC_VERBOSE([looking for library in lib]) - 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"], - [# 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" = "no" && test -d "$opal_With/lib64"], - [$2_LDFLAGS="$$2_LDFLAGS -L$opal_With/lib64" - LDFLAGS="$LDFLAGS -L$opal_With/lib64" - AC_VERBOSE([looking for library in lib64]) + [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]) + [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])])]) + [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