Fix: lttng: track-untrack: error assigned to wrong variable
[lttng-tools.git] / m4 / ax_jni_include_dir.m4
CommitLineData
504d4ace 1# ===========================================================================
6333b87b 2# https://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html
504d4ace
DG
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#
6333b87b
MJ
35# This macro depends on AC_CANONICAL_HOST which requires that config.guess
36# and config.sub be distributed along with the source code. See autoconf
37# manual for details.
38#
504d4ace
DG
39# Note: This macro can work with the autoconf M4 macros for Java programs.
40# This particular macro is not part of the original set of macros.
41#
42# LICENSE
43#
44# Copyright (c) 2008 Don Anderson <dda@sleepycat.com>
45#
46# Copying and distribution of this file, with or without modification, are
47# permitted in any medium without royalty provided the copyright notice
48# and this notice are preserved. This file is offered as-is, without any
49# warranty.
50
6333b87b 51#serial 15
504d4ace
DG
52
53AU_ALIAS([AC_JNI_INCLUDE_DIR], [AX_JNI_INCLUDE_DIR])
54AC_DEFUN([AX_JNI_INCLUDE_DIR],[
55
6333b87b
MJ
56AC_REQUIRE([AC_CANONICAL_HOST])
57
504d4ace
DG
58JNI_INCLUDE_DIRS=""
59
60if test "x$JAVA_HOME" != x; then
61 _JTOPDIR="$JAVA_HOME"
62else
63 if test "x$JAVAC" = x; then
64 JAVAC=javac
65 fi
66 AC_PATH_PROG([_ACJNI_JAVAC], [$JAVAC], [no])
67 if test "x$_ACJNI_JAVAC" = xno; then
68 AC_MSG_ERROR([cannot find JDK; try setting \$JAVAC or \$JAVA_HOME])
69 fi
70 _ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC")
71 _JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'`
72fi
73
74case "$host_os" in
6333b87b
MJ
75 darwin*) # Apple Java headers are inside the Xcode bundle.
76 macos_version=$(sw_vers -productVersion | sed -n -e 's/^@<:@0-9@:>@*.\(@<:@0-9@:>@*\).@<:@0-9@:>@*/\1/p')
77 if @<:@ "$macos_version" -gt "7" @:>@; then
78 _JTOPDIR="$(xcrun --show-sdk-path)/System/Library/Frameworks/JavaVM.framework"
79 _JINC="$_JTOPDIR/Headers"
80 else
81 _JTOPDIR="/System/Library/Frameworks/JavaVM.framework"
82 _JINC="$_JTOPDIR/Headers"
83 fi
84 ;;
85 *) _JINC="$_JTOPDIR/include";;
504d4ace
DG
86esac
87_AS_ECHO_LOG([_JTOPDIR=$_JTOPDIR])
88_AS_ECHO_LOG([_JINC=$_JINC])
89
90# On Mac OS X 10.6.4, jni.h is a symlink:
91# /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/jni.h
92# -> ../../CurrentJDK/Headers/jni.h.
6333b87b
MJ
93AC_CACHE_CHECK(jni headers, ac_cv_jni_header_path,
94[
95 if test -f "$_JINC/jni.h"; then
96 ac_cv_jni_header_path="$_JINC"
97 JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path"
98 else
99 _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
100 if test -f "$_JTOPDIR/include/jni.h"; then
101 ac_cv_jni_header_path="$_JTOPDIR/include"
102 JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path"
103 else
104 ac_cv_jni_header_path=none
105 fi
106 fi
107])
504d4ace
DG
108
109# get the likely subdirectories for system specific java includes
110case "$host_os" in
111bsdi*) _JNI_INC_SUBDIRS="bsdos";;
112freebsd*) _JNI_INC_SUBDIRS="freebsd";;
6333b87b 113darwin*) _JNI_INC_SUBDIRS="darwin";;
504d4ace
DG
114linux*) _JNI_INC_SUBDIRS="linux genunix";;
115osf*) _JNI_INC_SUBDIRS="alpha";;
116solaris*) _JNI_INC_SUBDIRS="solaris";;
117mingw*) _JNI_INC_SUBDIRS="win32";;
118cygwin*) _JNI_INC_SUBDIRS="win32";;
119*) _JNI_INC_SUBDIRS="genunix";;
120esac
121
6333b87b
MJ
122if test "x$ac_cv_jni_header_path" != "xnone"; then
123 # add any subdirectories that are present
124 for JINCSUBDIR in $_JNI_INC_SUBDIRS
125 do
504d4ace
DG
126 if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then
127 JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR"
128 fi
6333b87b
MJ
129 done
130fi
504d4ace
DG
131])
132
133# _ACJNI_FOLLOW_SYMLINKS <path>
134# Follows symbolic links on <path>,
135# finally setting variable _ACJNI_FOLLOWED
136# ----------------------------------------
137AC_DEFUN([_ACJNI_FOLLOW_SYMLINKS],[
138# find the include directory relative to the javac executable
139_cur="$1"
140while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do
141 AC_MSG_CHECKING([symlink for $_cur])
142 _slink=`ls -ld "$_cur" | sed 's/.* -> //'`
143 case "$_slink" in
144 /*) _cur="$_slink";;
145 # 'X' avoids triggering unwanted echo options.
146 *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";;
147 esac
148 AC_MSG_RESULT([$_cur])
149done
150_ACJNI_FOLLOWED="$_cur"
151])# _ACJNI
This page took 0.051454 seconds and 4 git commands to generate.