1212# All rights reserved.
1313# Copyright (c) 2012-2015 Cisco Systems, Inc. All rights reserved.
1414# Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
15- # Copyright (c) 2014 Intel, Inc. All rights reserved.
15+ # Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
1616# Copyright (c) 2017 Research Organization for Information Science
1717# and Technology (RIST). All rights reserved.
1818# $COPYRIGHT$
@@ -36,9 +36,14 @@ AC_DEFUN([_PMIX_CHECK_PACKAGE_HEADER], [
3636 # of header includes without killing off the cache variable and trying
3737 # again...
3838 unset pmix_Header
39-
4039 pmix_check_package_header_happy= " no"
41- AS_IF([test " $3 " = " /usr" || test " $3 " = " /usr/local" ],
40+
41+ # get rid of the trailing slash(es)
42+ hdir_prefix= $( echo $3 | sed -e ' sX/*$XXg' )
43+
44+ AS_IF([test " $hdir_prefix " = " " || \
45+ test " $hdir_prefix " = " /usr" || \
46+ test " $hdir_prefix " = " /usr/local" ],
4247 [ # try as is...
4348 AC_VERBOSE([looking for header without includes])
4449 AC_CHECK_HEADERS([$2 ], [pmix_check_package_header_happy= " yes" ], [])
@@ -47,12 +52,21 @@ AC_DEFUN([_PMIX_CHECK_PACKAGE_HEADER], [
4752 unset pmix_Header])])
4853
4954 AS_IF([test " $pmix_check_package_header_happy " = " no" ],
50- [AS_IF([test " $3 " != " " ],
51- [$1 _CPPFLAGS= " $$ 1_CPPFLAGS -I$3 /include"
52- CPPFLAGS= " $CPPFLAGS -I$3 /include" ])
53- AC_CHECK_HEADERS([$2 ], [pmix_check_package_header_happy= " yes" ], [], [$6 ])
54- AS_IF([test " $pmix_check_package_header_happy " = " yes" ], [$4 ], [$5 ])],
55- [$4 ])
55+ [AS_IF([test " $hdir_prefix " != " " ],
56+ [$1 _CPPFLAGS= " $$ 1_CPPFLAGS -I$hdir_prefix "
57+ CPPFLAGS= " $CPPFLAGS -I$hdir_prefix "
58+ AC_VERBOSE([looking for header in $hdir_prefix ])
59+ AC_CHECK_HEADERS([$2 ], [pmix_check_package_header_happy= " yes" ], [], [$6 ])
60+ AS_IF([test " $pmix_check_package_header_happy " = " no" ],
61+ [unset pmix_Header
62+ $1 _CPPFLAGS= " $$ 1_CPPFLAGS -I$hdir_prefix /include"
63+ CPPFLAGS= " $CPPFLAGS -I$hdir_prefix /include"
64+ AC_VERBOSE([looking for header in $hdir_prefix /include])
65+ AC_CHECK_HEADERS([$2 ], [pmix_check_package_header_happy= " yes" ], [], [$6 ])])])])
66+
67+ AS_IF([test " $pmix_check_package_header_happy " = " yes" ],
68+ [$4 ], [$5 ])
69+
5670 unset pmix_check_package_header_happy
5771
5872 AS_VAR_POPDEF([pmix_Header])dnl
@@ -74,10 +88,14 @@ AC_DEFUN([_PMIX_CHECK_PACKAGE_LIB], [
7488 # see comment above
7589 unset pmix_Lib
7690 pmix_check_package_lib_happy= " no"
77- AS_IF([test " $6 " != " " ],
78- [ # libdir was specified - search only there
79- $1 _LDFLAGS= " $$ 1_LDFLAGS -L$6 "
80- LDFLAGS= " $LDFLAGS -L$6 "
91+
92+ # get rid of the trailing slash(es)
93+ libdir_prefix= $( echo $6 | sed -e ' sX/*$XXg' )
94+
95+ AS_IF([test " $libdir_prefix " != " " ],
96+ [# libdir was specified - search only there
97+ $1 _LDFLAGS= " $$ 1_LDFLAGS -L$libdir_prefix "
98+ LDFLAGS= " $LDFLAGS -L$libdir_prefix "
8199 AC_SEARCH_LIBS([$3 ], [$2 ],
82100 [pmix_check_package_lib_happy= " yes" ],
83101 [pmix_check_package_lib_happy= " no" ], [$4 ])
@@ -86,24 +104,30 @@ AC_DEFUN([_PMIX_CHECK_PACKAGE_LIB], [
86104 $1 _LDFLAGS= " $pmix_check_package_ $1 _orig_LDFLAGS"
87105 unset pmix_Lib])],
88106 [ # libdir was not specified - go through search path
89- pmix_check_package_libdir= " $5 "
90- AS_IF([test " $pmix_check_package_libdir " = " " || test " $pmix_check_package_libdir " = " /usr" || test " $pmix_check_package_libdir " = " /usr/local" ],
91- [ # try as is...
92- AC_VERBOSE([looking for library without search path])
93- AC_SEARCH_LIBS([$3 ], [$2 ],
94- [pmix_check_package_lib_happy= " yes" ],
95- [pmix_check_package_lib_happy= " no" ], [$4 ])
96- AS_IF([test " $pmix_check_package_lib_happy " = " no" ],
97- [ # no go on the as is.. see what happens later...
98- LDFLAGS= " $pmix_check_package_ $1 _save_LDFLAGS"
99- $1 _LDFLAGS= " $pmix_check_package_ $1 _orig_LDFLAGS"
100- unset pmix_Lib])])
107+ # get rid of the trailing slash(es)
108+ libdir_prefix= $( echo $5 | sed -e ' sX/*$XXg' )
109+
110+ # first try standard locations as otherwise our
111+ # searches with libdir_prefix locations might come
112+ # back positive and unnecessarily add an LDFLAG
113+ AC_VERBOSE([looking for library without search path])
114+ AC_SEARCH_LIBS([$3 ], [$2 ],
115+ [pmix_check_package_lib_happy= " yes" ],
116+ [pmix_check_package_lib_happy= " no" ], [$4 ])
117+ AS_IF([test " $pmix_check_package_lib_happy " = " no" ],
118+ [ # no go on the as is.. see what happens later...
119+ LDFLAGS= " $pmix_check_package_ $1 _save_LDFLAGS"
120+ $1 _LDFLAGS= " $pmix_check_package_ $1 _orig_LDFLAGS"
121+ unset pmix_Lib])
101122
102123 AS_IF([test " $pmix_check_package_lib_happy " = " no" ],
103- [AS_IF([test " $pmix_check_package_libdir " != " " ],
104- [$1 _LDFLAGS= " $$ 1_LDFLAGS -L$pmix_check_package_libdir /lib"
105- LDFLAGS= " $LDFLAGS -L$pmix_check_package_libdir /lib"
106- AC_VERBOSE([looking for library in lib])
124+ # if we didn't find it, check the libdir_prefix/lib64 directory
125+ [AS_IF([test " $libdir_prefix " != " " && \
126+ test " $libdir_prefix " != " /usr" && \
127+ test " $libdir_prefix " != " /usr/local" ],
128+ [$1 _LDFLAGS= " $$ 1_LDFLAGS -L$libdir_prefix /lib64"
129+ LDFLAGS= " $LDFLAGS -L$libdir_prefix /lib64"
130+ AC_VERBOSE([looking for library in $libdir_prefix /lib64])
107131 AC_SEARCH_LIBS([$3 ], [$2 ],
108132 [pmix_check_package_lib_happy= " yes" ],
109133 [pmix_check_package_lib_happy= " no" ], [$4 ])
@@ -114,18 +138,23 @@ AC_DEFUN([_PMIX_CHECK_PACKAGE_LIB], [
114138 unset pmix_Lib])])])
115139
116140 AS_IF([test " $pmix_check_package_lib_happy " = " no" ],
117- [AS_IF([test " $pmix_check_package_libdir " != " " ],
118- [$1 _LDFLAGS= " $$ 1_LDFLAGS -L$pmix_check_package_libdir /lib64"
119- LDFLAGS= " $LDFLAGS -L$pmix_check_package_libdir /lib64"
120- AC_VERBOSE([looking for library in lib64])
141+ # if we still haven't found it, check the libdir_prefix/lib directory
142+ [AS_IF([test " $libdir_prefix " != " " && \
143+ test " $libdir_prefix " != " /usr" && \
144+ test " $libdir_prefix " != " /usr/local" ],
145+ [$1 _LDFLAGS= " $$ 1_LDFLAGS -L$libdir_prefix /lib"
146+ LDFLAGS= " $LDFLAGS -L$libdir_prefix /lib"
147+ AC_VERBOSE([looking for library in $libdir_prefix /lib])
121148 AC_SEARCH_LIBS([$3 ], [$2 ],
122149 [pmix_check_package_lib_happy= " yes" ],
123150 [pmix_check_package_lib_happy= " no" ], [$4 ])
124151 AS_IF([test " $pmix_check_package_lib_happy " = " no" ],
125152 [ # no go on the as is.. see what happens later...
126153 LDFLAGS= " $pmix_check_package_ $1 _save_LDFLAGS"
127154 $1 _LDFLAGS= " $pmix_check_package_ $1 _orig_LDFLAGS"
128- unset pmix_Lib])])])])
155+ unset pmix_Lib])])])
156+ ])
157+
129158
130159 AS_IF([test " $pmix_check_package_lib_happy " = " yes" ],
131160 [$1 _LIBS= " -l$2 $4 "
0 commit comments