source: gs2-extensions/tdb/trunk/src/jni/m4/ax_jni_include_dir.m4@ 30206

Last change on this file since 30206 was 30206, checked in by jmt12, 5 years ago

A m4 directory containing a number of M4 packages used to compile this project. Running aclocal will cause the other (default) M4 packages to be linked into here too (so there is a .svnignore to ignore them)

File size: 4.3 KB
Line 
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
48
49AU_ALIAS([AC_JNI_INCLUDE_DIR], [AX_JNI_INCLUDE_DIR])
50AC_DEFUN([AX_JNI_INCLUDE_DIR],[
51
52JNI_INCLUDE_DIRS=""
53
54if test "x$JAVA_HOME" != x; then
55 _JTOPDIR="$JAVA_HOME"
56else
57 if test "x$JAVAC" = x; then
58 JAVAC=javac
59 fi
60 AC_PATH_PROG([_ACJNI_JAVAC], [$JAVAC], [no])
61 if test "x$_ACJNI_JAVAC" = xno; then
62 AC_MSG_ERROR([cannot find JDK; try setting \$JAVAC or \$JAVA_HOME])
63 fi
64 _ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC")
65 _JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'`
66fi
67
68case "$host_os" in
69 darwin*) # Apple JDK is at /System location and has headers symlinked elsewhere
70 case "$_JTOPDIR" in
71 /System/Library/Frameworks/JavaVM.framework/*)
72 _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
73 _JINC="$_JTOPDIR/Headers";;
74 *) _JINC="$_JTOPDIR/include";;
75 esac;;
76 *) _JINC="$_JTOPDIR/include";;
77esac
78_AS_ECHO_LOG([_JTOPDIR=$_JTOPDIR])
79_AS_ECHO_LOG([_JINC=$_JINC])
80
81# On Mac OS X 10.6.4, jni.h is a symlink:
82# /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/jni.h
83# -> ../../CurrentJDK/Headers/jni.h.
84AC_CHECK_FILE([$_JINC/jni.h],
85 [JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JINC"],
86 [_JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
87 AC_CHECK_FILE([$_JTOPDIR/include/jni.h],
88 [JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include"],
89 AC_MSG_ERROR([cannot find JDK header files]))
90 ])
91
92# get the likely subdirectories for system specific java includes
93case "$host_os" in
94bsdi*) _JNI_INC_SUBDIRS="bsdos";;
95freebsd*) _JNI_INC_SUBDIRS="freebsd";;
96darwin*) _JNI_INC_SUBDIRS="darwin";;
97linux*) _JNI_INC_SUBDIRS="linux genunix";;
98osf*) _JNI_INC_SUBDIRS="alpha";;
99solaris*) _JNI_INC_SUBDIRS="solaris";;
100mingw*) _JNI_INC_SUBDIRS="win32";;
101cygwin*) _JNI_INC_SUBDIRS="win32";;
102*) _JNI_INC_SUBDIRS="genunix";;
103esac
104
105# add any subdirectories that are present
106for JINCSUBDIR in $_JNI_INC_SUBDIRS
107do
108 if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then
109 JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR"
110 fi
111done
112])
113
114# _ACJNI_FOLLOW_SYMLINKS <path>
115# Follows symbolic links on <path>,
116# finally setting variable _ACJNI_FOLLOWED
117# ----------------------------------------
118AC_DEFUN([_ACJNI_FOLLOW_SYMLINKS],[
119# find the include directory relative to the javac executable
120_cur="$1"
121while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do
122 AC_MSG_CHECKING([symlink for $_cur])
123 _slink=`ls -ld "$_cur" | sed 's/.* -> //'`
124 case "$_slink" in
125 /*) _cur="$_slink";;
126 # 'X' avoids triggering unwanted echo options.
127 *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";;
128 esac
129 AC_MSG_RESULT([$_cur])
130done
131_ACJNI_FOLLOWED="$_cur"
132])# _ACJNI
Note: See TracBrowser for help on using the repository browser.