1
- dnl -* - shell-script -* -
1
+ dnl -*- autoconf -*-
2
2
dnl
3
3
dnl Copyright (c) 2021 IBM Corporation. All rights reserved.
4
- dnl
4
+ dnl Copyright (c) 2021 Amazon.com, Inc. or its affiliates. All Rights
5
+ dnl reserved.
5
6
dnl $COPYRIGHT$
6
7
dnl
7
8
dnl Additional copyrights may follow
@@ -10,96 +11,62 @@ dnl $HEADER$
10
11
dnl
11
12
12
13
13
- dnl OPAL_CHECK_PKG_CONFIG
14
+ dnl OPAL_CHECK_PKG_CONFIG()
15
+ dnl
14
16
dnl Check for availability of pkg-config and store the result.
15
17
dnl If it is not available, store any passed in libs from the
16
18
dnl --with-extra-libs configure option, or the known defaults.
17
19
dnl
18
20
dnl If it is available, allow configury to check for .pc files
19
21
dnl and append to OPAL_WRAPPER_EXTRA_LIBS.
20
22
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
- )
23
+ AC_CHECK_PROG ( [ PKG_CONFIG] , [ pkg-config] , [ pkg-config] )
38
24
] )
39
25
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], [
26
+ dnl OPAL_GET_LDFLAGS_FROM_PC(library name, variable-to-set-if-found,
27
+ dnl action-if-not-found)
28
+ AC_DEFUN ( [ OPAL_GET_LDFLAGS_FROM_PC] , [
29
+ OPAL_VAR_SCOPE_PUSH([ pkg_config_results happy] )
54
30
55
31
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
32
64
- AS_LITERAL_WORD_IF([$1 ], [], [m4_fatal([Non-literal argument $1 ])], [])
65
- $1 _OMPI_PC_DIR= " "
33
+ AC_MSG_CHECKING ( [ for ldflags from pkg-config file $1 ] )
34
+
35
+ happy=1
36
+ AS_IF ( [ test "$PKG_CONFIG" = ""] ,
37
+ [ happy=0] ,
38
+ [ OPAL_LOG_COMMAND([ pkg_config_results=`$PKG_CONFIG --static --libs-only-L --libs-only-other $1 `] ,
39
+ [ AS_VAR_COPY ( [ $2 ] , [ pkg_config_results] ) ] ,
40
+ [ happy=0] )] )
41
+ AS_IF ( [ test $happy -eq 0] ,
42
+ [ pkg_config_results="none"
43
+ $3 ] )
66
44
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
45
+ AC_MSG_RESULT ( [ $pkg_config_results] )
46
+
47
+ OPAL_VAR_SCOPE_POP
48
+ ] )
49
+
50
+ dnl OPAL_GET_LIBS_FROM_PC(library name, variable-to-set-if-found,
51
+ dnl action-if-not-found)
52
+ AC_DEFUN ( [ OPAL_GET_LIBS_FROM_PC] , [
53
+ OPAL_VAR_SCOPE_PUSH([ pkg_config_results happy] )
54
+
55
+ AC_REQUIRE ( [ OPAL_CHECK_PKG_CONFIG] )
76
56
77
- # Shift the arguments by one to get to the actual paths.
78
- opal_pkg_config_args= m4_shift($@ )
57
+ AC_MSG_CHECKING ( [ for libs from pkg-config file $1 ] )
79
58
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
- )
59
+ happy=1
60
+ AS_IF ( [ test "$PKG_CONFIG" = ""] ,
61
+ [ happy=0] ,
62
+ [ OPAL_LOG_COMMAND([ pkg_config_results=`$PKG_CONFIG --libs-only-l $1 `] ,
63
+ [ AS_VAR_COPY ( [ $2 ] , [ pkg_config_results] ) ] ,
64
+ [ happy=0] )] )
65
+ AS_IF ( [ test $happy -eq 0] ,
66
+ [ pkg_config_results="none"
67
+ $3 ] )
88
68
89
- OPAL_LOG_MSG([pkg-config cmd for $opal_pkg_config_name : $opal_pkg_config_cmd ])
69
+ AC_MSG_RESULT ( [ $pkg_config_results ] )
90
70
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
- )
71
+ OPAL_VAR_SCOPE_POP
105
72
] )
0 commit comments