there was an #include directive missing
[openmpi-llc.git] / config / ompi_check_package.m4
blob6708d4282c6aeea79fbece93bfd7016d16eba5bc
1 # -*- shell-script -*-
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
8 #                         reserved.
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.
13 # $COPYRIGHT$
14
15 # Additional copyrights may follow
16
17 # $HEADER$
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
31     # again...  
32     unset ompi_Header
34     ompi_check_package_header_happy="no"
35     AS_IF([test "$3" = "/usr" -o "$3" = "/usr/local"],
36            [ # try as is...
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
42                    unset ompi_Header])])
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])],
49           [$4])
50     unset ompi_check_package_header_happy])
51     
52     dnl AS_VAR_POPDEF([ompi_Header])dnl
56 # _OMPI_CHECK_PACKAGE_LIB(prefix, library, function, extra-libraries,
57 #                         dir-prefix, libdir,
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
64     AS_LITERAL_IF([$2],
65                   [AS_VAR_PUSHDEF([ompi_Lib], [ac_cv_lib_$2_$3])],
66                   [AS_VAR_PUSHDEF([ompi_Lib], [ac_cv_lib_$2''_$3])])dnl
68     # see comment above
69     unset ompi_Lib
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"
81                   unset ompi_Lib])],
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"],
85                [ # try as is...
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"
94                      unset ompi_Lib])])
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"
108                           unset ompi_Lib])])])
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"],
125           [$7], [$8])
127     AS_VAR_POPDEF([ompi_Lib])dnl
129     
131 # OMPI_CHECK_PACKAGE(prefix, 
132 #                    header, 
133 #                    library, 
134 #                    function, 
135 #                    extra-libraries, 
136 #                    dir-prefix,
137 #                    libdir-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"],
160           [$8
161            $1_LIBS="-l$3 $5"],
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"
165            $9])
167     CPPFLAGS="$ompi_check_package_$1_save_CPPFLAGS"
168     LDFLAGS="$ompi_check_package_$1_save_LDFLAGS"
169     LIBS="$ompi_check_package_$1_save_LIBS"
170 ])