Commit | Line | Data |
---|---|---|
e03d7c66 MJ |
1 | # SPDX-License-Identifier: FSFAP |
2 | # | |
5c5aae82 | 3 | # =========================================================================== |
e465639e | 4 | # https://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html |
5c5aae82 CB |
5 | # =========================================================================== |
6 | # | |
7 | # SYNOPSIS | |
8 | # | |
9 | # AX_JNI_INCLUDE_DIR | |
10 | # | |
11 | # DESCRIPTION | |
12 | # | |
13 | # AX_JNI_INCLUDE_DIR finds include directories needed for compiling | |
14 | # programs using the JNI interface. | |
15 | # | |
16 | # JNI include directories are usually in the Java distribution. This is | |
17 | # deduced from the value of $JAVA_HOME, $JAVAC, or the path to "javac", in | |
18 | # that order. When this macro completes, a list of directories is left in | |
19 | # the variable JNI_INCLUDE_DIRS. | |
20 | # | |
21 | # Example usage follows: | |
22 | # | |
23 | # AX_JNI_INCLUDE_DIR | |
24 | # | |
25 | # for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS | |
26 | # do | |
27 | # CPPFLAGS="$CPPFLAGS -I$JNI_INCLUDE_DIR" | |
28 | # done | |
29 | # | |
30 | # If you want to force a specific compiler: | |
31 | # | |
32 | # - at the configure.in level, set JAVAC=yourcompiler before calling | |
33 | # AX_JNI_INCLUDE_DIR | |
34 | # | |
35 | # - at the configure level, setenv JAVAC | |
36 | # | |
e465639e MJ |
37 | # This macro depends on AC_CANONICAL_HOST which requires that config.guess |
38 | # and config.sub be distributed along with the source code. See autoconf | |
39 | # manual for details. | |
40 | # | |
5c5aae82 CB |
41 | # Note: This macro can work with the autoconf M4 macros for Java programs. |
42 | # This particular macro is not part of the original set of macros. | |
43 | # | |
44 | # LICENSE | |
45 | # | |
46 | # Copyright (c) 2008 Don Anderson <dda@sleepycat.com> | |
47 | # | |
48 | # Copying and distribution of this file, with or without modification, are | |
49 | # permitted in any medium without royalty provided the copyright notice | |
50 | # and this notice are preserved. This file is offered as-is, without any | |
51 | # warranty. | |
52 | ||
e465639e | 53 | #serial 15 |
5c5aae82 CB |
54 | |
55 | AU_ALIAS([AC_JNI_INCLUDE_DIR], [AX_JNI_INCLUDE_DIR]) | |
56 | AC_DEFUN([AX_JNI_INCLUDE_DIR],[ | |
57 | ||
e465639e MJ |
58 | AC_REQUIRE([AC_CANONICAL_HOST]) |
59 | ||
5c5aae82 CB |
60 | JNI_INCLUDE_DIRS="" |
61 | ||
62 | if test "x$JAVA_HOME" != x; then | |
63 | _JTOPDIR="$JAVA_HOME" | |
64 | else | |
65 | if test "x$JAVAC" = x; then | |
66 | JAVAC=javac | |
67 | fi | |
68 | AC_PATH_PROG([_ACJNI_JAVAC], [$JAVAC], [no]) | |
69 | if test "x$_ACJNI_JAVAC" = xno; then | |
70 | AC_MSG_ERROR([cannot find JDK; try setting \$JAVAC or \$JAVA_HOME]) | |
71 | fi | |
72 | _ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC") | |
73 | _JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'` | |
74 | fi | |
75 | ||
76 | case "$host_os" in | |
e465639e MJ |
77 | darwin*) # Apple Java headers are inside the Xcode bundle. |
78 | macos_version=$(sw_vers -productVersion | sed -n -e 's/^@<:@0-9@:>@*.\(@<:@0-9@:>@*\).@<:@0-9@:>@*/\1/p') | |
79 | if @<:@ "$macos_version" -gt "7" @:>@; then | |
80 | _JTOPDIR="$(xcrun --show-sdk-path)/System/Library/Frameworks/JavaVM.framework" | |
81 | _JINC="$_JTOPDIR/Headers" | |
82 | else | |
83 | _JTOPDIR="/System/Library/Frameworks/JavaVM.framework" | |
84 | _JINC="$_JTOPDIR/Headers" | |
85 | fi | |
86 | ;; | |
87 | *) _JINC="$_JTOPDIR/include";; | |
5c5aae82 CB |
88 | esac |
89 | _AS_ECHO_LOG([_JTOPDIR=$_JTOPDIR]) | |
90 | _AS_ECHO_LOG([_JINC=$_JINC]) | |
91 | ||
92 | # On Mac OS X 10.6.4, jni.h is a symlink: | |
93 | # /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/jni.h | |
94 | # -> ../../CurrentJDK/Headers/jni.h. | |
e465639e MJ |
95 | AC_CACHE_CHECK(jni headers, ac_cv_jni_header_path, |
96 | [ | |
97 | if test -f "$_JINC/jni.h"; then | |
98 | ac_cv_jni_header_path="$_JINC" | |
99 | JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path" | |
100 | else | |
101 | _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'` | |
102 | if test -f "$_JTOPDIR/include/jni.h"; then | |
103 | ac_cv_jni_header_path="$_JTOPDIR/include" | |
104 | JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path" | |
105 | else | |
106 | ac_cv_jni_header_path=none | |
107 | fi | |
108 | fi | |
109 | ]) | |
5c5aae82 CB |
110 | |
111 | # get the likely subdirectories for system specific java includes | |
112 | case "$host_os" in | |
113 | bsdi*) _JNI_INC_SUBDIRS="bsdos";; | |
114 | freebsd*) _JNI_INC_SUBDIRS="freebsd";; | |
e465639e | 115 | darwin*) _JNI_INC_SUBDIRS="darwin";; |
5c5aae82 CB |
116 | linux*) _JNI_INC_SUBDIRS="linux genunix";; |
117 | osf*) _JNI_INC_SUBDIRS="alpha";; | |
118 | solaris*) _JNI_INC_SUBDIRS="solaris";; | |
119 | mingw*) _JNI_INC_SUBDIRS="win32";; | |
120 | cygwin*) _JNI_INC_SUBDIRS="win32";; | |
121 | *) _JNI_INC_SUBDIRS="genunix";; | |
122 | esac | |
123 | ||
e465639e MJ |
124 | if test "x$ac_cv_jni_header_path" != "xnone"; then |
125 | # add any subdirectories that are present | |
126 | for JINCSUBDIR in $_JNI_INC_SUBDIRS | |
127 | do | |
5c5aae82 CB |
128 | if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then |
129 | JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR" | |
130 | fi | |
e465639e MJ |
131 | done |
132 | fi | |
5c5aae82 CB |
133 | ]) |
134 | ||
135 | # _ACJNI_FOLLOW_SYMLINKS <path> | |
136 | # Follows symbolic links on <path>, | |
137 | # finally setting variable _ACJNI_FOLLOWED | |
138 | # ---------------------------------------- | |
139 | AC_DEFUN([_ACJNI_FOLLOW_SYMLINKS],[ | |
140 | # find the include directory relative to the javac executable | |
141 | _cur="$1" | |
142 | while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do | |
143 | AC_MSG_CHECKING([symlink for $_cur]) | |
144 | _slink=`ls -ld "$_cur" | sed 's/.* -> //'` | |
145 | case "$_slink" in | |
146 | /*) _cur="$_slink";; | |
147 | # 'X' avoids triggering unwanted echo options. | |
148 | *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";; | |
149 | esac | |
150 | AC_MSG_RESULT([$_cur]) | |
151 | done | |
152 | _ACJNI_FOLLOWED="$_cur" | |
153 | ])# _ACJNI |