3 # Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4 # University Research and Technology
5 # Corporation. All rights reserved.
6 # Copyright (c) 2004-2005 The University of Tennessee and The University
7 # of Tennessee Research Foundation. All rights
9 # Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10 # University of Stuttgart. All rights reserved.
11 # Copyright (c) 2004-2005 The Regents of the University of California.
12 # All rights reserved.
15 # Additional copyrights may follow
20 # _OMPI_CHECK_PACKAGE_HEADER(prefix, hedaer, dir-prefix,
21 # [action-if-found], [action-if-not-found])
22 # --------------------------------------------------------------------
23 AC_DEFUN([_OMPI_CHECK_PACKAGE_HEADER], [
24 # This is stolen from autoconf to peek under the covers to get the
25 # cache variable for the library check. one should not copy this
26 # code into other places unless you want much pain and suffering
27 AS_VAR_PUSHDEF([ompi_Header], [ac_cv_header_$2])
29 # so this sucks, but there's no way to get through the progression
30 # of header includes without killing off the cache variable and trying
34 ompi_check_package_header_happy="no"
35 AS_IF([test "$3" = "/usr" -o "$3" = "/usr/local"],
37 AC_VERBOSE([looking for header without includes])
38 AC_CHECK_HEADER([$2], [ompi_check_package_header_happy="yes"],
39 [ompi_check_package_header_happy="no"])
40 AS_IF([test "$ompi_check_package_header_happy" = "no"],
41 [# no go on the as is - reset the cache and try again
44 AS_IF([test "$ompi_check_package_header_happy" = "no"],
45 [AS_IF([test "$3" != ""],
46 [$1_CPPFLAGS="$$1_CPPFLAGS -I$3/include"
47 CPPFLAGS="$CPPFLAGS -I$3/include"])
48 AC_CHECK_HEADER([$2], [$4], [$5])],
50 unset ompi_check_package_header_happy])
52 dnl AS_VAR_POPDEF([ompi_Header])dnl
56 # _OMPI_CHECK_PACKAGE_LIB(prefix, library, function, extra-libraries,
58 # [action-if-found], [action-if-not-found]])
59 # --------------------------------------------------------------------
60 AC_DEFUN([_OMPI_CHECK_PACKAGE_LIB], [
61 # This is stolen from autoconf to peek under the covers to get the
62 # cache variable for the library check. one should not copy this
63 # code into other places unless you want much pain and suffering
65 [AS_VAR_PUSHDEF([ompi_Lib], [ac_cv_lib_$2_$3])],
66 [AS_VAR_PUSHDEF([ompi_Lib], [ac_cv_lib_$2''_$3])])dnl
70 ompi_check_package_lib_happy="no"
71 AS_IF([test "$6" != ""],
72 [ # libdir was specified - search only there
73 $1_LDFLAGS="$$1_LDFLAGS -L$6"
74 LDFLAGS="$LDFLAGS -L$6"
75 AC_CHECK_LIB([$2], [$3],
76 [ompi_check_package_lib_happy="yes"],
77 [ompi_check_package_lib_happy="no"], [$4])
78 AS_IF([test "$ompi_check_package_lib_happy" = "no"],
79 [LDFLAGS="$ompi_check_package_$1_save_LDFLAGS"
80 $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS"
82 [ # libdir was not specified - go through search path
83 ompi_check_package_libdir="$5"
84 AS_IF([test "$ompi_check_package_libdir" = "" -o "$ompi_check_package_libdir" = "/usr" -o "$ompi_check_package_libdir" = "/usr/local"],
86 AC_VERBOSE([looking for library without search path])
87 AC_CHECK_LIB([$2], [$3],
88 [ompi_check_package_lib_happy="yes"],
89 [ompi_check_package_lib_happy="no"], [$4])
90 AS_IF([test "$ompi_check_package_lib_happy" = "no"],
91 [ # no go on the as is.. see what happens later...
92 LDFLAGS="$ompi_check_package_$1_save_LDFLAGS"
93 $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS"
96 AS_IF([test "$ompi_check_package_lib_happy" = "no"],
97 [AS_IF([test "$ompi_check_package_libdir" != ""],
98 [$1_LDFLAGS="$$1_LDFLAGS -L$ompi_check_package_libdir/lib"
99 LDFLAGS="$LDFLAGS -L$ompi_check_package_libdir/lib"
100 AC_VERBOSE([looking for library in lib])
101 AC_CHECK_LIB([$2], [$3],
102 [ompi_check_package_lib_happy="yes"],
103 [ompi_check_package_lib_happy="no"], [$4])
104 AS_IF([test "$ompi_check_package_lib_happy" = "no"],
105 [ # no go on the as is.. see what happens later...
106 LDFLAGS="$ompi_check_package_$1_save_LDFLAGS"
107 $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS"
110 AS_IF([test "$ompi_check_package_lib_happy" = "no"],
111 [AS_IF([test "$ompi_check_package_libdir" != ""],
112 [$1_LDFLAGS="$$1_LDFLAGS -L$ompi_check_package_libdir/lib64"
113 LDFLAGS="$LDFLAGS -L$ompi_check_package_libdir/lib64"
114 AC_VERBOSE([looking for library in lib64])
115 AC_CHECK_LIB([$2], [$3],
116 [ompi_check_package_lib_happy="yes"],
117 [ompi_check_package_lib_happy="no"], [$4])
118 AS_IF([test "$ompi_check_package_lib_happy" = "no"],
119 [ # no go on the as is.. see what happens later...
120 LDFLAGS="$ompi_check_package_$1_save_LDFLAGS"
121 $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS"
122 unset ompi_Lib])])])])
124 AS_IF([test "$ompi_check_package_lib_happy" = "yes"],
127 AS_VAR_POPDEF([ompi_Lib])dnl
131 # OMPI_CHECK_PACKAGE(prefix,
138 # [action-if-found], [action-if-not-found]
139 # -----------------------------------------------------------
140 # check for package defined by header and libs, and probably
141 # located in dir-prefix, possibly with libs in libdir-prefix.
142 # Both dir-prefix and libdir-prefix can be empty. Will set
143 # prefix_{CPPFLAGS, LDFLAGS, LIBS} as needed
144 AC_DEFUN([OMPI_CHECK_PACKAGE],[
145 ompi_check_package_$1_save_CPPFLAGS="$CPPFLAGS"
146 ompi_check_package_$1_save_LDFLAGS="$LDFLAGS"
147 ompi_check_package_$1_save_LIBS="$LIBS"
149 ompi_check_package_$1_orig_CPPFLAGS="$$1_CPPFLAGS"
150 ompi_check_package_$1_orig_LDFLAGS="$$1_LDFLAGS"
151 ompi_check_package_$1_orig_LIBS="$$1_LIBS"
153 _OMPI_CHECK_PACKAGE_HEADER([$1], [$2], [$6],
154 [_OMPI_CHECK_PACKAGE_LIB([$1], [$3], [$4], [$5], [$6], [$7],
155 [ompi_check_package_happy="yes"],
156 [ompi_check_package_happy="no"])],
157 [ompi_check_package_happy="no"])
159 AS_IF([test "$ompi_check_package_happy" = "yes"],
162 [$1_CPPFLAGS="$ompi_check_package_$1_orig_CPPFLAGS"
163 $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS"
164 $1_LIBS="$ompi_check_package_$1_orig_LIBS"
167 CPPFLAGS="$ompi_check_package_$1_save_CPPFLAGS"
168 LDFLAGS="$ompi_check_package_$1_save_LDFLAGS"
169 LIBS="$ompi_check_package_$1_save_LIBS"