Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / nlunit-test / repo / third_party / nlbuild-autotools / repo / third_party / autoconf / m4 / ax_jni_include_dir.m4
1 # ===========================================================================
2 #    http://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 #   AX_JNI_INCLUDE_DIR
8 #
9 # DESCRIPTION
10 #
11 #   AX_JNI_INCLUDE_DIR finds include directories needed for compiling
12 #   programs using the JNI interface.
13 #
14 #   JNI include directories are usually in the Java distribution. This is
15 #   deduced from the value of $JAVA_HOME, $JAVAC, or the path to "javac", in
16 #   that order. When this macro completes, a list of directories is left in
17 #   the variable JNI_INCLUDE_DIRS.
18 #
19 #   Example usage follows:
20 #
21 #     AX_JNI_INCLUDE_DIR
22 #
23 #     for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS
24 #     do
25 #             CPPFLAGS="$CPPFLAGS -I$JNI_INCLUDE_DIR"
26 #     done
27 #
28 #   If you want to force a specific compiler:
29 #
30 #   - at the configure.in level, set JAVAC=yourcompiler before calling
31 #   AX_JNI_INCLUDE_DIR
32 #
33 #   - at the configure level, setenv JAVAC
34 #
35 #   Note: This macro can work with the autoconf M4 macros for Java programs.
36 #   This particular macro is not part of the original set of macros.
37 #
38 # LICENSE
39 #
40 #   Copyright (c) 2008 Don Anderson <dda@sleepycat.com>
41 #
42 #   Copying and distribution of this file, with or without modification, are
43 #   permitted in any medium without royalty provided the copyright notice
44 #   and this notice are preserved. This file is offered as-is, without any
45 #   warranty.
46
47 #serial 11.1
48 # This version of the script has a local patch that has not yet been upstreamed.
49
50 AU_ALIAS([AC_JNI_INCLUDE_DIR], [AX_JNI_INCLUDE_DIR])
51 AC_DEFUN([AX_JNI_INCLUDE_DIR],[
52
53 JNI_INCLUDE_DIRS=""
54
55 # if JAVA_HOME is set, always use that.
56 if test "x$JAVA_HOME" != x; then
57     _JTOPDIR="$JAVA_HOME"
58 else
59     case "$host_os" in
60         darwin*)
61             # on OS X, use the java_home command to find the user's prefered JVM.
62             _JTOPDIR=`/usr/libexec/java_home`
63             ;;
64         *)
65             # otherwise, attempt to infer the JDK directory from the location of the
66             # javac command.
67             if test "x$JAVAC" = x; then
68                 JAVAC=javac
69             fi
70             AC_PATH_PROG([_ACJNI_JAVAC], [$JAVAC], [no])
71             if test "x$_ACJNI_JAVAC" = xno; then
72                 AC_MSG_ERROR([cannot find JDK; try setting \$JAVAC or \$JAVA_HOME])
73             fi
74             _ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC")
75             _JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::' -e 's:/[[^/]]*$::'`
76             ;;
77     esac
78 fi
79
80 # always include the main JDK include directory. this is where jni.h should be located.
81 _JINC="$_JTOPDIR/include"
82
83 _AS_ECHO_LOG([_JTOPDIR=$_JTOPDIR])
84 _AS_ECHO_LOG([_JINC=$_JINC])
85
86 # verify that jni.h can be found.
87 if test -f "$_JINC/jni.h"; then
88     JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JINC"
89 else
90     AC_MSG_ERROR([cannot find JDK; try setting \$JAVAC or \$JAVA_HOME])
91 fi
92
93 # get the likely subdirectories for system specific java includes (e.g. jni_md.h).
94 case "$host_os" in
95 bsdi*)          _JNI_INC_SUBDIRS="bsdos";;
96 freebsd*)       _JNI_INC_SUBDIRS="freebsd";;
97 darwin*)        _JNI_INC_SUBDIRS="darwin";;
98 linux*)         _JNI_INC_SUBDIRS="linux genunix";;
99 osf*)           _JNI_INC_SUBDIRS="alpha";;
100 solaris*)       _JNI_INC_SUBDIRS="solaris";;
101 mingw*)         _JNI_INC_SUBDIRS="win32";;
102 cygwin*)        _JNI_INC_SUBDIRS="win32";;
103 *)              _JNI_INC_SUBDIRS="genunix";;
104 esac
105
106 # add any subdirectories that are present
107 for JINCSUBDIR in $_JNI_INC_SUBDIRS
108 do
109     if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then
110          JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR"
111     fi
112 done
113 ])
114
115 # _ACJNI_FOLLOW_SYMLINKS <path>
116 # Follows symbolic links on <path>,
117 # finally setting variable _ACJNI_FOLLOWED
118 # ----------------------------------------
119 AC_DEFUN([_ACJNI_FOLLOW_SYMLINKS],[
120 # find the include directory relative to the javac executable
121 _cur="$1"
122 while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do
123         AC_MSG_CHECKING([symlink for $_cur])
124         _slink=`ls -ld "$_cur" | sed 's/.* -> //'`
125         case "$_slink" in
126         /*) _cur="$_slink";;
127         # 'X' avoids triggering unwanted echo options.
128         *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";;
129         esac
130         AC_MSG_RESULT([$_cur])
131 done
132 _ACJNI_FOLLOWED="$_cur"
133 ])# _ACJNI