File: ompi_setup_java.m4

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (249 lines) | stat: -rw-r--r-- 12,145 bytes parent folder | download
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl                         University Research and Technology
dnl                         Corporation.  All rights reserved.
dnl Copyright (c) 2004-2006 The University of Tennessee and The University
dnl                         of Tennessee Research Foundation.  All rights
dnl                         reserved.
dnl Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
dnl                         University of Stuttgart.  All rights reserved.
dnl Copyright (c) 2004-2006 The Regents of the University of California.
dnl                         All rights reserved.
dnl Copyright (c) 2006-2012 Los Alamos National Security, LLC.  All rights
dnl                         reserved.
dnl Copyright (c) 2007-2012 Oracle and/or its affiliates.  All rights reserved.
dnl Copyright (c) 2008-2018 Cisco Systems, Inc.  All rights reserved
dnl Copyright (c) 2013      Intel, Inc.  All rights reserved.
dnl Copyright (c) 2015-2018 Research Organization for Information Science
dnl                         and Technology (RIST). All rights reserved.
dnl Copyright (c) 2017      FUJITSU LIMITED.  All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl

dnl _OMPI_SETUP_JAVA()
dnl ----------------
dnl Invoked by OMPI_SETUP_JAVA only if --enable-mpi-java was specified.
AC_DEFUN([_OMPI_SETUP_JAVA],[
    OPAL_VAR_SCOPE_PUSH([ompi_java_bad ompi_java_found ompi_java_dir ompi_java_jnih ompi_java_PATH_save ompi_java_CPPFLAGS_save])

    # Check for bozo case: ensure a directory was specified
    AS_IF([test "$with_jdk_dir" = "yes" || test "$with_jdk_dir" = "no"],
          [AC_MSG_WARN([Must specify a directory name for --with-jdk-dir])
           AC_MSG_ERROR([Cannot continue])])
    AS_IF([test "$with_jdk_bindir" = "yes" || test "$with_jdk_bindir" = "no"],
          [AC_MSG_WARN([Must specify a directory name for --with-jdk-bindir])
           AC_MSG_ERROR([Cannot continue])])
    AS_IF([test "$with_jdk_headers" = "yes" || test "$with_jdk_headers" = "no"],
          [AC_MSG_WARN([Must specify a directory name for --with-jdk-headers])
           AC_MSG_ERROR([Cannot continue])])

    # Check for bozo case: either specify --with-jdk-dir or
    # (--with-jdk-bindir, --with-jdk-headers) -- not both.
    ompi_java_bad=0
    AS_IF([test -n "$with_jdk_dir" && \
           (test -n "$with_jdk_bindir" || test -n "$with_jdk_headers")],
          [ompi_java_bad=1])
    AS_IF([(test -z "$with_jdk_bindir" && test -n "$with_jdk_headers") || \
           (test -n "$with_jdk_bindir" && test -z "$with_jdk_headers")],
          [ompi_java_bad=1])
    AS_IF([test $ompi_java_bad -eq 1],
          [AC_MSG_WARN([Either specify --with-jdk-dir or both of (--with-jdk_bindir, --with-jdk-headers) -- not both.])
           AC_MSG_ERROR([Cannot continue])])

    AS_IF([test -n "$with_jdk_dir"],
          [with_jdk_bindir=$with_jdk_dir/bin
           with_jdk_headers=$with_jdk_dir/include])

    ##################################################################
    # with_jdk_dir can now be ignored; with_jdk_bindir and
    # with_jdk_headers will be either empty or have valid values.
    ##################################################################

    # Some java installations are in obscure places.  So let's
    # hard-code a few of the common ones so that users don't have to
    # specify --with-java-<foo>=LONG_ANNOYING_DIRECTORY.
    AS_IF([test -z "$with_jdk_bindir"],
          [ # OS X/macOS
           ompi_java_found=0
           # The following logic was deliberately decided upon in
           # https://github.com/open-mpi/ompi/pull/5015 specifically
           # to prevent this script and the rest of Open MPI's build
           # system from getting confused by the somewhat unorthodox
           # Java toolchain layout present on OS X/macOS systems,
           # described in depth by
           # https://github.com/open-mpi/ompi/pull/5015#issuecomment-379324639,
           # and mishandling OS X/macOS Java toolchain path detection
           # as a result.
           AS_IF([test -x /usr/libexec/java_home],
                 [ompi_java_dir=`/usr/libexec/java_home`],
                 [ompi_java_dir=/System/Library/Frameworks/JavaVM.framework/Versions/Current])
           AC_MSG_CHECKING([for Java in OS X/macOS locations])
           AS_IF([test -d $ompi_java_dir],
                 [AC_MSG_RESULT([found ($ompi_java_dir)])
                  ompi_java_found=1
                  if test -d "$ompi_java_dir/Headers" && test -d "$ompi_java_dir/Commands"; then
                      with_jdk_headers=$ompi_java_dir/Headers
                      with_jdk_bindir=$ompi_java_dir/Commands
                  elif test -d "$ompi_java_dir/include" && test -d "$ompi_java_dir/bin"; then
                      with_jdk_headers=$ompi_java_dir/include
                      with_jdk_bindir=$ompi_java_dir/bin
                  else
                      AC_MSG_WARN([No recognized OS X/macOS JDK directory structure found under $ompi_java_dir])
                      ompi_java_found=0
                  fi],
                 [AC_MSG_RESULT([not found])])

           if test "$ompi_java_found" = "0"; then
               # Various Linux
               if test -z "$JAVA_HOME"; then
                   ompi_java_dir='/usr/lib/jvm/java-*-openjdk-*/include/'
               else
                   ompi_java_dir=$JAVA_HOME/include
               fi
               ompi_java_jnih=`ls $ompi_java_dir/jni.h 2>/dev/null | head -n 1`
               AC_MSG_CHECKING([for Java in Linux locations])
               AS_IF([test -r "$ompi_java_jnih"],
                     [with_jdk_headers=`dirname $ompi_java_jnih`
                      OPAL_WHICH([javac], [with_jdk_bindir])
                      AS_IF([test -n "$with_jdk_bindir"],
                            [AC_MSG_RESULT([found ($with_jdk_headers)])
                             ompi_java_found=1
                             with_jdk_bindir=`dirname $with_jdk_bindir`],
                            [with_jdk_headers=])],
                     [ompi_java_dir='/usr/lib/jvm/default-java/include/'
                      ompi_java_jnih=`ls $ompi_java_dir/jni.h 2>/dev/null | head -n 1`
                      AS_IF([test -r "$ompi_java_jnih"],
                            [with_jdk_headers=`dirname $ompi_java_jnih`
                             OPAL_WHICH([javac], [with_jdk_bindir])
                             AS_IF([test -n "$with_jdk_bindir"],
                                   [AC_MSG_RESULT([found ($with_jdk_headers)])
                                    ompi_java_found=1
                                    with_jdk_bindir=`dirname $with_jdk_bindir`],
                                   [with_jdk_headers=])],
                             [AC_MSG_RESULT([not found])])])
           fi

           if test "$ompi_java_found" = "0"; then
               # Solaris
               ompi_java_dir=/usr/java
               AC_MSG_CHECKING([for Java in Solaris locations])
               AS_IF([test -d $ompi_java_dir && test -r "$ompi_java_dir/include/jni.h"],
                     [AC_MSG_RESULT([found ($ompi_java_dir)])
                      with_jdk_headers=$ompi_java_dir/include
                      with_jdk_bindir=$ompi_java_dir/bin
                      ompi_java_found=1],
                     [AC_MSG_RESULT([not found])])
           fi
          ],
          [ompi_java_found=1])

    if test "$ompi_java_found" = "1"; then
        OPAL_CHECK_WITHDIR([jdk-bindir], [$with_jdk_bindir], [javac])
        OPAL_CHECK_WITHDIR([jdk-headers], [$with_jdk_headers], [jni.h])

        # Look for various Java-related programs
        ompi_java_happy=no
        ompi_java_PATH_save=$PATH
        AS_IF([test -n "$with_jdk_bindir" && test "$with_jdk_bindir" != "yes" && test "$with_jdk_bindir" != "no"],
              [PATH="$with_jdk_bindir:$PATH"])
        AC_PATH_PROG(JAVAC, javac)
        AC_PATH_PROG(JAR, jar)
        AC_PATH_PROG(JAVADOC, javadoc)
        AC_PATH_PROG(JAVAH, javah)
        PATH=$ompi_java_PATH_save

        # Check to see if we have all 3 programs.
        AS_IF([test -z "$JAVAC" || test -z "$JAR" || test -z "$JAVADOC"],
              [ompi_java_happy=no],
              [ompi_java_happy=yes])

        # Look for jni.h
        AS_IF([test "$ompi_java_happy" = "yes"],
              [ompi_java_CPPFLAGS_save=$CPPFLAGS
               # silence a stupid Mac warning
               CPPFLAGS="$CPPFLAGS -DTARGET_RT_MAC_CFM=0"
               AC_MSG_CHECKING([javac -h])
               cat > Conftest.java << EOF
public final class Conftest {
    public native void conftest();
}
EOF
               AS_IF([$JAVAC -d . -h . Conftest.java > /dev/null 2>&1],
                     [AC_MSG_RESULT([yes])],
                     [AC_MSG_RESULT([no])
                      AS_IF([test -n "$JAVAH"],
                            [ompi_javah_happy=yes],
                            [ompi_java_happy=no])])
               rm -f Conftest.java Conftest.class Conftest.h

               AS_IF([test -n "$with_jdk_headers" && test "$with_jdk_headers" != "yes" && test "$with_jdk_headers" != "no"],
                     [OMPI_JDK_CPPFLAGS="-I$with_jdk_headers"
                      # Some flavors of JDK also require -I<blah>/linux.
                      # See if that's there, and if so, add a -I for that,
                      # too.  Ugh.
                      AS_IF([test -d "$with_jdk_headers/linux"],
                            [OMPI_JDK_CPPFLAGS="$OMPI_JDK_CPPFLAGS -I$with_jdk_headers/linux"])
                      # Solaris JDK also require -I<blah>/solaris.
                      # See if that's there, and if so, add a -I for that,
                      # too.  Ugh.
                      AS_IF([test -d "$with_jdk_headers/solaris"],
                            [OMPI_JDK_CPPFLAGS="$OMPI_JDK_CPPFLAGS -I$with_jdk_headers/solaris"])
                      # Darwin JDK also require -I<blah>/darwin.
                      # See if that's there, and if so, add a -I for that,
                      # too.  Ugh.
                      AS_IF([test -d "$with_jdk_headers/darwin"],
                            [OMPI_JDK_CPPFLAGS="$OMPI_JDK_CPPFLAGS -I$with_jdk_headers/darwin"])

                      CPPFLAGS="$CPPFLAGS $OMPI_JDK_CPPFLAGS"])
               AC_CHECK_HEADER([jni.h], [],
                               [ompi_java_happy=no])
               CPPFLAGS=$ompi_java_CPPFLAGS_save
              ])
    else
        ompi_java_happy=no
    fi
    AC_SUBST(OMPI_JDK_CPPFLAGS)

    # Are we happy?
    AC_MSG_CHECKING([if Java support available])
    AS_IF([test "$ompi_java_happy" = "yes"],
          [AC_MSG_RESULT([yes])],
          [AC_MSG_RESULT([no])
           AC_MSG_WARN([Java support requested but not found.])
           AC_MSG_ERROR([Cannot continue])])

    OPAL_VAR_SCOPE_POP
])

dnl OMPI_SETUP_JAVA()
dnl ----------------
dnl Do everything required to setup the Java compiler.
AC_DEFUN([OMPI_SETUP_JAVA],[
    OPAL_VAR_SCOPE_PUSH([ompi_java_happy ompi_javah_happy])

    ompi_java_happy=no
    ompi_javah_happy=no

    AC_ARG_WITH([jdk-dir],
                [AS_HELP_STRING([--with-jdk-dir(=DIR)],
                               [Location of the JDK header directory.  If you use this option, do not specify --with-jdk-bindir or --with-jdk-headers.])])
    AC_ARG_WITH([jdk-bindir],
                [AS_HELP_STRING([--with-jdk-bindir(=DIR)],
                               [Location of the JDK bin directory.  If you use this option, you must also use --with-jdk-headers (and you must NOT use --with-jdk-dir)])])
    AC_ARG_WITH([jdk-headers],
                [AS_HELP_STRING([--with-jdk-headers(=DIR)],
                               [Location of the JDK header directory.  If you use this option, you must also use --with-jdk-bindir (and you must NOT use --with-jdk-dir)])])

    # Only setup the compiler if we were requested to
    AS_IF([test "$1" = "yes"],
          [_OMPI_SETUP_JAVA])

    AM_CONDITIONAL(OMPI_HAVE_JAVAH_SUPPORT, test "$ompi_javah_happy" = "yes")

    OPAL_VAR_SCOPE_POP
])