File: ompi_check_package.m4

package info (click to toggle)
openmpi 1.6.5-9.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 91,628 kB
  • ctags: 44,305
  • sloc: ansic: 408,966; cpp: 44,454; sh: 27,828; makefile: 10,486; asm: 3,882; python: 1,239; lex: 805; perl: 549; csh: 253; fortran: 232; f90: 126; tcl: 12
file content (174 lines) | stat: -rw-r--r-- 8,195 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
#                         University Research and Technology
#                         Corporation.  All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
#                         of Tennessee Research Foundation.  All rights
#                         reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
#                         University of Stuttgart.  All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
#                         All rights reserved.
# Copyright (c) 2012      Cisco Systems,Inc.  All rights reserved.
# Copyright (c) 2012      Oracle and/or its affiliates.  All rights reserved.
# $COPYRIGHT$
# 
# Additional copyrights may follow
# 
# $HEADER$
#

# _OMPI_CHECK_PACKAGE_HEADER(prefix, header, dir-prefix, 
#                            [action-if-found], [action-if-not-found],
*                            includes)
# --------------------------------------------------------------------
AC_DEFUN([_OMPI_CHECK_PACKAGE_HEADER], [
    # This is stolen from autoconf to peek under the covers to get the
    # cache variable for the library check.  one should not copy this
    # code into other places unless you want much pain and suffering
    AS_VAR_PUSHDEF([ompi_Header], [ac_cv_header_$2])

    # so this sucks, but there's no way to get through the progression
    # of header includes without killing off the cache variable and trying
    # again...  
    unset ompi_Header

    ompi_check_package_header_happy="no"
    AS_IF([test "$3" = "/usr" -o "$3" = "/usr/local"],
           [ # try as is...
            AC_VERBOSE([looking for header without includes])
            AC_CHECK_HEADER([$2], [ompi_check_package_header_happy="yes"],
                            [ompi_check_package_header_happy="no"])
            AS_IF([test "$ompi_check_package_header_happy" = "no"],
                  [# no go on the as is - reset the cache and try again
                   unset ompi_Header])])

    AS_IF([test "$ompi_check_package_header_happy" = "no"],
          [AS_IF([test "$3" != ""],
                 [$1_CPPFLAGS="$$1_CPPFLAGS -I$3/include"
                  CPPFLAGS="$CPPFLAGS -I$3/include"])
          AC_CHECK_HEADER([$2], [$4], [$5], [$6])],
          [$4])
    unset ompi_check_package_header_happy
    AS_VAR_POPDEF([ompi_Header])
])


# _OMPI_CHECK_PACKAGE_LIB(prefix, library, function, extra-libraries,
#                         dir-prefix, libdir,
#                         [action-if-found], [action-if-not-found]])
# --------------------------------------------------------------------
AC_DEFUN([_OMPI_CHECK_PACKAGE_LIB], [
    # This is stolen from autoconf to peek under the covers to get the
    # cache variable for the library check.  one should not copy this
    # code into other places unless you want much pain and suffering
    AS_LITERAL_IF([$2],
                  [AS_VAR_PUSHDEF([ompi_Lib], [ac_cv_lib_$2_$3])],
                  [AS_VAR_PUSHDEF([ompi_Lib], [ac_cv_lib_$2''_$3])])dnl

    # see comment above
    unset ompi_Lib
    ompi_check_package_lib_happy="no"
    AS_IF([test "$6" != ""],
          [ # libdir was specified - search only there
           $1_LDFLAGS="$$1_LDFLAGS -L$6"
           LDFLAGS="$LDFLAGS -L$6"
           AC_CHECK_LIB([$2], [$3], 
                        [ompi_check_package_lib_happy="yes"], 
                        [ompi_check_package_lib_happy="no"], [$4])
           AS_IF([test "$ompi_check_package_lib_happy" = "no"],
                 [LDFLAGS="$ompi_check_package_$1_save_LDFLAGS"
                  $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS"
                  unset ompi_Lib])],
          [ # libdir was not specified - go through search path
           ompi_check_package_libdir="$5"
           AS_IF([test "$ompi_check_package_libdir" = "" -o "$ompi_check_package_libdir" = "/usr" -o "$ompi_check_package_libdir" = "/usr/local"],
               [ # try as is...
                AC_VERBOSE([looking for library without search path])
                AC_CHECK_LIB([$2], [$3], 
                        [ompi_check_package_lib_happy="yes"], 
                        [ompi_check_package_lib_happy="no"], [$4])
                AS_IF([test "$ompi_check_package_lib_happy" = "no"],
                    [ # no go on the as is..  see what happens later...
                     LDFLAGS="$ompi_check_package_$1_save_LDFLAGS"
                     $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS"
                     unset ompi_Lib])])

           AS_IF([test "$ompi_check_package_lib_happy" = "no"],
               [AS_IF([test "$ompi_check_package_libdir" != ""],
                    [$1_LDFLAGS="$$1_LDFLAGS -L$ompi_check_package_libdir/lib"
                     LDFLAGS="$LDFLAGS -L$ompi_check_package_libdir/lib"
                     AC_VERBOSE([looking for library in lib])
                     AC_CHECK_LIB([$2], [$3], 
                               [ompi_check_package_lib_happy="yes"], 
                               [ompi_check_package_lib_happy="no"], [$4])
                     AS_IF([test "$ompi_check_package_lib_happy" = "no"],
                         [ # no go on the as is..  see what happens later...
                          LDFLAGS="$ompi_check_package_$1_save_LDFLAGS"
                          $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS"
                          unset ompi_Lib])])])

           AS_IF([test "$ompi_check_package_lib_happy" = "no"],
               [AS_IF([test "$ompi_check_package_libdir" != ""],
                    [$1_LDFLAGS="$$1_LDFLAGS -L$ompi_check_package_libdir/lib64"
                     LDFLAGS="$LDFLAGS -L$ompi_check_package_libdir/lib64"
                     AC_VERBOSE([looking for library in lib64])
                     AC_CHECK_LIB([$2], [$3], 
                               [ompi_check_package_lib_happy="yes"], 
                               [ompi_check_package_lib_happy="no"], [$4])
                     AS_IF([test "$ompi_check_package_lib_happy" = "no"],
                         [ # no go on the as is..  see what happens later...
                          LDFLAGS="$ompi_check_package_$1_save_LDFLAGS"
                          $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS"
                          unset ompi_Lib])])])])

    AS_IF([test "$ompi_check_package_lib_happy" = "yes"],
          [$1_LIBS="-l$2 $4"
           $7], [$8])

    AS_VAR_POPDEF([ompi_Lib])dnl
])
    

# OMPI_CHECK_PACKAGE(prefix, 
#                    header, 
#                    library, 
#                    function, 
#                    extra-libraries, 
#                    dir-prefix,
#                    libdir-prefix,
#                    [action-if-found], [action-if-not-found],
#                    includes)
# -----------------------------------------------------------
# check for package defined by header and libs, and probably
# located in dir-prefix, possibly with libs in libdir-prefix.
# Both dir-prefix and libdir-prefix can be empty.  Will set
# prefix_{CPPFLAGS, LDFLAGS, LIBS} as needed
AC_DEFUN([OMPI_CHECK_PACKAGE],[
    ompi_check_package_$1_save_CPPFLAGS="$CPPFLAGS"
    ompi_check_package_$1_save_LDFLAGS="$LDFLAGS"
    ompi_check_package_$1_save_LIBS="$LIBS"

    ompi_check_package_$1_orig_CPPFLAGS="$$1_CPPFLAGS"
    ompi_check_package_$1_orig_LDFLAGS="$$1_LDFLAGS"
    ompi_check_package_$1_orig_LIBS="$$1_LIBS"

    _OMPI_CHECK_PACKAGE_HEADER([$1], [$2], [$6], 
          [_OMPI_CHECK_PACKAGE_LIB([$1], [$3], [$4], [$5], [$6], [$7],
                [ompi_check_package_happy="yes"],
                [ompi_check_package_happy="no"])],
          [ompi_check_package_happy="no"],
          [$10])

    AS_IF([test "$ompi_check_package_happy" = "yes"],
          [$8],
          [$1_CPPFLAGS="$ompi_check_package_$1_orig_CPPFLAGS"
           $1_LDFLAGS="$ompi_check_package_$1_orig_LDFLAGS"
           $1_LIBS="$ompi_check_package_$1_orig_LIBS"
           $9])

    CPPFLAGS="$ompi_check_package_$1_save_CPPFLAGS"
    LDFLAGS="$ompi_check_package_$1_save_LDFLAGS"
    LIBS="$ompi_check_package_$1_save_LIBS"
])