|
| 1 | +dnl -*- shell-script -*- |
| 2 | +dnl |
| 3 | +dnl Copyright (c) 2021 IBM Corporation. All rights reserved. |
| 4 | +dnl |
| 5 | +dnl $COPYRIGHT$ |
| 6 | +dnl |
| 7 | +dnl Additional copyrights may follow |
| 8 | +dnl |
| 9 | +dnl $HEADER$ |
| 10 | +dnl |
| 11 | + |
| 12 | + |
| 13 | +dnl OPAL_CHECK_PKG_CONFIG |
| 14 | +dnl Check for availability of pkg-config and store the result. |
| 15 | +dnl If it is not available, store any passed in libs from the |
| 16 | +dnl --with-extra-libs configure option, or the known defaults. |
| 17 | +dnl |
| 18 | +dnl If it is available, allow configury to check for .pc files |
| 19 | +dnl and append to OPAL_WRAPPER_EXTRA_LIBS. |
| 20 | +AC_DEFUN([OPAL_CHECK_PKG_CONFIG], [ |
| 21 | + AS_IF([test -z "$OPAL_HAS_PKG_CONFIG"], |
| 22 | + [ |
| 23 | + AC_MSG_CHECKING([If pkg-config is available]) |
| 24 | + which pkg-config > /dev/null 2>&1 |
| 25 | + AS_IF([test "$?" -eq "0"], |
| 26 | + [ |
| 27 | + AC_MSG_RESULT([yes]) |
| 28 | + OPAL_HAS_PKG_CONFIG="yes" |
| 29 | + ], |
| 30 | + [ |
| 31 | + AC_MSG_RESULT([no]) |
| 32 | + OPAL_HAS_PKG_CONFIG="no" |
| 33 | + OPAL_FLAGS_APPEND_UNIQ([OPAL_WRAPPER_EXTRA_LIBS], [$OPAL_EXTRA_LIBS]) |
| 34 | + ] |
| 35 | + ) |
| 36 | + ] |
| 37 | + ) |
| 38 | +]) |
| 39 | + |
| 40 | +dnl OPAL_GET_LFLAGS_FROM_PC |
| 41 | +dnl Get the -l flags using pkg-config on the passed in .pc file, and |
| 42 | +dnl append them to OPAL_WRAPPER_EXTRA_LIBS. |
| 43 | +dnl |
| 44 | +dnl Requires 1 or more arguments. |
| 45 | +dnl |
| 46 | +dnl Arg 1 (Required): the name of the .pc file to look for (hwloc/pmix/libevent_core).pc |
| 47 | +dnl |
| 48 | +dnl Arg 2..n (Optional): The search path for the .pc file above and any dependencies. |
| 49 | +dnl These search will be appended and set in the env variable |
| 50 | +dnl PKG_CONFIG_PATH to tell pkg-config where to locate the .pc |
| 51 | +dnl file from argument 1, and its dependencies. |
| 52 | +dnl |
| 53 | +AC_DEFUN([OPAL_GET_LFLAGS_FROM_PC], [ |
| 54 | + |
| 55 | + AC_REQUIRE([OPAL_CHECK_PKG_CONFIG]) |
| 56 | + AS_IF([test "$OPAL_HAS_PKG_CONFIG" = "yes"], |
| 57 | + [ |
| 58 | + AC_MSG_NOTICE([Looking for pc file for $1]) |
| 59 | + OPAL_VAR_SCOPE_PUSH([opal_pkg_config_name opal_pkg_config_env_to_set opal_pkg_config_args opal_pkg_config_cmd opal_pkg_config_result]) |
| 60 | + opal_pkg_config_name=$1 |
| 61 | + opal_pkg_config_env_to_set="" |
| 62 | + opal_pkg_config_cmd="" |
| 63 | + |
| 64 | + AS_LITERAL_WORD_IF([$1], [], [m4_fatal([Non-literal argument $1])], []) |
| 65 | + $1_OMPI_PC_DIR="" |
| 66 | + |
| 67 | + # Tell pkg-config where to find the .pc file from argument 1 |
| 68 | + # as well as any/all dependencies. |
| 69 | + # The following block will append the path |
| 70 | + # to those .pc files into the pkg-config command. |
| 71 | + # num_paths > 1 implies there is at least one dependent .pc file |
| 72 | + # to append. |
| 73 | + AS_IF([test $# -gt 1], |
| 74 | + [ |
| 75 | + $1_OMPI_PC_DIR=$2 |
| 76 | + |
| 77 | + # Shift the arguments by one to get to the actual paths. |
| 78 | + opal_pkg_config_args=m4_shift($@) |
| 79 | + |
| 80 | + # Iterate over the comma seperated arguments, and replace the ',' |
| 81 | + for i in $(echo $opal_pkg_config_args | sed "s/,/ /g"); do |
| 82 | + opal_pkg_config_env_to_set="$i:${opal_pkg_config_env_to_set}" |
| 83 | + done |
| 84 | + opal_pkg_config_cmd="env PKG_CONFIG_PATH=$opal_pkg_config_env_to_set pkg-config --libs $opal_pkg_config_name" |
| 85 | + ], |
| 86 | + [opal_pkg_config_cmd="pkg-config --libs $opal_pkg_config_name"] |
| 87 | + ) |
| 88 | + |
| 89 | + OPAL_LOG_MSG([pkg-config cmd for $opal_pkg_config_name: $opal_pkg_config_cmd]) |
| 90 | + |
| 91 | + opal_pkg_config_result=$($opal_pkg_config_cmd) |
| 92 | + AS_IF([test -z "$opal_pkg_config_result"], |
| 93 | + [ |
| 94 | + AC_MSG_WARN([Could not find viable $opal_pkg_config_name.pc]) |
| 95 | + ], |
| 96 | + [ |
| 97 | + AC_MSG_NOTICE([pkg-config result $opal_pkg_config_result]) |
| 98 | + OPAL_FLAGS_APPEND_UNIQ([OPAL_WRAPPER_EXTRA_LIBS], [$opal_pkg_config_result]) |
| 99 | + ] |
| 100 | + ) |
| 101 | + OPAL_VAR_SCOPE_POP |
| 102 | + ], |
| 103 | + [] |
| 104 | + ) |
| 105 | +]) |
0 commit comments