|
| 1 | +dnl -*- shell-script -*- |
| 2 | +dnl |
| 3 | +dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana |
| 4 | +dnl University Research and Technology |
| 5 | +dnl Corporation. All rights reserved. |
| 6 | +dnl Copyright (c) 2004-2005 The University of Tennessee and The University |
| 7 | +dnl of Tennessee Research Foundation. All rights |
| 8 | +dnl reserved. |
| 9 | +dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, |
| 10 | +dnl University of Stuttgart. All rights reserved. |
| 11 | +dnl Copyright (c) 2004-2005 The Regents of the University of California. |
| 12 | +dnl All rights reserved. |
| 13 | +dnl Copyright (c) 2012-2017 Cisco Systems, Inc. All rights reserved. |
| 14 | +dnl Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved. |
| 15 | +dnl Copyright (c) 2014 Intel, Inc. All rights reserved. |
| 16 | +dnl Copyright (c) 2015-2018 Research Organization for Information Science |
| 17 | +dnl and Technology (RIST). All rights reserved. |
| 18 | +dnl $COPYRIGHT$ |
| 19 | +dnl |
| 20 | +dnl Additional copyrights may follow |
| 21 | +dnl |
| 22 | +dnl $HEADER$ |
| 23 | +dnl |
| 24 | + |
| 25 | +dnl OPAL_DECLARE_PACKAGE(name,[help],[cppflagshelp],[ldflagshelp]) |
| 26 | +AC_DEFUN([OPAL_DECLARE_PACKAGE],[ |
| 27 | + AC_ARG_WITH([$1], [AC_HELP_STRING([--with-$1=DIR], [$2])]) |
| 28 | + AC_ARG_WITH([$1-cppflags], [AC_HELP_STRING([--with-$1-cppflags=FLAGS], [$3])]) |
| 29 | + AC_ARG_WITH([$1-ldflags], [AC_HELP_STRING([--with-$1-ldflags=FLAGS], [$4])]) |
| 30 | + AC_ARG_WITH([$1-libdir], [AC_HELP_STRING([--with-$1-libdir=DIR], |
| 31 | + [Deprecated, use --with-$1-ldflags instead])]) |
| 32 | + AS_IF([test -n "$with_$1_libdir"], |
| 33 | + [AS_IF([test -n "$with_$1_ldflags"], |
| 34 | + [AC_MSG_WARN([It is not possible to use both --with-$1-ldflags and --with-$1-libdir]) |
| 35 | + AC_MSG_ERROR([Cannot continue])], |
| 36 | + [AC_MSG_WARN([--with_$1_libdir=DIR is deprecated, use --with-$1_ldflags=FLAGS instead]) |
| 37 | + with_$1_ldflags="-L$with_$1_libdir"])]) |
| 38 | +]) |
| 39 | + |
| 40 | +dnl -------------------------------------------------------------------- |
| 41 | +dnl _OPAL_CHECK_PACKAGE2_HEADER(prefix, header, cppflags, |
| 42 | +dnl [action-if-found], [action-if-not-found], |
| 43 | +dnl includes) |
| 44 | +dnl -------------------------------------------------------------------- |
| 45 | +AC_DEFUN([_OPAL_CHECK_PACKAGE2_HEADER], [ |
| 46 | + # This is stolen from autoconf to peek under the covers to get the |
| 47 | + # cache variable for the library check. one should not copy this |
| 48 | + # code into other places unless you want much pain and suffering |
| 49 | + AS_VAR_PUSHDEF([opal_Header], [ac_cv_header_$2]) |
| 50 | + |
| 51 | + # so this sucks, but there's no way to get through the progression |
| 52 | + # of header includes without killing off the cache variable and trying |
| 53 | + # again... |
| 54 | + unset opal_Header |
| 55 | + |
| 56 | + # get rid of the trailing slash(es) |
| 57 | + opal_check_package_header_happy="no" |
| 58 | + AS_IF([test -z "$3"], |
| 59 | + [# try as is... |
| 60 | + AC_VERBOSE([looking for header]) |
| 61 | + AC_CHECK_HEADERS([$2], [opal_check_package_header_happy="yes"], []) |
| 62 | + AS_IF([test "$opal_check_package_header_happy" = "no"], |
| 63 | + [# no go on the as is - reset the cache and try again |
| 64 | + unset opal_Header])], |
| 65 | + [$1_CPPFLAGS="$$1_CPPFLAGS $3" |
| 66 | + CPPFLAGS="$CPPFLAGS $3" |
| 67 | + #AC_CHECK_HEADERS([$2], [opal_check_package_header_happy="yes"], [], [$6])]) |
| 68 | + |
| 69 | + AS_IF([test "$opal_check_package_header_happy" = "yes"], [$4], [$5]) |
| 70 | + unset opal_check_package_header_happy |
| 71 | + |
| 72 | + AS_VAR_POPDEF([opal_Header])dnl |
| 73 | +]) |
| 74 | + |
| 75 | + |
| 76 | +dnl _OPAL_CHECK_PACKAGE2_LIB(prefix, library, function, extra-libraries, |
| 77 | +dnl package, |
| 78 | +dnl [action-if-found], [action-if-not-found]]) |
| 79 | +dnl -------------------------------------------------------------------- |
| 80 | +AC_DEFUN([_OPAL_CHECK_PACKAGE2_LIB], [ |
| 81 | + # This is stolen from autoconf to peek under the covers to get the |
| 82 | + # cache variable for the library check. one should not copy this |
| 83 | + # code into other places unless you want much pain and suffering |
| 84 | + AS_VAR_PUSHDEF([opal_Lib], [ac_cv_search_$3]) |
| 85 | + |
| 86 | + # see comment above |
| 87 | + unset opal_Lib |
| 88 | + opal_check_package_lib_happy="no" |
| 89 | + AS_IF([test -n "$with_$5_ldflags" || test -z "$with_$5" || test "$with_$5" = "yes"], |
| 90 | + [# ldflags was specified - use as is |
| 91 | + $1_LDFLAGS="$$1_LDFLAGS $with_$5_ldflags" |
| 92 | + LDFLAGS="$LDFLAGS $with_$5_ldflags" |
| 93 | + AS_IF([test -z "$with_$5_ldflags"], |
| 94 | + [AC_VERBOSE([looking for library without search path])]) |
| 95 | + AC_SEARCH_LIBS([$3], [$2], |
| 96 | + [opal_check_package_lib_happy="yes"], |
| 97 | + [opal_check_package_lib_happy="no"], [$4]) |
| 98 | + AS_IF([test "$opal_check_package_lib_happy" = "no"], |
| 99 | + [LDFLAGS="$opal_check_package_$1_save_LDFLAGS" |
| 100 | + $1_LDFLAGS="$opal_check_package_$1_orig_LDFLAGS" |
| 101 | + unset opal_Lib])], |
| 102 | + [AS_IF([test -d "$with_$5/lib"], |
| 103 | + [$1_LDFLAGS="$$1_LDFLAGS -L$with_$5/lib" |
| 104 | + LDFLAGS="$LDFLAGS -L$with_$5/lib" |
| 105 | + AC_VERBOSE([looking for library in lib]) |
| 106 | + AC_SEARCH_LIBS([$3], [$2], |
| 107 | + [opal_check_package_lib_happy="yes"], |
| 108 | + [opal_check_package_lib_happy="no"], [$4]) |
| 109 | + AS_IF([test "$opal_check_package_lib_happy" = "no"], |
| 110 | + [# no go on the as is.. see what happens later... |
| 111 | + LDFLAGS="$opal_check_package_$1_save_LDFLAGS" |
| 112 | + $1_LDFLAGS="$opal_check_package_$1_orig_LDFLAGS" |
| 113 | + unset opal_Lib])]) |
| 114 | + |
| 115 | + AS_IF([test "$opal_check_package_lib_happy" = "no" && test -d "$with_$5/lib64"], |
| 116 | + [$1_LDFLAGS="$$1_LDFLAGS -L$with_$5/lib64" |
| 117 | + LDFLAGS="$LDFLAGS -L$with_$5/lib64" |
| 118 | + AC_VERBOSE([looking for library in lib64]) |
| 119 | + AC_SEARCH_LIBS([$3], [$2], |
| 120 | + [opal_check_package_lib_happy="yes"], |
| 121 | + [opal_check_package_lib_happy="no"], [$4]) |
| 122 | + AS_IF([test "$opal_check_package_lib_happy" = "no"], |
| 123 | + [# no go on the as is.. see what happens later... |
| 124 | + LDFLAGS="$opal_check_package_$1_save_LDFLAGS" |
| 125 | + $1_LDFLAGS="$opal_check_package_$1_orig_LDFLAGS" |
| 126 | + unset opal_Lib])])]) |
| 127 | + |
| 128 | + AS_IF([test "$opal_check_package_lib_happy" = "yes"], |
| 129 | + [ # libnl v1 and libnl3 are known to *not* coexist |
| 130 | + # harmoniously in the same process. Check to see if this |
| 131 | + # new package will introduce such a conflict. |
| 132 | + OPAL_LIBNL_SANITY_CHECK([$2], [$3], [$$1_LIBS], |
| 133 | + [opal_check_package_libnl_check_ok]) |
| 134 | + AS_IF([test $opal_check_package_libnl_check_ok -eq 0], |
| 135 | + [opal_check_package_lib_happy=no]) |
| 136 | + ]) |
| 137 | + |
| 138 | + AS_IF([test "$opal_check_package_lib_happy" = "yes"], |
| 139 | + [ # The result of AC SEARCH_LIBS is cached in $ac_cv_search_[function] |
| 140 | + AS_IF([test "$ac_cv_search_$3" != "no" && |
| 141 | + test "$ac_cv_search_$3" != "none required"], |
| 142 | + [$1_LIBS="$ac_cv_search_$3 $4"], |
| 143 | + [$1_LIBS="$4"]) |
| 144 | + $6], |
| 145 | + [$7]) |
| 146 | + |
| 147 | + AS_VAR_POPDEF([opal_Lib])dnl |
| 148 | +]) |
| 149 | + |
| 150 | + |
| 151 | +dnl OPAL_CHECK_PACKAGE(prefix, |
| 152 | +dnl header, |
| 153 | +dnl library, |
| 154 | +dnl function, |
| 155 | +dnl extra-libraries, |
| 156 | +dnl package, |
| 157 | +dnl [action-if-found], [action-if-not-found], |
| 158 | +dnl includes) |
| 159 | +dnl ----------------------------------------------------------- |
| 160 | +dnl Check for package defined by header and libs, and probably |
| 161 | +dnl located in dir-prefix, possibly with libs in libdir-prefix. |
| 162 | +dnl Both dir-prefix and libdir-prefix can be empty. Will set |
| 163 | +dnl prefix_{CPPFLAGS, LDFLAGS, LIBS} as needed. |
| 164 | +dnl |
| 165 | +dnl The general intent of this macro is to provide finer-grained scoping |
| 166 | +dnl of C preprocessor flags, linker flags, and libraries (as opposed to |
| 167 | +dnl unconditionally adding to the top-level CPFLAGS, LDFLAGS, and LIBS, |
| 168 | +dnl which get used to compile/link *everything*). |
| 169 | +dnl |
| 170 | +dnl Here is a breakdown of the parameters: |
| 171 | +dnl |
| 172 | +dnl * prefix: the macro sets $prefix_CPPFLAGS, $prefix_LDFLAGS, and |
| 173 | +dnl $prefix_LIBS (and AC_SUBSTs all of them). For example, if a |
| 174 | +dnl provider uses this macro to check for a header/library that it |
| 175 | +dnl needs, it might well set prefix to be its provider name. |
| 176 | +dnl * header_filename: the foo.h file to check for |
| 177 | +dnl * library_name / function_name: check for function function_name in |
| 178 | +dnl -llibrary_name. Specifically, for library_name, use the "foo" form, |
| 179 | +dnl as opposed to "libfoo". |
| 180 | +dnl * extra_libraries: if the library_name you are checking for requires |
| 181 | +dnl additonal -l arguments to link successfully, list them here. |
| 182 | +dnl * dir_prefix: if the header/library is located in a non-standard |
| 183 | +dnl location (e.g., /opt/foo as opposed to /usr), list it here |
| 184 | +dnl * libdir_prefix: if the library is not under $dir_prefix/lib or |
| 185 | +dnl $dir_prefix/lib64, list it here. |
| 186 | +dnl * action_if_found: if both the header and library are found and |
| 187 | +dnl usable, execute action_if_found |
| 188 | +dnl * action_if_not_found: otherwise, execute action_if_not_found |
| 189 | +dnl * extra_includes: if including header_filename requires additional |
| 190 | +dnl headers to be included first, list them here |
| 191 | +dnl |
| 192 | +dnl The output _CPPFLAGS, _LDFLAGS, and _LIBS can be used to limit the |
| 193 | +dnl scope various flags in Makefiles. |
| 194 | +dnl |
| 195 | +AC_DEFUN([OPAL_CHECK_PACKAGE2],[ |
| 196 | + 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]) |
| 197 | + opal_check_package_$1_save_CPPFLAGS="$CPPFLAGS" |
| 198 | + opal_check_package_$1_save_LDFLAGS="$LDFLAGS" |
| 199 | + opal_check_package_$1_save_LIBS="$LIBS" |
| 200 | + |
| 201 | + opal_check_package_$1_orig_CPPFLAGS="$$1_CPPFLAGS" |
| 202 | + opal_check_package_$1_orig_LDFLAGS="$$1_LDFLAGS" |
| 203 | + opal_check_package_$1_orig_LIBS="$$1_LIBS" |
| 204 | + |
| 205 | + AS_IF([test "$with_$6" != "no"], |
| 206 | + [AS_IF([test -n "$with_$6_cppflags" || test -z "$with_$6" || test "$with_$6" = "yes"], |
| 207 | + [opal_check_package2_cppflags=$with_$6_cppflags], |
| 208 | + [AS_IF([test -n "$with_$6"], |
| 209 | + [AS_IF([test -r "$with_$6/$2"], |
| 210 | + [opal_check_package2_cppflags="-I$with_$6"], |
| 211 | + [AS_IF([test -r "$with_$6/include/$2"], |
| 212 | + [opal_check_package2_cppflags="-I$with_$6/include"], |
| 213 | + [opal_check_package2_happy=no])])])]) |
| 214 | + |
| 215 | + AS_IF([test "$opal_check_package2_happy" != "no"], |
| 216 | + [_OPAL_CHECK_PACKAGE2_HEADER([$1], [$2], [$opal_check_package2_cppflags], |
| 217 | + [_OPAL_CHECK_PACKAGE2_LIB([$1], [$3], [$4], [$5], [$6], [$8], |
| 218 | + [opal_check_package2_happy="yes"], |
| 219 | + [opal_check_package2_happy="no"])], |
| 220 | + [opal_check_package2_happy=no], |
| 221 | + [$9])])]) |
| 222 | + |
| 223 | + AS_IF([test "$opal_check_package2_happy" = "yes"], |
| 224 | + [$7], |
| 225 | + [$1_CPPFLAGS="$opal_check_package_$1_orig_CPPFLAGS" |
| 226 | + $1_LDFLAGS="$opal_check_package_$1_orig_LDFLAGS" |
| 227 | + $1_LIBS="$opal_check_package_$1_orig_LIBS" |
| 228 | + AS_IF([test "$with_$6" != "no"], |
| 229 | + [$8])]) |
| 230 | + |
| 231 | + OPAL_VAR_SCOPE_POP |
| 232 | + |
| 233 | + CPPFLAGS="$opal_check_package_$1_save_CPPFLAGS" |
| 234 | + LDFLAGS="$opal_check_package_$1_save_LDFLAGS" |
| 235 | + LIBS="$opal_check_package_$1_save_LIBS" |
| 236 | +]) |
0 commit comments